Skip to content

refactor(app): extract layout side effect controllers#877

Merged
Astro-Han merged 2 commits into
devfrom
codex/i875-layout-side-effects
May 23, 2026
Merged

refactor(app): extract layout side effect controllers#877
Astro-Han merged 2 commits into
devfrom
codex/i875-layout-side-effects

Conversation

@Astro-Han
Copy link
Copy Markdown
Owner

@Astro-Han Astro-Han commented May 23, 2026

Summary

Extract the first non-visual side-effect controller boundary from packages/app/src/pages/layout.tsx.

  • Move update polling into layout-update-polling.ts.
  • Move SDK notification, permission, question, and worktree event effects into layout-sdk-event-effects.ts.
  • Add focused helper tests for current/descendant suppression, question dedupe keys, terminal question reset, route-ready question notifications, and permission cooldown.

Why

layout.tsx was mixing shell composition with background update and SDK event behavior. This PR keeps the visible shell stable while making those side effects easier to review and safer to change later.

Related Issue

Refs #875

Human Review Status

Pending

Review Focus

Please focus on behavior preservation: Solid owner lifecycle, reactive accessor usage, SDK listener cleanup, update polling interval cleanup, notification dedupe/cooldown, and worktree ready/failed effects.

Risk Notes

  • Platform surface touched: updater polling and desktop notifications are mechanically preserved behind explicit dependencies.
  • (conditional) Visible UI/manual screenshot checklist left unticked because no visible UI, copy, DOM, aria, command, route, or storage key behavior changed.
  • (conditional) Docs/release/dependencies/generated-content checklist left unticked because none of those surfaces changed.

How To Verify

