File tree Expand file tree Collapse file tree
apps/web/src/components/chat Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4063,6 +4063,24 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
40634063 }
40644064 if ( item . type === "slash-command" ) {
40654065 if ( ( item . command === "side" || item . command === "btw" ) && onSideChatCommand ) {
4066+ // The menu hides these unless they can run, but a stale item can still be
4067+ // picked after the draft changes. Then keep the command as plain text.
4068+ if ( trigger . rangeStart !== 0 || composerHasNonPromptContent ) {
4069+ const replacement = `/${ item . command } ` ;
4070+ const replacementRangeEnd = extendReplacementRangeForTrailingSpace (
4071+ snapshot . value ,
4072+ trigger . rangeEnd ,
4073+ replacement ,
4074+ ) ;
4075+ const applied = applyPromptReplacement (
4076+ trigger . rangeStart ,
4077+ replacementRangeEnd ,
4078+ replacement ,
4079+ { expectedText : snapshot . value . slice ( trigger . rangeStart , replacementRangeEnd ) } ,
4080+ ) ;
4081+ if ( applied ) setComposerHighlightedItemId ( null ) ;
4082+ return ;
4083+ }
40664084 // `/btw` waits for a question; `/side` opens right away.
40674085 const opensNow = item . command === "side" ;
40684086 const replacement = opensNow ? "" : "/btw " ;
@@ -4214,6 +4232,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
42144232 planModeUiEnabled ,
42154233 onUsageLimitsCommand ,
42164234 onSideChatCommand ,
4235+ composerHasNonPromptContent ,
42174236 resolveActiveComposerTrigger ,
42184237 ] ,
42194238 ) ;
You can’t perform that action at this time.
0 commit comments