Skip to content

perf(renderer): lazy load Linear setup dialog - #11687

Merged
nwparker merged 1 commit into
stablyai:mainfrom
nwparker:perf-lazy-linear-setup
Jul 31, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
nwparker:perf-lazy-linear-setup

Conversation

@nwparker

Copy link
Copy Markdown
Contributor

Summary

Lazy-load the Linear agent skill setup dialog only when the prompt opens it.

This removes the setup implementation and its transitive dependencies from the main renderer startup graph while preserving the established lazyWithRetry stale-chunk recovery behavior.

Fresh A/B Electron builds against the same main baseline measured:

Entry Raw delta Gzip delta JS files
Renderer index -1,324,658 B -288,751 B -9
Popout +994 B +569 B +2
Web -307 B not measured unchanged

The popout entry tradeoff comes from exposing the dialog as a separate lazy chunk; the primary renderer startup win is substantially larger.

Screenshots

No visual change.

Testing

  • pnpm lint (targeted oxlint --deny-warnings passed)
  • pnpm typecheck (pnpm run typecheck:web passed)
  • pnpm test (4 focused test files, 61 tests passed)
  • pnpm build (fresh baseline and branch Electron builds passed)
  • Added or updated high-quality tests that would catch regressions

Also passed targeted formatting, max-lines ratchet, and git diff --check.

AI Review Report

Reviewed the lazy boundary, modal lifecycle, retry behavior, and test coverage. The dialog is mounted only while open, existing close/snooze/success flows remain unchanged, and lazyWithRetry retains stale-chunk recovery.

Cross-platform review found no changed shortcuts, labels, paths, shell behavior, native modules, or Electron platform branching. Existing native and WSL prerequisite paths are preserved.

Security Audit

No new input, command, path, authentication, secret, dependency, or IPC surface is introduced. Existing CLI prerequisite checks and terminal-opening callbacks are moved behind the lazy boundary without behavior changes.

Notes

This is the first focused extraction from draft PR #11539. It is independent and based directly on main.

@nwparker
nwparker marked this pull request as ready for review July 31, 2026 07:12
@greptile-apps

greptile-apps Bot commented Jul 31, 2026

Copy link
Copy Markdown

Greptile Summary

This PR lazy-loads LinearAgentSkillSetupDialog behind a lazyWithRetry boundary, mounting the dialog only when setupDialogOpen is true instead of keeping it in the DOM with an open prop. This removes the dialog and its transitive dependencies from the renderer startup bundle, yielding a ~289 KB (gzip) reduction in the renderer index entry.

  • LinearAgentSkillSetupDialog.tsx gains a default export to satisfy React.lazy's module contract; the named export is preserved for direct use.
  • LinearAgentSkillSetupPrompt.tsx replaces the static import with lazyWithRetry, wraps the conditionally-rendered dialog in <Suspense fallback={null}>, and switches from open={setupDialogOpen} to mount-on-demand (hardcoded open).
  • Tests are updated to await import('./LinearAgentSkillSetupDialog') after triggering actions that open the dialog, and a startup-routing assertion is added to guard the lazy boundary.

Confidence Score: 4/5

Safe to merge. The lazy-loading boundary is well-tested, all existing close/snooze/success flows are preserved, and the lazyWithRetry stale-chunk recovery path is unchanged.

The core logic is straightforward: the dialog is now mounted on demand instead of kept in the DOM with a closed state. The logic is covered by a thorough test suite that was updated to await the lazy chunk. The only tradeoff is that Radix UI's exit animation no longer fires when the dialog closes, since the component tree is unmounted before Radix can animate it out — but this is an accepted pattern for other lazy dialogs in the codebase.

Files Needing Attention: No files require special attention. The prompt component change is the most impactful but is well-exercised by the updated tests.

Important Files Changed

Filename Overview
src/renderer/src/components/sidebar/LinearAgentSkillSetupPrompt.tsx Core change: replaces static import with lazyWithRetry, gates dialog mount on setupDialogOpen, and wraps in Suspense. Logic is correct but the immediate unmount pattern forfeits Radix Dialog's CSS exit animation.
src/renderer/src/components/sidebar/LinearAgentSkillSetupDialog.tsx Adds export default LinearAgentSkillSetupDialog to satisfy React.lazy's default-export contract; the named export is preserved for backward compatibility.
src/renderer/src/components/sidebar/LinearAgentSkillSetupPrompt.test.tsx Updated to await the lazy dialog chunk before asserting dialog content, adds settleRender() calls after click events that open the dialog, and renames one test description to reflect lazy-load semantics.
src/renderer/src/app-startup-routing.test.ts Adds a source-level assertion that LinearAgentSkillSetupPrompt.tsx uses a dynamic import (not a static one) and mounts the dialog inside Suspense, acting as a ratchet against accidental re-eagerness.

Sequence Diagram

