Skip to content

Commit e6f006e

Browse files
committed
Revert "fix: force plan-accept to exit plan mode (#462)"
This reverts commit 847a31d.
1 parent 87ff8aa commit e6f006e

3 files changed

Lines changed: 18 additions & 251 deletions

File tree

src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1766,7 +1766,6 @@ function MainApp() {
17661766
connectWorkspace,
17671767
sendUserMessageToThread,
17681768
setSelectedCollaborationModeId,
1769-
persistThreadCodexParams,
17701769
});
17711770

17721771
const { handleMoveWorkspace } = useWorkspaceOrderingOrchestration({

src/features/app/hooks/usePlanReadyActions.test.tsx

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

src/features/app/hooks/usePlanReadyActions.ts

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ type UsePlanReadyActionsOptions = {
2525
resolvedEffort: string | null;
2626
connectWorkspace: (workspace: WorkspaceInfo) => Promise<void>;
2727
sendUserMessageToThread: SendUserMessageToThread;
28-
setSelectedCollaborationModeId: (modeId: string | null) => void;
29-
persistThreadCodexParams: (patch: { collaborationModeId?: string | null }) => void;
28+
setSelectedCollaborationModeId: (modeId: string) => void;
3029
};
3130

3231
export function usePlanReadyActions({
@@ -38,7 +37,6 @@ export function usePlanReadyActions({
3837
connectWorkspace,
3938
sendUserMessageToThread,
4039
setSelectedCollaborationModeId,
41-
persistThreadCodexParams,
4240
}: UsePlanReadyActionsOptions) {
4341
const findCollaborationMode = useCallback(
4442
(wanted: string) => {
@@ -59,28 +57,6 @@ export function usePlanReadyActions({
5957
[collaborationModes],
6058
);
6159

62-
const isPlanMode = useCallback((mode: CollaborationModeOption | null) => {
63-
if (!mode) {
64-
return false;
65-
}
66-
const modeValue = (mode.mode || mode.id).trim().toLowerCase();
67-
return modeValue === "plan";
68-
}, []);
69-
70-
const findImplementationMode = useCallback(() => {
71-
const defaultMode = findCollaborationMode("default");
72-
if (defaultMode && !isPlanMode(defaultMode)) {
73-
return defaultMode;
74-
}
75-
76-
const codeMode = findCollaborationMode("code");
77-
if (codeMode && !isPlanMode(codeMode)) {
78-
return codeMode;
79-
}
80-
81-
return collaborationModes.find((mode) => !isPlanMode(mode)) ?? null;
82-
}, [collaborationModes, findCollaborationMode, isPlanMode]);
83-
8460
const buildCollaborationModePayloadFor = useCallback(
8561
(mode: CollaborationModeOption | null) => {
8662
if (!mode) {
@@ -117,28 +93,31 @@ export function usePlanReadyActions({
11793
await connectWorkspace(activeWorkspace);
11894
}
11995

120-
const implementationMode = findImplementationMode();
121-
const implementationModeId = implementationMode?.id ?? null;
122-
setSelectedCollaborationModeId(implementationModeId);
123-
persistThreadCodexParams({
124-
collaborationModeId: implementationModeId,
125-
});
96+
const defaultMode =
97+
findCollaborationMode("default") ??
98+
findCollaborationMode("code") ??
99+
collaborationModes[0] ??
100+
null;
101+
102+
if (defaultMode?.id) {
103+
setSelectedCollaborationModeId(defaultMode.id);
104+
}
126105

127-
const collaborationMode = buildCollaborationModePayloadFor(implementationMode);
106+
const collaborationMode = buildCollaborationModePayloadFor(defaultMode);
128107
await sendUserMessageToThread(
129108
activeWorkspace,
130109
activeThreadId,
131110
makePlanReadyAcceptMessage(),
132111
[],
133-
{ collaborationMode: collaborationMode ?? null },
112+
collaborationMode ? { collaborationMode } : undefined,
134113
);
135114
}, [
136115
activeThreadId,
137116
activeWorkspace,
138117
buildCollaborationModePayloadFor,
118+
collaborationModes,
139119
connectWorkspace,
140-
findImplementationMode,
141-
persistThreadCodexParams,
120+
findCollaborationMode,
142121
sendUserMessageToThread,
143122
setSelectedCollaborationModeId,
144123
]);
@@ -155,19 +134,17 @@ export function usePlanReadyActions({
155134
}
156135

157136
const planMode = findCollaborationMode("plan");
158-
const planModeId = planMode?.id ?? null;
159-
setSelectedCollaborationModeId(planModeId);
160-
persistThreadCodexParams({
161-
collaborationModeId: planModeId,
162-
});
137+
if (planMode?.id) {
138+
setSelectedCollaborationModeId(planMode.id);
139+
}
163140
const collaborationMode = buildCollaborationModePayloadFor(planMode);
164141
const message = makePlanReadyChangesMessage(trimmed);
165142
await sendUserMessageToThread(
166143
activeWorkspace,
167144
activeThreadId,
168145
message,
169146
[],
170-
{ collaborationMode: collaborationMode ?? null },
147+
collaborationMode ? { collaborationMode } : undefined,
171148
);
172149
},
173150
[
@@ -176,7 +153,6 @@ export function usePlanReadyActions({
176153
buildCollaborationModePayloadFor,
177154
connectWorkspace,
178155
findCollaborationMode,
179-
persistThreadCodexParams,
180156
sendUserMessageToThread,
181157
setSelectedCollaborationModeId,
182158
],

0 commit comments

Comments
 (0)