refactor: decompose Sidebar (#115)#130
Merged
Merged
Conversation
#115) Split the 1652-line Sidebar.tsx into focused modules: - lib/sidebarTypes.ts — tree-node + metadata interfaces - lib/sidebarNodes.ts — pure emptyFolder/makeTableNode/hydrateSchemaNodes (+tests) - hooks/useSidebarTree.ts — per-datasource tree state, loaders, toggle handlers - components/SidebarIcons.tsx — icon glyphs (dedupes repeated inline SVGs) - components/TreeRow.tsx, SidebarChrome.tsx — presentational primitives - components/SidebarTableNode.tsx + SidebarConnectionNode.tsx — tree render Sidebar.tsx (315 lines) now owns only the toolbar/search/tree/menu/footer shell. Every resulting file is <500 lines. No behavior change; 464 unit (+8 new) + 91 e2e pass, tsc + biome clean.
5 tasks
nkcoder
added a commit
that referenced
this pull request
Jul 4, 2026
…131) * test: cover Find, ConnectionGeneralTab, and session-hook error paths Fills gaps surfaced while regression-testing the #127–#130 refactor: - e2e/query-editor-find.spec.ts: in-editor Find (Cmd+F) had no e2e coverage after the #128 QueryEditor/FindBar split — open/focus/close, match count, next/prev navigation, clear-resets. - ConnectionGeneralTab.test.tsx: the #129-extracted tab had no test (40% func) — field edits, port numeric coercion, password mask/reveal, isEdit placeholder, derived URL. - useDatasourceSession: GetCompletions failure during connect/refresh; disconnect no-op when nothing is connected. - useQueryHistory: null history result coerces to []. * test: raise hooks branch coverage + set two-tier coverage thresholds Adds the missing hooks-branch tests and turns the flat #51 threshold into a two-tier gate: - useSidebarTree.test.ts (new): the hook had no direct test — covers the live-load error branches (columns/sub-folder load failures), the toggleColumnsFolder guard + toggle, and each sub-folder loader. - useQueryExecution: non-result-set (DDL) rows-affected path; error leaves a pinned tab intact; double-pin preserves the first; close a non-active tab. - useDatasourceSession: successful refresh clears a same-ds warning; a refresh for one ds leaves another ds's warning intact. hooks branch coverage 78.6% -> 82.7%; overall 89.8% -> 90.6% stmt. vitest.config.ts: global ratchet floor (90/82/90/91) as a regression gate, plus higher per-dir floors for pure logic (lib/ 97/90/100/99, hooks/ 95/82/95/97). Verified the glob thresholds are enforced.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Final slice of #115 (M2 — oversized components). Decomposes
Sidebar.tsx(1652 → 315 lines) into focused modules. No behavior change — the whole tree renders identically; onlySidebaris imported externally (byApp.tsx), so all 13 integration test suites pass unchanged.New modules
lib/sidebarTypes.ts(81) — tree-node + metadata interfaceslib/sidebarNodes.ts(61) — pureemptyFolder/makeTableNode/hydrateSchemaNodes, now unit-tested insidebarNodes.test.ts(8 tests)hooks/useSidebarTree.ts(312) — per-datasource lazy tree: schema/table/sub-folder state, loaders (live + cached-metadata + refresh), and all toggle handlerscomponents/SidebarIcons.tsx(133) — icon glyphs; dedupes the checks/index SVGs that appeared twice inlinecomponents/TreeRow.tsx(83) — theTreeRowprimitive +ROW_Hcomponents/SidebarChrome.tsx(83) —ToolBtn,CtxMenuItemcomponents/SidebarTableNode.tsx(232) — a table row + its five sub-folders and itemscomponents/SidebarConnectionNode.tsx(403) — a connection node (schemas → tables → views + saved-queries folder)Sidebar.tsxnow owns only the toolbar / search / tree map / context menu / footer shell and wires the hook to the components.Acceptance criteria (issue #115 — all three files now done)
lib/sidebarNodes.ts)T.*) and patterns preservedtsc, biome cleanNotes
useSidebarTree;hydrateSchemaNodesbecame a pure function (was an in-componentuseCallback) and is now directly testable.