From 0f7250879ae3791512e3d00095aba91f797c0dec Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Mon, 20 Jul 2026 03:18:32 -0700 Subject: [PATCH] refactor(comments): slim verbose comments in renderer state (store/hooks/lib) (#9545) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Collapse multi-line explanatory comment blocks into single-line "why" statements per AGENTS.md ("Document the Why, Briefly"): drop restatements of the code and mechanism narration; keep the non-obvious reason, external refs, and directives. Comments-only — verified no code changed via a Babel/esbuild comment-strip token-equality gate against origin/main; typecheck and oxlint clean. Area: renderer — store, hooks, lib, runtime. 36 files changed, 1673 insertions(+), 5677 deletions(-). Co-authored-by: Orca --- src/renderer/src/App.tsx | 562 ++++------------ .../src/hooks/useAutoAckViewedAgent.ts | 101 +-- src/renderer/src/hooks/useComposerState.ts | 427 +++--------- .../src/hooks/useEditorExternalWatch.ts | 220 ++----- src/renderer/src/hooks/useIpcEvents.ts | 491 ++++---------- src/renderer/src/lib/agent-status.test.ts | 81 +-- src/renderer/src/lib/agent-status.ts | 59 +- .../src/lib/launch-agent-in-new-tab.ts | 94 +-- .../pane-terminal-output-scheduler.ts | 176 ++--- .../terminal-arabic-shaping-joiner.ts | 92 +-- src/renderer/src/lib/telemetry.ts | 65 +- src/renderer/src/lib/use-tab-agent.ts | 122 +--- src/renderer/src/lib/workspace-session.ts | 88 +-- src/renderer/src/lib/worktree-activation.ts | 132 +--- src/renderer/src/lib/worktree-status.ts | 69 +- .../src/runtime/sync-runtime-graph.ts | 93 +-- .../src/runtime/web-runtime-session.ts | 75 +-- .../src/runtime/web-session-tabs-sync.ts | 164 ++--- src/renderer/src/store/slices/agent-status.ts | 476 +++----------- src/renderer/src/store/slices/browser.ts | 124 +--- src/renderer/src/store/slices/diffComments.ts | 110 +--- src/renderer/src/store/slices/editor.ts | 484 +++----------- src/renderer/src/store/slices/github.ts | 497 ++++---------- src/renderer/src/store/slices/repos.ts | 190 ++---- .../src/store/slices/store-cascades.test.ts | 69 +- .../slices/store-session-cascades.test.ts | 112 +--- src/renderer/src/store/slices/tabs.test.ts | 125 +--- src/renderer/src/store/slices/tabs.ts | 180 ++--- .../store/slices/terminals-hydration.test.ts | 57 +- src/renderer/src/store/slices/terminals.ts | 615 ++++-------------- src/renderer/src/store/slices/ui.ts | 280 ++------ .../src/store/slices/worktree-nav-history.ts | 65 +- .../src/store/slices/worktrees.test.ts | 84 +-- src/renderer/src/store/slices/worktrees.ts | 543 ++++------------ src/renderer/src/web/web-preload-api.ts | 141 ++-- src/renderer/src/web/web-runtime-client.ts | 87 +-- 36 files changed, 1673 insertions(+), 5677 deletions(-) diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index 977b32d30..faf1b7bb9 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -195,18 +195,13 @@ import { subscribeBackgroundTerminalWorktreeMountRequests } from './components/terminal/background-terminal-worktree-mount' -// Why: agents alive during a hard kill (crash, forced update install) need a -// reasonably fresh resume record on disk; one minute bounds the lost window -// without measurable per-tick cost (the capture skips unchanged records). +// Why: bound the resume-record loss window on a hard kill to ~1 min; capture skips unchanged records so per-tick cost is negligible. const SLEEPING_AGENT_RESUME_CAPTURE_INTERVAL_MS = 60_000 const isMac = navigator.userAgent.includes('Mac') const isWindows = !isMac && navigator.userAgent.includes('Windows') const shortcutPlatform: NodeJS.Platform = isMac ? 'darwin' : isWindows ? 'win32' : 'linux' -// Why: Windows and Linux both run with the native title bar removed (Windows -// via titleBarStyle: 'hidden', Linux via frame: false), so the renderer draws -// its own logo/menu anchor and min/max/close controls on both. Paired web -// clients run in a browser tab, so they must not render desktop window chrome. +// Why: Windows and Linux remove the native title bar so the renderer draws its own chrome; paired web clients run in a browser tab and must not. const hasCustomTitleBar = shouldRenderDesktopWindowChrome({ platform: shortcutPlatform, isWebClient: isPairedWebClientWindow() @@ -229,9 +224,7 @@ function getKeybindingContext(target: EventTarget | null): KeybindingContext { : 'app' } -// Abstraction over a real KeyboardEvent and a synthetic double-tap gesture so a -// single dispatch path serves both. KeybindingInput-compatible (key/code + -// modifier flags) so it flows straight into keybindingMatchesAction. +// Abstraction over a real KeyboardEvent and a synthetic double-tap gesture so one dispatch path serves both; KeybindingInput-compatible. type ShortcutDispatchInput = { key?: string code?: string @@ -245,16 +238,11 @@ type ShortcutDispatchInput = { preventDefault: () => void } -// Why: Windows ('hidden' titleBarStyle) and Linux (frame: false) both remove -// the native OS title bar, so we render our own minimize/maximize/close -// buttons. These SVG icons match the Fluent/Win11 style: thin 10×10 paths on a -// 40×30 hit area. +// Why: Windows and Linux both remove the native title bar, so we render our own min/max/close buttons (Fluent/Win11-style SVGs). function WindowControls(): React.JSX.Element { const [maximized, setMaximized] = useState(false) useEffect(() => { - // Why: window:maximize-changed only fires on transitions, so a window - // restored to a maximized state at startup would render the wrong icon - // until the user first clicks the button. Seed from main on mount. + // Why: maximize-changed only fires on transitions; seed from main on mount so a startup-maximized window shows the right icon. let cancelled = false void window.api.ui.isMaximized().then((value) => { if (!cancelled) { @@ -302,10 +290,7 @@ function WindowControls(): React.JSX.Element {