Skip to content

feat(tui): /model command with provider-grouped model picker - #4

Merged
buchenberg merged 3 commits into
mainfrom
feature/model-switching
Jul 14, 2026
Merged

feat(tui): /model command with provider-grouped model picker#4
buchenberg merged 3 commits into
mainfrom
feature/model-switching

Conversation

@buchenberg

Copy link
Copy Markdown
Owner

Changes

Model switching

  • /model\ slash command opens a provider-grouped model picker
  • Pre-fetches models from all providers at startup via \GET /v1/models\
  • Config \models:\ override per provider skips the API query
  • Up/down to navigate, type to filter, enter to select, esc to cancel
  • Session-only switching (no config file writes)

Config enhancements

  • \Provider.Name\ — display name shown as palette heading
  • \Defaults.Provider\ — explicit default provider key
  • \Provider.Models\ — optional override list

Provider client

  • \ModelLister\ interface + \OpenAIClient.ListModels()\
  • Resolution priority: \default.provider\ → model prefix → first alphabetical

Bug fixes

  • \�djustViewport\ now accounts for \modelMode\ (was only checking \commandMode)
  • Model palette caps visible lines to terminal height via \maxModelLines()\

Tests

  • 9 new tests (3 provider, 6 TUI), all passing
  • \go vet\ and \gofmt\ clean

Gregory Buchenberger added 3 commits July 13, 2026 21:02
- Add Provider.Name field for display names in model palette
- Add Defaults.Provider for explicit default provider selection
- Add ModelLister interface + OpenAIClient.ListModels (GET /v1/models)
- Add Provider.Models override in config to skip API query
- Pre-fetch all provider models at TUI startup (background goroutine)
- Model palette groups by provider name with bold headings
- Up/down navigation, type-to-filter, enter to select, esc to cancel
- Session-only model switching via sessionModel (no config persistence)
- Dynamic viewport adjustment (paletteLines + maxModelLines)
- Fix adjustViewport to account for modelMode (not just commandMode)
- Update resolveProviderName to check default.provider first
- Update scaffold config with name, provider, models examples
@buchenberg
buchenberg merged commit 6714cc0 into main Jul 14, 2026
8 checks passed
@buchenberg
buchenberg deleted the feature/model-switching branch July 14, 2026 03:20
buchenberg added a commit that referenced this pull request Aug 4, 2026
Renamed across all packages:
- MaxIterations -> MaxLoopCycles (hard limit on total loop cycles)
- MaxTurns -> MaxToolTurns (when tools are stripped)
- WrapUpAhead -> WrapUpThreshold (wrap-up notice threshold)
- WrapUpTurns -> WrapUpThreshold (config yaml alias)
- injectWrapUp -> injectWrapUpNotice

YAML tags preserved for backward compat ('max_iterations', 'max_turns',
'wrap_up_turns' remain unchanged).

Touches: agent, config, pipeline, tools, subagent, cmd/yaah packages.
buchenberg added a commit that referenced this pull request Aug 4, 2026
…#131)

* refactor: complete CtxMgr/Persister/Hooks migration, remove deprecated Loop fields

