Skip to content

fix: surface global config writes and correct first-run guidance#37

Merged
karngyan merged 1 commit into
mainfrom
fix/setup-config-scoping-guidance
Jul 17, 2026
Merged

fix: surface global config writes and correct first-run guidance#37
karngyan merged 1 commit into
mainfrom
fix/setup-config-scoping-guidance

Conversation

@karngyan

Copy link
Copy Markdown
Contributor

Claim

Commands are honest about what they touch and guide the new user correctly. Four coherent UX fixes across setup, status, sessions, and search — output text only, no behavior or storage changes.

What changed

  1. setup surfaces global config writes. When settings would be written to the global config file (AUTOPHAGY_CONFIG_DIR unset) while an explicit --database points elsewhere, setup now prints a notice before writing. Interactive runs fold it into the summary; --yes runs send it to stderr so JSON stdout stays clean. Config location is unchanged — only made visible. The "Re-running setup" line now keys off an on-disk config file rather than a possibly-stale flag.
  2. status reports the real database size. The store opens in WAL mode, so a naive read of the main file right after migrations undercounts a brand-new database (~4 KiB header, not the ~250 KiB migrated schema). status now sums the -wal/-shm sidecars, and labels a file it just created as created new database.
  3. Fresh-DB search hint. An empty database's search line points at autophagy setup (nothing to reindex yet). The reindex --index-tool-input hint stays for the imported-but-unindexed case where it is correct.
  4. Friendly empty states. Empty sessions prints no sessions imported yet — run autophagy setup (no bare header); search against a zero-event database says so. --output json shapes are unchanged — empty arrays stay empty arrays.

Evidence

New CLI integration tests in crates/autophagy-cli/tests/cli.rs:

  • status_reports_post_migration_size_for_a_new_databasesize_bytes > 100_000 (was ~4 KiB), exists=false, text says created new database.
  • status_search_hint_points_at_setup_before_import_and_reindex_after — empty DB → autophagy setup and no reindex; imported-unindexed → reindex --index-tool-input.
  • empty_sessions_and_search_guide_the_user_but_keep_json_arrays — friendly text for both; JSON result stays []; a real miss on a populated DB still says no retrieval matches.
  • setup_warns_before_writing_global_config_for_explicit_database — notice fires; the faked global path resolves under a throwaway HOME, never the real one.
  • setup_omits_global_notice_when_config_dir_is_isolated — notice silent when AUTOPHAGY_CONFIG_DIR isolates the run.

Before / after (fresh empty database):

# status size — before: "4.0 KiB · schema v2 · new database (nothing imported yet)"
#                after:  "313.6 KiB · schema v2 · created new database (nothing imported yet)"

# status search line — before: "commands not indexed — run `autophagy reindex --index-tool-input`"
#                      after:  "commands not indexed — run `autophagy setup` to import your sessions"

# sessions — before: "SESSION\tSOURCE\tEVENTS\tLAST EVENT\tPROJECT"  (bare header)
#            after:  "no sessions imported yet — run `autophagy setup`"

# search   — before: "no retrieval matches"
#            after:  "no events imported yet — run `autophagy setup` to import your sessions"

# setup --database /tmp/x.db --yes (global config) — new stderr line:
#   note: settings are saved globally to <path> (set AUTOPHAGY_CONFIG_DIR to keep this run isolated)

Privacy implications

None. Output text only; no new persistence, network, or execution. Config write location is unchanged (now merely announced). The global-notice test fakes the global path via a throwaway HOME/XDG_DATA_HOME and never touches the real config or database.

Quality gate

mise run check green (ci + fmt + lint + test + docs).

🤖 Generated with Claude Code

https://claude.ai/code/session_015LY7xtercMc3NtLeX2z4YV

Make read and setup commands honest about what they touch and guide the
new user to the right next step.

- setup now prints a notice before writing when settings land in the
  global config file (AUTOPHAGY_CONFIG_DIR unset) while --database points
  elsewhere; interactive runs fold it into the summary, --yes runs send it
  to stderr so JSON stdout stays clean. The "Re-running setup" line now
  keys off an on-disk config file rather than a possibly-stale flag.
- status reports the true on-disk footprint by summing the WAL/shm
  sidecars, so a brand-new WAL database no longer under-reports ~4 KiB
  when it actually holds the ~250 KiB migrated schema, and says "created
  new database" for a file it just made.
- status's search line points a fresh, empty database at `autophagy
  setup` instead of a `reindex` that has nothing to rebuild; the reindex
  hint stays for imported-but-unindexed stores.
- empty `sessions` and `search` print friendly guidance instead of a bare
  header / unqualified "no matches"; JSON shapes are unchanged (empty
  arrays stay empty arrays).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@karngyan
karngyan merged commit 59cf9df into main Jul 17, 2026
1 check failed
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