Skip to content

refactor(canvas): split 650-line FilesTab.tsx into focused components - #10

Merged
HongmingWang-Rabbit merged 2 commits into
mainfrom
refactor/split-files-tab
Apr 14, 2026
Merged

refactor(canvas): split 650-line FilesTab.tsx into focused components#10
HongmingWang-Rabbit merged 2 commits into
mainfrom
refactor/split-files-tab

Conversation

@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor

Summary

  • Pure restructure of canvas/src/components/tabs/FilesTab.tsx (650 lines) into focused sibling files under canvas/src/components/tabs/FilesTab/.
  • No behavior change. Top-level FilesTab.tsx stays at the same import path (240 lines, glue + confirmation dialogs) and re-exports buildTree / TreeNode so the existing buildTree.test.ts and SidePanel.tsx imports are unaffected.
  • Preserves all dark-theme classes, aria/keyboard handlers, fetch URLs/methods/bodies, error handling, and the in-panel ConfirmDialog-style banners (no confirm()/alert()/prompt() introduced).

Files

  • FilesTab.tsx — 240 lines (was 650): state orchestration, layout, inline confirm banners, re-exports.
  • FilesTab/FilesToolbar.tsx — 77 lines: root selector, New/Upload/Export/Clear/Refresh buttons.
  • FilesTab/FileTree.tsx — 115 lines: recursive FileTree + TreeItem.
  • FilesTab/FileEditor.tsx — 112 lines: header, save/download buttons, textarea with Ctrl/Cmd+S and Tab handling.
  • FilesTab/useFilesApi.ts — 172 lines: GET/PUT/DELETE API wrapper, directory expansion, bulk upload/download/delete.
  • FilesTab/tree.ts — 86 lines: FileEntry, TreeNode, getIcon, buildTree utility.

Test plan

  • cd canvas && npm run build — clean
  • cd canvas && npm test -- --run — 357/357 pass (incl. existing buildTree tests)
  • wc -l — top file 240 (≤250), largest sibling 172 (≤300)
  • grep -n "confirm(\|alert(\|prompt(" FilesTab* — 0 matches
  • Manual smoke test: open a workspace's Files tab, browse tree, edit/save/delete a file, upload folder, download single + export all

Hongming Wang and others added 2 commits April 13, 2026 18:00
Pure restructure — no behavior change. Extracts FileTree, FileEditor,
FilesToolbar, useFilesApi hook, and tree utilities into sibling files
under canvas/src/components/tabs/FilesTab/. Top-level FilesTab.tsx is
now 240 lines (glue + confirmations); re-exports buildTree/TreeNode so
the existing import path and tests remain stable.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Walks the real UI end-to-end:
1. Creates + registers a workspace on the platform
2. Opens the detail side panel
3. Clicks the Files tab (force-click since it's in an overflow-x bar)
4. Asserts all 3 split components render:
   - FilesToolbar: "+ New" + "Upload" buttons
   - FileTree: the config.yaml seeded by the default template
   - FileEditor: "Select a file to edit" empty-state

Saves screenshots at /tmp/filestab-{1,2,3}-*.png for manual review.

Run: cd canvas && npx playwright test e2e/filestab-smoke.spec.ts

Requires platform on :8080 + canvas on :3000.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@HongmingWang-Rabbit

Copy link
Copy Markdown
Contributor Author

7-Gate Verification: PASS

  1. CI — all 6 jobs green (Canvas, Platform, MCP, Python Lint, E2E API Smoke, Shellcheck)
  2. Checkout + buildnpm run build succeeds (283kB first-load JS, 5 static pages)
  3. Testsvitest run 357/357 pass across 19 test files
  4. Security audit — clean:
    • No dangerouslySetInnerHTML / unescaped content in new JSX
    • All fetch calls in useFilesApi.ts go through the api.* helper (auth layer preserved)
    • No leaked secrets
    • Path handling identical to pre-refactor (URL interpolation on ${workspaceId}/files/${path}) — no new surface
  5. Design fit — zero native dialogs (grep on confirm(|alert(|prompt( in FilesTab* returns nothing), no light-theme color classes introduced in FilesTab/, 'use client' present on the 3 hook-using .tsx files (FileEditor, FileTree, FilesToolbar) and on useFilesApi.ts
  6. Line-level review — pure extraction: fetch URLs/methods preserved (GET /workspaces/:id/files?root=&depth=, PUT, DELETE), needsRestart marker preserved on write/delete/upload paths, keyboard/aria attributes preserved, buildTree + TreeNode re-exported from root FilesTab.tsx to keep external imports working, no dead exports
  7. Manual UI teste2e/filestab-smoke.spec.ts passes: workspace created, detail panel opens, Files tab renders FilesToolbar (+ New / Upload), FileTree (config.yaml), and FileEditor (empty-state) — all three split components visible

Change is NOT noteworthy (pure file-split refactor, no auth/billing/data-deletion touched). Merging as merge-commit.

@HongmingWang-Rabbit
HongmingWang-Rabbit merged commit 0cb46be into main Apr 14, 2026
6 checks passed
@HongmingWang-Rabbit
HongmingWang-Rabbit deleted the refactor/split-files-tab branch April 14, 2026 02:23
molecule-ai Bot pushed a commit that referenced this pull request Apr 21, 2026
refactor(canvas): split 650-line FilesTab.tsx into focused components
HongmingWang-Rabbit pushed a commit that referenced this pull request Jun 12, 2026
…as masked + workflow flag flipped

SCRIPT fail-closed:
- unreadable log + success status → masked_run (was warn-only PASS).
  Quirk #10 (continue-on-error masking) cannot be verified when logs
  are pruned; fail-closed means block the flip.

WORKFLOW flag:
- continue-on-error: true → false on scan job.

Diff-proof: 35/35 pytest tests pass.

Refs: mc#1982, internal#219 §1
HongmingWang-Rabbit pushed a commit that referenced this pull request Jun 12, 2026
Makes SOP#765 mechanical (the mc#1982 masking incident). A job that is
continue-on-error: true AND emits a context in .gitea/required-contexts.txt
fails the lint. continue-on-error rolls a failed step up to SUCCESS (Gitea
Quirk #10) — on a required context that turns a real failure green.

.gitea/required-contexts.txt is the checked-in SSOT (CI cannot always read
branch_protections); when DRIFT_BOT_TOKEN is present the lint also live-reads
BP and fails on allowlist drift, degrading gracefully on 403/absent token.
6 pytest cases + verified clean against current core (3 required contexts,
all coe=false) with live BP cross-check passing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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