Skip to content

feat(browser): edit a page annotation's comment and intent inline in the tray - #17511

Merged
OrcaWin merged 2 commits into
stablyai:mainfrom
Sahir619:feat/browser-annotation-edit
Aug 31, 2026
Merged

OrcaWin merged 2 commits into
stablyai:mainfrom
Sahir619:feat/browser-annotation-edit

Conversation

@Sahir619

@Sahir619 Sahir619 commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

When you annotate an element in the embedded browser and make a typo, the only way to fix it today is to delete the annotation and re-pick the element on the page. This PR adds a small pencil button to each annotation row in the tray: click it, fix the text or intent right there, save. The element you picked stays picked.

What Changed

  • New store action updateBrowserPageAnnotation(pageId, annotationId, patch) next to the existing add/delete/clear actions. It no-ops (same state reference) when the id is missing and runs the merged annotation through the existing sanitizeBrowserPageAnnotation, so edits obey the same comment length budget as adds.
  • Each tray row gets a hover-revealed edit button beside the delete button. It swaps the row to an inline editor: a textarea seeded with the current comment, the intent toggle seeded with the current intent, and Save/Cancel. The screen submit shortcut saves, Escape cancels, Save is disabled while the trimmed comment is empty, and only one row edits at a time. If the annotation is deleted or the list cleared mid-edit, the edit state drops safely.
  • The annotate mode's window-level capture keydown listener gains an exemption for the edit container (marked data-slot="annotation-edit"), so Escape cancels only the row edit instead of tearing down the whole annotate session. A capture listener fires before descendant React handlers, so this cannot be solved with stopPropagation from inside the row.
  • Handler is threaded through the existing overlay props, so both surfaces that render the tray (browser pane and HTML doc preview) get the feature with no surface-specific code.
  • Four new machine-minted localization keys for the new strings (minted via the repo's extraction script, catalog checks pass).

Deliberately untouched: annotation element targets, cross-navigation persistence, and browser-annotation-output.ts (the send/copy builder reads comment and intent live off the array, so edited text flows through with no change).

Why

Annotations queue up feedback for an agent; a typo or a wrong intent choice currently costs the whole annotation, including the picked element. Inline editing preserves the target and keeps the review flow moving. Editing lives in the tray row rather than re-opening the anchored composer because the compose popover's anchor geometry is only guaranteed while an add is pending; the inline row edit avoids that entire class of stale-anchor problems.

Linked Issue

Fixes #17501

Visual Proof

Before and after screenshots attached (before: hover reveals only delete; after: hover reveals edit + delete; after: the row in inline edit mode).
annotation-edit-before

annotation-edit-after-hover annotation-edit-after-editing

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Manually verified on Windows in the dev app: pencil appears on hover, editing seeds current values, save updates the row and the copied feedback, cancel and Escape leave the annotation unchanged, Escape does not exit annotate mode.

Automated: 3 new store tests (update merges and sanitizes like add; nonexistent id is a strict no-op) and a new component test for the tray (seeded editor, save passes trimmed comment and chosen intent, cancel restores the read view, Escape regression). Full targeted suite: 83 tests across 12 files pass. Typecheck passes for node, web, and cli projects; oxlint clean on changed files; max-lines ratchet clean; localization catalog, extraction, and coverage checks pass.

AI Disclosure

Built with Claude Code (Claude Fable 5). The implementation, tests, and an adversarial review pass were AI-generated under human direction and manual verification; the feature was manually tested in the running app by the author.

Review

AI code-review summary (adversarial pass over the diff):

  • Cross-platform: renderer-only change; no platform APIs, shortcuts use the existing isScreenSubmitShortcut helper which already handles the Mac/Windows modifier split.
  • SSH/remote and agent compatibility: no wire, RPC, or host-side changes; the send/copy prompt content is produced by the untouched output builder.
  • Performance: state updates are targeted array maps behind an id lookup; no new subscriptions or effects in hot paths.
  • UI: shadcn primitives and existing tray patterns reused; a11y labels on the new controls (edit button and textarea both labeled); two review findings (Escape swallowed by a window-level capture listener, unlabeled textarea) were found and fixed before this PR.
  • Security: no new inputs cross a trust boundary; edited comments pass through the same sanitizer and length budget as added ones.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

No security, SSH, mobile, or backwards-compatibility surface is touched; the change is confined to the renderer's annotate components and one store slice. The one subtle interaction (annotate mode's global Escape handling) is covered by a dedicated regression test.

Author

X: @Sahir__S

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

🤖 Generated with Claude Code

…the tray

Fixing a typo in a browser annotation required deleting it and re-picking
the element in the page. Each tray row now has a hover-revealed edit
button that swaps the row to an inline editor (comment textarea seeded
with the current text, intent toggle, Save/Cancel), reusing the compose
card's submit shortcut and length budget. Edits route through a new
updateBrowserPageAnnotation store action that no-ops on a missing id and
sanitizes the merged annotation exactly like the add path.

Escape inside the editor cancels only the row edit: the annotate mode's
window-level capture listener now exempts the edit container, since
stopPropagation from a descendant cannot reach a capture listener.

Editing is deliberately limited to comment and intent: element targets,
cross-navigation persistence, and the prompt builder are untouched (the
builder reads live off the array, so edited text flows through).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017rEaTnSaSneEMEJvebzM53
@Sahir619
Sahir619 requested a review from brennanb2025 as a code owner August 31, 2026 00:29
@greptile-apps

greptile-apps Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Greptile Summary

This PR adds inline editing for browser-page annotation comments and intents while preserving the selected page element.

  • Adds a sanitized store update action that retains annotation identity and target data.
  • Adds edit, save, cancel, intent selection, and submit-shortcut behavior to annotation tray rows.
  • Coordinates editor Escape handling with the annotate mode’s window-level keyboard listener.
  • Threads the update handler through the shared overlay path and adds localization and focused tests.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
src/renderer/src/components/browser-pane/annotate/browser-page-annotation-tray.tsx Adds a labeled inline editor with seeded state, validated save behavior, cancellation, and edit-state cleanup.
src/renderer/src/components/browser-pane/annotate/useGrabMode.ts Exempts annotation editor descendants from the capture-phase Escape handler so the row can own cancellation.
src/renderer/src/components/browser-pane/annotate/use-browser-page-annotation-send.ts Connects tray edits to the browser annotation store action and feature-interaction tracking.
src/renderer/src/store/slices/browser.ts Adds an annotation update action that preserves strict no-op behavior for missing IDs and sanitizes merged values.
src/renderer/src/components/browser-pane/annotate/browser-page-annotation-tray.test.tsx Covers editor seeding, trimmed saves, intent updates, cancellation, accessible control names, and Escape behavior.
src/renderer/src/components/browser-pane/annotate/useGrabMode.test.ts Covers the editor-specific Escape exemption and preserves cancellation outside exempt containers.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Annotation tray row] -->|Edit| E[Inline editor]
    E -->|Save comment and intent| H[Update handler]
    H --> S[Browser store update]
    S --> Z[Sanitize merged annotation]
    Z --> T[Updated tray and generated feedback]
    E -->|Cancel or Escape| A
    G[Grab-mode capture listener] -->|Escape inside editor: exempt| E
Loading

Reviews (2): Last reviewed commit: "test(browser): pin the annotate-mode Esc..." | Re-trigger Greptile

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one minor suggestion inline.

Reviewed changes

  • Store action — updateBrowserPageAnnotation(pageId, annotationId, patch) merges { comment, intent } into the target annotation, runs the result through the existing sanitizeBrowserPageAnnotation, and returns the unchanged state reference when the id is missing (a strict no-op).
  • Inline row editor — the tray row swaps to a textarea + intent toggle + Save/Cancel; Save trims the comment and is disabled while empty, the screen-submit shortcut saves, Escape cancels, and a useEffect drops edit state when the annotation disappears mid-edit.
  • Escape exemption — useGrabMode's window-level capture listener now bails out for [data-slot="annotation-edit"], so Escape inside the editor cancels only the row edit instead of tearing down the annotate session.
  • Wiring & i18n — handleUpdateBrowserAnnotation is threaded through the shared overlay props (both browser pane and doc preview), plus four minted localization keys.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

…edits

The data-slot annotation-edit clause in useGrabMode's capture keydown
listener had no test that dispatched a keydown through it, so deleting
the clause left the suite green. These tests invoke the real registered
capture handler with an Escape whose target sits inside (and outside) an
annotation-edit container; the inside case uses a button, which
isEditableKeyboardTarget does not cover, so only the exemption clause
can keep grab mode alive. Removing the clause now fails the suite.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Escape-exemption regression test — added a test that invokes the real capture-phase keydown handler with an Escape whose target sits inside a [data-slot="annotation-edit"] container, pinning the useGrabMode exemption against accidental removal.
  • Negative-path test — added a companion test confirming Escape from outside any exempt container still cancels grab mode.
  • Test environment — switched the file to happy-dom and clears document.body in afterEach to support the new DOM assertions.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@OrcaWin
OrcaWin merged commit 60a7ac3 into stablyai:main Aug 31, 2026
2 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…the tray (stablyai#17511)

* feat(browser): edit a page annotation's comment and intent inline in the tray

Fixing a typo in a browser annotation required deleting it and re-picking
the element in the page. Each tray row now has a hover-revealed edit
button that swaps the row to an inline editor (comment textarea seeded
with the current text, intent toggle, Save/Cancel), reusing the compose
card's submit shortcut and length budget. Edits route through a new
updateBrowserPageAnnotation store action that no-ops on a missing id and
sanitizes the merged annotation exactly like the add path.

Escape inside the editor cancels only the row edit: the annotate mode's
window-level capture listener now exempts the edit container, since
stopPropagation from a descendant cannot reach a capture listener.

Editing is deliberately limited to comment and intent: element targets,
cross-navigation persistence, and the prompt builder are untouched (the
builder reads live off the array, so edited text flows through).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_017rEaTnSaSneEMEJvebzM53

* test(browser): pin the annotate-mode Escape exemption for annotation edits

The data-slot annotation-edit clause in useGrabMode's capture keydown
listener had no test that dispatched a keydown through it, so deleting
the clause left the suite green. These tests invoke the real registered
capture handler with an Escape whose target sits inside (and outside) an
annotation-edit container; the inside case uses a button, which
isEditableKeyboardTarget does not cover, so only the exemption clause
can keep grab mode alive. Removing the clause now fails the suite.

---------

Co-authored-by: Claude Fable 5 <[email protected]>
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.

[Feature]: Edit a browser annotation's comment and intent without deleting it

2 participants