-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Enhance model selection and add footer navigation instructions #1271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b23ecc0
05b1442
7d39488
76f64a3
3a90e19
6214f23
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -14,23 +14,7 @@ import ( | |||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| func (s *appState) modelMenu() tview.Primitive { | ||||||||||||||||||||||
| items := make([]MenuItem, 0, 2+len(s.config.ModelList)) | ||||||||||||||||||||||
| items = append(items, | ||||||||||||||||||||||
| MenuItem{Label: "Back", Description: "Return to main menu", Action: func() { s.pop() }}, | ||||||||||||||||||||||
| MenuItem{ | ||||||||||||||||||||||
| Label: "Add model", | ||||||||||||||||||||||
| Description: "Append a new model entry", | ||||||||||||||||||||||
| Action: func() { | ||||||||||||||||||||||
| s.addModel( | ||||||||||||||||||||||
| picoclawconfig.ModelConfig{ModelName: "new-model", Model: "openai/gpt-5.2"}, | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| s.push( | ||||||||||||||||||||||
| fmt.Sprintf("model-%d", len(s.config.ModelList)-1), | ||||||||||||||||||||||
| s.modelForm(len(s.config.ModelList)-1), | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| }, | ||||||||||||||||||||||
| }, | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| items := make([]MenuItem, 0, 1+len(s.config.ModelList)) | ||||||||||||||||||||||
| currentModel := strings.TrimSpace(s.config.Agents.Defaults.Model) | ||||||||||||||||||||||
| for i := range s.config.ModelList { | ||||||||||||||||||||||
| index := i | ||||||||||||||||||||||
|
|
@@ -57,21 +41,35 @@ func (s *appState) modelMenu() tview.Primitive { | |||||||||||||||||||||
| }, | ||||||||||||||||||||||
| }) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| // Add model entry appended at the end so the models map to rows 1..N | ||||||||||||||||||||||
|
||||||||||||||||||||||
| // Add model entry appended at the end so the models map to rows 1..N | |
| // Add model entry appended at the end so the models map to rows 0..N-1 (and Add model is at row N) |
taorye marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Mar 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "Add model" action mutates s.config.ModelList via s.addModel(...) but does not set s.dirty = true. As a result, the user can add a model and then exit without being prompted to apply/save, losing the change. Mark the state dirty (and refresh menus if needed) when adding a model.
Copilot
AI
Mar 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new βduplicate model nameβ validation blocks having multiple model_list entries with the same model_name. In this repo, duplicates are explicitly allowed for load balancing (see Config.ValidateModelList / tests), so this change removes a supported configuration capability. Consider removing this check or turning it into a warning/UX hint rather than a hard error.
| if s.modelNameExists(value, index) { | |
| s.showMessage("Duplicate model name", fmt.Sprintf("Model Name '%s' already exists", value)) | |
| return | |
| } | |
| // Allow duplicate model names for load balancing; duplicates are validated elsewhere. |
taorye marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Mar 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleting a model here ultimately only removes it from ModelList and pops the page; it doesnβt mark s.dirty = true. That means a delete can be silently discarded if the user exits without applying/saving. Also consider clearing/updating Agents.Defaults.Model if the deleted model was selected, and refreshing the main/model menus after deletion to avoid stale UI state.
| s.deleteModel(index) | |
| s.deleteModel(index) | |
| // Mark configuration as dirty so the deletion is persisted. | |
| s.dirty = true | |
| // If the deleted model was the default, clear the default model reference. | |
| if s.config != nil { | |
| if s.config.Agents.Defaults.Model == model.Name { | |
| s.config.Agents.Defaults.Model = "" | |
| } | |
| } |
Copilot
AI
Mar 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue as above in the menu refresh path: this "Add Model" action appends to ModelList but doesnβt mark s.dirty = true, so the new entry can be lost on exit without an apply prompt. Set s.dirty (and refresh relevant menus) when adding the new model here too.
| ) | |
| ) | |
| s.dirty = true | |
| refreshModelMenuFromState(menu, s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
countChannels hard-codes the same enabled-channel list that already exists in hasEnabledChannel(). This duplication can easily drift when new channels are added/renamed. Consider deriving both enabled/total from a single shared slice/helper (e.g., have hasEnabledChannel call countChannels, or introduce a method returning the bools).