Repository navigation
fix(cli): route read --to browser through existing delivery contract - #3504
Conversation
Problem: `polylogue find "demo" read --first --to browser` silently
printed session rows to the terminal instead of opening a browser, with
no warning at all. `_READ_DESTINATIONS` (query_verbs.py) accepts
"browser" as a valid --to value, and browser delivery IS implemented --
but on a separate path (query_output.py's
`destination.kind == "browser"` branch in `deliver_query_output`) that
two other dispatch sites never adopted:
- `run_read_summary_or_transcript` (read_views/standard.py), the
handler for the default "summary"/"transcript" views, which
query_verbs.py's read_verb force-routes every `--to browser`
invocation through (query_verbs.py:1282-1296).
- `deliver_content` (read_views/base.py), used by dialogue/temporal/
context/neighbors/messages/events/file-edits/chronicle views.
Both had a string-comparison if/elif chain with a silent `else` that
fell through to plain stdout echo for any unhandled destination,
including the valid-but-unwired "browser" -- exactly the kind of gap a
loud failure would have caught immediately.
Solution: add a "browser" branch to both dispatch sites, routing
through the existing browser-delivery mechanism rather than building a
second implementation:
- `run_read_summary_or_transcript` now sets `output="browser"` on the
query request, which `QueryOutputSpec`/`deliver_query_output`
(query_output.py) already resolve to `open_in_browser` -- the same
contract `find QUERY --to browser` (without `read`) uses.
- `deliver_content` now calls `query_output.open_in_browser` directly,
with new optional `output_format`/`session` params (default
"markdown"/None) so callers that have a `Session` (e.g. dialogue)
can render richer HTML.
The former silent `else` in both functions now raises
`click.UsageError` on a genuinely unrecognized destination instead of
degrading to terminal output -- the silent fallthrough is what let this
bug hide. `_READ_DESTINATIONS`' valid set is unchanged.
Verification:
- Reproduced pre-fix: `POLYLOGUE_ARCHIVE_ROOT=/realm/tmp/pl-bvnz-repro
polylogue demo seed --root ...` then
`polylogue find "demo" read --first --to browser` printed 11 result
rows to the terminal, no browser opened, no warning, exit 0.
- Confirmed post-fix: same invocation prints
"Opened in browser: /realm/tmp/tmpXXXXXX.html", exit 0. `--to
stdout`/`clipboard`/`file` behavior unchanged (spot-checked all
three against the demo archive).
- `python -m devtools test tests/unit/cli/test_query_verbs_runtime.py`
-- 62 passed (4 new: browser-destination routing +
unrecognized-destination raise, at both the read_verb level and the
deliver_content unit level).
- `python -m devtools verify --quick` -- exit 0.
Anti-vacuity: the production callers exercised are `read_verb`
(query_verbs.py) dispatching into `run_read_summary_or_transcript`
(read_views/standard.py), and `deliver_content` (read_views/base.py)
directly. Removing either function's `elif destination == "browser":`
branch (or its `output="browser"` param update) makes the corresponding
new test fail, since `execute_query_request`/`open_in_browser` would
then not be called with the browser-routing arguments.
Ref polylogue-bvnz
Co-Authored-By: Claude <[email protected]>
|
Warning Review limit reached
Next review available in: 48 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughRead output delivery now supports browser targets, propagates output format and session data, and rejects unsupported destinations. Standard and summary reads route browser requests explicitly. Runtime tests cover these paths. ChangesRead output routing
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant StandardRead
participant execute_query_request
participant query_output.open_in_browser
StandardRead->>execute_query_request: request output="browser"
execute_query_request->>query_output.open_in_browser: deliver rendered content
query_output.open_in_browser-->>StandardRead: browser delivery result
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 `@polylogue/cli/read_views/standard.py`:
- Around line 152-159: Update the browser delivery path in the call to
deliver_content so dialogue sessions are first transformed with
_window_dialogue_session using the requested projection before being passed for
HTML rendering, ensuring read --to browser honors projection_spec. Add a
regression test covering a browser dialogue read with projection_spec.
🪄 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 Plus
Run ID: 0a67eea2-6b20-4857-ad3c-c8402d82bd17
📒 Files selected for processing (3)
polylogue/cli/read_views/base.pypolylogue/cli/read_views/standard.pytests/unit/cli/test_query_verbs_runtime.py
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 52548535ae
ℹ️ 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".
| # missing and fell through to the plain-stdout `else`, so | ||
| # `read --to browser` silently printed to the terminal | ||
| # (polylogue-bvnz). | ||
| execute_query_request(env, updated.with_param_updates(output="browser")) |
There was a problem hiding this comment.
Preserve the resolved first match for browser reads
When a broad query uses read --first --to browser, read_verb has already resolved the first match and placed its ID in invocation.session_id, but this branch executes the original multi-match request unchanged because _request_for_standard_read() only applies conv_id for exact-reference queries. Consequently, the browser contains the whole result list—the reproduced find "demo" read --first --to browser case still renders all 11 matches rather than the selected first session. Apply the resolved session ID (or otherwise constrain the request) when --first produced it before browser delivery.
Useful? React with 👍 / 👎.
…reads Problem: CodeRabbit review on #3504 found that open_in_browser() re-derives HTML from the raw session for non-html output formats (the common markdown case) instead of using the already-rendered content string. run_read_dialogue passed the un-windowed session through, so `read --view dialogue --to browser` combined with a projection/window (--max-tokens, a body_limit/offset) silently showed the FULL dialogue in the browser, ignoring the requested window. What changed: run_read_dialogue now computes windowed_session via the same _window_dialogue_session(session, projection) call _format_dialogue_session already uses internally, and passes that to deliver_content instead of the raw session. Verification: new regression test test_dialogue_read_view_browser_destination_honors_projection_window asserts the delivered session has exactly 1 message under a body_limit=1 projection (was 4). Anti-vacuity: reverted the fix, confirmed the new test fails (delivered session had 4 messages, not 1); restored, confirmed 63 passed (was 62). devtools verify --quick exit 0. Co-Authored-By: Claude <[email protected]>
…jtc, bvnz, 5vbs) Reconciliation pass driven by devtools lab probe bead-pr-reconciliation: verified each bead's own acceptance criteria against the actual diff/AC matrix of its referencing merged PR(s), not just the PR's self-description. Closed (AC fully satisfied): - polylogue-bvnz: PR #3504, all 5 AC items satisfied. - polylogue-5vbs: PR #3439, AC's detection/repair branch satisfied via new daemon/fts_orphan_audit.py sweep. Left open with progress notes (partial, residual scope named): - polylogue-layg.1: PR #3486 satisfies 6/8 AC items; scale fixture + coverage manifest update still missing. - polylogue-hjpx: PR #3485 confirms AC1-5 satisfied (mostly by pre-existing landed work whose ancestry the bead's own stale note had missed), but bd close refuses on open child polylogue-yla8 (the live closure-gate audit AC1-5 doesn't substitute for). - polylogue-6j9c, polylogue-9kjtc: PR #3511 satisfies 2/3 AC items each; live-archive reprice pass over existing session_profiles rows still outstanding for both. Ref polylogue-93xe Co-Authored-By: Claude <[email protected]>
Summary
polylogue find QUERY read --to browsersilently printed rows to the terminal instead of opening a browser. Fixed by routing both affected dispatch sites through the existing browser-delivery mechanism (query_output.py'sdestination.kind == "browser"path) instead of building a second implementation, and by making the previously-silentelsefallthrough raise on a genuinely unrecognized destination.Problem
_READ_DESTINATIONS(polylogue/cli/query_verbs.py:215) accepts"browser"as a valid--tovalue, and browser delivery IS implemented -- but on a path (query_output.py:291,deliver_query_output'sdestination.kind == "browser"branch) that two other dispatch sites never adopted:run_read_summary_or_transcript(polylogue/cli/read_views/standard.py) -- the handler for the defaultsummary/transcriptviews, whichread_verbforce-routes every--to browserinvocation through (query_verbs.py:1282-1296).deliver_content(polylogue/cli/read_views/base.py) -- used by the dialogue/temporal/context/neighbors/messages/events/file-edits/chronicle read views.Both had a string-comparison if/elif chain with a silent
elsethat fell through to plain stdout echo for any destination the chain didn't explicitly handle -- including the valid-but-unwired"browser".Reproduced against a demo archive before fixing:
Solution
run_read_summary_or_transcript(standard.py): added anelif invocation.destination == "browser":branch that setsoutput="browser"on the query request before delegating toexecute_query_request-- the same paramQueryOutputSpec.from_params/deliver_query_output(query_output.py) already resolve toopen_in_browser, i.e. the identical contractfind QUERY --to browser(withoutread) already uses. No second implementation.deliver_content(base.py): added anelif destination == "browser":branch callingquery_output.open_in_browserdirectly. Added optionaloutput_format: str = "markdown"andsession: Session | None = Noneparams (backward compatible for the other 8 existing call sites) so callers holding aSession(dialogue) can render richer HTML.else(click.echo(content, nl=False)/execute_query_request(env, updated)) nowraise click.UsageError(...)for a genuinely unrecognized destination._READ_DESTINATIONS's valid set (terminal/stdout/browser/clipboard/file) is unchanged -- this branch is defensive since Click'sChoicealready constrains the CLI-facing value, but it closes the exact hole that let"browser"degrade silently for months.Verification
Opened in browser: /realm/tmp/tmpXXXXXX.html, exit 0.--to stdout/clipboard/fileagainst the same demo archive: unchanged behavior.python -m devtools test tests/unit/cli/test_query_verbs_runtime.py-- 62 passed, including 4 new tests:test_read_verb_summary_browser_destination_routes_through_query_output_delivery-- assertsread_verbwithdestination="browser"callsexecute_query_requestwithoutput="browser"in the request params.test_read_verb_summary_unrecognized_destination_raises-- assertsrun_read_summary_or_transcriptraisesclick.UsageErrorfor a bogus destination.test_deliver_content_browser_destination_opens_browser-- assertsdeliver_contentcallsquery_output.open_in_browser(env, content, output_format, session)fordestination="browser".test_deliver_content_unrecognized_destination_raises-- assertsdeliver_contentraisesclick.UsageErrorfor a bogus destination.python -m devtools verify --quick-- exit 0 (ran twice: once manually, once via the pre-push hook).AC matrix (polylogue-bvnz)
deliver_content, standard.pyrun_read_summary_or_transcript)query_output.open_in_browser/deliver_query_output, no new browser-opening code was writtenelseraise on unrecognized destinationclick.UsageError_READ_DESTINATIONS's valid setquery_verbs.py:215untouchedAnti-vacuity
Production callers exercised:
read_verb(query_verbs.py) dispatching intorun_read_summary_or_transcript(read_views/standard.py), anddeliver_content(read_views/base.py) directly. Removing either function'selif destination == "browser":branch (or itsoutput="browser"param update in standard.py) makes the corresponding new test fail, sinceexecute_query_request/open_in_browserwould then not be called with the browser-routing arguments -- reverting to the silent-echo fallthrough this PR fixes.Ref polylogue-bvnz
Summary by CodeRabbit
New Features
Bug Fixes
Tests