Skip to content

Launch the TUI on a fresh install and open on Add collection - #220

Merged
ben-dev-au merged 1 commit into
mainfrom
fix/first-run-tui-launch
Oct 21, 2026
Merged

ben-dev-au merged 1 commit into
mainfrom
fix/first-run-tui-launch

Conversation

@ben-dev-au

Copy link
Copy Markdown
Owner

Summary

A fresh install could not start the TUI: fnd tui exited 1 with "no index at ...", so the Settings UI was unreachable for adding the first collection. The app itself already opens without an index; the CLI guard was the only blocker.

  • Launch: fnd tui passes missing_ok=True to prompt_and_rebuild_or_exit. An absent index launches; a stale schema still prompts; fnd search still refuses.
  • Opens on Add collection: with zero collections and no index, FNDApp pushes AddCollectionWizard on mount (as the README's Quick start already describes).
  • First collection is in scope: ScopeController._seed_first_collections reseeds an empty scope from defaults.collection when the config previously had no collections. Covers the wizard, the config-file editor and config recovery (all go through refresh_collections_panel). Never persists, so a later CLI-added collection still seeds on relaunch.
  • Footer honesty: the main footer re-renders on screen_change_signal when the main screen is active again. It was rendered for the wizard's focus, so after Esc it showed q Quit while q typed into the query bar.
  • Index built outside the app: a search with no searcher takes up an index the CLI built meanwhile (via on_reindex_complete), rather than returning nothing until relaunch.
  • Removed the now-dead invoked="tui" branch of _next_step.

Test plan

  • tests/test_a_fresh_install_opens_on_add_collection.py: launch path, wizard on fresh install plus two controls (configured collection, existing index), footer after Esc, first-collection scope (and no state written), emptied-scope control, config-file reload with two collections, outside-built index. Each fails with its fix removed.
  • make test-fast green; make batch-close green on the rebased tree.
  • tmux on an empty HOME: launch, wizard, Ctrl+S, u, search finds the file with 1/1 active; Esc from the wizard gives the query-bar footer and q quits.

Parked (pre-existing, out of scope): deleting or renaming a collection does not prune its name from the scope selection.

`fnd tui` exited 1 when no index existed, so a new user could not reach
the Settings UI to add their first collection. The app already copes
with a missing index; only the CLI guard refused.

- `prompt_and_rebuild_or_exit(missing_ok=True)` from `fnd tui`: an absent
  index launches the app. A stale schema still prompts; `fnd search`
  still refuses.
- With no collections and no index, the app opens on Add collection.
- An empty scope over a config that had no collections reseeds from
  `defaults.collection` on the next panel refresh, so the first
  collection (wizard or config file) is searched without a relaunch.
  Nothing is persisted, so later collections still seed on relaunch.
- The main footer re-renders when its screen is active again: it was
  last rendered for the wizard's focus and offered `q` to the query bar.
- A search with no searcher opens an index built by the CLI meanwhile.
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 673a5e64-0e53-4402-9f19-2e5d82a42cbf
📥 Commits

Reviewing files that changed from the base of the PR and between 9f9bce2 and 221cad6.

📒 Files selected for processing: 7
  • fnd/cli.py
  • fnd/migrate.py
  • fnd/tui/app.py
  • fnd/tui/scope_panel.py
  • fnd/tui/search_controller.py
  • tests/test_a_fresh_install_opens_on_add_collection.py
  • tests/test_first_run_advice_moves_forward.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The TUI can start without an index and opens the collection wizard on a fresh install. The scope controller seeds newly available collections when the scope is empty. Search preparation can adopt a ready index built outside the running application.

Changes: First-run TUI setup and search readiness

Layer / File(s) Summary
Missing-index handling and wizard startup
fnd/cli.py, fnd/migrate.py, fnd/tui/app.py, tests/test_a_fresh_install_opens_on_add_collection.py, tests/test_first_run_advice_moves_forward.py
The TUI allows a missing index and opens AddCollectionWizard when no collections or index are available. Empty-index advice uses the standard collection-add guidance. Tests cover startup routing and CLI behaviour.
Collection scope initialisation
fnd/tui/scope_panel.py, tests/test_a_fresh_install_opens_on_add_collection.py
The scope controller seeds available collections when the previous scope and panel configuration are empty. Tests cover initial selection and preservation of an intentionally emptied scope.
Search with an externally built index
fnd/tui/search_controller.py, tests/test_a_fresh_install_opens_on_add_collection.py
Search preparation adopts a ready external index when no searcher is attached. An integration test covers a successful search after an external index build.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant CLI as fnd tui
  participant Prompt as prompt_and_rebuild_or_exit
  participant App as FNDApp
  participant Wizard as AddCollectionWizard
  CLI->>Prompt: allow a missing index
  Prompt-->>CLI: return when the index is absent
  CLI->>App: launch the TUI
  App->>Wizard: open when no collections or search index are available
Loading
Merge Risk: ⚪ Minimal · up to 221ca

The first-run setup and external-index search paths have no identified issue requiring a fix before merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 77.42% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 31 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly summarises the main change: launching the TUI on a fresh install and opening the Add Collection flow.
Description check Passed The description directly explains the fresh-install launch behaviour, collection wizard flow, scope handling, index handling, tests, and out-of-scope work.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

I’m a rabbit, quick to hop,
The TUI starts without a stop.
A fresh install brings the wizard near,
The first collection joins the sphere.
Ready indexes help searches run,
I nibble greens beneath the sun.

Comment @coderabbitai help to get the list of available commands.

@ben-dev-au
ben-dev-au merged commit 583406b into main Oct 21, 2026
22 checks passed
@ben-dev-au
ben-dev-au deleted the fix/first-run-tui-launch branch October 21, 2026 06:50
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