Skip to content

feat(reader): conversation compare side-by-side (#1124) - #1175

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/reader-conversation-compare
May 17, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/reader-conversation-compare

Conversation

@Sinity

@Sinity Sinity commented May 17, 2026

Copy link
Copy Markdown
Owner

Summary

Extend the reader's existing /api/compare endpoint with anchor-based message alignment, per-pair diff classification, and a metadata diff panel so two conversations can be inspected side-by-side with explicit content-drift markers. Adds a "Compare with…" entry point in the inspector and pins the new compare module under polylogue/daemon/compare.py.

Closes #1124.

Problem

The compare workspace shipped only as a positional pair view: messages were zipped index-by-index, the UI showed no diff affordance, and no metadata delta surfaced (provider, model, repo, tags). Operators could open /w/compare?left=…&right=… but could not see what differed between the two sides, and there was no entry point from a single-conversation view. The issue calls for:

  • Message-level alignment using shared anchors when present, otherwise sequential.
  • Diff affordances highlighting changed message content.
  • Metadata diff (provider / model / timestamps / tags).
  • Empty / degraded states when one side fails to load.
  • An entry point ("Compare with…") from the reader.

Solution

  • polylogue/daemon/compare.py (new) owns alignment + diff semantics. Lifts the inline pairing logic out of workspace_routes and adds:
    • Shared-anchor walker covering the fork/branch case where messages retain identical anchors. Falls back to sequential pairing otherwise. The chosen strategy is reported as alignment: "anchor" | "sequential" so the UI can show it.
    • Per-pair diff_status (equal | changed | added | removed) plus a role_match flag for cross-role drift.
    • METADATA_FIELDS sweep producing a metadata_diff envelope keyed by field with left/right/status. Tag membership normalised so order is irrelevant.
    • degraded_sides + degraded_count so a one-side-missing or both-sides-missing scenario renders an explicit banner instead of crashing the UI.
  • polylogue/daemon/workspace_routes.py — build_compare_payload now delegates to the new module. The dispatcher and align-mode validation are untouched, preserving the existing 400-rejection of unsupported align= values.
  • polylogue/daemon/web_shell_workspace.py renders the metadata diff panel above the pair list, colours each pair gutter by diff_status (green/red/yellow for added/removed/changed), and shows the alignment strategy as a header chip. The degraded banner now names which side failed to load.
  • polylogue/daemon/web_shell.py adds a "Compare with…" action in the inspector Info tab that prompts for another conversation id and opens the compare route. Self-compare is rejected client-side.
  • Tests:
    • tests/unit/daemon/test_compare.py — exhaustive unit coverage for metadata diff, anchor vs sequential alignment, added/removed/changed/equal classification, role-match flag, and missing-side envelope. Uses synthetic dict payloads so it does not boot the daemon.
    • tests/unit/daemon/test_web_reader.py — HTTP smoke updated to assert the new envelope fields (alignment, degraded_sides, metadata_diff) and a new two-conversation scenario covering diff_status + metadata changes for the seeded archive.
  • docs/plans/file-size-budgets.yaml records a focused exception for polylogue/daemon/web_shell.py (was already near the default ceiling — picked up ~21 lines for the Compare entry point). Matches the existing daemon/http.py exception pattern with a stated split candidate (daemon/web_shell_inspector.py).
  • docs/plans/topology-target.yaml and docs/topology-status.md regenerated via devtools build-topology-projection to declare the new polylogue/daemon/compare.py module.

Verification

nix develop -c devtools verify --quick
  → "exit_code": 0  ("total_duration_s": 21.29)
nix develop -c pytest tests/unit/daemon/test_compare.py tests/unit/daemon/test_web_reader.py
  → 82 passed in 12.08s

Acceptance criteria (#1124)

  • Reader exposes a compare mode taking two conversation ids — existing /w/compare?left=…&right=…&align=prompt route, now also reachable via the inspector "Compare with…" action.
  • Compare mode renders both conversation payloads without unbounded raw payload expansion — same messageBlocksHtml collapse cap (2000 chars) as single mode.
  • Message-level alignment uses shared anchors when present, falls back to sequential — compare.align_messages returns ("anchor" | "sequential", pairs) and the UI surfaces the strategy as a chip. Lineage substrate (feat(topology): materialize session identity and lineage graph #866) can supply richer anchors without changing the envelope.
  • Metadata diff panel shows provider / model / timestamp / tag deltas — metadata_diff envelope + #compare-metadata-panel.
  • One-side-missing and one-side-error states rendered explicitly — degraded_sides populated, banner names the failing side.
  • Reader routes go through the shared query/status contracts (refactor(api): define shared query/status contracts for all read surfaces #859) — endpoint unchanged from existing dispatcher; payload reuses TargetRefPayload via the existing _do_get_conversation loader.
  • Visual smoke harness (test(reader): add local web reader visual smoke harness #865) covers aligned/unaligned/one-side-missing — structural HTTP smoke + DOM-region asserts pin alignment/missing-side now; pixel/playwright wiring belongs in test(reader): add local web reader visual smoke harness #865's own scope.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented May 17, 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 5 minutes and 37 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: bc8223b9-a55b-471d-9c93-b16d75dc2f39

📥 Commits

Reviewing files that changed from the base of the PR and between eb133fd and f3d2e42.

📒 Files selected for processing (9)
  • docs/plans/file-size-budgets.yaml
  • docs/plans/topology-target.yaml
  • docs/topology-status.md
  • polylogue/daemon/compare.py
  • polylogue/daemon/web_shell.py
  • polylogue/daemon/web_shell_workspace.py
  • polylogue/daemon/workspace_routes.py
  • tests/unit/daemon/test_compare.py
  • tests/unit/daemon/test_web_reader.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/feat/reader-conversation-compare

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.

Extend the reader's existing /api/compare endpoint with anchor-based
message alignment, per-pair diff classification, and a metadata diff
panel so two conversations can be inspected side-by-side with explicit
content-drift markers.

Problem
-------
The compare workspace shipped only as a positional pair view: messages
were zipped index-by-index, the UI showed no diff affordance, and no
metadata delta surfaced (provider, model, repo, tags). Operators could
open the layout but could not see what differed between the two sides,
and there was no entry point from a single-conversation view.

Solution
--------
- New polylogue/daemon/compare.py owns alignment + diff semantics. Lifts
  the inline pairing logic out of workspace_routes and adds:
  * shared-anchor walker (covers fork/branch case where messages retain
    identical anchors); falls back to sequential pairing otherwise.
  * per-pair diff_status (equal | changed | added | removed) plus a
    role_match flag for cross-role drift.
  * METADATA_FIELDS sweep producing a metadata_diff envelope keyed by
    field with left/right/status; tag membership normalised so order is
    irrelevant.
  * envelope carries alignment ("anchor" | "sequential"),
    degraded_sides, and degraded_count so the UI can render precise
    empty/degraded banners.
- workspace_routes.build_compare_payload now delegates to the new
  module; the existing dispatcher and align validation are untouched.
- web_shell_workspace renders the metadata diff panel above the pair
  list, colours each pair gutter by diff_status, and shows the
  alignment strategy as a header chip. Degraded banner names which
  side failed to load.
- web_shell adds a "Compare with..." action in the inspector Info tab
  that prompts for another conversation id and opens the compare route.
- Tests:
  * tests/unit/daemon/test_compare.py — exhaustive unit coverage for
    metadata diff, anchor vs sequential alignment, added/removed/
    changed/equal classification, and missing-side envelope.
  * tests/unit/daemon/test_web_reader.py — HTTP smoke for the new
    envelope fields and a two-conversation diff scenario.
- File-size budgets updated: web_shell.py picked up ~21 lines for the
  Compare entry point and exceeded the default 1100 ceiling. Recorded
  a focused exception with split candidate, matching the existing
  daemon/http.py pattern. Topology projection regenerated.

Verification
------------
nix develop -c devtools verify --quick → exit_code 0 (22s).
nix develop -c pytest tests/unit/daemon/test_compare.py tests/unit/daemon/test_web_reader.py
  → 82 passed in 12s.

Closes #1124

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@Sinity
Sinity force-pushed the feature/feat/reader-conversation-compare branch from f939515 to f3d2e42 Compare May 17, 2026 10:25
@Sinity
Sinity merged commit bd026f1 into master May 17, 2026
3 checks passed
@Sinity
Sinity deleted the feature/feat/reader-conversation-compare branch May 17, 2026 10:25
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): conversation compare side-by-side

1 participant