Diagnostics for focus and layering (--diag / WAYBETTER_DIAG=1): one timestamped line per event in the app's log folder

For the macOS reports (the menu never shows and the window goes inactive on a click; the find field gets no keyboard): off unless the app is started with `--diag` or WAYBETTER_DIAG=1. Then native code and the shell append to `diag.log` in the app's log folder (truncated at launch): menu open requests and every close with its reason, overlay counts, raise/lower and `shell_raise` results, native `shell_focus` calls and their result, the shell document's focus/blur/visibility, and where the find bar's focus is right after it opens and 300 ms later. A line is an event and a few words in plain ASCII (capped); never a URL, a query or page text. `diag_get` / `diag_log` are shell-only (in commands::SHELL and the template's list).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
CRTkafa 2026-10-01 04:11:53 +07:00
parent 7f9e172196
commit 43fc8a15f5
8 changed files with 147 additions and 69 deletions

View file

@ -12,6 +12,7 @@
import { useEffect, useRef, useState } from 'react';
import { invoke, listen } from './bridge.ts';
import { describe, diag } from './diag.ts';
import { useT } from './hooks.ts';
import { formatNumber } from './i18n.ts';
import { Icon } from './icons.tsx';
@ -47,6 +48,8 @@ export function FindBar({ tabId, url, onClose }: { tabId: string; url: string; o
useEffect(() => {
invoke('shell_focus').catch(() => {});
input.current?.focus();
diag(`find bar open: hasFocus=${document.hasFocus()} active=${describe(document.activeElement)}`);
setTimeout(() => diag(`find bar +300ms: hasFocus=${document.hasFocus()} active=${describe(document.activeElement)}`), 300);
const again = (event: Event) => { if ((event as CustomEvent<string>).detail === tabId) { input.current?.focus(); input.current?.select(); } };
const onStep = (event: Event) => { const detail = (event as CustomEvent<{ id: string; direction: 1 | -1 }>).detail; if (detail.id === tabId) step(detail.direction); };
window.addEventListener('bt-find', again);