Skip to content

Keep the Approve button visible after the watcher disconnects - #148

Open
jamescbury wants to merge 1 commit into
Lex-Inc:mainfrom
jamescbury:fix/sticky-approve-button
Open

jamescbury wants to merge 1 commit into
Lex-Inc:mainfrom
jamescbury:fix/sticky-approve-button

Conversation

@jamescbury

Copy link
Copy Markdown

Problem

The Approve / Done Reviewing button is rendered only while an agent watcher is connected:

const showReviewHandoffButton =
  !!activeDocumentPath &&
  (reviewWatcherCount > 0 || reviewHandoffState !== "idle");

Watcher status is polled every 1.5s, so if the roughdraft open/watch process dies mid-review (agent crash, server restart, or the >5-minute watch timeout addressed in #144), the button silently unmounts while the reviewer is still reading. From the reviewer's side the Approve button just disappears with no explanation, and there is no way to hand the document back.

This happened in practice: a reviewer finished commenting on a document, went to approve, and the button was gone because the watching agent's process had died minutes earlier.

Fix

Track whether a watcher has ever been seen for the active document (reviewWatcherSeen, reset when the document changes) and keep the button rendered once one has. A transient watcher drop no longer hides the handoff affordance.

Clicking while no watcher is connected already degrades cleanly through the existing machinery: the server reports delivered: false, the UI enters the undelivered state ("No agent is watching now"), and the existing effect re-arms the button to idle when a watcher reconnects — no new states or copy needed.

Documents opened without any watcher behave exactly as before (no button).

Testing

  • pnpm --filter @roughdraft/app test — 225 tests pass.
  • Manual: registered a watcher via roughdraft watch, opened the document (?path=), confirmed the button renders; killed the watcher process and waited for the server-side waiter to expire (/api/review-events/status reporting watcherCount: 0); the button remains visible. On main it unmounts within one 1.5s poll.

Independent of #144, but the two failures compound: #144 stops the watcher dying at the 5-minute mark, and this PR stops the UI stranding the reviewer whenever a watcher dies anyway.

🤖 Generated with Claude Code

The Approve / Done Reviewing button was rendered only while an agent
watcher was connected (reviewWatcherCount > 0). If the watch process
crashed or the server restarted mid-review, the button silently
unmounted within one 1.5s poll, leaving the reviewer with no way to
hand off — and no explanation.

Track whether a watcher has ever been seen for the active document
(reviewWatcherSeen, reset on document change) and keep the button
rendered once it has. Clicking with no watcher already degrades
cleanly: the server reports delivered=false, the existing
"undelivered" state explains that no agent is watching, and the
button re-arms automatically when a watcher reconnects.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

@jamescbury is attempting to deploy a commit to the Lex Team on Vercel.

A member of the Team first needs to authorize it.

jmatthewpryor added a commit to jmatthewpryor/roughdraft that referenced this pull request Sep 11, 2026
… bump to 0.1.11-patched.2

Adapts Lex-Inc#149 to a per-watch undici Agent instead of a process-wide
singleton: the singleton kept a pooled keep-alive socket to a server that
had since restarted, so the next watch in the same process failed with
UND_ERR_SOCKET "other side closed". The Agent is now created per watch in
both the CLI and the MCP watch tool and closed in a finally.

Fixes a pre-existing race in two CLI tests that posted the review event as
soon as the watch request had been sent, before the server had registered
the waiter; they now poll /api/review-events/status for a watcher first.

Documents the new patches, the Lex-Inc#149 adaptation, the merge-conflict notes,
and the new "handoff after watcher lost" state in the screenshot guide.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
felciano added a commit to felciano/roughdraft that referenced this pull request Oct 31, 2026
…the watcher disconnects

From Lex-Inc#148, unmerged upstream as of 2026-10-31.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LXZP8LMTVHbkEsmdNZzjyf

This branch has not been deployed

No deployments
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