Skip to content

Commit 125105c

Browse files
committed
fix(web): guard chat shell run action for incomplete commands
1 parent 345895b commit 125105c

3 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎apps/web/src/components/ChatMarkdown.test.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ describe("ChatMarkdown streaming", () => {
225225
"```bash\necho one\necho two\n```",
226226
"```typescript\necho hello\n```",
227227
"```bash\n\n```",
228+
"```bash\necho hello\n\n```",
229+
"```bash\necho hello\\\n```",
228230
"```bash\necho safe \u202e#\n```",
229231
"```bash\necho incomplete",
230232
"~~~bash\necho incomplete",

‎apps/web/src/components/ChatMarkdown.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,10 +960,12 @@ function MarkdownCodeBlock({
960960
onRunShellCommand !== undefined &&
961961
!isStreaming &&
962962
/^(?:sh|bash|zsh|fish|shell|powershell|pwsh)$/.test(language) &&
963+
code.endsWith("\n") &&
963964
command.length > 0 &&
965+
!command.endsWith("\\") &&
964966
// Control and invisible format characters (bidi overrides, zero-width) can
965967
// make the rendered command differ from what the terminal would receive.
966-
!/[\p{Cc}\p{Cf}]/u.test(command);
968+
!/[\p{Cc}\p{Cf}]/u.test(code.slice(0, -1));
967969

968970
const handleCopy = useCallback(() => {
969971
if (typeof navigator === "undefined" || navigator.clipboard == null) {

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9903,7 +9903,7 @@ export default function ChatView(props: ChatViewProps) {
99039903
agentPanelModel,
99049904
onOpenAgents: addAgentsSurface,
99059905
onUseArtifactTemplate: useArtifactTemplate,
9906-
onRunShellCommand: runShellCommand,
9906+
...(activeProject ? { onRunShellCommand: runShellCommand } : {}),
99079907
}
99089908
: {})}
99099909
isWorking={!paintOnlyDisplayedTimeline && isWorking}

0 commit comments

Comments
 (0)