Skip to content

feat: warn before closing annotation review unless submitted #179

Description

@blimmer

What's the problem?

The annotation UI can currently lose review feedback if a user closes the browser window or tab before submitting. The in-app discard dialog in PR #174 protects an active draft when users dismiss the annotation popover, but it does not cover broader page-close cases such as Cmd+W or closing the spawned browser window.

The risk is broader than losing typed feedback. Today the CLI blocks indefinitely on server.result (packages/cli/src/annotation/runAnnotation.ts:121) when the user closes the browser window without submitting — the TCP connection drops but nothing resolves the promise. A user reported their terminal stayed "suspended" after closing the window instead of clicking Submit/Approve, and only realized after sending Claude another prompt and waiting that the CLI was still hung waiting on the happy-path exit. (CLI-side resilience to a dropped browser connection is tracked separately; this issue is scoped to the UI guard.)

Proposed solution

Register a beforeunload listener for the annotation UI whenever the review has not yet been successfully submitted, regardless of whether any pending feedback exists. The only state that disables the guard is "submission succeeded" — once setSubmitted(true) fires (packages/annotation/src/useAnnotationState.ts:152), the listener must be removed so the auto-close countdown's window.close() call (useAnnotationState.ts:194-215) completes silently.

An unload prompt should fire when the user closes the browser/tab in any of these states:

  • the page just loaded and nothing has been added yet (today this hangs the terminal silently);
  • one or more annotation threads have been saved but not submitted;
  • a non-whitespace global comment has been typed but not submitted;
  • a dirty active draft is open.

The submitted-and-auto-closing state must not prompt.

Alternatives considered

Guard only when pending feedback exists (the original proposal on this issue). Rejected: it leaves the "user closes window without submitting" path silent, and that path hangs the CLI even when there is no feedback to lose. The cost of an extra confirmation prompt on an empty review is small compared to a stuck terminal.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions