Repository navigation
fix(new-workspace): stop UI flashing when typing ahead of search - #11436
Conversation
Hold branch results while queries settle, show the spinner only on initial load, use stable cmdk values, and guard selections against stale rows. This prevents the highlight from jumping around when typing faster than the debounced search settles.
Hold the last search results while the user extends or trims the query, only hiding them when the query diverges completely. This prevents the dropdown from flashing empty between debounced keystrokes and removes the guard that made provider rows unselectable during typing.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughUpdated smart workspace search to retain compatible provider and branch results during pending queries, while clearing them when input is emptied or diverges. Stabilized 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/renderer/src/components/new-workspace/SmartWorkspaceNameField.tsx (1)
1084-1089: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winHide provider rows immediately when the input is cleared.
isQueryStalebecomes false for an empty live value, whilerowsstill includes the prior GitHub, GitLab, and Linear arrays until debounce-triggered requests clear them. Those stale rows remain visible and selectable; only branches are synchronously hidden. Gate all provider rows on the live query being non-empty (or clear visible rows immediately) and add coverage for clearing each provider mode. This contradicts the stated requirement to hide previous results when the input is cleared.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a2328ea6-e65e-4153-8cf6-da7f5b13865f
📒 Files selected for processing (5)
src/renderer/src/components/new-workspace/SmartWorkspaceNameField.tsxsrc/renderer/src/components/new-workspace/smart-workspace-command-value.test.tssrc/renderer/src/components/new-workspace/smart-workspace-source-results.test.tssrc/shared/new-workspace/smart-workspace-command-value.tssrc/shared/new-workspace/smart-workspace-source-results.ts
Greptile SummaryThis PR eliminates the "flash" in the New Workspace dropdown when the user types faster than the 200ms debounce by holding the last resolved results while the live query is still settling, stabilizing cmdk item values for typed-text actions so rows are not remounted on every keystroke, and freezing the highlight while the query is stale.
Confidence Score: 4/5Mostly safe to merge; the branch hold logic is correct and well-tested, but provider results (GitHub/GitLab/Linear) are held without a divergence check, so stale items from a prior query remain visible and selectable when the user fully changes their input. The branch-result hold correctly drops when the query is unrelated, thanks to Files Needing Attention: src/shared/new-workspace/smart-workspace-source-results.ts —
|
| Filename | Overview |
|---|---|
| src/shared/new-workspace/smart-workspace-source-results.ts | Adds shouldHoldSourceResultsForQuery (with delta cap) for branches and getVisibleHeldProviderResults for GitHub/GitLab/Linear. Branch divergence check is correct; provider hold lacks the divergence guard and keeps stale items visible when the query fully changes. |
| src/shared/new-workspace/smart-workspace-command-value.ts | Resolves command value by freezing the current arm while the query is stale, falling back to typed-text row or first available row — logic is correct and well-tested. |
| src/renderer/src/components/new-workspace/SmartWorkspaceNameField.tsx | Wires up the hold functions for providers, freezes cmdk onValueChange while stale, adds commandValue resync effect, changes spinner to show only on first load, and allows selecting held rows. Changes are self-consistent. |
| src/renderer/src/components/new-workspace/smart-workspace-source-results.test.ts | Adds coverage for hold logic, delta cap, empty-field clear, and stable cmdk values; missing a test for getVisibleHeldProviderResults with a fully-diverged query (e.g., value='bug', debouncedQuery='feat'). |
| src/renderer/src/components/new-workspace/smart-workspace-command-value.test.ts | Tests updated to reflect stable use-name/create-branch values and the new freeze/fallback behavior; scenarios are thorough and match the new implementation. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[User Keystroke] --> B[value updated instantly]
B --> C{isQueryStale?\ntrimmedValue ≠ trimmedDebouncedQuery}
C -- Yes --> D[cmdk onValueChange ignored\nresolvedCommandValue frozen]
C -- No --> E[cmdk onValueChange accepted]
B --> F[200ms debounce]
F --> G[debouncedQuery settles]
G --> H[Effects fire: GitHub / GitLab / Linear / Branches]
H --> I{Which provider?}
I -- Branches --> J[getVisibleBranchResults\nshouldHoldSourceResultsForQuery\nprefix + delta≤4 check]
I -- GitHub/GitLab/Linear --> K[getVisibleHeldProviderResults\nonly empty-field guard]
J -- query diverges --> L[Returns empty — rows clear]
J -- query extends/trims --> M[Returns held branches]
K -- value empty, debounce non-empty --> L
K -- value non-empty --> N[Returns items — regardless of query divergence]
M --> O[buildSmartWorkspaceSourceRows]
N --> O
O --> P[rows memoized]
P --> Q[resolveSmartWorkspaceCommandValue\nfreeze or pick arm]
Q --> R[Command value= prop → highlight stable]
Reviews (2): Last reviewed commit: "fix(new-workspace): align held provider ..." | Re-trigger Greptile
Cap prefix hold by length delta, hide GitHub/GitLab/Linear rows when the field is cleared ahead of debounce, and re-sync the cmdk arm when search settles so the highlight cannot lag the resolved selection.
| export function getVisibleHeldProviderResults<T>({ | ||
| items, | ||
| value, | ||
| debouncedQuery | ||
| }: { | ||
| items: readonly T[] | ||
| value: string | ||
| debouncedQuery: string | ||
| }): T[] { | ||
| if (!isSmartWorkspaceSourceQueryWithinLimit(value)) { | ||
| return [] | ||
| } | ||
| if (value.trim() === '' && debouncedQuery.trim() !== '') { | ||
| return [] | ||
| } | ||
| return items.slice() | ||
| } |
There was a problem hiding this comment.
Provider hold is unbounded on full query divergence
getVisibleHeldProviderResults only guards the cleared-field case (value === ''). It has no equivalent of shouldHoldSourceResultsForQuery, so GitHub/GitLab/Linear items from a prior query stay visible and clickable when the user types an entirely different string. For example: type feat, get PR results, then immediately edit to bug — during the debounce + API-call window, the feat PRs are still rendered and selecting one picks the wrong item. The test plan says "Change the query to an unrelated string (e.g. feat → bug); previous results should clear until the new search settles" but that step only passes for branches (which go through shouldHoldSourceResultsForQuery); providers are not covered.
The root gap is that getVisibleHeldProviderResults does not receive a resultQuery parameter, so it cannot apply the same prefix/delta check. Adding per-provider result-query tracking (analogous to branchResultsSource) would enable the same guard.
…blyai#11436) * fix(new-workspace): stop UI flashing when typing ahead of search Hold branch results while queries settle, show the spinner only on initial load, use stable cmdk values, and guard selections against stale rows. This prevents the highlight from jumping around when typing faster than the debounced search settles. * fix(new-workspace): keep dropdown visible while typing within settled qu Hold the last search results while the user extends or trims the query, only hiding them when the query diverges completely. This prevents the dropdown from flashing empty between debounced keystrokes and removes the guard that made provider rows unselectable during typing. * fix(new-workspace): align held provider results with live typing Cap prefix hold by length delta, hide GitHub/GitLab/Linear rows when the field is cleared ahead of debounce, and re-sync the cmdk arm when search settles so the highlight cannot lag the resolved selection.
Summary
Test plan
feat→bug); previous results should clear until the new search settles.smart-workspace-source-resultsandsmart-workspace-command-value.