Repository navigation
Closed
Description
Goal
Harden Review Tutor for unusually long answer streams and simultaneous browser tabs after PR #61 ships.
Context
Local review of PR #61 confirmed the current behavior is correct for the single-user flow, but identified two bounded follow-ups that should not expand the approved page-focused PR:
appendAnswerreparses and rebuilds the complete Markdown tree for every SSE delta. A long answer split into many small chunks can create avoidable main-thread work and clear native text selection.- When a page has no
currentQuestionId, reconnect state adopts the newest queued/running question. That is useful for reload recovery, but a second tab can cause a question it started to appear in the first tab.
PR #61 already buffers pre-response events, reconciles canonical state, bounds Markdown recursion, and prevents duplicate active submissions. This issue is about efficiency and explicit multi-tab ownership, not correctness recovery.
Acceptance criteria
- Coalesce streamed Markdown renders to at most one DOM update per animation frame while preserving exact accumulated answer text.
- Terminal question events render synchronously from canonical state and cannot lose a final delta.
- Native selection in an answer is not repeatedly destroyed by multiple deltas in one frame.
- Add a deterministic large-stream test that proves bounded render count and exact final output.
- Define page/question ownership for reload recovery versus a second active tab without exposing the bearer token or changing the parent Pi session.
- A reload can still recover its sole queued/running question.
- A separate tab does not silently adopt another tab's new question unless the ownership contract explicitly permits it.
- Preserve
rt/1unless a protocol change is demonstrably required; if required, document compatibility before implementation. - Keep the loopback, read-only, bounded-process, persistence, export, and cancellation contracts unchanged.
Evidence
- Source PR: feat(review-tutor): redesign guided review interface #61
- Review measurement: repeated full Markdown renders reached seconds of parser/DOM work for a tens-of-KiB answer split across hundreds of deltas in happy-dom.
- Current multi-tab behavior is intentionally accepted for the local single-tab release and has no P0–P2 impact.
Metadata
Metadata
Assignees
Labels
No labels
Activity
ElbertePlinio commentedon Aug 23, 2026
Agent plan
Goal: coalesced long-answer streaming and explicit multi-tab question ownership, as one PR stacked on #65 for a single batched human review.
Checklist:
Current status: In progress (worktree feat/review-tutor-hardening, based on #65)
Next: implementation lane dispatch
ElbertePlinio commentedon Aug 23, 2026
Progress update — PR open: #66 (stacked on #65)
ownerPageId, owner-or-legacy adoption; rt/1 unchanged)bun run check: 419 passed | 25 skipped, coverage 78.34%Next: CI, then Ready for human review. No merge without Elberte's authorization.
ElbertePlinio commentedon Aug 23, 2026
PR #66 is Ready for human review at
551cb83(matches the locally verified tree; basefeat/review-tutor-package, mergeable).No merge attempted; batched with the #65 → #66 → #62 chain for one human review.
ElbertePlinio commentedon Aug 24, 2026
PR #66 was auto-closed by GitHub when its base branch was deleted by the #65 merge (it cannot be reopened). Recreated as #68 against
mainat9576fb0— same reviewed content, rebased. #67 is rebased on top. Ready for human review once CI is green.ElbertePlinio commentedon Aug 24, 2026
Human smoke on #68 (2026-08-24): streaming passed. Reload/second-tab blocked by a real defect:
GET /requires?session=but the page strips it after load, so a browser refresh returns the 401 JSONpage token failed. Pre-existing from #61, but #68 owns the reload-recovery criterion and its test did not cross the HTTP boundary. Fix in progress on the #68 branch: token-less/serves a bootstrap page that re-enters via the tab's sessionStorage token; a wrong token serves a non-redirecting stale-session page. Second tabs still require the tokenized link by design.