* refactor: decompose Loop struct into LoopConfig + LoopState sub-types (P0 #1)

Split the ~70-field Loop struct into:
- LoopConfig: 32 immutable config fields (Model, MaxIterations, ContextWindow, etc.)
- LoopState: 14 mutable runtime fields (Messages, TotalTokens, etc.)
- Loop: ~28 dependency/internals (Provider, Registry, CtxMgr, Persister, etc.)

Renamed options.LoopConfig -> AgentConfig and WithLoopConfig -> WithAgentConfig
to avoid collision with the new LoopConfig sub-struct type.

Addresses ARCHITECTURE-REVIEW.md P0 #1 'Refactor Loop struct into composed types.'

* refactor: decompose runMiddleware into logical helpers (P0 #2)

Extracted 7 focused methods from the ~320-line runMiddleware:
- publishDone / teardown: deferred cleanup (broker, persister, hooks)
- initMessages: conversation initialization and session-start hooks
- buildTurnRequest: PrepareStep middleware + request construction + MaxTurns
- guardContextBeforeCall: pre-flight compaction + payload guard
- recordTurnSpanAttrs: OTel span attribute population
- executeToolPhase: tool truncation, execution, conflict detection, PostTool

runMiddleware reduced from ~320 lines to ~180 lines with clear delegation.

* refactor: clarify turn vs iteration naming (P1 #4)

Renamed across all packages:
- MaxIterations -> MaxLoopCycles (hard limit on total loop cycles)
- MaxTurns -> MaxToolTurns (when tools are stripped)
- WrapUpAhead -> WrapUpThreshold (wrap-up notice threshold)
- WrapUpTurns -> WrapUpThreshold (config yaml alias)
- injectWrapUp -> injectWrapUpNotice

YAML tags preserved for backward compat ('max_iterations', 'max_turns',
'wrap_up_turns' remain unchanged).

Touches: agent, config, pipeline, tools, subagent, cmd/yaah packages.

* docs: update ARCHITECTURE-REVIEW with implementation status

* fix: gofmt cmd/yaah/agent_frame.go
buchenberg added a commit that referenced this pull request Aug 7, 2026
…anup

- Thread pane width through renderMarkdown via GetInnerRect().Dx()
  instead of hard-coded 80 columns (CodeRabbit #6)
- Update architecture review: tui2 markdown entry now says tviewmd instead
  of glamour (#4), model-picker wiring is partial not missing (#5)
- Add language identifiers to unlabeled code fences in plan (#markdownlint)
- Phase 1 text already replaced by checkmarked completion in amended commit
buchenberg added a commit that referenced this pull request Aug 7, 2026
* feat: extract tviewmd markdown renderer and wire into tui2

Replace glamour+TranslateANSI in tui2 with native tview color-tag
rendering via the published github.com/buchenberg/tviewmd module (v0.1.0).

The tviewmd module (14 files, MIT) provides:
- CommonMark + GFM parsing via goldmark
- chroma syntax highlighting for fenced code blocks
- tview color-tag backend (no ANSI round-trip)
- 23 tests + fuzz (315k+ executions, zero panics)

Adds architecture review (docs/architecture-review.md) and implementation
plan (.agents/plans/tui2-hardening/PLAN.md).

* feat: extract tviewmd markdown renderer and wire into tui2

Replace glamour+TranslateANSI in tui2 with native tview color-tag
rendering via the published github.com/buchenberg/tviewmd module (v0.1.0).

The tviewmd module (14 files, MIT) provides:
- CommonMark + GFM parsing via goldmark
- chroma syntax highlighting for fenced code blocks
- tview color-tag backend (no ANSI round-trip)
- 23 tests + fuzz (315k+ executions, zero panics)

Adds architecture review (docs/architecture-review.md) and implementation
plan (.agents/plans/tui2-hardening/PLAN.md).

* fix: address PR review — dynamic markdown width, stale docs, plan cleanup

- Thread pane width through renderMarkdown via GetInnerRect().Dx()
  instead of hard-coded 80 columns (CodeRabbit #6)
- Update architecture review: tui2 markdown entry now says tviewmd instead
  of glamour (#4), model-picker wiring is partial not missing (#5)
- Add language identifiers to unlabeled code fences in plan (#markdownlint)
- Phase 1 text already replaced by checkmarked completion in amended commit

* docs(architecture): add deep-dive review of tui2 internals

Expand the architecture review with a comprehensive §4 section covering
`internal/tui2`'s package topology (~19 subpackages), the flat-factory
component pattern, and an analysis of the imperative widget tree model
with its strengths (simplicity, zero abstraction overhead) and weaknesses
(no lifecycle standardization, lack of isolation via shared *App).

Update the §3 recommendation to reference the new deep-dive section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant