Skip to content

fix(desktop-gpui): take keyboard shortcuts as soon as the screenshot editor opens - #4303

Merged
richiemcilroy merged 3 commits into
mainfrom
fix/screenshot-editor-keys-on-open
Nov 17, 2026
Merged

richiemcilroy merged 3 commits into
mainfrom
fix/screenshot-editor-keys-on-open

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

The screenshot editor ignored Cmd+C (and every other shortcut) until you clicked inside it. It now takes keys as soon as it opens, as the 0.6.0 editor did.

Root cause

flowchart LR
  K[Cmd+C] --> D{window focus}
  D -- "nothing focused (before)" --> R[root view node only]
  R -.x.- H["on_key on the editor's root div"]
  D -- "editor focus handle (after)" --> H
  H --> C[copy to clipboard]
Loading
  • Every shortcut lives on one on_key_down listener on the editor's root div (apps/desktop-gpui/src/screenshot_editor.rs, track_focus(&self.focus)).
  • gpui dispatches keys along the focused element's path. With nothing focused it uses the dispatch tree's root node, which is the root view, not the div under it, so the listener never runs (focus_node_id_in_rendered_frame in gpui's window.rs).
  • ScreenshotEditorWindow::new created self.focus but never focused it. A click on any control called window.focus(&self.focus, cx), which is why it started working after a click.

Change

  • ScreenshotEditorWindow::new ends with window.focus(&this.focus, cx).
  • Window::focus only sets gpui's in-window focus. It does not activate the app or order the window, so nothing is taken from other apps. Activation is unchanged: bring_screenshot_editor_forward already activates the editor when it opens, as before.
  • Covers every shortcut on that listener: Cmd/Ctrl+C, V, S, Z, Shift+Z, Y, zoom (-, =), tool keys (A, R, M, C/O, D, T, V/S), popovers (P, B, H, E), L, Escape, Backspace/Delete. Text fields still win: the handler bails when an input is focused, and clicking an input moves focus to it as before.
  • Reopening an editor that is already open goes through bring_screenshot_editor_forward and keeps whatever had focus.

Tests

  • open_focus::shortcuts_work_before_the_window_is_clicked: opens the editor as a window root with no extra focus call, presses p (padding popover opens) and cmd-c (copy export starts). Fails on main at the first assertion.

Proof

Real screenshot on macOS 27 (Apple silicon), debug builds, CAP_GPUI_AUTO_RECORD=screenshot, Cap frontmost, pasteboard primed with a text sentinel, then a posted Cmd+C:

Build Cmd+C right after the editor opens Click in the editor, then Cmd+C
main pasteboard unchanged (string sentinel) image on pasteboard (PNGf, TIFF, ...)
this branch image on pasteboard (PNGf, TIFF, ...) image on pasteboard

Linux full cap-gpui suite: same 2 hardware-enumeration failures as main, plus the new test passing. Clippy warning count unchanged.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

Gives the screenshot editor keyboard focus when it opens so shortcuts work before the first click.

  • The screenshot editor responds to shortcuts as soon as it opens.

Reviews (1) · Last reviewed commit: "fix(desktop-gpui): take keyboard shortcu..." · Reviewed by Greptile

@sandchest-com

sandchest-com Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Sandchest

Sandchest reviewed 94f74fa: nothing exploitable found in this change.

Sandchest reviews every change for vulnerabilities an attacker could use · Review details

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Capy found no issues.

Open in Capy

@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cap-status Skipped Skipped Nov 17, 2026 12:36am UTC

@vercel
vercel Bot temporarily deployed to Preview – cap-status November 17, 2026 00:36 Inactive
@richiemcilroy
richiemcilroy merged commit 4fea2eb into main Nov 17, 2026
53 checks passed

This branch was previously deployed

1 inactive deployment
Preview – cap-status — 94f74fa6 Deployed Nov 17, 2026 by vercel[bot]
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