feat: add switch to remote button for local mode

This commit is contained in:
weishu
2025-12-22 00:05:55 +08:00
parent 8cbe68c47a
commit 7c86f83d5c
7 changed files with 112 additions and 2 deletions
+4
View File
@@ -622,6 +622,10 @@ export class SyncEngine {
await this.sessionRpc(sessionId, 'abort', { reason: 'User aborted via Telegram Bot' })
}
async switchSession(sessionId: string, to: 'remote' | 'local'): Promise<void> {
await this.sessionRpc(sessionId, 'switch', { to })
}
async setPermissionMode(
sessionId: string,
mode: 'default' | 'acceptEdits' | 'bypassPermissions' | 'plan'
+15
View File
@@ -111,6 +111,21 @@ export function createSessionsRoutes(getSyncEngine: () => SyncEngine | null): Ho
return c.json({ ok: true })
})
app.post('/sessions/:id/switch', async (c) => {
const engine = requireSyncEngine(c, getSyncEngine)
if (engine instanceof Response) {
return engine
}
const sessionResult = requireSessionFromParam(c, engine, { requireActive: true })
if (sessionResult instanceof Response) {
return sessionResult
}
await engine.switchSession(sessionResult.sessionId, 'remote')
return c.json({ ok: true })
})
app.post('/sessions/:id/permission-mode', async (c) => {
const engine = requireSyncEngine(c, getSyncEngine)
if (engine instanceof Response) {