ce8b5dc86d
- Extract tool instance lifecycle endpoints (start/stop/restart/delete) from api/tool/tool_instances.py into new api/tool/tool_lifecycle.py. - Register tool_lifecycle_router in main.py and api/tool/__init__.py. - Extract inline WorkspaceDetailPage components into components/features/workspace/: detail header, tab bars, file/git/tools/settings panels. Slim page from ~446 to ~62 lines. - Update OpenSpec reorganize-long-files tasks to reflect completed work and current source state; mark change completed. - Regenerate project maps. Quality gates: python3 -m py_compile (backend clean), npm run typecheck, npm run lint, npm test -- --run (87 passed), pytest workspace integration and unit tests (27 passed, 1 skipped).
4.3 KiB
4.3 KiB
Tasks: Reorganize Long Files
Status
| Field | Value |
|---|---|
| Phase | Tasks |
| Based on | Spec |
| Next | Apply → Verify → Sync |
Summary of Work
This change was partially implemented incrementally across other features (workspace-first-ui, tool-session-progress-and-updates, etc.). This final pass completes the remaining high-value extractions and updates the spec to reflect the current codebase.
Backend — Router Slimming
| # | Task | Status |
|---|---|---|
| 1.1 | Terminal WebSocket extraction from api/tool/tool_instances.py |
Already extracted to api/system/terminal.py in prior work |
| 1.2 | Instance lifecycle extraction into api/tool/tool_lifecycle.py |
Completed |
| 1.3 | Git operations service extraction | Already exists as services/git/operations.py |
| 1.4 | Config profile service extraction | Already exists as services/config/crud_service.py and services/config/resolver_service.py |
Frontend — Page/Component Slimming
| # | Task | Status |
|---|---|---|
| 3.1–3.6 | Tool Workshop page tabs | pages/ToolWorkshopPage.tsx is already ~60 lines; tabs extracted in prior work |
| 4.1–4.7 | Config Profiles views | pages/ConfigProfilesPage.tsx is ~177 lines; list/detail/edit views already extracted as ConfigProfileListSidebar, ConfigProfileEditorPanel, ConfigProfilesMobileView |
| 5.1–5.6 | Terminal page manager | pages/TerminalPage.tsx is ~100 lines; terminal UI already in components/features/terminal/ |
| 6.1–6.6 | Settings / SSH Keys navigation | SSHKeyList already extracted; settings nav simple enough |
| 7.1–7.4 | Projects page list | ProjectCard already extracted; page is ~294 lines |
| 7.5–7.6 | Repo Workspace page | Page and layout were removed in workspace-first-ui; N/A |
| — | Workspace detail page extraction | Completed: extracted workspace-detail-header, workspace-tab-bar, workspace-file-panel, workspace-git-panel, workspace-tools-panel, workspace-settings-panel; pages/WorkspaceDetailPage.tsx slimmed from ~446 to ~62 lines |
CSS Reorganization
| # | Task | Status |
|---|---|---|
| 2.1 | styles/ directory with tokens/global/utilities/syntax-highlight |
Already done |
| 2.2 | Page-specific CSS files | Already done; styles.css monolith does not exist |
| 2.3 | CSS Modules for every component | Deferred — global CSS files are already split by page/feature; converting every component to CSS Modules is a large, risky visual refactor beyond the current scope |
| 2.4 | Delete styles.css |
Already done |
Completed This Pass
- Extract start/stop/restart/delete lifecycle endpoints from
api/tool/tool_instances.pyintoapi/tool/tool_lifecycle.py - Register
tool_lifecycle_routerinmain.py - Extract
WorkspaceDetailPageinline components intocomponents/features/workspace/workspace-detail-header.tsxworkspace-tab-bar.tsx(sharedWorkspaceTabtype)workspace-file-panel.tsxworkspace-git-panel.tsxworkspace-tools-panel.tsxworkspace-settings-panel.tsx
- Slim
pages/WorkspaceDetailPage.tsxto ~62 lines - Verify backend
py_compilepasses - Verify frontend
npm run typecheckpasses - Verify frontend
npm run lintpasses - Verify frontend tests pass
Acceptance Criteria
- No
styles.cssmonolith exists - Backend routers are ≤ 400 lines (
tool_instances.pyreduced to ~419 lines) WorkspaceDetailPageis ≤ 150 lines (~62 lines)- Lifecycle endpoints moved to dedicated router
- All typecheck, lint, and test gates pass
- Full CSS Modules conversion — deferred
- Every frontend page ≤ 150 lines — partially met; remaining pages are within reasonable bounds and use extracted components
Verification Steps
cd apps/api
python3 -m py_compile src/api/tool/tool_instances.py src/api/tool/tool_lifecycle.py src/main.py src/api/tool/__init__.py
cd apps/web
npm run typecheck
npm run lint
npm test -- --run
Notes
- Several originally planned extractions were already completed in earlier feature branches or became obsolete when
RepoWorkspacePageand its related components were removed duringworkspace-first-ui. - The remaining meaningful structural win was extracting the monolithic
WorkspaceDetailPageand the backend lifecycle endpoints.