Skip to content

refactor: replace !!origin proxy with dedicated isApiMode in review editor #419

@backnotprop

Description

@backnotprop

Problem

The review editor uses !!origin as a proxy for "is there a server backing this UI?" in multiple places:

  • useCodeAnnotationDraft({ isApiMode: !!origin, ... }) (line 175)
  • useExternalAnnotations({ enabled: !!origin }) (line 189)
  • if (!origin) return; // Demo mode in the keyboard shortcut handler (line 954)
  • Conditional UI rendering ({origin ? ( at line 1102)

origin is an identity field ("claude-code", "opencode", "pi") indicating who launched the review. It's not a connectivity signal. The standalone dev server (apps/review/) doesn't set origin, so all server-dependent features are silently disabled there.

Proposed Fix

Add a dedicated isApiMode boolean state to ReviewApp, matching the pattern already used in the plan editor (packages/editor/App.tsx):

const [isApiMode, setIsApiMode] = useState(false);

Set it in the /api/diff fetch:

  • .then(...)setIsApiMode(true)
  • .catch(...) → remains false

Replace all !!origin API-mode checks with isApiMode. Leave origin for its intended purpose: display branding and agent-specific features.

Files

  • packages/review-editor/App.tsx — main change
  • packages/ui/hooks/useCodeAnnotationDraft.ts — already accepts isApiMode param, just needs the correct value passed in

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions