Skip to content

feat(reader): topology stack + branch chips + thread-continue shortcuts (#1203) - #1343

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/reader-topology-stack-1203-v2
May 19, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/reader-topology-stack-1203-v2

Conversation

@Sinity

@Sinity Sinity commented May 19, 2026

Copy link
Copy Markdown
Owner

Summary

Bridges the lineage topology view (#1121) into the workspace stack route and
adds per-message "continue this thread in another agent" deep-link shortcuts.
Implements the #1203 work that was outstanding from MK3 Slice 6
(docs/design/mk3/docs/10-implementation-slices.md:104).

Problem

MK3 Slice 6 called for the bridge between topology and the stack workspace —
"select this branch chip, open its parent chain as a stack workspace". #1121 /
PR #1176 landed the lineage and topology view; #1057 added the workspace shell
modes (tabs / stack / compare / timeline). The stack lane previously accepted
manually-entered conversation ids only — there was no UI affordance for
"render the root → sub-agent → continuation chain as a stack", and the
conversation header carried no branch chip telling the operator that a
conversation belonged to a multi-branch cluster.

Separately, the reader had no path back to the originating agent: an operator
who wanted to keep working a thread in Claude Code or Codex had to copy the
message text by hand. That is exactly the friction the MK3 design called out
as the "thread-resumption hub" idea (also tracked in the #1203 ambitious
section).

Solution

Substrate / daemon

  • polylogue/daemon/topology_http.py grows build_parent_chain_envelope()
    which projects a SessionTopology into a stack-ready chain (root → target
    → descendants) with branch_kind, parent_id, siblings, and focus_id
    surfaced. Uses the existing SessionTopology.ancestors() / descendants() / siblings() helpers so the lineage walk stays in insights/.
  • GET /api/conversations/{id}/topology/parent-chain returns the envelope.
    ?descendants=0 narrows to the ancestor chain only.
  • polylogue/daemon/thread_continue.py owns the per-agent URL-template
    registry (built-ins: claude-code, codex, copy-prompt clipboard
    fallback) and the URL constructor. Overrides flow through
    POLYLOGUE_READER_AGENT_TEMPLATES; invalid JSON falls back to the
    built-ins so the reader never crashes on a malformed env var. Templates
    are substituted client-side so the daemon never observes the message
    text the operator is "continuing" elsewhere.
  • GET /api/thread-continue-templates returns the active registry envelope.

Reader surface

  • Conversation header (web_shell.py) renders a topology branch chip
    (continuation / sidechain / fork / subagent / root) using the MK3 q-*
    chip vocabulary, plus an "open chain" button next to it. The chip click
    routes to the Lineage inspector tab as the popover surface.
  • Lineage inspector tab (web_shell_lineage.py) gains a third action,
    "Open chain as stack", so the same affordance is reachable from either
    the header or the inspector.
  • Workspace JS (web_shell_workspace.py) gains openParentChainAsStack(id)
    which fetches the parent-chain envelope and routes to
    /w/stack?ids=…&focus=….
  • Per-message action rail (web_shell_reader.py) gains a continue button
    that opens a small popover menu of agent templates. The copy-prompt
    entry writes to navigator.clipboard; every other entry hands off to the
    OS URL handler. The template registry is fetched once per session and
    cached.

Alternatives rejected

  • Computing the parent chain client-side from the existing /topology
    envelope. Rejected: that envelope is BFS-ordered and bounded by node
    count; the stack needs the explicit ancestor walk + focus anchor. A
    dedicated endpoint also keeps the topology→stack contract single-sourced
    for tests.
  • Persisting agent URL templates in polylogue.toml like the embedding
    keys. Rejected for this PR scope: an env-var override is sufficient for
    the operator workflow and avoids a config-schema migration. Can be
    promoted to TOML later without breaking the endpoint shape.

Verification

$ devtools verify --quick
"exit_code": 0
$ devtools verify --seed-testmon --skip-slow
"passed": 8219, "xfailed": 2, "exit_code": 0
$ pytest tests/unit/daemon/ -q
622 passed
$ pytest tests/unit/daemon/test_topology_stack.py tests/unit/daemon/test_thread_continue.py -q
53 passed

File-size budgets updated to reflect the +14 lines on web_shell.py
(branch chip helpers, openLineageInspector) and +52 lines on http.py
(two new handlers + dispatch). Topology projection re-rendered to
include the new daemon/thread_continue.py module.

Closes #1203

Bridges the lineage topology (#1121) into the workspace stack route and
adds per-message "continue this thread in another agent" deep-link
shortcuts. Implements the #1203 work that was outstanding from MK3
Slice 6 (docs/design/mk3/docs/10-implementation-slices.md:104).

Backend:
- polylogue/daemon/topology_http.py grows build_parent_chain_envelope()
  which projects a SessionTopology into a stack-ready chain (root ->
  target -> descendants), with branch_kind, parent_id, and siblings
  surfaced for the popover/inspector. Uses the existing SessionTopology
  ancestors()/descendants()/siblings() helpers so the lineage walk
  stays in insights/.
- GET /api/conversations/{id}/topology/parent-chain returns that
  envelope; ?descendants=0 narrows to the ancestor chain only.
- polylogue/daemon/thread_continue.py owns the per-agent URL template
  registry (Claude Code, Codex, plus a copy-as-prompt clipboard
  fallback) and the URL constructor. Overrides flow through
  POLYLOGUE_READER_AGENT_TEMPLATES; invalid JSON falls back to the
  built-ins so the reader never crashes on a malformed env var.
- GET /api/thread-continue-templates returns the active registry.
  Templates are substituted client-side so the daemon never observes
  the message text the operator is "continuing" elsewhere.

Reader:
- Conversation header gains a topology branch chip
  (continuation / sidechain / fork / subagent) using the MK3 q-*
  vocabulary, plus an "open chain" button that pre-populates the
  stack workspace with the parent chain.
- Lineage inspector tab gains a third action: "Open chain as stack".
- Per-message action rail gains a "continue" button that opens a
  small popover menu of agent templates; the copy-prompt entry writes
  to navigator.clipboard, every other entry hands off to the OS URL
  handler.

Tests:
- tests/unit/daemon/test_topology_stack.py covers chain ordering,
  branch-kind surfacing, sibling isolation, descendant exclusion,
  end-to-end dispatch against a seeded multi-generation tree, and the
  reader-shell structural contract (chip helpers, lineage action,
  parent-chain endpoint URL).
- tests/unit/daemon/test_thread_continue.py covers the built-in
  registry, env override (add / replace / disable), URL substitution
  encoding, endpoint dispatch, and the action-button + JS hook
  presence in the shipped HTML.

Budgets:
- daemon/web_shell.py 1514 lines (1500 -> 1550), daemon/http.py 2062
  lines (2050 -> 2100). Both file-size-budgets.yaml entries updated
  with the new endpoint/affordance attribution.
- Topology projection re-rendered to include the new
  daemon/thread_continue.py module.

Verification:
- devtools verify --quick: exit_code 0
- devtools verify --seed-testmon --skip-slow: 8219 passed, 2 xfailed
- Focused: pytest tests/unit/daemon/ -> 622 passed

Closes #1203
@coderabbitai

coderabbitai Bot commented May 19, 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 49 minutes and 8 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ 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: 10d4e898-b03b-444b-9f01-55f6b184d55e

📥 Commits

Reviewing files that changed from the base of the PR and between a9b21aa and d728b00.

📒 Files selected for processing (12)
  • docs/plans/file-size-budgets.yaml
  • docs/plans/topology-target.yaml
  • docs/topology-status.md
  • polylogue/daemon/http.py
  • polylogue/daemon/thread_continue.py
  • polylogue/daemon/topology_http.py
  • polylogue/daemon/web_shell.py
  • polylogue/daemon/web_shell_lineage.py
  • polylogue/daemon/web_shell_reader.py
  • polylogue/daemon/web_shell_workspace.py
  • tests/unit/daemon/test_thread_continue.py
  • tests/unit/daemon/test_topology_stack.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/reader-topology-stack-1203-v2

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 c6e646b into master May 19, 2026
2 of 5 checks passed
@Sinity
Sinity deleted the feature/feat/reader-topology-stack-1203-v2 branch May 19, 2026 02:00

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

ℹ️ 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/daemon/web_shell.py Resolved
@Sinity

Sinity commented Sep 30, 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.

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.

feat(reader): topology stack builder, branch chips, open-parent-chain-as-stack

1 participant