Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(mobile): close terminal reconnect state

Dash12c8e55b87de
diff --git a/apps/mobile/src/__tests__/remoteSessionStore.test.ts b/apps/mobile/src/__tests__/remoteSessionStore.test.ts
index 7e9e339b7d..6468bbb061 100644
--- a/apps/mobile/src/__tests__/remoteSessionStore.test.ts
+++ b/apps/mobile/src/__tests__/remoteSessionStore.test.ts
@@ -2666,6 +2666,22 @@ describe('remoteSessionStore', () => {
expect(remoteSessionStore.getInputProjection('s1').pendingQueue[0]?.clientId).toBe('q-1');
});
+ it('clears a continuation owner at a terminal boundary without a projection clear push', () => {
+ remoteSessionStore.setInputProjection('s1', {
+ ...projection('s1'),
+ continuationTurnClientId: 'resume-1',
+ });
+ remoteSessionStore.setSessionRunning('s1', true);
+
+ remoteSessionStore.applyRemotePush('dev-1', 'maker:status-changed', {
+ sessionId: 's1',
+ status: 'closed',
+ });
+
+ expect(remoteSessionStore.getInputProjection('s1').continuationTurnClientId).toBeNull();
+ expect(remoteSessionStore.isSessionMakerTurnRunning('s1')).toBe(false);
+ });
+
it('soft-invalidates an offline device without deleting sessions or messages', () => {
const meta = session('s1', {
updatedAt: '2026-01-01T00:00:01.000Z',
diff --git a/apps/mobile/src/session/autoResumePresentation.ts b/apps/mobile/src/session/autoResumePresentation.ts
index 1df7514b00..3154fa0b1a 100644
--- a/apps/mobile/src/session/autoResumePresentation.ts
+++ b/apps/mobile/src/session/autoResumePresentation.ts
@@ -42,7 +42,7 @@ export function summarizeMobileInterruption(detail?: string): string | undefined
.replace(/\s+/g, ' ')
.trim();
if (!compact) return undefined;
- const firstSentence = compact.split(/(?<=[.。!?!?])\s/)[0] ?? compact;
+ const firstSentence = compact.match(/^.*?[.。!?!?](?=\s|$)/)?.[0] ?? compact;
return firstSentence.length > 72 ? `${firstSentence.slice(0, 71)}…` : firstSentence;
}
diff --git a/apps/mobile/src/session/remoteSessionStore.ts b/apps/mobile/src/session/remoteSessionStore.ts
index e32abbd6e7..0f0b672c1a 100644
--- a/apps/mobile/src/session/remoteSessionStore.ts
+++ b/apps/mobile/src/session/remoteSessionStore.ts
@@ -1891,6 +1891,21 @@ export const remoteSessionStore = {
// A maker turn boundary supersedes any projection query that started
// before it. This is the terminal fence for late owner snapshots.
bumpInputProjectionAuthorityEpoch(sessionId);
+ // The terminal event is also authoritative for the continuation owner. A
+ // paired projection clear push may be lost during a disconnect, so clear a
+ // known owner here instead of leaving the mobile row live until rehydrate.
+ let continuationOwnerCleared = false;
+ if (!running) {
+ const currentProjection = inputProjections.get(sessionId);
+ if (currentProjection?.continuationTurnClientId) {
+ const nextProjection: InputProjection = {
+ ...currentProjection,
+ continuationTurnClientId: null,
+ };
+ continuationOwnerCleared = !deepValueEqual(currentProjection, nextProjection);
+ if (continuationOwnerCleared) inputProjections.set(sessionId, nextProjection);
+ }
+ }
// 本方法只被 maker 权威信号调用(done / terminal error / status-changed closed),
// 与 maker turn 边界同步;activity / 快照流走 writeSessionRunStatus,不经过这里。
// 边界变化必须独立参与 emit 判定:activity 流可能已把宽 run status 置 false,此时
@@ -1907,7 +1922,10 @@ export const remoteSessionStore = {
sideTaskRunning: running ? current.sideTaskRunning : false,
startedAt: running ? (current.startedAt ?? Date.now()) : null,
};
- if (writeSessionRunStatus(sessionId, next) || turnBoundaryChanged || streamingChanged) emit();
+ if (writeSessionRunStatus(sessionId, next)
+ || turnBoundaryChanged
+ || streamingChanged
+ || continuationOwnerCleared) emit();
},
captureActiveSessionSnapshotEpoch(): number {