Skip to content

Commit c4156e3

Browse files
committed
undo mode switch changes
1 parent 2eef20d commit c4156e3

File tree

6 files changed

+21
-217
lines changed

6 files changed

+21
-217
lines changed

apps/array/src/main/preload.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,6 @@ contextBridge.exposeInMainWorld("electronAPI", {
187187
sdkSessionId?: string;
188188
}): Promise<{ sessionId: string; channel: string } | null> =>
189189
ipcRenderer.invoke("agent-reconnect", params),
190-
agentSetSessionMode: async (
191-
sessionId: string,
192-
modeId: string,
193-
): Promise<void> => ipcRenderer.invoke("agent-set-session-mode", sessionId, modeId),
194190
onAgentEvent: (
195191
channel: string,
196192
listener: (payload: unknown) => void,

apps/array/src/main/services/session-manager.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -302,24 +302,6 @@ export class SessionManager {
302302
}
303303
}
304304

305-
async setSessionMode(taskRunId: string, modeId: string): Promise<void> {
306-
const session = this.sessions.get(taskRunId);
307-
if (!session) {
308-
throw new Error(`Session not found: ${taskRunId}`);
309-
}
310-
311-
try {
312-
await session.connection.setSessionMode({
313-
sessionId: taskRunId,
314-
modeId,
315-
});
316-
log.info("Session mode changed", { taskRunId, modeId });
317-
} catch (err) {
318-
log.error("Failed to set session mode", { taskRunId, modeId, err });
319-
throw err;
320-
}
321-
}
322-
323305
getSession(taskRunId: string): ManagedSession | undefined {
324306
return this.sessions.get(taskRunId);
325307
}
@@ -606,15 +588,4 @@ export function registerAgentIpc(
606588
return session ? toSessionResponse(session) : null;
607589
},
608590
);
609-
610-
ipcMain.handle(
611-
"agent-set-session-mode",
612-
async (
613-
_event: IpcMainInvokeEvent,
614-
sessionId: string,
615-
modeId: string,
616-
): Promise<void> => {
617-
return sessionManager.setSessionMode(sessionId, modeId);
618-
},
619-
);
620591
}

apps/array/src/renderer/features/sessions/components/MessageEditor.tsx

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import { ArrowUp, Paperclip, Stop } from "@phosphor-icons/react";
33
import { Box, Flex, IconButton, Tooltip } from "@radix-ui/themes";
44
import { logger } from "@renderer/lib/logger";
55
import type { MentionItem } from "@shared/types";
6-
import {
7-
type SessionMode,
8-
SessionModeSwitcher,
9-
} from "./SessionModeSwitcher";
106
import { Extension, type JSONContent } from "@tiptap/core";
117
import { Mention } from "@tiptap/extension-mention";
128
import { Placeholder } from "@tiptap/extension-placeholder";
@@ -186,8 +182,6 @@ interface MessageEditorProps {
186182
onCancel?: () => void;
187183
onAttachFiles?: (files: File[]) => void;
188184
autoFocus?: boolean;
189-
currentMode?: SessionMode;
190-
onModeChange?: (mode: SessionMode) => void;
191185
}
192186

