From ddde85a1e8dcd3c9d104f48bc70877de360c3748 Mon Sep 17 00:00:00 2001 From: QQ Date: Tue, 17 Nov 2026 08:32:25 +0800 Subject: [PATCH] Import apps/android/src/state/session-catalog-commands.ts --- .../src/state/session-catalog-commands.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 apps/android/src/state/session-catalog-commands.ts diff --git a/apps/android/src/state/session-catalog-commands.ts b/apps/android/src/state/session-catalog-commands.ts new file mode 100644 index 0000000..71c8565 --- /dev/null +++ b/apps/android/src/state/session-catalog-commands.ts @@ -0,0 +1,31 @@ +import type { AgentBackend, ConnectionPhase } from '../types' +import { useAppStore } from './store' + +export type SessionCatalogCommand = + | { type: 'refresh-session-status' } + | { type: 'refresh-catalog'; backend?: AgentBackend } + +/** + * Legacy Hosts and Hosts missing `@deepseek-ai/dsh-api-remotes` keep the 8s + * `session/list` poll. Hosts advertising `remote.session.events.v1` drive + * running state, activity, and catalog membership from `$events` + `session/control`. + */ +export function shouldPollSessionStatus(options: { + enabled: boolean + phase: ConnectionPhase + hostSessionEvents: boolean +}): boolean { + return options.enabled && options.phase === 'connected' && !options.hostSessionEvents +} + +export async function dispatchSessionCatalogCommand(command: SessionCatalogCommand): Promise { + const state = useAppStore.getState() + switch (command.type) { + case 'refresh-session-status': + await state.refreshSessionStatus() + return + case 'refresh-catalog': + await state.refreshWorkspaces(command.backend) + return + } +}