Skip to content

feat(cli): first-run status actionable text + tutorial (#1263) - #1376

Merged
Sinity merged 2 commits into
masterfrom
feature/feat/first-run-status-1263-v3
May 19, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/feat/first-run-status-1263-v3

Conversation

@Sinity

@Sinity Sinity commented May 19, 2026 •

Copy link
Copy Markdown
Owner

feat(cli): first-run status actionable text + tutorial (#1263)

First-run UX for polylogue status and a new polylogue tutorial
walkthrough.

Problem

  • On a fresh install, polylogue status reported tracebacks or vague
    states for empty/unconfigured/degraded scenarios — no archive, no
    sources, no daemon, stale pidfile, schema mismatch, locked DB,
    missing optional dep.

Solution

  • New polylogue/cli/commands/status_diagnostics.py centralises the
    first-run probe chain in diagnose_first_run(daemon_alive). Every
    probe is defensive and never raises — schema mismatch reuses
    schema_version_mismatch_message, stale pidfile mirrors
    _verify_pidfile (proc cmdline check), the optional-dep probe
    targets sqlite_vec (feat(daemon): post-ingest embedding task — voyage-4 integration, cost tracking, status surface #828).
  • polylogue/cli/commands/status.py wires the diagnostic into both
    _show_direct_status (pre-flight + empty-archive branches) and
    _show_direct_json (replaces the ad-hoc next_action; surfaces a
    structured diagnostic block).
  • polylogue/cli/commands/tutorial.py adds a five-stage interactive
    walkthrough — detect sources, write config, start daemon, first
    search, open reader. Each stage probes its own preconditions so
    reruns pick up where the previous run stopped. --non-interactive
    skips prompts for tests and previews.

Verification

  • nix develop -c pytest tests/unit/cli/test_status_diagnostics.py tests/unit/cli/test_tutorial.py tests/unit/cli/test_status.py -q
    → 31 passed.
  • nix develop -c devtools verify --quick → exit 0.

Closes #1263.
Ref #869.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Summary by CodeRabbit

  • New Features
    • Added interactive tutorial command providing step-by-step guidance through initial setup
  • Bug Fixes
    • Enhanced status command with improved diagnostics including detection of database schema issues, stale daemon configuration, and missing optional dependencies with actionable next steps
  • Documentation
    • Updated CLI reference documentation and verification catalogs

Review Change Stack

Sinity and others added 2 commits May 19, 2026 14:06
First-run UX for `polylogue status` and a new `polylogue tutorial`
walkthrough.

Problem
- On a fresh install, `polylogue status` reported tracebacks or vague
  states for empty/unconfigured/degraded scenarios — no archive, no
  sources, no daemon, stale pidfile, schema mismatch, locked DB,
  missing optional dep.

Solution
- New `polylogue/cli/commands/status_diagnostics.py` centralises the
  first-run probe chain in `diagnose_first_run(daemon_alive)`. Every
  probe is defensive and never raises — schema mismatch reuses
  `schema_version_mismatch_message`, stale pidfile mirrors
  `_verify_pidfile` (proc cmdline check), the optional-dep probe
  targets `sqlite_vec` (#828).
- `polylogue/cli/commands/status.py` wires the diagnostic into both
  `_show_direct_status` (pre-flight + empty-archive branches) and
  `_show_direct_json` (replaces the ad-hoc next_action; surfaces a
  structured `diagnostic` block).
- `polylogue/cli/commands/tutorial.py` adds a five-stage interactive
  walkthrough — detect sources, write config, start daemon, first
  search, open reader. Each stage probes its own preconditions so
  reruns pick up where the previous run stopped. `--non-interactive`
  skips prompts for tests and previews.

Verification
- `nix develop -c pytest tests/unit/cli/test_status_diagnostics.py
  tests/unit/cli/test_tutorial.py tests/unit/cli/test_status.py -q`
  → 31 passed.
- `nix develop -c devtools verify --quick` → exit 0.

Closes #1263.
Ref #869.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 19, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1b4aa9e6-b859-441e-8598-dee6eee2e3f5

📥 Commits

Reviewing files that changed from the base of the PR and between c2d716e and 8a6795e.

📒 Files selected for processing (12)
  • docs/cli-reference.md
  • docs/plans/topology-target.yaml
  • docs/test-quality-workflows.md
  • docs/topology-status.md
  • docs/verification-catalog.md
  • polylogue/cli/click_command_registration.py
  • polylogue/cli/commands/status.py
  • polylogue/cli/commands/status_diagnostics.py
  • polylogue/cli/commands/tutorial.py
  • tests/unit/cli/test_status.py
  • tests/unit/cli/test_status_diagnostics.py
  • tests/unit/cli/test_tutorial.py

📝 Walkthrough

Walkthrough

This pull request adds a new interactive polylogue tutorial command and centralizes first-run diagnostics for the polylogue status command. When the daemon is unreachable, both commands now probe system state and deliver actionable guidance instead of tracebacks or generic messages.

Changes

Interactive onboarding and first-run diagnostics

Layer / File(s) Summary
Status diagnostics contracts and probe implementation
polylogue/cli/commands/status_diagnostics.py
StatusDiagnostic dataclass and DiagnosticKind union encode probe outcomes (missing archive, schema mismatch, locked DB, stale pidfile, no sources, missing optional dep, healthy). diagnose_first_run(daemon_alive) runs a deterministic probe chain across SQLite schema, file locking, PID validity via /proc, TOML config text scanning, and importlib.util.find_spec dependency checks, returning the first matched diagnostic.
Status command integration with diagnostics
polylogue/cli/commands/status.py
_show_direct_json populates next_action and diagnostic payload from diagnose_first_run(). New _render_diagnostic() helper renders diagnostic headlines/details consistently. _show_direct_status adds pre-flight diagnostic gate (short-circuits row counting on schema mismatch/locked DB/stale pidfile) and detects empty archives to show diagnostic-driven guidance.
Tutorial command with five-stage onboarding flow
polylogue/cli/commands/tutorial.py
TutorialStage dataclass wraps per-stage probe, title, and action text. STAGES tuple chains five stages: detect chat sources → verify config → check daemon/diagnostics → confirm archive/conversations → check reader launch. tutorial_command iterates stages, prints status/diagnostics, and prompts for action (or runs silently with --non-interactive).
CLI command registration for tutorial
polylogue/cli/click_command_registration.py
Adds tutorial entry to _SHORT_HELP and includes _L("tutorial") in ROOT_COMMANDS tuple to register as a top-level subcommand.
Unit tests for status diagnostics module
tests/unit/cli/test_status_diagnostics.py
Covers diagnose_first_run() across all diagnostic paths: missing archive/config, schema mismatches (including false-positive guard), locked DBs, stale PIDfiles (with daemon-alive skip guard), empty sources, healthy state, and missing optional dependencies. Validates diagnostic_payload() JSON serialization.
Integration tests for status command with diagnostics
tests/unit/cli/test_status.py
End-to-end subprocess tests with isolated XDG paths and unreachable daemon. Asserts three first-run scenarios (schema mismatch, stale pidfile, empty roots) emit actionable text, exit cleanly, and avoid tracebacks.
Unit tests for tutorial command and stages
tests/unit/cli/test_tutorial.py
Validates stage list structure/numbering, --non-interactive execution, and stage probe outcomes (missing sources, missing config, empty/missing archives). Uses mocked environment with capturing console and temporary XDG sandbox.
Documentation and topology metadata updates
docs/cli-reference.md, docs/plans/topology-target.yaml, docs/test-quality-workflows.md, docs/topology-status.md, docs/verification-catalog.md
CLI reference adds tutorial command entry. Topology projection metadata updated for new modules (status_diagnostics.py, tutorial.py) and line-of-code counts. Test-quality workflow and verification catalogs updated with new scenario/exercise/subject counts.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • Sinity/polylogue#680: Modifies polylogue/cli/click_command_registration.py root-subcommand registry; this PR adds tutorial while that PR modified the watch command entry.
  • Sinity/polylogue#968: Also updates polylogue/cli/click_command_registration.py to register a new root subcommand in ROOT_COMMANDS (context-pack vs tutorial here).

🐰 A tutorial now guides the lost and weary soul,
With probes that peek at archives, daemons, and config whole!
No more cryptic tracebacks—just "press enter, carry on,"
The first-run blues are gone, the onboarding is drawn! 🎉

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/first-run-status-1263-v3

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

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

@Sinity
Sinity merged commit 1d1a2cc into master May 19, 2026
1 of 4 checks passed
@Sinity
Sinity deleted the feature/feat/first-run-status-1263-v3 branch May 19, 2026 15:58

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8a6795e5a1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +63 to +64
if diag.kind == "healthy":
return True, "Daemon is running and archive is healthy."

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Mark daemon step complete when only optional dep is missing

_stage_start_daemon() treats the step as complete only when diagnose_first_run(...).kind == "healthy", but diagnose_first_run intentionally returns "missing_optional_dep" when sqlite_vec is absent even if the daemon is up. In environments without sqlite-vec installed, step 3 is therefore always shown as not done and tells users to run polylogued run again, which is a false instruction and prevents the tutorial from accurately resuming progress.

Useful? React with 👍 / 👎.

Sinity added a commit that referenced this pull request May 19, 2026
## Summary

Make `polylogue ingest PATH` satisfy the three observable outcomes
called for by #869 slice C (#1264): **accepted+observable**, **rejected
(input)**, or **rejected (daemon)**. Eliminates the case where the
daemon returns HTTP 202 and the CLI prints success without anything
observable.

## Problem

The previous ingest implementation staged the file into
`archive_root()/inbox`, POSTed `/api/ingest`, and printed `Scheduled:
...` as long as `ImportOperation.status` was not literally `failed` or
`error`. That violated the issue's anti-trap "Do not trust `polylogue
ingest` just because the daemon returns 202":

- an unrecognized daemon status (e.g. `mystery_status`) was silently
treated as success;
- a daemon HTTP 4xx/5xx (`HTTPError`) escaped as a raw traceback rather
than an actionable message;
- the success output did not reveal the staged inbox path or point at
`polylogue status`, so the user had no observable handle on the
scheduled work.

## Solution

`polylogue/cli/commands/ingest.py`:

- Catch `HTTPError` explicitly and report status code + staged path so
operators know the file landed on disk and which contract failed.
- Catch `URLError` separately so "connection refused" produces an
actionable "is polylogued running?" message that names the daemon URL
and the `polylogued` binary.
- Treat only an explicit `accepted` / `pending` / `scheduled` / `queued`
status as success; any other status fails loudly instead of fabricating
a green line.
- Success output now lists the staged path, operation id, daemon URL,
and the `polylogue status` next-step pointer so the work is observable.

`tests/unit/cli/test_ingest.py`: extended to cover the AC matrix —
accept+observable, missing path, daemon-unreachable, daemon HTTP error,
unrecognized status, daemon-reported failure.

Inherited baseline cleanup per CLAUDE.md §19a: regenerated
`docs/cli-reference.md`, `docs/test-quality-workflows.md`,
`docs/verification-catalog.md`, `docs/topology-status.md` (drifted on
master) and added `tutorial` to `test_all_subcommands_registered` plus
the help snapshot (the #1263 / PR #1376 merge missed both regenerations
and left master with two failing tests).

No `polylogue run` resurrection. No new daemon endpoints — the CLI
consumes the existing `/api/ingest` contract from #861/#1247.

## Verification

```
nix develop -c pytest tests/unit/cli/test_ingest.py -x
  → 8 passed in 9.22s

nix develop -c devtools verify --quick
  → exit_code: 0, total_duration_s: 37.31

nix develop -c pytest tests/unit/cli/test_click_app.py::TestCliMetadata::test_all_subcommands_registered tests/unit/cli/test_help_snapshots.py::test_root_help_snapshot
  → 2 passed in 9.15s
```

Ref #869
Closes #1264
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.

feat(cli): first-run polylogue status reports actionable next steps (#869 slice B)

1 participant