refactor: decompose QueryEditor (#115)#128
Merged
Merged
Conversation
…r modules (#115) Extract the pure SQL autocomplete helpers (parsing, context detection, fuzzy matching, keyword constants) into lib/sqlCompletion.ts, the CodeMirror theme/highlight into lib/editorTheme.ts, and the FindBar component + findMatchInfo into components/FindBar.tsx. QueryEditor.tsx drops from 1040 to 352 lines and now only owns the editor wiring. Tests split to match: pure-helper tests move to lib/sqlCompletion.test.ts, FindBar/findMatchInfo tests to components/FindBar.test.tsx. No behavior change; unit (449) + e2e (91) suites pass. Part of M2 code-review finding.
The callback's return is only inspected via the `=== false` sentinel. The prior `boolean | undefined` type rejected the void-returning callback in innerSubqueryContext under strict TypeScript (ts 2345), while `void` in the union trips biome's noConfusingVoidType. `unknown` satisfies both. Pre-existing looseness carried over from QueryEditor.tsx; no behavior change.
Revert to the honest `boolean | undefined` contract (return false to stop early). The only offender was innerSubqueryContext's first callback, which had no return statement and so inferred `void`; give it an explicit `return undefined` to match the documented protocol. No any/unknown, no behavior change.
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
First slice of #115 (M2 — oversized components). Decomposes
QueryEditor.tsx(1040 → 352 lines) by lifting cohesive units into focused, independently-testable modules. No behavior change.New modules
lib/sqlCompletion.ts(421) — pure SQL autocomplete helpers:extractFromTables,extractAliasMap,detectSqlContext, statement/string/subquery scanning,applyFuzzyMatch,buildCompletionOptions, keyword constants,makeKeyTypeBadge, and theCompletionEntry/SqlContext/FuzzyCompletiontypes.lib/editorTheme.ts(115) — the CodeMirrorsnowySqlHighlight+editorThemedefinitions.components/FindBar.tsx(172) — theFindBarcomponent plusfindMatchInfoand itsMatchInfo/FindBarPropstypes.QueryEditor.tsxnow only owns the editor instance wiring (completion source, keymaps, find state) and imports the above.Tests split to match the modules
lib/sqlCompletion.test.ts— the pure-helper testscomponents/FindBar.test.tsx—FindBar+findMatchInfotestsQueryEditor.test.tsx— keeps only the component-level tests (and CodeMirror mocks)useDatasourceSessionnow importsCompletionEntryfrom its new home instead of viaQueryEditor(no re-export left behind).Acceptance criteria
T.*) and patterns preservedtscbuild, biome checkScope note
This is the QueryEditor slice of the three-file issue.
ConnectionManagerandSidebarwill follow as separate PRs.