Skip to content

feat(list): always display fully-qualified daemon names#467

Merged
jdx merged 1 commit into
jdx:mainfrom
gaojunran:feat-list-full
Jun 6, 2026
Merged

feat(list): always display fully-qualified daemon names#467
jdx merged 1 commit into
jdx:mainfrom
gaojunran:feat-list-full

Conversation

@gaojunran

@gaojunran gaojunran commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

fixes #465.

Modify pitchfork ls to always show namespace/name format instead of omitting the namespace when there's no local conflict.

Also add state_file fallback in resolve_daemon_id() for resolving short daemon IDs globally when no local config matches. When ambiguous, error now lists all matching fully-qualified IDs.

Summary by CodeRabbit

  • New Features

    • Daemon ID resolution now consults persisted state when matching short daemon names and provides guidance when multiple matches exist.
  • Bug Fixes

    • Daemon list output consistently displays fully-qualified names in namespace/name format.
  • Tests

    • Added an end-to-end test to ensure list output always shows fully-qualified daemon names.

@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds a persisted-state fallback to daemon ID resolution and simplifies list display-name generation to use per-entry qualified styling; tests are updated to require fully-qualified daemon names in list output.

Changes

Daemon ID Resolution and Display Name

Layer / File(s) Summary
State-file fallback for daemon ID resolution
src/pitchfork_toml.rs
resolve_daemon_id consults the persisted state file when no configured daemon matches a short user_id, returning a single state match, erroring on multiple matches with an ambiguity message, or falling back to short-id validation. Adds private helpers to read/query the state file and treats read errors as no matches.
List display-name simplification and test alignment
src/cli/list.rs, tests/test_e2e_namespace.rs
Removes pre-collection of daemon IDs and computes each list row's display name via entry.id.styled_qualified(). Updates e2e test to assert fully-qualified daemon names (namespace/name) appear in list output.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through state files, sniffed each daemon name,
Found one, found many — and called out if they came the same.
The list now speaks plainly, each name fully shown,
No pre-gathered baskets — each entry stands alone.
A tiny rabbit cheer for clarity grown! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(list): always display fully-qualified daemon names' directly and clearly summarizes the main objective of the pull request: modifying daemon display output to always use fully-qualified names.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@greptile-apps

greptile-apps Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR changes pitchfork ls to always emit fully-qualified namespace/name daemon identifiers and moves the state-file short-ID fallback from resolve_daemon_id_with_namespace into resolve_daemon_id so it is active for all callers and covers every namespace (not just global).

  • src/cli/list.rs: Drops the all_ids collection and conflict-detection logic; calls styled_qualified() directly, always rendering namespace/name.
  • src/pitchfork_toml.rs: Extracts find_in_state_file and wires it into resolve_daemon_id as a post-config fallback; when multiple state entries match, an ambiguity error listing all qualified candidates is returned. The narrower global-only check in resolve_daemon_id_with_namespace is removed since it is now subsumed by the generalised fallback.
  • tests/test_e2e_namespace.rs: Renames and rewrites the list test to assert fully-qualified names are present, removing the old "namespace must not appear" assertion.

Confidence Score: 5/5

Safe to merge — changes are well-scoped, the state-file fallback generalisation is backwards-compatible, and the list simplification has no failure modes.

All three changed files have clean, correct logic. The StateFile::read already returns Ok(empty_state) for a missing file, so the new warn! path fires only on genuine parse or lock errors — not on fresh installs. The removal of the old global-only state-file check in resolve_daemon_id_with_namespace is fully covered by the new broader fallback inside resolve_daemon_id, which that function already delegates to. No regressions identified.

No files require special attention.

Important Files Changed

Filename Overview
src/cli/list.rs Removes the all_ids collection and replaces styled_display_name(Some(all_ids.iter())) with styled_qualified(), always showing namespace/name format. Straightforward simplification with no side-effects.
src/pitchfork_toml.rs Introduces find_in_state_file helper and moves the state-file fallback from resolve_daemon_id_with_namespace into resolve_daemon_id, making it general across all namespaces (not just global). Ambiguity now returns a clear error listing all matching qualified IDs. Logic is correct; StateFile::read already returns Ok(empty) for a missing file so the warn! path only fires on genuine parse/lock errors.
tests/test_e2e_namespace.rs Test function renamed from test_list_hides_namespace_without_conflict to test_list_always_shows_qualified_names and assertions flipped to verify fully-qualified output is present; previous "should NOT contain namespace" assertion removed.

Reviews (3): Last reviewed commit: "feat(list): always display fully-qualifi..." | Re-trigger Greptile

Comment thread src/pitchfork_toml.rs Outdated

@coderabbitai coderabbitai 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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
tests/test_e2e_namespace.rs (1)

