mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
feat: add switch to remote button for local mode
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user