Files
paseo/docs/keyboard-shortcuts.md
T
Mohamed Boudra 6f685d37be Command center tabs, recent workspaces, and archived workspace search (#9689)
* feat(app): command center tabs, recent workspaces, and agents in workspace search

The command center gets All · Workspaces · Files · Actions tabs under the search
field. Tab and Shift+Tab rotate them on web, a tab keeps the query and starts at
its top, and Backspace on an empty field returns to All. ⌘P opens on Files in
place of the Files scope chip.

All leads with the three most recent workspaces other than the open one. Agent
rows are gone: an agent's title now finds its workspace, which shows the agent on
a third line and opens that agent's tab.

The selection now follows the first result until the user moves it, so rows that
load above it do not leave it on the row below.

* feat(app): archived workspaces in command center search

A query in All or Workspaces now also finds archived workspaces through
agent history, appended after the active matches. Archived rows show the
archive time and an Archived badge, and open the workspace's latest agent
where it can be unarchived. Hosts without history search contribute
nothing. History's archived badge moves into a shared ArchivedBadge.

* fix(app): put the command center divider between the field and the tabs

The tabs belong to the results, not the search field, so the rule now
separates the field from the tab bar. The tab-rotation test also pins the
list's top, since the tabs no longer live inside the header it measured.

* fix(app): rank agent matches by quality, keep background workspaces out of Recent, explain Files off-workspace

- Score each agent together with its workspace's title and subtitle, so a
  query split across them ("payments login") finds the row, and pick the
  workspace's own match only when it is as good as its best agent match.
  Across workspaces, match quality now ranks before own-versus-agent.
- Carry the workspace's background flag through the project summary and
  leave background workspaces out of Recent workspaces, as the sidebar
  does. A query still finds them.
- The Files tab outside a workspace says "Open a workspace to search
  files" instead of "No matches".

* fix(app): settle command center selection, name agents only for loose matches, drop Files off-workspace

- Name a workspace's agent only when the workspace's own text does not match
  contiguously and the agent does; a change-request hit is always an own match.
- Follow the first row only until every source for the query and tab has
  loaded, then keep the selection by ID so reorders do not move it.
- Projects stay loading until an online host's workspaces have arrived; the
  agent directory reports ready first.
- Outside a workspace there is no Files tab and All lists no files; the All
  placeholder names only what the available tabs search.
- The unqueried Workspaces list follows the sidebar's Show background setting.

* fix(app): keep Projects loading honest, rank own-name matches by their agents too, refresh archived search after archive

- The command center waits for online hosts' workspaces itself instead of
  through useProjects. useProjects held isLoading until workspaces
  hydrated, but a failed workspace request never hydrates, so the
  Projects screen could spin forever.
- A workspace that matches on its own name is ranked by the better of
  that match and its agents', so typing into an agent title shared with
  another workspace no longer drops it below that workspace and back.
- Archiving a workspace marks agent history stale. Archived search reused
  a cached page that still listed the agents as active, so a workspace
  archived in the last 30 seconds matched in neither list.

* fix(app): decide command center agent matches by match class

One rule now picks both what a workspace row shows and how it ranks. A
match falls in a class: every word at a word boundary, a word inside a
word, or scattered/misspelled. A row names its agent only when the agent
matches in a closer class than the workspace's own text, never on a
change-request hit. Rows rank by class, then own text ahead of an agent,
then score, then recency.

The previous rules chose the ranking candidate and the displayed
candidate separately, so each fix moved the edge case: positional tier
gaps named agents mid-word, and ranking by a hidden agent let a mid-word
name outrank a word-boundary one with nothing on screen to explain it.

* style(app): format command center workspace search import

* fix(app): settle archived search when no history host is reachable

With no searchable host online, the history query is disabled under a new
key, and keepPreviousData kept serving the old key's rows as placeholder
data. Archived search read that as still waiting for results, so the
command center selection never settled and followed every re-rank.
Previous results now stand in only while the query can run.
2026-11-15 10:58:15 +07:00

6.4 KiB
Raw Blame History

Keyboard shortcuts

Define shortcuts in the shared binding table. Platforms contribute key sources, not separate action maps, so matching and user rebinds stay consistent across runtimes. Add a shortcut through a binding; add platform support through a key source.

Badges and routing

Routing runs whenever the app mounts its key sources, independently of layout. Use useHardwareKeyboardPresent() for hints and the Shortcuts settings section. iOS reads GCKeyboard.coalesced and connection notifications. Android watches input devices and hardware keyboard configuration. Web starts with a fine hover pointer and recognizes the first modified keydown, including on touch devices. Compact Electron keeps its bindings.

Keyboard navigation needs the sidebar's filtered workspace model even when its visual panel is hidden. Retain that model while keyboard navigation is active; gating it on panel visibility leaves number shortcuts with no targets after a compact startup.

Composer send-key customization remains a separate capability. Native retains its existing Return submission path; advertising its web-only customization would expose settings the native composer does not implement.

Native sources

Use the iOS window press stream for hardware keys. The stream reaches JavaScript after the focused text control has already handled the press, so the pipeline's preventDefault cannot stop a key from typing. A key the text control would type must be claimed up front. UIKeyCommand takes only those keys: composer Return, the top overlay's Enter and arrows, and the Shift or Option shortcuts whose binding is active in the current focus scope, such as Shift+Tab in the composer. sources/native.ts computes the claims from the published bindings and recomputes them when the focus scope changes. Cmd and Ctrl combos are never claimed, because text controls do not type them. Android takes no claims: a focused EditText types nothing for these combos. Keep the stream as the sole shortcut emitter: a command-owned press is still observed by the window.

The source spike used an iPad Pro 11-inch (M4) simulator on iOS 18.6 with a UITextView first responder. Both UIWindow.sendEvent and the root controller's pressesBegan received Cmd+B, Cmd+P and Escape. With Escape registered as a UIKeyCommand, the window observed it and the command handler also ran.

Simulator reserves Cmd+K for Toggle Software Keyboard. Injecting it produced HID 184 with empty characters rather than K; plain K, Cmd+B and Cmd+P arrived normally. Keep Simulator input capture off: Send Keyboard Input to Device prevented synthetic AppleScript input from arriving, including plain text. For simulator QA, use Cmd+B/P to check delivery and rebind the command center to Cmd+J to check toggle and rebind behavior. Cmd+K delivery needs a physical iPad. Simulator also reserves Cmd+1…4, Cmd+Shift+A and Cmd+comma. Exercise those actions through rebinds. For numeric injection, use AppleScript physical key codes (for example 25 for 9); keystroke "9" did not deliver a digit in the QA session. Simulator exposes a virtual GCKeyboard even with Connect Hardware Keyboard off. Verify the iOS absence case on a physical iPhone.

Never register Backspace: it would take deletion away from text fields. Changes to the native module require a native rebuild; an over-the-air JavaScript update cannot deliver them.

Overlay ownership

Register keyboard handling with useOverlayRegistration from @/keyboard. Pass the surface's open state, layer, handled keys and onKeyDown. The highest layer gets first refusal; the latest registration wins a tie. Native registration does not need a DOM ref. Web adds focus trapping and restoration through its adapter. Declaring Tab takes it from the web focus trap and hands it to onKeyDown; the command center rotates its tabs with it. Native sources drop Tab from the declarations.

Capture a global overlay’s layer in state for its opening lifetime. Memo caches can be discarded or removed by React Compiler; recomputing against the registry lets an open modal rise above its own children and creates competing focus traps.

Declare Enter and arrow keys only while the surface owns them. Native sources use the top overlay's declarations to take those keys before text controls edit. Backspace stays with the focused input. Composition confirmation must not select an overlay row or submit the composer.

Android modals have their own windows. Observe them through React Native's ExtraWindowEventListener as well as the activity window. The dev client bypasses Expo's root-container handler, so an activity root-view wrapper misses presses. A modal can forward an unhandled event into the activity window. Observe the event once across that nested delivery without retaining recycled Android KeyEvents. Keep an overlay-owned press consumed through key-up, even if its key-down closes the overlay; otherwise the modal's default Escape handler can close a second layer.

iOS scene startup installs the observing window after Expo creates its root view. Keep that integration in the hardware keyboard module's config plugin. Its window owns both the press stream and the text-control key commands, including above modals.

Focus scopes

The composer and terminal declare focus with useKeyboardFocusSurface. Native scope derives from those declarations and command-center state. Releasing an old surface must not clear a newer owner's declaration during a tab switch. Web keeps its DOM-derived scope.

Escape interrupts an agent only in the message input or an unclaimed surface. A focused terminal excludes that binding. The source leaves terminal Escape alone; terminal Escape/Ctrl forwarding is a separate feature.

Terminal arrows never pass through the shortcut pipeline. The Android hardware module claims them while the terminal's hidden input (nativeID) owns the focus. TextInput.onKeyPress only sees IME keys, and an arrow that falls through moves the hidden caret and desyncs the next text change, so the pipeline cannot own them.

Keys shared with text editing

A binding on a key the platform already uses for editing, such as Cmd/Ctrl+Z for workspace archive undo, declares editable: false and registers its handler with isActive true only while it has work. An inactive handler leaves the key unhandled, so the pipeline skips preventDefault and the platform's own undo runs.