Skip to content

Commit 9dd4549

Browse files
committed
WIP
Signed-off-by: Thomas Kosiewski <tk@coder.com>
1 parent cf7265d commit 9dd4549

File tree

3 files changed

+48
-21
lines changed

3 files changed

+48
-21
lines changed

src/browser/components/ChatInput/index.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,15 +185,15 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
185185
const creationState = useCreationWorkspace(
186186
variant === "creation"
187187
? {
188-
projectPath: props.projectPath,
189-
onWorkspaceCreated: props.onWorkspaceCreated,
190-
}
188+
projectPath: props.projectPath,
189+
onWorkspaceCreated: props.onWorkspaceCreated,
190+
}
191191
: {
192-
// Dummy values for workspace variant (never used)
193-
projectPath: "",
194-
// eslint-disable-next-line @typescript-eslint/no-empty-function
195-
onWorkspaceCreated: () => { },
196-
}
192+
// Dummy values for workspace variant (never used)
193+
projectPath: "",
194+
// eslint-disable-next-line @typescript-eslint/no-empty-function
195+
onWorkspaceCreated: () => {},
196+
}
197197
);
198198

199199
const focusMessageInput = useCallback(() => {
@@ -756,11 +756,15 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
756756
}
757757

758758
// Only show success toast if prompt sent successfully (or no prompt to send)
759-
setToast({
760-
id: Date.now().toString(),
761-
type: exitCode === 0 ? "success" : "warning",
762-
message: toastMessage,
763-
});
759+
// AND if there is a message to show (either from file or fallback)
760+
// If it was empty/success (common for silent scripts), don't show empty toast
761+
if (toastMessage && toastMessage.trim().length > 0) {
762+
setToast({
763+
id: Date.now().toString(),
764+
type: exitCode === 0 ? "success" : "warning",
765+
message: toastMessage,
766+
});
767+
}
764768

765769
// Log the full output to console for debugging
766770
if (toolResult.output) {

src/node/services/agentSession.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,20 @@ export class AgentSession {
505505
} satisfies AgentSessionChatEvent);
506506
}
507507

508+
private _isScriptRunning = false;
509+
510+
public get isScriptRunning(): boolean {
511+
return this._isScriptRunning;
512+
}
513+
514+
public setScriptRunning(value: boolean): void {
515+
this._isScriptRunning = value;
516+
}
517+
518+
public processQueue(): void {
519+
this.sendQueuedMessages();
520+
}
521+
508522
queueMessage(message: string, options?: SendMessageOptions & { imageParts?: ImagePart[] }): void {
509523
this.assertNotDisposed("queueMessage");
510524
this.messageQueue.add(message, options);

src/node/services/ipcMain.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -960,8 +960,11 @@ export class IpcMain {
960960
// Update recency on user message (fire and forget)
961961
void this.extensionMetadata.updateRecency(workspaceId);
962962

963-
// Queue new messages during streaming, but allow edits through
964-
if (this.aiService.isStreaming(workspaceId) && !options?.editMessageId) {
963+
// Queue new messages during streaming OR script execution, but allow edits through
964+
if (
965+
(this.aiService.isStreaming(workspaceId) || session.isScriptRunning) &&
966+
!options?.editMessageId
967+
) {
965968
session.queueMessage(message, options);
966969
return Ok(undefined);
967970
}
@@ -1111,8 +1114,8 @@ export class IpcMain {
11111114
const historyResult = await this.historyService.getHistory(workspaceId);
11121115
const deletedSequences = historyResult.success
11131116
? historyResult.data
1114-
.map((msg) => msg.metadata?.historySequence ?? -1)
1115-
.filter((s) => s >= 0)
1117+
.map((msg) => msg.metadata?.historySequence ?? -1)
1118+
.filter((s) => s >= 0)
11161119
: [];
11171120

11181121
// Clear entire history
@@ -1254,6 +1257,9 @@ export class IpcMain {
12541257
? metadata.projectPath
12551258
: runtimeInstance.getWorkspacePath(metadata.projectPath, metadata.name);
12561259

1260+
const session = this.getOrCreateSession(workspaceId);
1261+
session.setScriptRunning(true);
1262+
12571263
try {
12581264
// 1. Create and persist script execution message immediately
12591265
// This ensures the user sees "Executing script..." in the timeline while it runs
@@ -1333,6 +1339,9 @@ export class IpcMain {
13331339
} catch (error) {
13341340
const message = error instanceof Error ? error.message : String(error);
13351341
return Err(`Failed to execute script: ${message}`);
1342+
} finally {
1343+
session.setScriptRunning(false);
1344+
session.processQueue();
13361345
}
13371346
} catch (error) {
13381347
const message = error instanceof Error ? error.message : String(error);
@@ -1920,10 +1929,10 @@ export class IpcMain {
19201929
config:
19211930
| { type: "local"; workspacePath: string }
19221931
| {
1923-
type: "ssh";
1924-
sshConfig: Extract<RuntimeConfig, { type: "ssh" }>;
1925-
remotePath: string;
1926-
}
1932+
type: "ssh";
1933+
sshConfig: Extract<RuntimeConfig, { type: "ssh" }>;
1934+
remotePath: string;
1935+
}
19271936
): Promise<void> {
19281937
const isSSH = config.type === "ssh";
19291938

0 commit comments

Comments
 (0)