sequenceDiagram
    participant User
    participant Prompt as LinearAgentSkillSetupPrompt
    participant Suspense as React Suspense
    participant Lazy as lazyWithRetry
    participant Dialog as LinearAgentSkillSetupDialog (chunk)

    Note over Prompt: Renderer startup — Dialog chunk NOT loaded
    Prompt->>Prompt: "render inline prompt (setupDialogOpen=false)"

    User->>Prompt: click "Set up"
    Prompt->>Prompt: setSetupDialogOpen(true)
    Prompt->>Suspense: "mount Suspense fallback=null"
    Suspense->>Lazy: trigger dynamic import('./LinearAgentSkillSetupDialog')
    Note over Suspense: fallback=null while chunk loads
    Lazy-->>Suspense: chunk loaded (with retry on failure)
    Suspense->>Dialog: "mount LinearAgentSkillSetupDialog open=true"
    Dialog-->>User: dialog visible

    User->>Dialog: close (Escape / x / outside click)
    Dialog->>Prompt: onOpenChange(false)
    Prompt->>Prompt: setSetupDialogOpen(false)
    Prompt->>Suspense: unmount entire Suspense+Dialog tree
    Note over Dialog: Dialog removed immediately (no exit animation)
Loading

Reviews (1): Last reviewed commit: "perf(renderer): lazy load Linear setup d..." | Re-trigger Greptile

Comment on lines +285 to +349
const setupDialog = setupDialogOpen ? (
<Suspense fallback={null}>
<LinearAgentSkillSetupDialog
open
showSuccess={showSuccessModal}
successDescription={successDescription}
missingLabel={missingLabel}
command={command}
installedCommand={installedCommand}
terminalShellOverride={terminalShellOverride}
installed={skill.installed}
loading={showCheckingModal || cliLoading || skill.loading}
error={skill.error}
getPrerequisiteStatus={
agentRuntime.runtime === 'wsl'
? await ensureWslCliAvailableForAgentSkillTerminal(agentRuntime)
: await ensureOrcaCliAvailableForAgentSkillTerminal({
onStatusChange: (nextCliStatus) => {
writeIfCurrent(() => setCliStatus(nextCliStatus))
}
})
if (agentRuntime.runtime === 'wsl') {
writeIfCurrent(() => setCliStatus(nextStatus))
}
}}
onRecheck={async () => {
if (surface === 'modal') {
setActiveSetupCheckIdentity(setupCheckIdentity)
setSetupCheckResult('checking')
await Promise.all([refreshCliStatus(), skill.refresh()])
return
? () => window.api.cli.getWslInstallStatus(getWslCliDistroRequest(agentRuntime))
: undefined
}
await refreshCliStatus()
await skill.refresh()
}}
onOpenChange={(open) => {
if (open) {
setSetupDialogOpen(true)
return
}
if (showSuccessModal) {
closeSuccessModal()
return
}
if (surface === 'modal') {
snoozeForSession()
return
}
setSetupDialogOpen(false)
}}
onDismissPermanently={dismissPermanently}
onDone={closeSuccessModal}
/>
)
onBeforeOpenTerminal={async () => {
const requestIdentity = setupCheckIdentity
const writeIfCurrent = (write: () => void): void => {
writeCliStatusForIdentity(requestIdentity, write)
}
const nextStatus =
agentRuntime.runtime === 'wsl'
? await ensureWslCliAvailableForAgentSkillTerminal(agentRuntime)
: await ensureOrcaCliAvailableForAgentSkillTerminal({
onStatusChange: (nextCliStatus) => {
writeIfCurrent(() => setCliStatus(nextCliStatus))
}
})
if (agentRuntime.runtime === 'wsl') {
writeIfCurrent(() => setCliStatus(nextStatus))
}
}}
onRecheck={async () => {
if (surface === 'modal') {
setActiveSetupCheckIdentity(setupCheckIdentity)
setSetupCheckResult('checking')
await Promise.all([refreshCliStatus(), skill.refresh()])
return
}
await refreshCliStatus()
await skill.refresh()
}}
onOpenChange={(open) => {
if (open) {
setSetupDialogOpen(true)
return
}
if (showSuccessModal) {
closeSuccessModal()
return
}
if (surface === 'modal') {
snoozeForSession()
return
}
setSetupDialogOpen(false)
}}
onDismissPermanently={dismissPermanently}
onDone={closeSuccessModal}
/>
</Suspense>
) : null

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Close animation lost on unmount

Because the dialog is now unmounted immediately when setupDialogOpen becomes false (rather than transitioning via open={false}), Radix UI never gets to run its CSS exit animation — the overlay and content disappear instantly. The other lazy dialogs in the codebase (e.g. AddProjectFromFolderDialog) appear to accept this same tradeoff, so this is consistent with the established pattern, but it's worth a deliberate confirmation that the snap-close is acceptable for this dialog.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@nwparker
nwparker merged commit 11936f0 into stablyai:main Jul 31, 2026
163 of 167 checks passed
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6a724a5c-3a00-4cfc-8de0-3f951949502c

📥 Commits

Reviewing files that changed from the base of the PR and between a2d0e77 and 86ec13f.

📒 Files selected for processing (6)
  • src/renderer/src/app-startup-routing.test.ts
  • src/renderer/src/components/sidebar/LinearAgentSkillSetupDialog.tsx
  • src/renderer/src/components/sidebar/LinearAgentSkillSetupPrompt.reminder-toast.test.tsx
  • src/renderer/src/components/sidebar/LinearAgentSkillSetupPrompt.test.tsx
  • src/renderer/src/components/sidebar/LinearAgentSkillSetupPrompt.tsx
  • src/renderer/src/components/sidebar/LinearAgentSkillSetupPrompt.update-command.test.tsx

📝 Walkthrough

Walkthrough

The Linear agent skill setup dialog now uses retry-enabled lazy loading and renders inside Suspense only when opened. The dialog also has a default export for the lazy import. Tests now await module loading during prompt rendering and setup interactions, verify the absence of eager loading, and use shared prompt cleanup.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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