feat(tui): show number legends on the first nine tabs#4
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the TUI to support configurable tab ordering (via config), and adds 1–9 numeric legends to the first nine tabs to match the existing digit quick-select behavior.
Changes:
- Add TOML-backed config loading/saving with legacy YAML fallback and tab-order validation (
tabs.order). - Route tab activation/rendering by tab IDs (instead of fixed indices), based on configured tab order.
- Prefix the first nine tab titles with
1–9legends and introduce a subtle digit style for inactive tabs.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates configuration docs to TOML format and documents tabs.order. |
| main.go | Enters setup when a loaded config is missing required fields. |
| internal/tui/theme/theme.go | Adds a dedicated TabNumber style for numeric legends. |
| internal/tui/screens/setup.go | Preserves non-URL/APIKey config fields when completing setup. |
| internal/tui/app.go | Adds tab ID–based routing/configured tab ordering and renders numeric legends in the tab bar. |
| internal/tui/app_test.go | Adds tests for configured tab order, settings save flow, and Ctrl+C behavior during setup. |
| internal/config/config.go | Implements TOML config, YAML fallback, tabs.order, and tab validation helpers. |
| internal/config/config_test.go | Adds test coverage for TOML paths, YAML fallback, tab ordering, and validation errors. |
| go.mod | Adds go-toml/v2 dependency entry. |
| go.sum | Adds checksums for the TOML dependency. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+389
to
+393
| if i == a.active { | ||
| titles[i] = digit + " " + t | ||
| } else { | ||
| titles[i] = theme.TabNumber.Render(digit) + " " + t | ||
| } |
Comment on lines
229
to
+231
| // Settings is a form, so keep Tab/digits/q available for the inputs. | ||
| // Esc returns to Collections. | ||
| if a.active == a.settingsTabIndex() { | ||
| if a.activeTabID() == "settings" { |
|
|
||
| The `tabs.order` list controls both which tabs are shown and where they appear. Remove a tab ID to hide it, or reorder the IDs to change the tab bar placement. Valid IDs are `collections`, `aliases`, `nl_models`, `curations`, `synonyms`, `stopwords`, `presets`, `conversations`, `api_keys`, `analytics`, `cluster`, and `settings`. | ||
|
|
||
| A legacy `config.yaml` at the same path is still loaded if no `config.toml` is present. |
| github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect | ||
| github.com/muesli/cancelreader v0.2.2 // indirect | ||
| github.com/muesli/termenv v0.16.0 // indirect | ||
| github.com/pelletier/go-toml/v2 v2.2.4 // indirect |
Comment on lines
+20
to
+27
| app := NewApp(cfg, "/tmp/config.toml", false) | ||
|
|
||
| want := []string{"analytics", "collections", "settings"} | ||
| for i, id := range want { | ||
| if app.tabIDs[i] != id { | ||
| t.Fatalf("tabIDs = %+v, want %+v", app.tabIDs, want) | ||
| } | ||
| } |
Comment on lines
+31
to
+33
| cfg := config.Config{URL: "http://localhost:8108", APIKey: "xyz"} | ||
| path := filepath.Join(t.TempDir(), "config.yaml") | ||
| app := NewApp(cfg, path, false) |
| } | ||
|
|
||
| func TestCtrlCQuitsInitialSetup(t *testing.T) { | ||
| app := NewApp(config.Config{}, "/tmp/config.yaml", true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1–9quick-select digitdepends on: #3