193187
export const MessageEditor = forwardRef<
@@ -205,8 +199,6 @@ export const MessageEditor = forwardRef<
205199
onCancel,
206200
onAttachFiles,
207201
autoFocus = false,
208-
currentMode,
209-
onModeChange,
210202
},
211203
ref,
212204
) => {
@@ -442,35 +434,26 @@ export const MessageEditor = forwardRef<
442434
<EditorContent editor={editor} />
443435
</Box>
444436
<Flex justify="between" align="center">
445-
<Flex gap="1" align="center">
446-
<input
447-
ref={fileInputRef}
448-
type="file"
449-
multiple
450-
onChange={handleFileSelect}
451-
style={{ display: "none" }}
452-
/>
453-
<Tooltip content="Attach file">
454-
<IconButton
455-
size="1"
456-
variant="ghost"
457-
color="gray"
458-
onClick={() => fileInputRef.current?.click()}
459-
disabled={disabled}
460-
title="Attach file"
461-
style={{ marginLeft: "0px" }}
462-
>
463-
<Paperclip size={14} weight="bold" />
464-
</IconButton>
465-
</Tooltip>
466-
{currentMode && onModeChange && (
467-
<SessionModeSwitcher
468-
value={currentMode}
469-
onChange={onModeChange}
470-
disabled={disabled}
471-
/>
472-
)}
473-
</Flex>
437+
<input
438+
ref={fileInputRef}
439+
type="file"
440+
multiple
441+
onChange={handleFileSelect}
442+
style={{ display: "none" }}
443+
/>
444+
<Tooltip content="Attach file">
445+
<IconButton
446+
size="1"
447+
variant="ghost"
448+
color="gray"
449+
onClick={() => fileInputRef.current?.click()}
450+
disabled={disabled}
451+
title="Attach file"
452+
style={{ marginLeft: "0px" }}
453+
>
454+
<Paperclip size={14} weight="bold" />
455+
</IconButton>
456+
</Tooltip>
474457
<Flex gap="4" align="center">
475458
{isLoading && onCancel ? (
476459
<Tooltip content="Stop">

apps/array/src/renderer/features/sessions/components/SessionModeSwitcher.tsx

Lines changed: 0 additions & 110 deletions
This file was deleted.

apps/array/src/renderer/features/sessions/components/SessionView.tsx

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import {
1010
Text,
1111
TextField,
1212
} from "@radix-ui/themes";
13-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
14-
import { logger } from "@renderer/lib/logger";
15-
import type { SessionMode } from "./SessionModeSwitcher";
13+
import { useCallback, useEffect, useMemo, useRef } from "react";
1614
import type { SessionEvent } from "../stores/sessionStore";
1715
import { useSessionViewStore } from "../stores/sessionViewStore";
1816
import { AgentMessage } from "./AgentMessage";
@@ -341,8 +339,6 @@ function groupMessagesIntoTurns(
341339
return turns;
342340
}
343341

344-
const log = logger.scope("session-view");
345-
346342
export function SessionView({
347343
events,
348344
sessionId,
@@ -353,35 +349,6 @@ export function SessionView({
353349
repoPath,
354350
}: SessionViewProps) {
355351
const searchInputRef = useRef<HTMLInputElement>(null);
356-
const [currentMode, setCurrentMode] = useState<SessionMode>("default");
357-
358-
const handleModeChange = useCallback(
359-
async (mode: SessionMode) => {
360-
if (!sessionId) return;
361-
setCurrentMode(mode);
362-
try {
363-
await window.electronAPI.agentSetSessionMode(sessionId, mode);
364-
log.info("Session mode changed", { sessionId, mode });
365-
} catch (error) {
366-
log.error("Failed to change session mode", { sessionId, mode, error });
367-
setCurrentMode(currentMode);
368-
}
369-
},
370-
[sessionId, currentMode],
371-
);
372-
373-
useEffect(() => {
374-
for (const event of events) {
375-
if (event.type !== "session_update") continue;
376-
const update = event.notification?.update;
377-
if (update?.sessionUpdate === "current_mode_update" && "currentModeId" in update) {
378-
const newMode = update.currentModeId as SessionMode;
379-
if (newMode !== currentMode) {
380-
setCurrentMode(newMode);
381-
}
382-
}
383-
}
384-
}, [events, currentMode]);
385352

386353
const {
387354
showRawLogs,
@@ -654,8 +621,6 @@ export function SessionView({
654621
isLoading={isPromptPending}
655622
onSubmit={handleSubmit}
656623
onCancel={onCancelPrompt}
657-
currentMode={currentMode}
658-
onModeChange={handleModeChange}
659624
/>
660625
</Box>
661626
</Flex>

apps/array/src/renderer/types/electron.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ declare global {
138138
logUrl?: string;
139139
sdkSessionId?: string;
140140
}) => Promise<{ sessionId: string; channel: string } | null>;
141-
agentSetSessionMode: (sessionId: string, modeId: string) => Promise<void>;
142141
onAgentEvent: (
143142
channel: string,
144143
listener: (event: unknown) => void,

0 commit comments

Comments
 (0)