@@ -49,7 +49,7 @@ import { isRecord, isStringArray } from "./lib/type-guards";
4949import { parseJsonBody , parseParams , parseQuery } from "./api-validation" ;
5050import { hasRecentDashboardActivity , touchDashboardActivity } from "./services/dashboard-activity" ;
5151import { buildArchivedWorktreePathSet , normalizeArchivePath } from "./services/archive-service" ;
52- import { resolveAgentChatSupport } from "./services/agent-chat-service" ;
52+ import { resolveAgentChatSupport , resolveAgentTerminalSubmitDelayMs } from "./services/agent-chat-service" ;
5353import { validateCustomAgentInput } from "./services/agent-validation-service" ;
5454import { getAgentDefinition , isBuiltInAgentId , listAgentDetails , listAgentSummaries , normalizeCustomAgentId } from "./services/agent-registry" ;
5555import {
@@ -319,6 +319,7 @@ async function withRemovingBranch<T>(branch: string, fn: () => Promise<T>): Prom
319319async function resolveTerminalWorktree ( branch : string ) : Promise < {
320320 worktreeId : string ;
321321 attachTarget : TerminalAttachTarget ;
322+ agentName : WorktreeSnapshot [ "agentName" ] ;
322323} > {
323324 ensureBranchNotBusy ( branch ) ;
324325 let state = projectRuntime . getWorktreeByBranch ( branch ) ;
@@ -339,6 +340,7 @@ async function resolveTerminalWorktree(branch: string): Promise<{
339340 ownerSessionName : state . session . sessionName ,
340341 windowName : state . session . windowName ,
341342 } ,
343+ agentName : state . agentName ,
342344 } ;
343345}
344346
@@ -510,6 +512,13 @@ function resolveWorktreeAgentChatSupport(worktree: WorktreeSnapshot, action: "ch
510512 } ) ;
511513}
512514
515+ function resolveWorktreeTerminalSubmitDelayMs ( agentName : WorktreeSnapshot [ "agentName" ] ) : number {
516+ return resolveAgentTerminalSubmitDelayMs ( {
517+ agentId : agentName ,
518+ agent : agentName ? getAgentDefinition ( config , agentName ) : null ,
519+ } ) ;
520+ }
521+
513522async function apiAttachAgentsWorktree ( branch : string ) : Promise < Response > {
514523 touchDashboardActivity ( ) ;
515524 const resolved = await resolveAgentsWorktree ( branch ) ;
@@ -929,12 +938,14 @@ async function apiSendPrompt(name: string, req: Request): Promise<Response> {
929938 const preamble = body . preamble ;
930939 log . info ( `[worktree:send] name=${ name } text="${ text . slice ( 0 , 80 ) } "` ) ;
931940 const terminalWorktree = await resolveTerminalWorktree ( name ) ;
941+ const submitDelayMs = resolveWorktreeTerminalSubmitDelayMs ( terminalWorktree . agentName ) ;
932942 const result = await sendTerminalPrompt (
933943 terminalWorktree . worktreeId ,
934944 terminalWorktree . attachTarget ,
935945 text ,
936946 0 ,
937947 preamble ,
948+ submitDelayMs ,
938949 ) ;
939950 if ( ! result . ok ) return errorResponse ( result . error , 503 ) ;
940951 return jsonResponse ( { ok : true } ) ;
0 commit comments