Skip to content

fix(new-workspace): stop UI flashing when typing ahead of search - #11436

Merged
AmethystLiang merged 3 commits into
mainfrom
typing-fast-on-new-worktree-dialog-is-flashing
Jul 30, 2026
Merged

AmethystLiang merged 3 commits into
mainfrom
typing-fast-on-new-worktree-dialog-is-flashing

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

  • Hold the last branch results while the live query is a prefix extension/trim of the settled search, so the dropdown does not blank between debounced keystrokes.
  • Stabilize cmdk item values for typed-text actions, freeze the highlight while search lags, and only show the spinner on first load.
  • Keep selection WYSIWYG for visible provider rows (click/Enter match the highlight) and drop the hold when the query fully diverges.

Test plan

  • Open New Workspace and type quickly in Smart / Branch mode; dropdown should stay populated without flashing empty or thrashing the highlight.
  • Confirm the spinner only appears when there are no results yet, not on every keystroke refresh.
  • With results visible while still typing ahead, click a branch/PR row and press Enter on a highlighted row — both should select it.
  • Change the query to an unrelated string (e.g. feat → bug); previous results should clear until the new search settles.
  • Clear the input; prior non-empty results should hide.
  • Unit tests: smart-workspace-source-results and smart-workspace-command-value.

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.
@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3da840b6-9c27-494a-8185-49432c00e510

📥 Commits

Reviewing files that changed from the base of the PR and between 324ebc9 and 5ea9380.

📒 Files selected for processing (3)
  • src/renderer/src/components/new-workspace/SmartWorkspaceNameField.tsx
  • src/renderer/src/components/new-workspace/smart-workspace-source-results.test.ts
  • src/shared/new-workspace/smart-workspace-source-results.ts

📝 Walkthrough

Walkthrough

Updated smart workspace search to retain compatible provider and branch results during pending queries, while clearing them when input is emptied or diverges. Stabilized use-name and create-branch command values, improved stale-query selection fallback behavior, and expanded tests for held results and command resolution. Search highlight updates now pause for stale queries, and the spinner appears only during initial empty-result loading.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a summary and test plan, but it omits required screenshots, testing checkboxes, AI review, security audit, and notes sections. Add the missing template sections: Screenshots, testing checkboxes, AI Review Report, Security Audit, and Notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main New Workspace UI change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Hide provider rows immediately when the input is cleared.

isQueryStale becomes false for an empty live value, while rows still 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4f536ed and 324ebc9.

📒 Files selected for processing (5)
  • src/renderer/src/components/new-workspace/SmartWorkspaceNameField.tsx
  • src/renderer/src/components/new-workspace/smart-workspace-command-value.test.ts
  • src/renderer/src/components/new-workspace/smart-workspace-source-results.test.ts
  • src/shared/new-workspace/smart-workspace-command-value.ts
  • src/shared/new-workspace/smart-workspace-source-results.ts

@greptile-apps

greptile-apps Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Greptile Summary

This 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.

  • Branch hold with divergence guard: getVisibleBranchResults now defers to shouldHoldSourceResultsForQuery, which keeps prior results only if the live query is a prefix extension/trim of the settled query within a 4-character delta, correctly dropping the hold on unrelated input (e.g. feat → bug).
  • Provider hold (GitHub/GitLab/Linear): A simpler getVisibleHeldProviderResults keeps items visible as long as the field is non-empty, immediately clearing on field-clear ahead of debounce. Unlike branches, it has no divergence check, so items from an old query remain visible when the user fully changes their input.
  • UX stabilization: cmdk value props are now fixed strings ('use-name', 'create-branch') instead of embedding the typed text, the spinner only appears when there are no rows yet, and the onValueChange handler ignores cmdk re-emissions while the query is stale.

Confidence Score: 4/5

Mostly 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 shouldHoldSourceResultsForQuery with its prefix+delta cap. Provider results (getVisibleHeldProviderResults) lack the same guard: typing feat, getting GitHub PR results, then editing to bug leaves the feat PRs visible and clickable until the new API call resolves. This directly contradicts the test plan step about unrelated query changes clearing results, and there is no test covering that diverged-query path for providers. The risk is limited to the debounce+API window (~400ms–1s), but within that window the wrong item can be selected.

Files Needing Attention: src/shared/new-workspace/smart-workspace-source-results.ts — getVisibleHeldProviderResults needs a divergence check analogous to shouldHoldSourceResultsForQuery; a corresponding test case in smart-workspace-source-results.test.ts would be needed too.

Important Files Changed

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]
Loading

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.
@AmethystLiang
AmethystLiang merged commit 8d4e975 into main Jul 30, 2026
23 of 24 checks passed
Comment on lines +83 to +99
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()
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant