Skip to content

fix(cli): add show verb that resolves provider:id directly - #482

Merged
Sinity merged 2 commits into
masterfrom
feature/fix/show-verb-provider-id
Apr 26, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/fix/show-verb-provider-id

Conversation

@Sinity

@Sinity Sinity commented Apr 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Register show as a query verb so polylogue <provider:id> show resolves directly by id instead of falling into FTS.
  • Mirror open's positional-id pattern, but accept the id from either the parent query terms (<id> show) or the verb's target terms (show <id>).
  • Update CLI help snapshots and generated catalogs (cli-reference, verification-catalog, test-quality-workflows) to include the new verb.

Closes #422.

Problem

Before this change, polylogue codex:019dbae3-... show exited after ~95s with No conversations matched filters: search: codex:019dbae3-... show. Root cause: there was no show verb registered, so the bare-token interception in _split_query_mode_args swept both codex:... and show into query_terms, ran the concatenated string as an FTS search, and timed out. The conversation existed in the archive (visible via list); only the surface was broken.

Solution

polylogue/cli/query_verbs.py:

  • Add show_verb. When the parent query terms plus the verb's positional target_terms collapse to exactly one token containing :, set conv_id and clear the query terms — direct id lookup, prefix match handled by _apply_runtime_filters. Otherwise append target_terms to existing query terms (preserving the search path).
  • Add "show" to VERB_NAMES so _split_query_mode_args recognizes it as a verb at any position (matching list, count, stats, open, delete).
  • Add show_verb to QUERY_VERBS so it's registered with the root group.

Other surfaces:

  • tests/unit/cli/test_query_verbs_runtime.py: three new tests covering id-from-target-terms, id-from-parent-query-terms (the regression), and search fallback for non-id terms.
  • tests/unit/cli/test_click_app.py: extend the registered-commands assertion.
  • tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr: refreshed via --snapshot-update (help now lists show).
  • docs/cli-reference.md, docs/verification-catalog.md, docs/test-quality-workflows.md: regenerated by devtools render-all.

Verification

nix develop -c pytest tests/unit/cli/ -q                # 844 passed
nix develop -c devtools verify --quick                  # all checks passed
nix develop -c pytest -q --ignore=tests/integration     # 5570 passed, 10 xfailed
                                                        # (1 unrelated flaky pass on re-run:
                                                        #  test_async_backend_schema_and_lock_contracts)

End-to-end:

$ time polylogue --plain --limit 1 claude-code:8d821a23-10a show
# investigate open issues and propose a set you'd tackle next ...
Provider: claude-code
Conversation ID: claude-code:8d821a23-10a6-4aa9-9c1f-ce5c7086f784
real  0m3.12s

(Was ~95s timeout with no results before this change.)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a new show command to display matched conversation content via existing query execution paths.
  • Documentation

    • Updated CLI reference with documentation for the new show command.
  • Tests

    • Updated test snapshots and assertions to include the new show command.
    • Added runtime tests validating the new command's routing behavior for conversation lookups.

Closes #422.

`polylogue codex:abc show` previously concatenated `show` into the FTS
query (no `show` verb existed), producing a ~95s search timeout that
returned no results despite the conversation being in the archive.

Register `show` as a query verb that mirrors `open`'s positional-id
handling: when the candidate set (parent query terms + verb target
terms) is a single token containing a colon, route to a direct
conv_id lookup instead of the search path.

Both argument orders now resolve in seconds:

    polylogue codex:abc show
    polylogue show codex:abc

Non-id terms still fall through to the search path unchanged.

Verification:

- pytest tests/unit/cli/ -q (844 passed)
- devtools verify --quick (all checks passed)
- live: polylogue --plain --limit 1 claude-code:8d821a23-10a show
  resolves the conversation in ~3s

Co-Authored-By: Claude <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 26, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 54 minutes and 25 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 54 minutes and 25 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b070805b-9e87-4f29-8350-15b14d8522c8

📥 Commits

Reviewing files that changed from the base of the PR and between c1fe34e and 6dfb53f.

📒 Files selected for processing (2)
  • tests/baselines/showcase/help-main.txt
  • tests/baselines/showcase/help-show.txt
📝 Walkthrough

Walkthrough

A new CLI command show is implemented to display conversation content from archive via direct ID lookup or query routing. The implementation detects provider:id-shaped identifiers in input and routes them through direct ID lookup rather than full-text search, alongside corresponding documentation, snapshot updates, and runtime tests.

Changes

