Skip to content

feat(web): execute context preamble read view (#1846) - #2162

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/workbench-read-flow-1846
Jun 19, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/workbench-read-flow-1846

Conversation

@Sinity

@Sinity Sinity commented Jun 19, 2026

Copy link
Copy Markdown
Owner

Summary

Adds executable context read support to the daemon workbench by routing /api/sessions/:id/read?view=context through the same typed ContextPreamble contract used by CLI/MCP/API surfaces. The web shell now enables and renders the context preamble profile instead of treating it as a pending browser-only placeholder.

Problem

#1846 tracks the workbench as a browser cockpit over existing archive contracts. After #2160, context-pack was route-backed, but context remained disabled in the reader even though the context preamble already existed as a real CLI/MCP-facing payload. That left the workbench fragmented: browser code could show profile metadata but not execute one of the concrete read profiles without inventing a separate shape.

Solution

  • Added build_context_preamble_payload(...) in polylogue/context/preamble.py as the shared async builder for context preamble DTOs.
  • Exposed Polylogue.context_preamble_payload(...) and registered it in the facade route catalog.
  • Routed daemon read?view=context&format=json through the shared builder and rendered it in web_shell.py.
  • Reused the builder from MCP compose_context_preamble while preserving seedless SessionStart behavior.
  • Extended ContextPreamble with typed assertion guidance so injectable assertion claims remain structured across API, daemon, MCP, and shell surfaces.

Closes part of #1846. The issue remains open for the broader operator-flow polish, remaining read profiles (neighbors, correlation), overlay UX, and visual end-to-end flow completion.

Verification

  • devtools test tests/unit/cli/test_context_view.py tests/unit/mcp/test_compose_context_preamble.py tests/unit/daemon/test_web_reader.py::TestReaderViewProfiles tests/visual/test_reader_dom_smoke.py::test_reader_evidence_panel_endpoint_and_shell_smoke tests/unit/cli/test_status.py::test_archive_facade_route_catalog_covers_public_async_facade tests/unit/api/test_facade_contracts.py::test_no_undiscovered_async_methods
  • devtools test tests/unit/cli/test_plain_cli_snapshots.py::test_json_status_snapshot --snapshot-update
  • devtools test tests/unit/cli/test_plain_cli_snapshots.py::test_json_status_snapshot
  • devtools verify --quick
  • devtools verify --seed-testmon --skip-slow (11505 passed, 1 xfailed; peak pytest RSS 3449.3 MiB)
  • devtools verify (7 affected tests passed)

Problem: the daemon web reader exposed the context read profile as pending even though the CLI/MCP side already had a context preamble contract. That left the workbench unable to use an existing archive read surface and encouraged separate browser-only payload shapes.

What changed: route /api/sessions/:id/read?view=context through a shared ContextPreamble DTO builder, expose a Polylogue.context_preamble_payload facade method, reuse the same builder from MCP context preamble composition, and render the context view in the daemon web shell. The DTO now carries typed assertion guidance so injected assertion claims remain structured across surfaces.

Verification: devtools test tests/unit/cli/test_context_view.py tests/unit/mcp/test_compose_context_preamble.py tests/unit/daemon/test_web_reader.py::TestReaderViewProfiles tests/visual/test_reader_dom_smoke.py::test_reader_evidence_panel_endpoint_and_shell_smoke tests/unit/cli/test_status.py::test_archive_facade_route_catalog_covers_public_async_facade tests/unit/api/test_facade_contracts.py::test_no_undiscovered_async_methods; devtools verify --quick.
@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 6 minutes and 23 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 07b820f0-80fc-4f24-972b-1b0d0bed2720

📥 Commits

Reviewing files that changed from the base of the PR and between 05feeed and fdfb510.

📒 Files selected for processing (12)
  • polylogue/api/archive.py
  • polylogue/cli/commands/status.py
  • polylogue/context/preamble.py
  • polylogue/daemon/http.py
  • polylogue/daemon/web_shell.py
  • polylogue/mcp/server_context_tools.py
  • polylogue/surfaces/payloads.py
  • tests/unit/api/test_facade_contracts.py
  • tests/unit/cli/__snapshots__/test_plain_cli_snapshots.ambr
  • tests/unit/daemon/test_web_reader.py
  • tests/unit/mcp/test_compose_context_preamble.py
  • tests/visual/test_reader_dom_smoke.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/workbench-read-flow-1846

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 2ad1fe0 into master Jun 19, 2026
13 checks passed
@Sinity
Sinity deleted the feature/feat/workbench-read-flow-1846 branch June 19, 2026 11:52

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

ℹ️ 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".

if session_id:
try:
claims = await polylogue.list_assertion_claim_payloads( # type: ignore[attr-defined]
target_ref=f"session:{session_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.

P2 Badge Resolve session IDs before loading guidance

When the new context read/API path is called with a short ID or other token that get_session() resolves, the payload succeeds but this assertion query still uses the unresolved token. Assertion claims are filtered by exact target_ref = ?, so claims stored under the canonical session:<full id> are omitted from guidance, leaving injected context incomplete for prefix-based reads; use the resolved conv.id after get_session() for the assertion target.

Useful? React with 👍 / 👎.

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.

1 participant