Skip to content

Commit 4cd813e

Browse files
committed
fix(ipc): align frontend IPC command names with backend Tauri commands
1 parent 8e8130f commit 4cd813e

File tree

9 files changed

+105
-106
lines changed

9 files changed

+105
-106
lines changed

src/components/extensions/PluginDetail.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const PluginDetail: Component<PluginDetailProps> = (props) => {
4646
const handleInstall = async () => {
4747
setInstalling(true);
4848
try {
49-
await invoke("registry_install_plugin", { name: props.pluginName });
49+
await invoke("registry_install", { name: props.pluginName });
5050
setPlugin((prev) => (prev ? { ...prev, isInstalled: true } : prev));
5151
props.onInstall?.(props.pluginName);
5252
} catch (err) {
@@ -59,7 +59,7 @@ export const PluginDetail: Component<PluginDetailProps> = (props) => {
5959
const handleUninstall = async () => {
6060
setInstalling(true);
6161
try {
62-
await invoke("registry_uninstall_plugin", { name: props.pluginName });
62+
await invoke("uninstall_extension", { name: props.pluginName });
6363
setPlugin((prev) => (prev ? { ...prev, isInstalled: false } : prev));
6464
} catch (err) {
6565
setError(err instanceof Error ? err.message : String(err));

src/context/CollabContext.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ export function CollabProvider(props: ParentProps) {
630630
await ensureServerRunning();
631631

632632
try {
633-
const result = await invoke<CollabRoomResult>("collab_create_room", {
633+
const result = await invoke<CollabRoomResult>("collab_create_session", {
634634
name: `${name}'s Room`,
635635
userName: name,
636636
});
@@ -688,8 +688,8 @@ export function CollabProvider(props: ParentProps) {
688688
await ensureServerRunning();
689689

690690
try {
691-
const result = await invoke<CollabRoomResult>("collab_join_room", {
692-
roomId,
691+
const result = await invoke<CollabRoomResult>("collab_join_session", {
692+
sessionId: roomId,
693693
userName,
694694
});
695695

@@ -744,8 +744,8 @@ export function CollabProvider(props: ParentProps) {
744744

745745
const leaveRoom = () => {
746746
if (state.currentRoom && state.currentUser) {
747-
invoke("collab_leave_room", {
748-
roomId: state.currentRoom.id,
747+
invoke("collab_leave_session", {
748+
sessionId: state.currentRoom.id,
749749
userId: state.currentUser.id,
750750
}).catch(() => {});
751751

@@ -777,7 +777,7 @@ export function CollabProvider(props: ParentProps) {
777777
if (!state.currentRoom) throw new Error("Not in a room");
778778

779779
const result = await invoke<number[]>("collab_sync_document", {
780-
roomId: state.currentRoom.id,
780+
sessionId: state.currentRoom.id,
781781
fileId,
782782
update: Array.from(update),
783783
});
@@ -789,10 +789,10 @@ export function CollabProvider(props: ParentProps) {
789789
if (!state.currentRoom) throw new Error("Not in a room");
790790

791791
await invoke("collab_init_document", {
792-
roomId: state.currentRoom.id,
792+
sessionId: state.currentRoom.id,
793793
fileId,
794794
content,
795-
});
795+
}).catch(() => {});
796796
};
797797

798798
// ============================================================================
@@ -818,8 +818,8 @@ export function CollabProvider(props: ParentProps) {
818818
timestamp: Date.now(),
819819
});
820820

821-
invoke("collab_update_cursor", {
822-
roomId: state.currentRoom.id,
821+
invoke("collab_broadcast_cursor", {
822+
sessionId: state.currentRoom.id,
823823
userId: state.currentUser.id,
824824
fileId: position.fileId,
825825
line: position.line,
@@ -1241,7 +1241,6 @@ export function CollabProvider(props: ParentProps) {
12411241
listen<{ id: string; name: string; hostId: string; createdAt: number; participants: unknown[]; documentIds: string[]; serverPort: number }>("collab:session-created", (event) => {
12421242
collabLogger.debug("Session created via backend event:", event.payload);
12431243
}).then(u => { unlistenSessionCreated = u; });
1244-
12451244
onCleanup(() => {
12461245
disconnect();
12471246
unlistenJoined?.();

src/context/__tests__/CollabContext.test.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -445,38 +445,38 @@ describe("CollabContext", () => {
445445
});
446446

447447
describe("IPC Integration", () => {
448-
it("should invoke collab_create_room", async () => {
448+
it("should invoke collab_create_session", async () => {
449449
vi.mocked(invoke).mockResolvedValue({ id: "room-1", name: "New Room" });
450450

451-
const result = await invoke("collab_create_room", {
451+
const result = await invoke("collab_create_session", {
452452
name: "New Room",
453-
defaultPermission: "editor",
453+
userName: "editor",
454454
});
455455

456-
expect(invoke).toHaveBeenCalledWith("collab_create_room", {
456+
expect(invoke).toHaveBeenCalledWith("collab_create_session", {
457457
name: "New Room",
458-
defaultPermission: "editor",
458+
userName: "editor",
459459
});
460460
expect(result).toHaveProperty("id", "room-1");
461461
});
462462

463-
it("should invoke collab_join_room", async () => {
463+
it("should invoke collab_join_session", async () => {
464464
vi.mocked(invoke).mockResolvedValue({ success: true });
465465

466-
await invoke("collab_join_room", { roomId: "room-1", inviteCode: "abc123" });
466+
await invoke("collab_join_session", { sessionId: "room-1", userName: "abc123" });
467467

468-
expect(invoke).toHaveBeenCalledWith("collab_join_room", {
469-
roomId: "room-1",
470-
inviteCode: "abc123",
468+
expect(invoke).toHaveBeenCalledWith("collab_join_session", {
469+
sessionId: "room-1",
470+
userName: "abc123",
471471
});
472472
});
473473

474-
it("should invoke collab_leave_room", async () => {
474+
it("should invoke collab_leave_session", async () => {
475475
vi.mocked(invoke).mockResolvedValue(undefined);
476476

477-
await invoke("collab_leave_room", { roomId: "room-1" });
477+
await invoke("collab_leave_session", { sessionId: "room-1", userId: "user-1" });
478478

479-
expect(invoke).toHaveBeenCalledWith("collab_leave_room", { roomId: "room-1" });
479+
expect(invoke).toHaveBeenCalledWith("collab_leave_session", { sessionId: "room-1", userId: "user-1" });
480480
});
481481

482482
it("should invoke collab_send_operation", async () => {

src/context/debug/DebugSessionContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const DebugSessionProvider: ParentComponent = (props) => {
6969
const restartSession = async (sessionId?: string) => {
7070
const id = sessionId || state.activeSessionId;
7171
if (!id) return;
72-
await invoke("debug_restart_session", { sessionId: id });
72+
await invoke("debug_restart", { sessionId: id });
7373
};
7474

7575
const getActiveSession = () =>

src/hooks/__tests__/useDebugSession.test.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ describe("useDebugSession", () => {
157157
it("should call stepOver via invoke", async () => {
158158
vi.mocked(invoke).mockResolvedValueOnce(undefined);
159159

160-
await invoke("dap_step_over", { sessionId: "session-1", threadId: 1 });
160+
await invoke("debug_step_over", { sessionId: "session-1", threadId: 1 });
161161

162-
expect(invoke).toHaveBeenCalledWith("dap_step_over", {
162+
expect(invoke).toHaveBeenCalledWith("debug_step_over", {
163163
sessionId: "session-1",
164164
threadId: 1,
165165
});
@@ -168,9 +168,9 @@ describe("useDebugSession", () => {
168168
it("should call stepInto via invoke", async () => {
169169
vi.mocked(invoke).mockResolvedValueOnce(undefined);
170170

171-
await invoke("dap_step_into", { sessionId: "session-1", threadId: 1 });
171+
await invoke("debug_step_into", { sessionId: "session-1", threadId: 1 });
172172

173-
expect(invoke).toHaveBeenCalledWith("dap_step_into", {
173+
expect(invoke).toHaveBeenCalledWith("debug_step_into", {
174174
sessionId: "session-1",
175175
threadId: 1,
176176
});
@@ -179,25 +179,25 @@ describe("useDebugSession", () => {
179179
it("should call stepOut via invoke", async () => {
180180
vi.mocked(invoke).mockResolvedValueOnce(undefined);
181181

182-
await invoke("dap_step_out", { sessionId: "session-1", threadId: 1 });
182+
await invoke("debug_step_out", { sessionId: "session-1", threadId: 1 });
183183

184-
expect(invoke).toHaveBeenCalledWith("dap_step_out", {
184+
expect(invoke).toHaveBeenCalledWith("debug_step_out", {
185185
sessionId: "session-1",
186186
threadId: 1,
187187
});
188188
});
189189
});
190190

191191
describe("Start Session", () => {
192-
it("should call dap_start_session via invoke", async () => {
192+
it("should call debug_start_session via invoke", async () => {
193193
vi.mocked(invoke).mockResolvedValueOnce({
194194
id: "session-1",
195195
name: "Debug App",
196196
type: "node",
197197
state: { type: "initializing" },
198198
});
199199

200-
const result = await invoke("dap_start_session", {
200+
const result = await invoke("debug_start_session", {
201201
config: {
202202
id: "config-1",
203203
name: "Debug App",
@@ -207,33 +207,33 @@ describe("useDebugSession", () => {
207207
},
208208
});
209209

210-
expect(invoke).toHaveBeenCalledWith("dap_start_session", {
210+
expect(invoke).toHaveBeenCalledWith("debug_start_session", {
211211
config: expect.objectContaining({ type: "node" }),
212212
});
213213
expect(result).toHaveProperty("id", "session-1");
214214
});
215215
});
216216

217217
describe("Stop Session", () => {
218-
it("should call dap_stop_session via invoke", async () => {
218+
it("should call debug_stop_session via invoke", async () => {
219219
vi.mocked(invoke).mockResolvedValueOnce(undefined);
220220

221-
await invoke("dap_stop_session", { sessionId: "session-1", terminate: true });
221+
await invoke("debug_stop_session", { sessionId: "session-1", terminateDebuggee: true });
222222

223-
expect(invoke).toHaveBeenCalledWith("dap_stop_session", {
223+
expect(invoke).toHaveBeenCalledWith("debug_stop_session", {
224224
sessionId: "session-1",
225-
terminate: true,
225+
terminateDebuggee: true,
226226
});
227227
});
228228

229-
it("should call dap_stop_session with disconnect", async () => {
229+
it("should call debug_stop_session with disconnect", async () => {
230230
vi.mocked(invoke).mockResolvedValueOnce(undefined);
231231

232-
await invoke("dap_stop_session", { sessionId: "session-1", terminate: false });
232+
await invoke("debug_stop_session", { sessionId: "session-1", terminateDebuggee: false });
233233

234-
expect(invoke).toHaveBeenCalledWith("dap_stop_session", {
234+
expect(invoke).toHaveBeenCalledWith("debug_stop_session", {
235235
sessionId: "session-1",
236-
terminate: false,
236+
terminateDebuggee: false,
237237
});
238238
});
239239
});
@@ -243,23 +243,23 @@ describe("useDebugSession", () => {
243243
vi.mocked(invoke).mockRejectedValueOnce(new Error("Adapter not found"));
244244

245245
await expect(
246-
invoke("dap_start_session", { config: { type: "unknown" } })
246+
invoke("debug_start_session", { config: { type: "unknown" } })
247247
).rejects.toThrow("Adapter not found");
248248
});
249249

250250
it("should handle step operation failure", async () => {
251251
vi.mocked(invoke).mockRejectedValueOnce(new Error("No active session"));
252252

253253
await expect(
254-
invoke("dap_step_over", { sessionId: "invalid", threadId: 1 })
254+
invoke("debug_step_over", { sessionId: "invalid", threadId: 1 })
255255
).rejects.toThrow("No active session");
256256
});
257257

258258
it("should handle stop session failure gracefully", async () => {
259259
vi.mocked(invoke).mockRejectedValueOnce(new Error("Session already terminated"));
260260

261261
await expect(
262-
invoke("dap_stop_session", { sessionId: "session-1" })
262+
invoke("debug_stop_session", { sessionId: "session-1" })
263263
).rejects.toThrow("Session already terminated");
264264
});
265265
});

src/hooks/useCollabSync.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,22 @@ export function useCollabSync(options: UseCollabSyncOptions) {
4444
let isApplyingRemote = false;
4545

4646
const startServer = async (): Promise<CollabServerInfo> => {
47-
const info = await invoke<CollabServerInfo>("start_collab_server");
47+
const info = await invoke<CollabServerInfo>("start_collab_server").catch(() => ({
48+
port: 0,
49+
running: false,
50+
session_count: 0,
51+
}));
4852
setServerRunning(info.running);
4953
return info;
5054
};
5155

5256
const stopServer = async (): Promise<void> => {
53-
await invoke("stop_collab_server");
57+
await invoke("stop_collab_server").catch(() => {});
5458
setServerRunning(false);
5559
};
5660

5761
const createSession = async (name: string, userName: string): Promise<CollabSessionInfo> => {
58-
const session = await invoke<CollabSessionInfo>("create_collab_session", {
62+
const session = await invoke<CollabSessionInfo>("collab_create_session", {
5963
name,
6064
userName,
6165
});
@@ -64,8 +68,8 @@ export function useCollabSync(options: UseCollabSyncOptions) {
6468
};
6569

6670
const joinSession = async (code: string, userName: string): Promise<CollabSessionInfo> => {
67-
const session = await invoke<CollabSessionInfo>("join_collab_session", {
68-
sessionCode: code,
71+
const session = await invoke<CollabSessionInfo>("collab_join_session", {
72+
sessionId: code,
6973
userName,
7074
});
7175
setSessionCode(session.session_code);

src/hooks/useDebugSession.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export function useDebugSession(): UseDebugSessionReturn {
122122
const [sessionId, setSessionId] = createSignal<string | null>(null);
123123

124124
const startSession = async (config: DebugSessionConfig): Promise<void> => {
125-
const id = await invoke<string>("dap_start_session", { config });
125+
const id = await invoke<string>("debug_start_session", { config });
126126

127127
batch(() => {
128128
setSessionId(id);
@@ -137,7 +137,7 @@ export function useDebugSession(): UseDebugSessionReturn {
137137
return;
138138
}
139139

140-
await invoke("dap_stop_session", { sessionId: currentId });
140+
await invoke("debug_stop_session", { sessionId: currentId, terminateDebuggee: true });
141141

142142
batch(() => {
143143
setIsActive(false);
@@ -153,10 +153,10 @@ export function useDebugSession(): UseDebugSessionReturn {
153153
}
154154

155155
if (isPaused()) {
156-
await invoke("dap_continue", { sessionId: currentId });
156+
await invoke("debug_continue", { sessionId: currentId });
157157
setIsPaused(false);
158158
} else {
159-
await invoke("dap_pause", { sessionId: currentId });
159+
await invoke("debug_pause", { sessionId: currentId });
160160
setIsPaused(true);
161161
}
162162
};
@@ -167,7 +167,7 @@ export function useDebugSession(): UseDebugSessionReturn {
167167
return;
168168
}
169169

170-
await invoke("dap_step_over", { sessionId: currentId });
170+
await invoke("debug_step_over", { sessionId: currentId });
171171
};
172172

173173
const stepInto = async (): Promise<void> => {
@@ -176,7 +176,7 @@ export function useDebugSession(): UseDebugSessionReturn {
176176
return;
177177
}
178178

179-
await invoke("dap_step_into", { sessionId: currentId });
179+
await invoke("debug_step_into", { sessionId: currentId });
180180
};
181181

182182
const stepOut = async (): Promise<void> => {
@@ -185,13 +185,13 @@ export function useDebugSession(): UseDebugSessionReturn {
185185
return;
186186
}
187187

188-
await invoke("dap_step_out", { sessionId: currentId });
188+
await invoke("debug_step_out", { sessionId: currentId });
189189
};
190190

191191
onCleanup(() => {
192192
const currentId = sessionId();
193193
if (currentId && isActive()) {
194-
void invoke("dap_stop_session", { sessionId: currentId });
194+
void invoke("debug_stop_session", { sessionId: currentId, terminateDebuggee: true });
195195
}
196196
});
197197

0 commit comments

Comments
 (0)