Cohort / File(s) Summary
Core Implementation
polylogue/cli/query_verbs.py
Adds show_verb Click command function that detects provider:id candidates in combined term sets; when exactly one is found, sets conv_id directly and clears query terms (bypassing FTS); otherwise appends terms to query and executes normally. Registers show in VERB_NAMES, QUERY_VERBS, and __all__.
Documentation
docs/cli-reference.md, docs/verification-catalog.md
Adds polylogue show command entry to CLI reference and updates verification catalog metadata: increments subjects from 9046 to 9047, cli.command count from 50 to 51, updates proof obligations counts, and records polylogue show with its verb function reference.
Test Quality & Workflows
docs/test-quality-workflows.md
Increments scenario projections from 249 to 250, exercise count from 143 to 144, and adds new exercise entry help-show wired to conversation-query-loop with associated message/output mappings and tags.
Tests & Snapshots
tests/unit/cli/test_query_verbs_runtime.py, tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr, tests/unit/cli/test_click_app.py
Adds 45 lines of runtime tests validating show_verb routing with provider ID detection (direct lookup vs. fallback query), updates CLI help snapshot to display show command, and updates Click app test to expect show in subcommand set.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

Poem

🐰 A new show hops into view,
Provider IDs fast-tracked straight through!
No more FTS delays so long,
Direct lookups sing the rabbit's song. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a show verb that resolves provider:id directly, which is the core objective of this pull request.
Description check ✅ Passed The description follows the template structure with all required sections (Summary, Problem, Solution, Verification) filled out comprehensively, including specific code changes, test coverage, and end-to-end verification results.
Linked Issues check ✅ Passed The PR fully addresses issue #422 by implementing the show verb that resolves provider:id identifiers directly, with appropriate fallback to search, and includes comprehensive test coverage for all paths.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the show verb feature and updating related tests and documentation; no extraneous changes are present.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/show-verb-provider-id

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.

@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: c1fe34e6e9

ℹ️ 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 thread polylogue/cli/query_verbs.py Resolved

@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

Caution

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

⚠️ Outside diff range comments (2)
polylogue/cli/query_verbs.py (2)

76-107: 🧹 Nitpick | 🔵 Trivial

Extract shared positional-id resolution to remove duplication.

open_verb and show_verb now carry near-identical id-extraction rules. A small helper centralizes the policy and makes future tweaks (e.g., stripping a provider: prefix, supporting hash-only ids) a single-site change.

♻️ Suggested helper
+def _resolve_positional_id(
+    parent_terms: tuple[str, ...], target_terms: tuple[str, ...]
+) -> str | None:
+    """Return the single ``provider:id`` candidate spanning parent + target terms, if any."""
+    candidates = parent_terms + target_terms
+    if len(candidates) == 1 and ":" in candidates[0]:
+        return candidates[0]
+    return None

