Skip to content

feat(reader): insights browser (#1120) - #1177

Merged
Sinity merged 1 commit into
masterfrom
feature/feat/reader-insights-browser-v3
May 17, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/feat/reader-insights-browser-v3

Conversation

@Sinity

@Sinity Sinity commented May 17, 2026

Copy link
Copy Markdown
Owner

Summary

Adds the per-conversation insights browser to the daemon web reader plus
the backing GET /api/insights/sessions/{id} endpoint. The panel
surfaces the four per-session insight kinds (session profile,
work-event timeline, session phases, work-thread membership) as a
single typed envelope, with collapsible per-kind sections and an
explicit readiness chip on each.

Problem

Issue #1120 specifies an insights browser in the reader that exposes
the bounded session insight products (#1018) inline on the
conversation page, with a readiness/freshness chip per panel
(#1019), and reads only through the public insight surfaces — no
direct insight-table queries from the reader.

Until this PR the daemon web shell had no surface onto the per-session
insight substrate landed under #1018 / #1133 / #1135. Selecting a
conversation in the reader exposed Info / Cost / Raw / Notes tabs
only; the materialized profile, work events, phases, and work-thread
membership were reachable through MCP and the CLI but invisible to a
reader operator.

Solution

  • New route GET /api/insights/sessions/{id}[?include=profile,timeline, phases,threads] in polylogue/daemon/http.py. Routes through the
    public facade adapters
    (Polylogue.repository.get_session_profile,
    list_session_work_event_insights, list_session_phase_insights,
    list_work_thread_insights) — the same path the CLI and MCP use, so
    the reader does not import insight storage modules directly
    (AC#1120). Includes the ?include= query parameter to restrict the
    envelope to a subset of kinds; unknown tokens are dropped and the
    canonical kind ordering is preserved.
  • Module-level helpers _readiness_tag, _parse_insight_includes,
    _profile_panel_payload, _work_event_panel_payload,
    _phase_panel_payload, _thread_panel_payload project the typed
    insight records into a stable JSON shape. The readiness chip
    vocabulary is closed (q-ready / q-partial / q-missing) and is
    exercised by unit tests.
  • Reader inspector gains an Insights tab. The renderer lazy-loads
    the endpoint into state.insightsPanels, shows one collapsible
    section per kind, surfaces the readiness chip in each section header
    with a row count, and renders a per-kind empty body
    (No <kind> recorded.) when the substrate has no rows — the panel
    is never blank (AC#1120).
  • Unknown conversations return a hard 404 not_found. Existing
    conversations without materialized insights return 200 with
    explicit q-missing shapes per kind (AC#1120). Each per-kind list
    call is wrapped in a guard against
    ArchiveInsightUnavailableError so an unmaterialized substrate
    surfaces as q-missing rather than 503 the whole envelope.
  • CSS extends the existing MK3 chip vocabulary with q-ready and
    q-missing palette entries reusing the --ok / --text-dim
    tokens; adds .insight-section-header / .insight-toggle /
    .muted for the section affordances.
  • File-size budgets bumped: polylogue/daemon/http.py 1340 -> 1600,
    polylogue/daemon/web_shell.py 1280 -> 1460, both with a
    split candidate note pointing at the future per-domain handler /
    per-tab decomposition.

Verification

$ nix develop -c pytest tests/unit/daemon/test_insights_browser_endpoint.py \
                 tests/visual/test_reader_dom_smoke.py::test_reader_insights_browser_evidence -p no:randomly
22 passed in 9.27s

$ nix develop -c pytest tests/unit/daemon/test_cost_panel_endpoint.py \
                 tests/visual/test_reader_dom_smoke.py -p no:randomly -q
24 passed in 12.50s

$ nix develop -c devtools verify --quick
... exit_code: 0  (~36s, all gates pass after one render-pages refresh)

Unit contracts pin the readiness chip vocabulary mapping
(materialized/row_count -> q-ready/q-partial/q-missing), the
?include= parser (None/empty default, subset, unknown-token drop,
canonical ordering), the four panel projector empty shapes, and the
dispatch path (404 for unknown, 200 + typed envelope for known,
?include= honored). Visual DOM smoke evidence (#865) pins the
Insights inspector tab and the readiness chip vocabulary
(q-ready / q-partial / q-missing plus Work events, Phases,
Work threads section labels) in the shell HTML, and exercises the
live endpoint against the seeded reader workspace including the
subset and unknown-conversation paths.

Acceptance criteria status (#1120)

  • Reader exposes session-profile, work-events, phases, threads
    inline on the conversation page via the new Insights
    inspector tab.
  • Each panel renders a readiness chip from the closed
    q-ready / q-partial / q-missing vocabulary; missing /
    stale state is explicit (the empty-state body says
    "No recorded.").
  • Reader code does not import insight storage modules directly —
    only the public Polylogue.list_session_*_insights adapters
    and Polylogue.repository.get_session_profile.
  • Tests assert the reader survives stale, missing, and partial
    insight states (each kind defaults to q-missing; the handler
    catches ArchiveInsightUnavailableError per kind).
  • Visual smoke harness (test(reader): add local web reader visual smoke harness #865) covers the ready / missing /
    partial chip vocabulary in the shell and exercises both the
    known and unknown conversation paths.

Deferred to follow-ups (not in scope for this slice):

  • Day-summary and week-summary browse views — the inline conversation
    insights panel is the focus of this PR; the day/week dedicated
    routes are tracked separately as part of tracking: webui advanced functionality (resurrected from #955) #993.
  • Provenance-based staleness chip (stale) — wiring
    polylogue.insights.provenance.is_stale into the readiness chip
    per-kind requires source-high-water-mark plumbing that is out of
    scope here; the readiness chip currently reports
    q-ready/q-partial/q-missing based on materialization presence
    and row count.

Closes #1120

Co-authored-by: Claude Opus 4.7 (1M context) [email protected]

@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 37 minutes and 22 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: 17d6d4b9-daa3-4ea6-ad40-b1a61cc2454a

📥 Commits

Reviewing files that changed from the base of the PR and between b3f36da and 4908c59.

📒 Files selected for processing (5)
  • docs/plans/file-size-budgets.yaml
  • polylogue/daemon/http.py
  • polylogue/daemon/web_shell.py
  • tests/unit/daemon/test_insights_browser_endpoint.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/reader-insights-browser-v3

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.

Adds the per-conversation insights browser to the daemon web reader plus
the backing GET /api/insights/sessions/{id} endpoint. The panel surfaces
the four per-session insight kinds (session profile, work-event timeline,
session phases, work-thread membership) as a single typed envelope, with
collapsible per-kind sections and an explicit readiness chip on each.

Ref #1120

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@Sinity
Sinity force-pushed the feature/feat/reader-insights-browser-v3 branch from 6167e23 to 4908c59 Compare May 17, 2026 16:40

@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: 6167e23fc5

ℹ️ 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/http.py
Comment on lines +298 to +299
"readiness_tag": _readiness_tag(materialized=bool(events), row_count=len(events)),
"materialized": bool(events),

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 Mark empty insight rows as partial, not missing

This readiness mapping treats materialized as bool(events), so a conversation with a fully materialized insight surface but zero matching rows is reported as q-missing instead of q-partial. That misclassifies the state the endpoint is meant to convey (empty result vs unavailable substrate), and the same pattern is repeated for phases and threads, so the reader cannot reliably distinguish “no data for this session” from “insight kind not materialized.”

Useful? React with 👍 / 👎.

Comment thread polylogue/daemon/http.py
try:
# Work threads are not keyed per-conversation in the substrate;
# the reader filters the materialized rows by membership.
all_threads = await poly.list_work_thread_insights(WorkThreadInsightQuery(limit=None))

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 Avoid full archive thread scan per session request

The per-conversation insights handler fetches all work-thread insights with limit=None and then filters membership in Python. On archives with many threads, every GET /api/insights/sessions/{id} call does a full-table read and deserializes every thread payload just to return one conversation’s subset, which will noticeably slow the inspector and increase memory pressure as data grows.

Useful? React with 👍 / 👎.

@Sinity
Sinity merged commit 7c14cb5 into master May 17, 2026
4 checks passed
@Sinity
Sinity deleted the feature/feat/reader-insights-browser-v3 branch May 17, 2026 16:43
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): insights browser for session profiles, events, phases, threads

1 participant