Skip to content

Commit 85c8df4

Browse files
fix(core): accept portable mobile session events
Generated-By: PostHog Code Task-Id: 40c57a59-b4e1-4760-8e56-ecd03e9c2f0f
1 parent 8d79bf5 commit 85c8df4

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

apps/mobile/src/features/tasks/composer/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const MODELS: ModelOption[] = [
7070
];
7171

7272
export const DEFAULT_EXECUTION_MODE: ExecutionMode =
73-
DEFAULT_CLAUDE_EXECUTION_MODE;
73+
DEFAULT_CLAUDE_EXECUTION_MODE as ExecutionMode;
7474
export const DEFAULT_MODEL =
7575
defaultEligibleModel(DEFAULT_GATEWAY_MODEL) ??
7676
MODELS.find((model) => defaultEligibleModel(model.value))?.value ??

packages/core/src/sessions/sessionActivity.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
import { isNotification, POSTHOG_NOTIFICATIONS } from "./acpNotifications";
22
import type {
3-
PortableSessionEvent,
43
PortableSessionNotification,
54
PortableSessionToolCallStatus,
5+
PortableSessionUpdateEvent,
66
} from "./portableSessionEvents";
77

88
export type SessionActivityPhase = "idle" | "connecting" | "working";
99

10+
export type SessionActivityEvent =
11+
| PortableSessionUpdateEvent
12+
| {
13+
type: "acp_message";
14+
ts: number;
15+
message: unknown;
16+
};
17+
1018
export interface SessionActivityState {
1119
isPromptPending?: boolean;
1220
awaitingAgentOutput?: boolean;
1321
terminalStatus?: "failed" | "completed";
14-
events?: readonly PortableSessionEvent[];
22+
events?: readonly SessionActivityEvent[];
1523
}
1624

1725
function isQuestionNotification(
@@ -44,7 +52,7 @@ function isPendingQuestionStatus(
4452
}
4553

4654
export function isSessionAwaitingUserInput(
47-
events: readonly PortableSessionEvent[] = [],
55+
events: readonly SessionActivityEvent[] = [],
4856
): boolean {
4957
let awaitingUserInput = false;
5058
const questionStatuses = new Map<
@@ -87,7 +95,13 @@ export function isSessionAwaitingUserInput(
8795
continue;
8896
}
8997

90-
const method = "method" in event.message ? event.message.method : undefined;
98+
const method =
99+
typeof event.message === "object" &&
100+
event.message !== null &&
101+
"method" in event.message &&
102+
typeof event.message.method === "string"
103+
? event.message.method
104+
: undefined;
91105
if (method === "_posthog/awaiting_user_input") {
92106
awaitingUserInput = true;
93107
continue;
@@ -107,7 +121,7 @@ export function isSessionAwaitingUserInput(
107121
}
108122

109123
export function countUserMessages(
110-
events: readonly PortableSessionEvent[] = [],
124+
events: readonly SessionActivityEvent[] = [],
111125
): number {
112126
return events.filter(
113127
(event) =>

0 commit comments

Comments
 (0)