Both verbs then call _resolve_positional_id(_parent_query_terms(ctx), target_terms) and route to conv_id when non-None.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@polylogue/cli/query_verbs.py` around lines 76 - 107, open_verb and show_verb
duplicate the same positional-id extraction logic; add a helper
_resolve_positional_id(parent_terms: tuple[str,...], target_terms:
tuple[str,...]) -> Optional[str] that encapsulates the rule (e.g., single token
containing ":" or other future rules) and update both open_verb and show_verb to
call this helper: if it returns a conv_id, route via _execute_query_verb using
request.with_param_updates(conv_id=conv_id) (for open_verb) or
request.with_query_terms(()).with_param_updates(conv_id=conv_id) (for
show_verb), otherwise fall back to request.append_query_terms(target_terms) as
before; use _parent_query_terms(ctx), target_terms, _execute_query_verb, and
request.* methods to locate the call sites to change.

76-86: ⚠️ Potential issue | 🟠 Major

open_verb has the same parent-terms FTS bug that show_verb now fixes.

show_verb resolves a positional id from parent_terms + target_terms (combined length 1). open_verb only resolves it when parent_terms is empty and the id appears in target_terms. As a result, polylogue codex:abc open still routes codex:abc through FTS (the exact bug profile of issue #422 for show), even though polylogue codex:abc show is now fixed. The PR description states show "mirrors open’s positional-id behavior", but the fix is actually a superset of open's logic — leaving open inconsistent.

Recommend extending the same fix to open_verb so the two verbs behave uniformly:

🔧 Proposed fix for `open_verb`
 def open_verb(ctx: click.Context, print_path: bool, target_terms: tuple[str, ...]) -> None:
     """Open matched conversation in browser/editor."""
     request = _parent_request(ctx).with_param_updates(open_result=True, print_path=print_path)
-    if not _parent_query_terms(ctx) and len(target_terms) == 1 and ":" in target_terms[0]:
-        _execute_query_verb(ctx, request.with_param_updates(conv_id=target_terms[0]))
+    parent_terms = _parent_query_terms(ctx)
+    candidates = parent_terms + target_terms
+    if len(candidates) == 1 and ":" in candidates[0]:
+        _execute_query_verb(
+            ctx,
+            request.with_query_terms(()).with_param_updates(conv_id=candidates[0]),
+        )
         return
     _execute_query_verb(ctx, request.append_query_terms(target_terms))

Also applies to: 89-107

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@polylogue/cli/query_verbs.py` around lines 76 - 86, open_verb currently only
treats a single positional conv id when parent_terms is empty, so inputs like
"polylogue codex:abc open" still go through FTS; mirror the fix from show_verb
by combining the parent query terms and target_terms, check if their combined
length is 1 and the single term contains ":" and then call _execute_query_verb
with request.with_param_updates(conv_id=that_term) instead of appending to FTS;
update the logic in open_verb (and the similar block around lines 89-107) to use
_parent_query_terms(ctx) + list(target_terms) (or equivalent) and resolve the
positional id via with_param_updates(conv_id=...) when that combined condition
holds.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/unit/cli/test_query_verbs_runtime.py`:
- Line 167: Replace the loose disjunction assertion with a direct check that the
request query parameters do not contain the conv_id key; specifically, in the
test referencing request.query_params() and conv_id, change the assertion to
assert "conv_id" not in request.query_params() so the fallback path of show_verb
is validated to never populate conv_id.

---

Outside diff comments:
In `@polylogue/cli/query_verbs.py`:
- Around line 76-107: open_verb and show_verb duplicate the same positional-id
extraction logic; add a helper _resolve_positional_id(parent_terms:
tuple[str,...], target_terms: tuple[str,...]) -> Optional[str] that encapsulates
the rule (e.g., single token containing ":" or other future rules) and update
both open_verb and show_verb to call this helper: if it returns a conv_id, route
via _execute_query_verb using request.with_param_updates(conv_id=conv_id) (for
open_verb) or request.with_query_terms(()).with_param_updates(conv_id=conv_id)
(for show_verb), otherwise fall back to request.append_query_terms(target_terms)
as before; use _parent_query_terms(ctx), target_terms, _execute_query_verb, and
request.* methods to locate the call sites to change.
- Around line 76-86: open_verb currently only treats a single positional conv id
when parent_terms is empty, so inputs like "polylogue codex:abc open" still go
through FTS; mirror the fix from show_verb by combining the parent query terms
and target_terms, check if their combined length is 1 and the single term
contains ":" and then call _execute_query_verb with
request.with_param_updates(conv_id=that_term) instead of appending to FTS;
update the logic in open_verb (and the similar block around lines 89-107) to use
_parent_query_terms(ctx) + list(target_terms) (or equivalent) and resolve the
positional id via with_param_updates(conv_id=...) when that combined condition
holds.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: b56cfc5f-948a-442e-8079-ba350efb4182

📥 Commits

Reviewing files that changed from the base of the PR and between 850c372 and c1fe34e.

📒 Files selected for processing (7)
  • docs/cli-reference.md
  • docs/test-quality-workflows.md
  • docs/verification-catalog.md
  • polylogue/cli/query_verbs.py
  • tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr
  • tests/unit/cli/test_click_app.py
  • tests/unit/cli/test_query_verbs_runtime.py


request = execute.call_args.args[1]
assert isinstance(request, RootModeRequest)
assert "conv_id" not in request.query_params() or not request.query_params().get("conv_id")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Tighten the fallback assertion.

The disjunction "conv_id" not in ... or not ...get("conv_id") is broader than needed and obscures the contract. In the fallback path, show_verb must not populate conv_id, so assert that directly.

♻️ Proposed assertion
-    assert "conv_id" not in request.query_params() or not request.query_params().get("conv_id")
+    assert request.query_params().get("conv_id") is None
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
assert "conv_id" not in request.query_params() or not request.query_params().get("conv_id")
assert request.query_params().get("conv_id") is None
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/cli/test_query_verbs_runtime.py` at line 167, Replace the loose
disjunction assertion with a direct check that the request query parameters do
not contain the conv_id key; specifically, in the test referencing
request.query_params() and conv_id, change the assertion to assert "conv_id" not
in request.query_params() so the fallback path of show_verb is validated to
never populate conv_id.

The new ``show`` verb introduced in this PR exposes a new
``help-show`` showcase exercise via the auto-discovered help-N catalog.
Commit the captured baseline and refresh ``help-main`` to include the
verb in the top-level command listing.

