Skip to content

refactor(penpal): decompose Layout.tsx into focused components - #528

Merged
loganj merged 1 commit into
mainfrom
loganj/penpal-19-decompose-layouttsx
Mar 29, 2026
Merged

refactor(penpal): decompose Layout.tsx into focused components#528
loganj merged 1 commit into
mainfrom
loganj/penpal-19-decompose-layouttsx

Conversation

@loganj

@loganj loganj commented Mar 29, 2026

Copy link
Copy Markdown
Collaborator

Layout.tsx had grown to 1369 lines, making it difficult to navigate and maintain. This refactor decomposes it into focused modules (926 lines remaining, 32% reduction) with clear responsibilities:

  • Utilities: debounce, buildFileTree, flattenTree moved to utils/
  • Hooks: useSidebarResize, useActiveProject, useProjectFiles, useInstallTools extracted to hooks/
  • Components: Topbar, TabBar, HomeSidebar, ProjectSidebar extracted with each owning its own internal state (expansion, dropdowns, search, theme)

Layout.tsx remains the orchestrator for SSE, menu events, selection, modals, and link interception.

No behavior changes — all 224 frontend unit tests, 14 Go backend packages, and 23 e2e tests pass (2 pre-existing e2e failures unrelated to this change).

Closes https://linear.app/squareup/issue/PENPAL-19

@loganj
loganj force-pushed the loganj/penpal-19-decompose-layouttsx branch from b7c3c93 to bf3f9b1 Compare March 29, 2026 04:23
@loganj
loganj marked this pull request as ready for review March 29, 2026 04:53
@loganj loganj added the ai-outer-loop Managed by outer-loop label Mar 29, 2026
@loganj
loganj force-pushed the loganj/penpal-19-decompose-layouttsx branch from a50e93f to b7c3c93 Compare March 29, 2026 14:06

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b7c3c9353c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/penpal/frontend/src/components/Layout.tsx
@loganj
loganj force-pushed the loganj/penpal-19-decompose-layouttsx branch from b7c3c93 to acb2c78 Compare March 29, 2026 14:10
Extract Topbar, TabBar, HomeSidebar, and ProjectSidebar from the
monolithic Layout.tsx into separate component files. Layout.tsx remains
the orchestrator managing shared state, SSE, navigation, and context
menus while the extracted components handle UI rendering.

- Topbar (53 lines): back/forward nav, logo, search, theme toggle
- TabBar (37 lines): tab management with activate, close, new tab
- HomeSidebar (242 lines): workspace tree, standalone projects, global
  nav, view options panel
- ProjectSidebar (330 lines): breadcrumb, worktree dropdown, source
  file trees, in-review section

Layout.tsx reduced from 1368 to 926 lines (32% reduction).
No behavior changes -- pure refactor with all existing tests passing.

Closes PENPAL-19

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@loganj
loganj force-pushed the loganj/penpal-19-decompose-layouttsx branch from acb2c78 to 931f602 Compare March 29, 2026 14:14
@loganj
loganj merged commit 166654a into main Mar 29, 2026
4 checks passed
@loganj
loganj deleted the loganj/penpal-19-decompose-layouttsx branch March 29, 2026 15:42
loganj added a commit that referenced this pull request Mar 30, 2026
…-file-dis

* origin/main:
  fix(penpal): ensure repo badges are generated when repos are added (#534)
  fix(penpal): show agent selector dropdown below trigger button (#532)
  fix(penpal): filter ANCHORS.md from anchors source (#533)
  fix(penpal): show wave animation in sidebar when run phase is unknown (#531)
  fix(penpal): anchor stability improvements and code block highlights (#530)
  refactor(penpal): decompose Layout.tsx into focused components (#528)

# Conflicts:
#	apps/penpal/frontend/src/components/Layout.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-outer-loop Managed by outer-loop

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant