Skip to content

fix(daemon): differentiate multi-profile state in status output (#1575)#1593

Open
Chen17-sq wants to merge 1 commit into
jackwener:mainfrom
Chen17-sq:fix/1575-daemon-status-multi-profile-label
Open

fix(daemon): differentiate multi-profile state in status output (#1575)#1593
Chen17-sq wants to merge 1 commit into
jackwener:mainfrom
Chen17-sq:fix/1575-daemon-status-multi-profile-label

Conversation

@Chen17-sq
Copy link
Copy Markdown

Linked issue

Closes #1575.

Summary

opencli daemon status rendered the line Extension: disconnected for three structurally different states:

  1. zero profiles connected — accurate "disconnected"
  2. 2+ profiles connected, no default selected — misleading
  3. requested profile vanished mid-session — misleading

Users hitting case 2 (a common setup: work + personal Chrome profiles both running with the OpenCLI extension installed) read "disconnected" and start reinstalling extensions / restarting Chrome / restarting the daemon — when the actual one-command fix is opencli profile use <name>.

The daemon JSON has carried profileRequired / profileDisconnected flags for a while (see daemon.ts:259-260). This PR teaches the CLI formatter to mirror that distinction.

Implementation

src/commands/daemon.ts:

  • Extracted formatExtensionLabel(status: DaemonStatus): string (exported for direct unit testing).
  • Renders one of four states:
    • connected (vX.Y.Z) — single profile selected, extension OK (unchanged).
    • N profile(s) connected, none selected — run \opencli profile use `` — covers the 2+ profile no-default case AND the single-orphan-profile case where the user hasn't picked one yet. Grammar adjusts on count.
    • requested profile not connected — open that Chrome profile, or pick another with \opencli profile use `— coversprofileDisconnected`.
    • disconnected — true zero-profile case (unchanged).

Imported DaemonStatus type from daemon-client.js to type the helper signature.

The JSON payload does not change. The CLI text is the only user-visible surface that needed the three-state distinction.

Why this matters

A new user with a work + personal Chrome profile setup runs opencli daemon status, sees "Extension: disconnected", and goes down the reinstall-everything debug path. With this change they instead see:

Extension: 2 profiles connected, none selected — run `opencli profile use <name>`
Profiles: work v1.0.14, personal v1.0.14

— which is both diagnostic AND actionable in a single line.

Test plan

Added two describe blocks to src/commands/daemon.test.ts:

  • formatExtensionLabel — multi-profile state differentiation — covers all four label branches plus singular/plural grammar at the 1-profile-no-default edge.
  • daemonStatus output for issue #1575 fix — asserts the end-to-end formatter never emits the bare Extension: disconnected line in the 2-profiles-no-default case, and that the Profiles: follow-up line still lists both profile names.

Local test run

npx vitest run src/commands/daemon.test.ts
 Test Files  1 passed (1)
      Tests  16 passed (16)

5 new tests; 11 pre-existing tests still pass.

Checklist

  • CLI text only — no breaking changes to JSON payload or to getDaemonHealth() state machine.
  • Singular/plural grammar handled.
  • Existing tests pass.
  • New regression tests added.

@Chen17-sq Chen17-sq force-pushed the fix/1575-daemon-status-multi-profile-label branch from 6df17a1 to ff062d1 Compare May 15, 2026 19:40
@Chen17-sq
Copy link
Copy Markdown
Author

Self-review: tightened the patch.

  • Inlined the label logic back into daemonStatus() — no more exported formatExtensionLabel helper. The function was 8 lines; pulling it out as a named API was over-engineering for what's effectively a single 4-branch if/else.
  • Dropped one of the two test describe blocks. All four state branches are still covered, but only via the public daemonStatus() output (which is what users actually see).
  • Simplified the profileDisconnected message to match the profileRequired voice (run \opencli profile use `` in both cases).

Diff went from +148/-7 to +91/-3. Test count went from 16 to 14 (4 state-coverage tests + 10 pre-existing).

@Chen17-sq Chen17-sq force-pushed the fix/1575-daemon-status-multi-profile-label branch from ff062d1 to 70e1398 Compare May 15, 2026 19:46
…wener#1575)

``opencli daemon status`` rendered ``Extension: disconnected`` for three
structurally different states — zero profiles (accurate), 2+ profiles
connected with no default selected (misleading), and a requested
profile that vanished (misleading). Users in case 2 (a common setup:
work + personal Chrome profiles both running with the OpenCLI
extension installed) read "disconnected" and started reinstalling
extensions / restarting Chrome / restarting the daemon — when the
actual one-command fix was ``opencli profile use <name>``.

The status JSON already differentiates ``profileRequired`` and
``profileDisconnected`` flags (see ``daemon.ts:259-260``); this patch
teaches the CLI formatter in ``src/commands/daemon.ts`` to mirror
that distinction inline in ``daemonStatus()``. JSON payload is
unchanged — only the human-readable label gains the three-state
discrimination.

Closes jackwener#1575.

Test plan
---------
Added ``describe`` block ``daemonStatus extension label states (jackwener#1575)``
to ``src/commands/daemon.test.ts``. Four tests covering all label
branches via the public ``daemonStatus()`` output:

  * 2+ profiles with no default → "N profiles connected, none selected"
  * 1 profile with no default → singular grammar
  * requested profile disconnected → routable hint
  * zero profiles → plain "disconnected" (unchanged)

All 14 daemon tests pass (4 new + 10 pre-existing) via
``npx vitest run src/commands/daemon.test.ts``.
@jackwener jackwener force-pushed the fix/1575-daemon-status-multi-profile-label branch from 70e1398 to dce4120 Compare May 19, 2026 16:58
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.

daemon status: Extension: disconnected is misleading when multiple profiles are connected without a default

1 participant