mirror of
https://github.com/davidkaya/aryx.git
synced 2026-11-28 11:32:40 +01:00
feat: add turn cancellation UI and main process wiring
Adds cancel-turn IPC channel, SidecarClient.cancelTurn(), TurnCancelledError, EryxAppService.cancelSessionTurn(), finalizeCancelledTurn(), stop button in ChatPane, and cancelled run status throughout the run timeline. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
1 parent
d84b3021f2
commit
82fdadb312
13 files changed
+265
-49
No files matched your search
@@ -24,6 +24,7 @@ export const ipcChannels = {
|
||||
setSessionPinned: 'sessions:set-pinned',
|
||||
setSessionArchived: 'sessions:set-archived',
|
||||
sendSessionMessage: 'sessions:send-message',
|
||||
cancelSessionTurn: 'sessions:cancel-turn',
|
||||
resolveSessionApproval: 'sessions:resolve-approval',
|
||||
querySessions: 'sessions:query',
|
||||
updateScratchpadSessionConfig: 'sessions:update-scratchpad-config',
|
||||
|
||||
@@ -26,6 +26,10 @@ export interface SendSessionMessageInput {
|
||||
content: string;
|
||||
}
|
||||
|
||||
export interface CancelSessionTurnInput {
|
||||
sessionId: string;
|
||||
}
|
||||
|
||||
export interface ResolveSessionApprovalInput {
|
||||
sessionId: string;
|
||||
approvalId: string;
|
||||
@@ -120,6 +124,7 @@ export interface ElectronApi {
|
||||
setSessionPinned(input: SetSessionPinnedInput): Promise<WorkspaceState>;
|
||||
setSessionArchived(input: SetSessionArchivedInput): Promise<WorkspaceState>;
|
||||
sendSessionMessage(input: SendSessionMessageInput): Promise<void>;
|
||||
cancelSessionTurn(input: CancelSessionTurnInput): Promise<void>;
|
||||
resolveSessionApproval(input: ResolveSessionApprovalInput): Promise<WorkspaceState>;
|
||||
updateScratchpadSessionConfig(input: UpdateScratchpadSessionConfigInput): Promise<WorkspaceState>;
|
||||
querySessions(input: QuerySessionsInput): Promise<SessionQueryResult[]>;
|
||||
|
||||
@@ -79,6 +79,12 @@ export interface RunTurnCommand {
|
||||
tooling?: RunTurnToolingConfig;
|
||||
}
|
||||
|
||||
export interface CancelTurnCommand {
|
||||
type: 'cancel-turn';
|
||||
requestId: string;
|
||||
targetRequestId: string;
|
||||
}
|
||||
|
||||
export interface ResolveApprovalCommand {
|
||||
type: 'resolve-approval';
|
||||
requestId: string;
|
||||
@@ -90,6 +96,7 @@ export type SidecarCommand =
|
||||
| DescribeCapabilitiesCommand
|
||||
| ValidatePatternCommand
|
||||
| RunTurnCommand
|
||||
| CancelTurnCommand
|
||||
| ResolveApprovalCommand;
|
||||
|
||||
export interface RunTurnLocalMcpServerConfig {
|
||||
@@ -157,6 +164,7 @@ export interface TurnCompleteEvent {
|
||||
requestId: string;
|
||||
sessionId: string;
|
||||
messages: ChatMessageRecord[];
|
||||
cancelled?: boolean;
|
||||
}
|
||||
|
||||
export type AgentActivityType = 'thinking' | 'tool-calling' | 'handoff' | 'completed';
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { PatternDefinition, ReasoningEffort } from '@shared/domain/pattern'
|
||||
import type { ProjectRecord } from '@shared/domain/project';
|
||||
import { createId } from '@shared/utils/ids';
|
||||
|
||||
export type SessionRunStatus = 'running' | 'completed' | 'error';
|
||||
export type SessionRunStatus = 'running' | 'completed' | 'cancelled' | 'error';
|
||||
export type SessionRunWorkspaceKind = 'project' | 'scratchpad';
|
||||
export type RunTimelineEventKind =
|
||||
| 'run-started'
|
||||
@@ -17,6 +17,7 @@ export type RunTimelineEventKind =
|
||||
| 'approval'
|
||||
| 'message'
|
||||
| 'run-completed'
|
||||
| 'run-cancelled'
|
||||
| 'run-failed';
|
||||
export type RunTimelineEventStatus = 'running' | 'completed' | 'error';
|
||||
|
||||
@@ -318,7 +319,7 @@ export function normalizeSessionRunRecords(
|
||||
triggerMessageId,
|
||||
startedAt,
|
||||
completedAt: normalizeOptionalString(run.completedAt),
|
||||
status: run.status === 'error' ? 'error' : run.status === 'running' ? 'running' : 'completed',
|
||||
status: run.status === 'error' ? 'error' : run.status === 'running' ? 'running' : run.status === 'cancelled' ? 'cancelled' : 'completed',
|
||||
agents: run.agents.flatMap((agent) => {
|
||||
const normalized = normalizeRunTimelineAgent(agent);
|
||||
return normalized ? [normalized] : [];
|
||||
@@ -516,6 +517,24 @@ export function completeSessionRunRecord(
|
||||
});
|
||||
}
|
||||
|
||||
export function cancelSessionRunRecord(
|
||||
run: SessionRunRecord,
|
||||
cancelledAt: string,
|
||||
): SessionRunRecord {
|
||||
const settledRun = settleOpenMessageEvents(run, 'completed', cancelledAt);
|
||||
const cancelledRun: SessionRunRecord = {
|
||||
...settledRun,
|
||||
status: 'cancelled',
|
||||
completedAt: cancelledAt,
|
||||
};
|
||||
|
||||
return appendRunTimelineEvent(cancelledRun, {
|
||||
kind: 'run-cancelled',
|
||||
occurredAt: cancelledAt,
|
||||
status: 'completed',
|
||||
});
|
||||
}
|
||||
|
||||
export function failSessionRunRecord(
|
||||
run: SessionRunRecord,
|
||||
failedAt: string,
|
||||
|
||||
Reference in new issue
Block a user