Co-Authored-By: Claude <[email protected]>
@Sinity
Sinity merged commit 68e88f2 into master Apr 26, 2026
13 checks passed
@Sinity
Sinity deleted the feature/fix/show-verb-provider-id branch April 26, 2026 21:00
Sinity added a commit that referenced this pull request Apr 27, 2026
Three baselines drifted after the show/export/bulk-export fixes landed:

  - help-show: show verb body rewritten (#482)
  - help-export: gained provider:id-prefix note (#483)
  - help-main: show description text adjusted (#482)

Master CI (showcase-verify) has been red since 6b5c392. Refreshing
the baselines unblocks PRs that depend on a green master.

Verification: `devtools lab-scenario verify-baselines` exits 0.

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

Sinity commented Apr 28, 2026

Copy link
Copy Markdown
Owner Author

🤖 Post-hoc audit note: this PR received bot review feedback verified against current HEAD as part of #544. 1 finding(s) confirmed still present → tracked in #548.

Copilot AI 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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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

- Register `show` as a query verb so `polylogue <provider:id> show`
resolves directly by id instead of falling into FTS.
- Mirror `open`'s positional-id pattern, but accept the id from either
the parent query terms (`<id> show`) or the verb's target terms (`show
<id>`).
- Update CLI help snapshots and generated catalogs (cli-reference,
verification-catalog, test-quality-workflows) to include the new verb.

Closes #422.

## Problem

Before this change, `polylogue codex:019dbae3-... show` exited after
~95s with `No conversations matched filters: search: codex:019dbae3-...
show`. Root cause: there was no `show` verb registered, so the
bare-token interception in `_split_query_mode_args` swept both
`codex:...` and `show` into `query_terms`, ran the concatenated string
as an FTS search, and timed out. The conversation existed in the archive
(visible via `list`); only the surface was broken.

## Solution

`polylogue/cli/query_verbs.py`:

- Add `show_verb`. When the parent query terms plus the verb's
positional `target_terms` collapse to exactly one token containing `:`,
set `conv_id` and clear the query terms — direct id lookup, prefix match
handled by `_apply_runtime_filters`. Otherwise append `target_terms` to
existing query terms (preserving the search path).
- Add `"show"` to `VERB_NAMES` so `_split_query_mode_args` recognizes it
as a verb at any position (matching `list`, `count`, `stats`, `open`,
`delete`).
- Add `show_verb` to `QUERY_VERBS` so it's registered with the root
group.

Other surfaces:

- `tests/unit/cli/test_query_verbs_runtime.py`: three new tests covering
id-from-target-terms, id-from-parent-query-terms (the regression), and
search fallback for non-id terms.
- `tests/unit/cli/test_click_app.py`: extend the registered-commands
assertion.
- `tests/unit/cli/__snapshots__/test_terminal_snapshots.ambr`: refreshed
via `--snapshot-update` (help now lists `show`).
- `docs/cli-reference.md`, `docs/verification-catalog.md`,
`docs/test-quality-workflows.md`: regenerated by `devtools render-all`.

## Verification

```
nix develop -c pytest tests/unit/cli/ -q                # 844 passed
nix develop -c devtools verify --quick                  # all checks passed
nix develop -c pytest -q --ignore=tests/integration     # 5570 passed, 10 xfailed
                                                        # (1 unrelated flaky pass on re-run:
                                                        #  test_async_backend_schema_and_lock_contracts)
```

End-to-end:

```
$ time polylogue --plain --limit 1 claude-code:8d821a23-10a show
# investigate open issues and propose a set you'd tackle next ...
Provider: claude-code
Conversation ID: claude-code:8d821a23-10a6-4aa9-9c1f-ce5c7086f784
real  0m3.12s
```

(Was ~95s timeout with no results before this change.)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Added a new `show` command to display matched conversation content via
existing query execution paths.

* **Documentation**
  * Updated CLI reference with documentation for the new `show` command.

* **Tests**
* Updated test snapshots and assertions to include the new `show`
command.
* Added runtime tests validating the new command's routing behavior for
conversation lookups.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Claude <[email protected]>
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 61.F092 / P2: fixed-already at the checked revision: A merely reference-shaped token no longer makes a missing session lookup terminal. polylogue/cli/archive_query.py:587 returns None for a missing uncertain reference so the caller continues to ordinary query execution; only a certain or ambiguous identity lookup is refused.

Only the rows listed above are dispositioned. Held findings remain open.

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.

[bug] show action fails to resolve fully-qualified provider:id identifiers (returns 'No conversations matched' after ~60-90s)

2 participants