292-295: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Assert start commands succeed before validating list output.

This test can pass even when daemon startup fails, because list also shows available daemons. Please assert success for both start calls to prevent false positives.

Suggested fix
-    let _ = env.run_command_in_dir(&["start", "unique-api"], &project);
+    let start_api = env.run_command_in_dir(&["start", "unique-api"], &project);
+    assert!(start_api.status.success(), "Failed to start unique-api");
     env.sleep(Duration::from_secs(1));
-    let _ = env.run_command_in_dir(&["start", "unique-worker"], &project);
+    let start_worker = env.run_command_in_dir(&["start", "unique-worker"], &project);
+    assert!(start_worker.status.success(), "Failed to start unique-worker");
     env.sleep(Duration::from_secs(1));
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_e2e_namespace.rs` around lines 292 - 295, The test currently
ignores the results of env.run_command_in_dir when starting daemons; capture
each call's result (the calls invoking "start" for "unique-api" and
"unique-worker") and assert they succeeded before proceeding to list validation
— e.g. store the return value from env.run_command_in_dir for each start and
assert success (include the command output in the assertion message for
debugging) so the test fails if a daemon failed to start rather than producing a
false positive from the list output.
src/cli/list.rs (1)

30-34: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update list help output examples to qualified IDs.

The documented output still shows short names, but runtime now always renders namespace/name. This will mislead users reading --help.

Suggested doc update
-Output:
-  Name    PID    Status     Error
-  api     12345  running
-  worker         available
-  db             errored    exit code 127"
+Output:
+  Name                  PID    Status     Error
+  my-namespace/api      12345  running
+  my-namespace/worker           available
+  my-namespace/db               errored    exit code 127"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/cli/list.rs` around lines 30 - 34, Update the help example in
src/cli/list.rs so it shows qualified IDs (namespace/name) instead of short
names; locate the multiline help/example string used for the "list" command (the
help text or constant that contains the "Output:" block) and replace lines like
"api", "worker", "db" with their qualified forms (e.g., "default/api",
"default/worker", "default/db" or the appropriate namespace used by runtime) so
the printed --help output matches the runtime rendering of namespace/name.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/cli/list.rs`:
- Around line 30-34: Update the help example in src/cli/list.rs so it shows
qualified IDs (namespace/name) instead of short names; locate the multiline
help/example string used for the "list" command (the help text or constant that
contains the "Output:" block) and replace lines like "api", "worker", "db" with
their qualified forms (e.g., "default/api", "default/worker", "default/db" or
the appropriate namespace used by runtime) so the printed --help output matches
the runtime rendering of namespace/name.

In `@tests/test_e2e_namespace.rs`:
- Around line 292-295: The test currently ignores the results of
env.run_command_in_dir when starting daemons; capture each call's result (the
calls invoking "start" for "unique-api" and "unique-worker") and assert they
succeeded before proceeding to list validation — e.g. store the return value
from env.run_command_in_dir for each start and assert success (include the
command output in the assertion message for debugging) so the test fails if a
daemon failed to start rather than producing a false positive from the list
output.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ece0bac3-c0c1-44f9-984f-790ef150ba0b

📥 Commits

Reviewing files that changed from the base of the PR and between a723fc5 and 715446c.

📒 Files selected for processing (3)
  • src/cli/list.rs
  • src/pitchfork_toml.rs
  • tests/test_e2e_namespace.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/pitchfork_toml.rs

Modify pitchfork ls to always show namespace/name format instead of
omitting the namespace when there's no local conflict.

Also add state_file fallback in resolve_daemon_id() for resolving
short daemon IDs globally when no local config matches. When ambiguous,
error now lists all matching fully-qualified IDs.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/pitchfork_toml.rs`:
- Around line 425-435: The find_in_state_file function logs a warning for any
StateFile::read error, including the expected "file not found" case; change it
to only warn when the state file exists but is unreadable by inspecting the read
error (use e.kind() == io::ErrorKind::NotFound or check std::fs::metadata on
env::PITCHFORK_STATE_FILE) and suppress the warning when the file is absent,
otherwise log the error and return Vec::new(); update references in
find_in_state_file and keep StateFile::read usage intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7aad1baf-6c6a-4d11-b9d5-8a23a1b03b74

📥 Commits

Reviewing files that changed from the base of the PR and between 715446c and abb85cf.

📒 Files selected for processing (3)
  • src/cli/list.rs
  • src/pitchfork_toml.rs
  • tests/test_e2e_namespace.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/test_e2e_namespace.rs
  • src/cli/list.rs

Comment thread src/pitchfork_toml.rs
@jdx jdx merged commit 002b712 into jdx:main Jun 6, 2026
6 checks passed
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.

2 participants