Split dashboard-viewer-session.ts: a 1857-line file whose 1354-line closure holds every concern
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 42/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, testing-qa
Hướng nghiên cứu
Chờ phase 1 của #447, sau đó đọc src/dashboard/application/dashboard-viewer-session.ts và tests/unit/dashboard-viewer-session.test.ts cùng với các ranh giới runtime và state được đề xuất. Trước tiên, chạy các unit test hiện có và kiểm tra các thiết lập coverage trong tests/vitest.config.ts. Công việc được xem là hoàn tất khi các module được tách với input rõ ràng, behavior và public API không thay đổi, mỗi file mới đạt coverage, và npm run check:arch chạy thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Found while planning #447 phase 1. Deferred: doing it now would relocate code that #447 phase 1 deletes.
What
src/dashboard/application/dashboard-viewer-session.ts is 1857 lines, of which
1354 are a single factory closure — createDashboardViewerSession starts at line 503 and runs
to the end of the file. tests/unit/dashboard-viewer-session.test.ts is 3441 lines.
The closure holds ~65 members with no internal boundary: tile runtime construction, the parameter
analysis, target resolution, the option-source/provider wave engine, published-state assembly, the
execution pool, the commit API, and the session lifecycle all capture the same scope.
That has three concrete costs:
- Review surface. Any change to one concern reads as a change to the whole session.
- The 90% branch floor (
tests/vitest.config.ts,perFile: true, 100/95/90/100) is enforced
over the whole 1857-line file, so a defensive branch in one concern can only be covered through
the public session API, via a fixture that sets up every other concern too. That is a large part
of why the spec is 3441 lines. - Closure capture instead of parameters. Members read
tiles,filters,analysis,
documentRefand friends directly from scope, so there is no stated contract between concerns.
Why after #447, not before
#447 phase 1 removes the curated-filter/provider infrastructure, which accounts for roughly
500 lines (~27%) of this file:
| Region | Lines | What |
|---|---|---|
FilterSourceRuntime |
405-424 | provider record |
filterInitialActive / filterDefaultValue |
458-468 | persisted-default readers |
sourceBackedParams, filterSources |
610-640 | provider index |
curatedControls, staticFilterDiagnostics, mergeControls |
730-807 | provider/control merge |
optionsSignature … runFilterSourceWave |
1105-1466 | the whole option-source wave engine |
Splitting first would mean carefully extracting code that is about to be deleted, and would put two
large diffs on the same file back to back. After phase 1 the file is ~1350 lines with a clearer set
of responsibilities, and the extraction boundaries below fall out of what remains.
Proposed split (post-#447)
| File | Contents |
|---|---|
dashboard-viewer-session.ts |
public facade + lifecycle: start/refresh/refreshTile/syncDocument/destroy/setTileSearch/cancelTile/setGridRenderMode/setDashboardStyle/preflight |
viewer-tile-runtime.ts |
TileRuntime, buildTileRuntime, runTile, tileResultMeta, markTextAndErrorTiles, runnableTiles, isRunnableTileRuntime, runPool, supersede |
viewer-variable-runtime.ts |
variable runtime records, rawValues/activeMap/committedRootValues/prepareBatch, the commit API (setFilter/applyFilter/applyFilters/clearFilter/clearAllFilters/resetFilters), commitAndRerun/runAffectedWave/reserveAffected |
viewer-state.ts |
ViewerTileState/ViewerFilterState/DashboardViewState + buildState/publish |
dashboard-viewer-session.types.ts |
DashboardViewerDeps, ViewerExecutor, ViewerConnection, ViewerReadRequest (type-only seam contract, per ADR-0002 phase 0) |
tests/unit/dashboard-viewer-session.test.ts splits alongside, one spec per new module.
Acceptance
- No behaviour change; the existing session public API is byte-identical to callers
(src/ui/dashboard.tsis the only consumer). - Each new file independently meets 100/95/90/100. This is the real work — extracted
collaborators must take explicit inputs rather than capture closure scope, and each one must be
reachable from its own spec without standing up the whole session. npm run check:archstill passes:src/dashboard/applicationmay not importsrc/ui,
src/editor,src/application,src/state.ts,src/net,src/dashboard/ui
(build/check-boundaries.mjs), and the new siblings inherit that rule.- No new runtime dependency; no seam changes.
Non-goals
- Changing the session's public API or the published
DashboardViewStateshape. - Splitting
src/ui/dashboard.ts(2641 lines) — related, but a separate call.
- Ngôn ngữ chính
- TypeScript
- Star
- 8
- Fork
- 2
- 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
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Altinity/altinity-sql-browser
-
inbox
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Altinity/altinity-sql-browser#605 ·
-
inbox
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Altinity/altinity-sql-browser#509 ·
-
inbox
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Altinity/altinity-sql-browser#489 ·
-
flamegraphĐang mởenhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
Altinity/altinity-sql-browser#684 ·
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
Altinity/altinity-sql-browser#680 · 2 bình luận ·
Tất cả issue của Altinity/altinity-sql-browser
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
rajbos/ai-engineering-fluency#2340 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
community documentation first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 70/100
lingdojo/kana-dojo#31864 · 1 bình luận · 5 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
zenstackhq/zenstack#2873 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
CLI: TUI shows onboarding when the provider's API key is only in the environment (e.g. OPENROUTER_API_KEY)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởCLI
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
cline/cline#14923 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
paperclipai/paperclip#15490 ·
Maintainer thường phản hồi trong vòng 1 ngày