Skip to content

fix(lint): move the doc preview guest-focus handoff into its own hook - #28110

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/html-doc-preview-guest-focus
Oct 12, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/html-doc-preview-guest-focus

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 0 0 0 0
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​82 $\color{#cf222e}{\Huge{\mathbf{−}}}$​54 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​28

ELI5

Two PRs that each touched the HTML document preview (#27608 and #27875) pushed HtmlDocPreview.tsx to 403 lines, over the 400-line lint limit for .tsx files. Lint fails on that file, and the pre-commit hook rejects any merge commit that brings in current main. This moves one self-contained piece of the component into its own hook.

What Changed

  • The effect that hands the keyboard to a ready preview's page moves unchanged into use-doc-preview-guest-focus.ts as useDocPreviewGuestFocus. That covers the frame-by-frame retry, the yield on re-offer, and the re-offer when the window regains focus. Its GUEST_FOCUS_FRAMES constant moves with it.
  • HtmlDocPreview.tsx calls the hook and drops to 357 lines.

Why

The focus handoff reads only the webview ref and four values, and nothing else in the component uses its internals, so it splits out cleanly. This avoids a max-lines disable, which AGENTS.md forbids.

The effect used to depend on state, and now it takes ready: state === 'ready'. It only acted when state === 'ready', so moves between the other states never did anything, and it still re-runs whenever the preview becomes ready.

Linked Issue

Fixes the main lint break from #27608 + #27875 (HtmlDocPreview.tsx at 403 lines, max-lines 400).

Visual Proof

N/A: no behaviour change; an effect moves into a hook.

Testing

  • oxlint (.oxlintrc.json, anti-slop, code-quality native plugins, design system) with --deny-warnings and oxfmt --check pass on both files. Before this change, .oxlintrc.json failed with File has too many lines (403).

  • tsc -p config/tsconfig.tc.web.json: 0 errors.

  • vitest run src/renderer/src/components/browser-pane/workspace-doc: 11 files, 84/84 pass, including the HtmlDocPreview toolbar and page-pane tests that cover focus.

  • I manually tested these changes locally

  • Automated tests added/updated (behaviour unchanged; existing workspace-doc tests cover it)

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered: renderer-only refactor, no runtime change

HtmlDocPreview.tsx reached 403 lines on main (#27608 + #27875), over the
400-line limit for .tsx, so lint and the pre-commit hook fail on any
branch that merges main. The focus handoff effect moves unchanged into
use-doc-preview-guest-focus.ts.
@OrcaWin
OrcaWin merged commit 5e83ca0 into main Oct 12, 2026
3 checks passed
brennanb2025 pushed a commit that referenced this pull request Oct 15, 2026
…#28110)

HtmlDocPreview.tsx reached 403 lines on main (#27608 + #27875), over the
400-line limit for .tsx, so lint and the pre-commit hook fail on any
branch that merges main. The focus handoff effect moves unchanged into
use-doc-preview-guest-focus.ts.

Co-authored-by: Orca Worker <orca-worker@localhost>
(cherry picked from commit 5e83ca0)
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