Focused layout tests: 155 pass, 0 fail
Command: cd packages/app && bun test --preload ./happydom.ts ./src/pages/layout/*.test.ts ./src/pages/layout/*.test.tsx ./src/pages/update-install-flow-source.test.ts

Typecheck: 8 successful, 8 total
Command: bun run typecheck

Diff whitespace check: no errors
Command: git diff --check

Screenshots or Recordings

Not required. This PR has no visible UI change.

Checklist

How to use this checklist:

  • Tick a box by replacing [ ] with [x]. Do not edit, add, or remove items.
  • The bot-applied label items can only be honestly ticked AFTER the PR is opened and the labeler / priority-triage bots have run — return to the PR description and tick them then.
  • Most items are required. The few that are conditional are explicitly marked (conditional); for those, leave unticked if they truly do not apply and explain why in Risk Notes. All other items must be ticked before requesting human review.
  • Type label — this PR carries exactly one of bug, enhancement, task, documentation. Type labels are author-added; the labeler bot does NOT assign them. Add the label in the GitHub UI, then tick this.
  • Routing labels — this PR carries at least one of app, ui, platform, harness, ci. The labeler bot assigns these on PR open based on changed paths. Confirm the bot's choice (or override if wrong), then tick this.
  • Priority label — this PR carries exactly one of P0, P1, P2, P3. The priority-triage bot suggests one on PR open. Confirm or override, then tick this.
  • Human Review Status above is set to Pending, Approved by @<reviewer>, or Not required: <reason> (default is Pending; "not required" is restricted to bot-authored low-risk PRs).
  • I linked the related issue, or stated in Summary why there is no issue.
  • I described the review focus and any meaningful risks.
  • I replaced the example block in How To Verify with the real verification steps and the key result for each.
  • I did not introduce unrelated refactors, dependencies, generated files, or file changes beyond the stated scope.
  • (conditional) I manually checked visible UI or copy changes when needed, with screenshots or recordings. Leave unticked only if no visible UI or copy changed.
  • (conditional) I considered macOS and Windows impact for platform, packaging, updater, signing, paths, shell, or permissions changes. Leave unticked only if no platform/packaging surface was touched.
  • (conditional) I called out docs, release notes, dependencies, permissions, credentials, deletion behavior, generated content, or local file changes when relevant. Leave unticked only if none of those surfaces was touched.
  • I reviewed the final diff for unrelated changes and suspicious dependency changes.
  • I am targeting dev, and my PR title and commit messages use Conventional Commits in English.

@Astro-Han Astro-Han added P2 Medium priority app Application behavior and product flows ui Design system and user interface task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work tech-debt Supplemental cleanup, maintainability, architecture, test, or quality debt context labels May 23, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 23, 2026

Warning

Review limit reached

@Astro-Han, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 1 review/hour. Refill in 40 minutes and 52 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d537da95-8188-4476-a13d-37437fe75db9

📥 Commits

Reviewing files that changed from the base of the PR and between d9d052e and c8a6c13.

📒 Files selected for processing (5)
  • packages/app/src/pages/layout.tsx
  • packages/app/src/pages/layout/layout-sdk-event-effects.test.ts
  • packages/app/src/pages/layout/layout-sdk-event-effects.ts
  • packages/app/src/pages/layout/layout-update-polling.ts
  • packages/app/src/pages/update-install-flow-source.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/i875-layout-side-effects

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 and usage tips.

@github-actions github-actions Bot removed the task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work label May 23, 2026
Copy link
Copy Markdown

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Suggested priority: P2 (includes user-path files (packages/app/src/pages/layout.tsx, packages/app/src/pages/layout/layout-sdk-event-effects.test.ts, packages/app/src/pages/layout/layout-sdk-event-effects.ts, packages/app/src/pages/layout/layout-update-polling.ts, packages/app/src/pages/update-install-flow-source.test.ts)).

P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.

@Astro-Han Astro-Han added the task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work label May 23, 2026
@github-actions github-actions Bot removed the task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work label May 23, 2026
@Astro-Han Astro-Han added the task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work label May 23, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the main Layout component by extracting the update polling and SDK notification logic into separate, testable modules. New unit tests have been introduced for the SDK event effects. The reviewer suggested optimizing performance by deferring session lookups until they are strictly necessary and using targeted lookups to minimize memory overhead when processing events.

Comment thread packages/app/src/pages/layout/layout-sdk-event-effects.ts Outdated
Comment thread packages/app/src/pages/layout/layout-sdk-event-effects.ts Outdated
Comment thread packages/app/src/pages/layout/layout-sdk-event-effects.ts Outdated
@github-actions github-actions Bot removed the task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work label May 23, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 23, 2026

Perf delta summary

Comparator: pass

Profile / Scenario interaction median interaction worst long task max tbt frame gap p95 frame gap max jank count cls status
default / homepage-cold 24 -> 24 (0) 48 -> 32 (-16) 112 -> 69 (-43) 62 -> 19 (-43) 33.4 -> 16.8 (-16.6) 150 -> 183.3 (+33.3) 4 -> 3 (-1) 0 -> 0 (0) pass
default / long-session-input-lag 48 -> 48 (0) 64 -> 48 (-16) 0 -> 0 (0) 0 -> 0 (0) 16.8 -> 16.7 (-0.1) 16.8 -> 16.8 (0) 0 -> 0 (0) 0 -> 0 (0) pass
default / session-streaming-long 40 -> 48 (+8) 80 -> 64 (-16) 0 -> 0 (0) 0 -> 0 (0) 16.7 -> 16.8 (+0.1) 16.8 -> 33.4 (+16.6) 0 -> 0 (0) 0 -> 0 (0) pass
default / tool-call-expand 16 -> 16 (0) 24 -> 40 (+16) 0 -> 0 (0) 0 -> 0 (0) 16.7 -> 16.8 (+0.1) 16.7 -> 16.8 (+0.1) 0 -> 0 (0) 0 -> 0 (0) pass
default / tool-default-open-heavy-bash 16 -> 16 (0) 16 -> 24 (+8) 93 -> 66 (-27) 58 -> 29 (-29) 50 -> 50 (0) 116.6 -> 116.6 (0) 3 -> 3 (0) 0 -> 0 (0) pass
default / terminal-side-panel-open 40 -> 48 (+8) 48 -> 56 (+8) 0 -> 0 (0) 0 -> 0 (0) 33.3 -> 33.3 (0) 33.3 -> 33.4 (+0.1) 0 -> 0 (0) 0 -> 0 (0) pass
default / session-scroll-reading 16 -> 16 (0) 48 -> 32 (-16) 0 -> 0 (0) 0 -> 0 (0) 16.7 -> 16.7 (0) 16.7 -> 16.7 (0) 0 -> 0 (0) 0 -> 0 (0) pass

@Astro-Han Astro-Han added enhancement New feature or request task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work and removed enhancement New feature or request labels May 23, 2026
@github-actions github-actions Bot removed the task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work label May 23, 2026
@Astro-Han Astro-Han added the task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work label May 23, 2026
@github-actions github-actions Bot removed the task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work label May 23, 2026
@Astro-Han Astro-Han added enhancement New feature or request task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work and removed enhancement New feature or request labels May 23, 2026
@Astro-Han Astro-Han merged commit 0bf1014 into dev May 23, 2026
30 of 35 checks passed
@Astro-Han Astro-Han deleted the codex/i875-layout-side-effects branch May 23, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app Application behavior and product flows P2 Medium priority task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work tech-debt Supplemental cleanup, maintainability, architecture, test, or quality debt context ui Design system and user interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant