Conversation
Typing `@` or `/` opens the suggestion popover, and every later keystroke re-filters the list. The filter can empty it, and nothing closed the popover when it did, so the Enter handler still tried to accept the highlighted suggestion from an empty list: `applyPrefixSuggestion(undefined)`, which throws on its first line. The message was never sent and nothing appeared on screen, so any prompt opening with a name or a path (`@Ada please review this`, `/usr/bin/python is missing`) could not be sent from the keyboard at all. Clicking Send worked, which is what made it look so arbitrary. The popover already rendered only when it had suggestions; the key handlers disagreed. Both now read one condition, so a popover with nothing to offer claims no keystroke. That covers Enter, Tab, and the arrow keys, whose wraparound arithmetic divided by the same empty length and selected NaN. The condition and the filter move into their own module: the sidebar is 4600 lines and has no tests, and these two rules are what the regression is about. Closes plmbr#463
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.
Summary
A chat message beginning with
@or/that matches no participant or slash command could not be sent from the keyboard. Enter threwTypeError: Cannot read properties of undefined (reading 'startsWith'), the message was never sent, and nothing appeared on screen: the draft stayed in the box and the transcript stayed empty. Clicking Send with the same text worked, which is what made the failure look arbitrary.Ordinary prompts hit this, since any text opening with a name or a path qualifies:
@Ada please review this,/usr/bin/python is missing,@here can someone look.This is #463, found while exploring the chat input.
Solution
Typing
@or/opens the popover, and each later keystroke re-filters the suggestion list. The filter can empty that list, and nothing closed the popover when it did, so the Enter handler still tried to accept the highlighted suggestion:applyPrefixSuggestion(prefixSuggestions[0])with an empty array passesundefinedinto a function whose first statement isprefix.startsWith('/mcp:').The popover already rendered only when it had suggestions to show; the keyboard handlers disagreed with it. Both now read the same condition, so a popover with nothing to offer claims no keystroke and Enter falls through to sending the message. That covers three keys:
(index ± 1 + length) % length, which is% 0with an empty list, selectingNaN.The condition and the filter move into a small module of their own.
src/chat-sidebar.tsxis about 4,600 lines with no test coverage, and rendering it in jsdom would need a large JupyterLab mock, so extracting the two rules the regression is actually about is what makes it testable.Testing
jlpm tsc --noEmitclean,jlpm lint:checkclean,jlpm jest540 passed across 46 suites,pytest2104 passed.New tests cover the filter (everything for an empty prompt, substring narrowing, nothing once the prompt is typed past every match, and no mutation of the caller's list) and the popover condition (false with nothing to suggest even while open, true while it has something, false when closed).
Verified in JupyterLab against a build of
mainfor comparison:@Ada please review this+ EnterTypeError, nothing sent, draft stuckTypeError/new+ ArrowDown + Tab/newPythonFile/newPythonFile/new/new*commandsRisks and follow-ups
/mcp:server:promptlegitimately opens the argument dialog. Left alone deliberately; worth its own decision.Closes #463