Repository navigation
fix: a search of only spaces is no search - #378
Merged
Merged
Conversation
brtkwr
enabled auto-merge
November 22, 2026 02:37
Typing a space in the search box was read as a search that matched every session but still ranked them, so named sessions jumped above untitled ones and the preview showed only the first and last messages with gaps. Every place that reads the search now goes through searchQuery(), the box with the spaces around it trimmed: the filter and its narrowing, ranking, HITS, the preview and its hit jumps, the reorg-run filter, ? help, the hidden sidebar and the live tick's re-match, which now uses the same word rule as the filter instead of a substring of the whole query. ccs mcp's search_sessions trims its query too, so its reply names "foo", not " foo ". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
brtkwr
force-pushed
the
fix/whitespace-search
branch
from
November 22, 2026 02:39
737238f to
8d0479d
Compare
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.
Opus 5.5 ✨
What was weird
Typing a single space in the search box (or several, or a tab) was treated as a search that matches everything but still ranks the results. I reproduced it by running ccs on made-up sessions in a throwaway HOME, as
demo/record.pydoes, and typing a space:?stopped opening help, typing a?into the box instead.Some places already trimmed the query (whether HITS shows, the reorg-run filter) and others didn't (the filter, ranking, the preview, hit jumps,
?), so they disagreed.The fix
searchQuery()inui.gois the search box with the spaces around it trimmed, and every place that reads the search goes through it:updateFilter(and itsHasPrefixnarrowing),MatchRankvia the filter,hitCount, the preview (previewLines,renderPreview,previewMessageRows),jumpHit,hideReorgRuns, the?help key, the hidden sidebar's width, and the^] ^\hint.searching()is nowsearchQuery() != "".buildPreviewalso trims what it's handed, so it agrees whoever calls it.One real change for padded words: the live tick re-matched a changed session with
strings.Contains(searchLower, query), a substring of the whole query, so with" foo "(or"foo bar"with the words apart) a session that had just received a message could drop out of the results. It now usestranscript.QueryMatches, the same word rule asupdateFilter.ccs mcpsearch_sessionsalready matched withstrings.Fields, so a query of only spaces was already rejected as empty and padding found the same sessions. But its reply repeated the query as typed (… sessions match " deploy "), somcpSearchnow trims the query first too.Left as they were on purpose: the checks that protect typing in progress (a held menu giving up its keys, auto-select, auto-focus of the message box, the reorg popup, the orchestrator offer, Esc clearing the box, restoring the box after an update). Those read the raw box, so a typed space still counts as typing there.
Tests
TestSpacesAloneAreNoSearch: for" "," ","\t"and" \t ", the order (newest started first), ranks, HITS, the preview,buildPreviewLines,jumpHit, the hidden sidebar and?help are the same as with an empty search.TestPaddedSearchMatchesUnpadded:" deploy ","\tdeploy"and"deploy "give the same order, ranks, HITS and preview as"deploy", and after the same live-tick update they keep the same sessions (with the old substring match a padded search dropped the updated one).TestMCPSearchTrimsSpaces:search_sessionsgives the empty-query error for spaces alone and the same output for padded words.After the fix, the reproduction's screens with a space typed and with an empty box are identical, and
" flaky "matches"flaky"exactly.🤖 Generated with Claude Code