feat(config): named Typesense clusters with picker#5
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces named Typesense clusters backed by a TOML config format, and adds TUI affordances to switch clusters both from Settings and via a global cluster picker overlay, routing all connection usage through new config.Config helper methods.
Changes:
- Replace legacy flat YAML connection config with TOML
[clusters.<name>]plusglobal.default_cluster, including legacy YAML fallback/migration and tab-order validation. - Add a global cluster picker (
c) rendered as a centered overlay, plus Settings/setup support for selecting/creating clusters and auto-filling URL/API key. - Update the TUI app wiring to use configurable tab ordering and
Config.URL()/APIKey()/ActiveCluster...helpers, with new tests covering these behaviors.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents TOML config layout, named clusters, and picker/navigation keys. |
| main.go | Uses cfg.NeedsSetup() to decide whether to enter setup even when a config file loads. |
| internal/tui/screens/setup.go | Adds Cluster field and cluster cycling/new-cluster slot behavior in the setup form. |
| internal/tui/overlay.go | Introduces overlay composition helpers for rendering a centered modal over existing content. |
| internal/tui/app.go | Adds global cluster picker state/handlers, tab ID/title configuration, and routes client creation through config helpers. |
| internal/tui/app_test.go | Adds tests for tab ordering, settings save behavior, cluster switching, overlay rendering, and Ctrl+C behavior in setup. |
| internal/config/config.go | Implements TOML config (plus legacy YAML fallback), cluster selection helpers, tab-order validation, and migration utilities. |
| internal/config/config_test.go | Adds/updates tests for TOML round-trips, legacy YAML fallback, NeedsSetup, tab order, and invalid tabs errors. |
| go.mod | Adds go-toml/v2 dependency. |
| go.sum | Adds go-toml/v2 checksums. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+448
to
+452
| a.cfg.Global.DefaultCluster = names[a.pickIx] | ||
| if err := config.Save(a.cfgPath, a.cfg); err != nil { | ||
| a.pickErr = "save failed: " + err.Error() | ||
| return nil | ||
| } |
| 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 |
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.
[clusters.<name>]plusglobal.default_cluster. legacy flaturl/api_keymigrates to adefaultclusterConfig.URL()/APIKey()/ActiveCluster()/ClusterNames()helpers and update the app to route through themClusterfield in the Setup form+ newslot) with←/→on the Cluster field; URL and API key auto-replace from the selected clustercfrom any normal tab.Entersavesglobal.default_cluster, rebuilds the client/screens, and refreshes the current tabinternal/tui/overlay.go)j/kaliases alongside↑/↓in the global pickerdepends on: #4