#8030 · Pointer input without native focus recovery
Verdict: PARTIALLY REPRODUCED · Root-cause confidence: medium
1. TL;DR
The report describes a browser page that responds to clicks but does not accept typing. The production desktop view manager has no fallback that requests native keyboard focus when an unfocused page receives a pointer press. Its navigation guard can return focus to the host; a later pointer press only disarms that guard. Two new manager-boundary regression cases expose this missing recovery on unchanged trusted main in two clean checkouts. This is not a native macOS or Linear reproduction: the Electron objects are the repository's existing test doubles, so the actual platform event ordering and text-caret symptom remain unverified.
2. Claims vs findings
| Claim | Status | Evidence |
|---|---|---|
| Revealing a browser tab can intentionally leave it unfocused. | Verified in the manager | The new cases attach hidden, use setVisibleWithoutFocus, and confirm a visible view with zero native focus requests. |
| A navigation focus return can finish before the pointer press arrives. | Verified as an injected event ordering; native occurrence unverified | The navigation case runs the queued focus return first, verifies the host callback, and then emits a pointer press. |
| A later press can leave keyboard focus off the page. | Verified for the injected manager inputs | Both cases expect one native focus() request and receive zero, identically in both checkouts. |
| macOS delivers the described ordering and Linear loses its caret and keyboard input. | Unverified | No macOS desktop or authenticated Linear session was available. No real mouse interaction, DOM focus, or keystroke delivery was measured. |
| Automation, annotations, or application permissions are not responsible for the reported incident. | Unverified for that incident | The unit cases use no controller or annotation integration. They cannot inspect the original user's state. |
3. Environment
- Public target:
get-bb/bb; both checkouts at trustedorigin/main, commit796cdcc0f4bf8a55e23664035c54e8db6fe9d272. A final fetch found no newer main commit. - Execution environment: Linux x86_64; Node
v22.19.0; pnpm9.15.0; Vitest4.1.12. The desktop package declares Electron44.10.2; Electron was mocked, not launched. - Checkout A: isolated temporary clone from
https://github.com/get-bb/bb.git. Checkout B: a separate clean detached worktree at the same commit, verified clean before applying the same newly authored test-only patch. - No app, host daemon, browser session, provider turn, listening port, or runtime data directory was created. The user's live instance and credentials were not used.
- The first full build encountered an unbuilt Plugin SDK. After building its types and runtime, the normal full Turbo build passed:
74 successful, 74 total. A build-generated route-tree edit was restored; it is not part of the reproduction.
4. Minimal reproduction
This reproduces a conditional manager behavior, not the native macOS symptom. The supplied patch adds two cases to the existing Electron-mocked manager suite. The native focus return is simulated by the host callback, and the test observes requests at the real manager's Electron boundary. No production code is changed.
- Clone the public repository and select the exact trusted base:
git clone https://github.com/get-bb/bb.git bb-8030 cd bb-8030 git checkout --detach 796cdcc0f4bf8a55e23664035c54e8db6fe9d272 pnpm install --frozen-lockfile --prefer-offline
- Build trusted source using the repository's normal tasks, warming the SDK first:
pnpm exec turbo run build:types --filter=@get-bb/plugin-sdk pnpm exec turbo run build --filter=@get-bb/plugin-sdk pnpm exec turbo run build
- Download the report's test-only patch, apply it from the checkout root, and run:
git apply /path/to/downloaded/keyboard-focus.patch pnpm exec turbo run test --filter=@bb/desktop -- --testNamePattern='restores keyboard focus on pointer press'
- Expected: after an eligible pointer press, the manager requests native keyboard focus once. Actual, in both checkouts:
AssertionError: expected +0 to be 1 // Object.is equality - Expected + Received - 1 + 0 Test Files 1 failed | 64 skipped (65) Tests 2 failed | 658 skipped (660)
Artifacts: applicable patch, test insertion, first run, second run, existing suite. Checkout paths in logs are normalized to CHECKOUT_A and CHECKOUT_B; trailing output whitespace is trimmed.
No screenshot is included: a macOS text-caret failure was not observed, and a Linux test-output image would not demonstrate it.
Complete test insertion
This code belongs in the existing manager test file, whose fixtures it uses; it is not a standalone test module.
it.each([false, true])(
"restores keyboard focus on pointer press after an unfocused reveal (rejected navigation focus: %s)",
async (rejectNavigationFocus) => {
vi.useFakeTimers();
const focusHostWebContents = vi.fn(() => {
requireFakeView(0).webContents.nativelyFocused = false;
});
const manager = createDesktopBrowserViewManager({
partition: "persist:test",
focusHostWebContents,
});
const hostWindow = new FakeHostWindow({
contentBounds: { width: 700, height: 450 },
webContentsId: 92,
});
try {
manager.attach({
hostWindow,
request: {
threadId: "thread-1",
tabId: "browser:a",
url: "https://example.com",
bounds: { x: 0, y: 0, width: 700, height: 450 },
visible: false,
},
});
const view = requireFakeView(0);
manager.setVisibleWithoutFocus({
hostWindow,
request: { tabId: "browser:a", visible: true },
});
expect(view.visible).toBe(true);
expect(view.webContents.focusCalls).toBe(0);
if (rejectNavigationFocus) {
view.webContents.emitDidStartLoading();
view.webContents.nativelyFocused = true;
view.webContents.emitFocus();
await vi.advanceTimersByTimeAsync(0);
expect(focusHostWebContents).toHaveBeenCalledExactlyOnceWith(92);
}
expect(view.webContents.isFocused()).toBe(false);
view.webContents.emitInputEvent("mouseDown");
await vi.advanceTimersByTimeAsync(0);
expect(view.webContents.focusCalls).toBe(1);
} finally {
manager.destroyAll();
vi.useRealTimers();
}
},
);
5. Root cause
The confirmed code-level gap is that permission to retain focus is not a request to acquire focus. The load and focus handlers arm a navigation guard, then defer rejecting native focus by one timer turn. The pointer listener only clears that guard:
const listener: PointerFocusListener = (_event, input) => {
if (POINTER_PRESS_INPUT_TYPES.has(input.type)) {
stopAwaitingPointerFocus(entry);
}
};
When the timer has already returned focus to the host, clearing the listener cannot move keyboard focus back. Without a load-armed listener there is no corresponding pointer recovery at all. The actual focus operation exists in explicit focus handling, but the pointer path does not invoke it. Visibility handling intentionally skips that operation when asked to show without focus.
Existing coverage at the focus-event ordering table supplies native focus explicitly and delivers the press before the deferred rejection runs. It does not cover a press after completed rejection, or a press without native focus transfer. The focus guard originated in the self-reload focus-stealing fix; that protection must remain intact.
Overall confidence is medium, not high: the mechanism is deterministic under these inputs, but the unit fixture supplies the allegedly problematic native ordering. The test cannot establish whether Electron on macOS emits it during a real click, nor prove that this explains the original incident.
6. Proposed fix and safety gate
First confirm the native event sequence on a macOS development desktop with a local editable HTML page, recording guest document.hasFocus(), webContents.isFocused(), pointer events, and the host focus-return callback. Exercise both a revealed tab and a reload with the deferred rejection completed before the click.
If confirmed, preserve reload focus rejection and add a persistent pointer-press recovery path for the current, visible, live, user-controlled page only. It must not focus a hidden page, an inactive server, a controller-owned or leased tab, or a background host window, and must avoid duplicate notifications if native focus already arrived. Recheck those conditions when deferred work runs.
No fix branch or PR was created. The report is only partially reproduced, so it does not pass the autopilot's prerequisite of reproducing the reported native bug on trusted main before considering a simple fix. Native macOS focus and editable-text verification remain necessary. The test-only artifact is 51 added lines in one existing subsystem; there is no production patch, dependency, generated-file change, or stored-data change.
7. Linked PR review
PR #8031 — closed, unmerged
GitHub metadata shows #8031 is closed with no merge commit. No open PR linking this issue was found. Its diff was read only as untrusted data after the new reproduction had been authored and run; its branch and tests were never checked out or executed.
Static review: apps/desktop/src/desktop-browser-view.ts adds a permanent press listener and a guarded deferred focus request, while replacing the transient listener marker with a boolean. This direction addresses the manager gap exposed by the new tests. It remains unverified on native macOS; there is no runtime endorsement of that closed patch and no demonstrated additional defect claimed here. Only trusted-main tests were run.
8. Related issues
#6917 covers the earlier self-refresh focus-stealing problem that introduced the navigation guard. #7830 concerns native browser keyboard shortcuts; search metadata did not establish it as the same defect.
9. Verification
The same agent repeated the reproduction, not an independent reviewer. Checkout B was created clean with git worktree add --detach at the full base SHA, its empty status was checked, and a fresh frozen install was performed. Only the same newly authored test patch was applied; both production files and native implementation remained unchanged. The exact focused Turbo command from section 4 produced the same two failures at expect(view.webContents.focusCalls).toBe(1), receiving zero.
The existing manager tests were then run separately, excluding the two new expected failures:
pnpm exec turbo run test --filter=@bb/desktop -- test/desktop-browser-view-manager.test.ts --testNamePattern='^(?!.*restores keyboard focus on pointer press)'
Test Files 1 passed (1)
Tests 115 passed | 2 skipped (117)
No new ports or data directory were needed: neither run starts a live app. No report correction was needed after the second run; both runs support only the conditional manager finding. verified: true in the summary refers to that repeated partial finding, not native macOS verification.
10. Appendix
Evidence commands also included git fetch origin main, git rev-parse origin/main, git status --short, git log -- apps/desktop/src/desktop-browser-view.ts, git diff --check, and git diff --numstat origin/main. Source and line links were checked against the recorded base. The supplied keyboard-focus.patch changes only the manager test file. The source checkout was a fresh clone of the trusted target, not the pre-existing checkout's different origin.
Trust handling: issue text and the linked closed PR were treated as untrusted claims. No issue-provided command, patch, test, branch, or external URL was executed or fetched. New tests were derived from trusted repository fixtures and production event handlers. No live-user data was inspected, no account-dependent page was opened, and no screenshot or native-focus observation was fabricated.
> AGENT GENERATED