Skip to content

Extract workspace editor logic into composable hooks and modular breadcrumb components#49

Merged
rushabhcodes merged 1 commit into
tscircuit:mainfrom
rushabhcodes:refactor/workspace-editor-hooks-and-breadcrumbs
Jul 19, 2026
Merged

Extract workspace editor logic into composable hooks and modular breadcrumb components#49
rushabhcodes merged 1 commit into
tscircuit:mainfrom
rushabhcodes:refactor/workspace-editor-hooks-and-breadcrumbs

Conversation

@rushabhcodes

Copy link
Copy Markdown
Contributor

What changed

WorkspaceCodeEditor (previously ~600 lines) and Breadcrumbs (~450 lines) mixed
model management, navigation, keyboard handling, and rendering in single files.
This PR decomposes them into focused, independently testable units:

New hooks (src/hooks/)

  • useWorkspaceModelManager — owns the Monaco model manager: keeps a live
    model per text file so the TypeScript language service resolves cross-file
    imports project-wide, and defers TS worker-graph initialization until the
    workspace settles.
  • useWorkspaceNavigation — cross-file "go to definition" routed through
    onFileSelect, model swapping with per-file cursor/scroll state preservation,
    and pending-reveal application when the target file becomes active.
  • useDocumentSymbols — tracks the active model's symbol outline and the
    symbol path containing the cursor, refetching on content changes.
  • useWorkspacePalettes — mutually exclusive Quick Open / workspace search
    state plus the global Ctrl/Cmd+P and Ctrl/Cmd+Shift+F shortcuts.

Breadcrumbs modularization (src/components/breadcrumbs/)

BreadcrumbSegment, FileTreeMenu (with fuzzy file search), and
SymbolMenuItems are now standalone components; sibling lists per path depth
are computed in a single tree walk so cursor-move re-renders stay cheap.

API consistency

  • Multi-parameter callbacks converted to named-parameter objects
    (e.g. onReplace({ matches, replacement, useRegex })), keeping function
    signatures at two parameters or fewer per the handbook style guide.
  • Named closures hoisted to module scope for testability.

Test suite: one test per file

The suite (57 tests) is reorganized so each file contains exactly one test(),
grouped in per-module directories (tests/workspaceSearch/, tests/quickOpen/,
tests/tsciPackageSupport/, …) with shared setup hoisted into tests/fixtures/.
Assertions are unchanged.

Breaking changes

None. The public exports (WorkspaceCodeEditorProps, WorkspaceCodeEditorHandle,
EditorFile, monaco utilities) are untouched; the only changed signature
(WorkspaceSearchProps.onReplace) is internal and not exported from the package
entry point.

Verification

  • bun run typecheck — clean
  • bun test — 57 pass / 0 fail across 57 files
  • biome format — applied

…dcrumb components

- Add useWorkspaceModelManager, useWorkspaceNavigation, useDocumentSymbols,
  and useWorkspacePalettes hooks extracted from WorkspaceCodeEditor
- Split Breadcrumbs into BreadcrumbSegment, FileTreeMenu, and SymbolMenuItems
  under src/components/breadcrumbs/
- Convert multi-parameter callbacks to named-parameter objects per the
  handbook style guide (e.g. onReplace)
- Reorganize the test suite to one test per file in per-module directories,
  with shared setup hoisted into tests/fixtures/

No public API changes.
Copilot AI review requested due to automatic review settings July 19, 2026 09:28
@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
monaco-code-editor Ready Ready Preview, Comment Jul 19, 2026 9:28am

Request Review

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@rushabhcodes
rushabhcodes merged commit 4c1f531 into tscircuit:main Jul 19, 2026
5 checks passed
@rushabhcodes
rushabhcodes deleted the refactor/workspace-editor-hooks-and-breadcrumbs branch July 19, 2026 09:28
@tscircuitbot

Copy link
Copy Markdown
Collaborator

Thank you for your contribution! 🎉

PR Rating:
Impact: Tiny

Track your contributions and see the leaderboard at: tscircuit Contribution Tracker


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.

3 participants