Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Refactor FileTree read-only workspace categorization to a single flag

Đang mở
#753 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
52/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
typescript
Lĩnh vực
frontend

Hướng nghiên cứu

Read lua-learning-website/src/hooks/compositeFileSystemAdapter.ts and fileSystemTypes.ts first to trace TreeNode construction and the workspace flags. Then inspect FileTree.tsx and filterWritableFolders.ts for the duplicated categorization checks. Done means all listed workspace types remain in the correct sections, with related unit tests, examples-workspace.spec.ts, equivalent demos e2e tests, and mutation testing passing.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

tech-debt

Background

In FileTree.tsx, the categorization of workspaces into "regular" (editable) vs "readOnly" sections uses a hardcoded OR chain of per-type flags:

```ts
if (node.isLibraryWorkspace || node.isDocsWorkspace || node.isBookWorkspace
|| node.isExamplesWorkspace || node.isProjectsWorkspace || node.isDemosWorkspace) {
readOnly.push(node)
} else {
regular.push(node)
}
```

The same pattern is duplicated in src/components/AnsiGraphicsEditor/filterWritableFolders.ts:

```ts
return !!(node.isReadOnly || node.isLibraryWorkspace || node.isDocsWorkspace
|| node.isBookWorkspace || node.isExamplesWorkspace || node.isDemosWorkspace)
```

Every new read-only workspace type (library, docs, book, examples, projects, demos, ...) requires touching these OR chains. This is brittle and easy to forget — PR #751 demonstrated the failure mode: forgetting to plumb isDemosWorkspace caused ~40 e2e tests to fail because demos landed in the wrong tree section.

Proposal

Introduce a single node.isReadOnlyWorkspace (or reuse the existing node.isReadOnly for root-level workspace folders only) set once in buildTreeFromFileSystem based on workspace.isReadOnly === true. Collapse both OR chains to a single flag check.

```ts
// FileTree.tsx
if (node.isReadOnlyWorkspace) {
readOnly.push(node)
} else {
regular.push(node)
}
```

Files

  • lua-learning-website/src/hooks/compositeFileSystemAdapter.ts — set new flag
  • lua-learning-website/src/hooks/fileSystemTypes.ts — add to TreeNode
  • lua-learning-website/src/components/FileTree/FileTree.tsx — collapse OR chain
  • lua-learning-website/src/components/AnsiGraphicsEditor/filterWritableFolders.ts — collapse OR chain
  • Related tests

Verification

  • Unit tests for each workspace type (library, docs, book, examples, projects, demos) continue to land in the correct section
  • examples-workspace.spec.ts and equivalent demos e2e still pass
  • Mutation testing on the changed categorization logic

Risk / Scope

Medium. Affects all read-only workspace rendering paths. Needs a careful mutation-test pass since this is categorization logic that's load-bearing for file tree UX and test infrastructure.

Deferred from #751 per reviewer feedback as out-of-scope tech debt.

Ngôn ngữ chính
TypeScript
Star
1
Fork
0
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của jcollard/LuaInTheWeb

Tất cả issue của jcollard/LuaInTheWeb

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.