Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions apps/mobile/src/lib/threadActivity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import {
buildPendingUserInputAnswers,
buildThreadFeed,
derivePendingApprovals,
deriveThreadFeedPresentation,
isPendingUserInputOptionSelected,
setPendingUserInputCustomAnswer,
Expand Down Expand Up @@ -125,6 +126,33 @@ function makeActivity(
};
}

describe("derivePendingApprovals", () => {
it("keeps legacy unknown approvals actionable", () => {
const activities: OrchestrationThreadActivity[] = [
makeActivity({
id: EventId.make("approval-legacy-unknown"),
kind: "approval.requested",
summary: "Approval requested",
createdAt: "2026-04-01T00:00:02.000Z",
payload: {
requestId: "req-legacy-unknown",
requestType: "unknown",
detail: "*",
},
}),
];

expect(derivePendingApprovals(activities)).toEqual([
{
requestId: "req-legacy-unknown",
requestKind: "command",
createdAt: "2026-04-01T00:00:02.000Z",
detail: "*",
},
]);
});
});

function makeThread(
input: Partial<OrchestrationThread> & Pick<OrchestrationThread, "id" | "projectId" | "title">,
): OrchestrationThread {
Expand Down
1 change: 1 addition & 0 deletions apps/mobile/src/lib/threadActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ function requestKindFromRequestType(requestType: unknown): PendingApproval["requ
switch (requestType) {
case "command_execution_approval":
case "exec_command_approval":
case "unknown":
return "command";
case "file_read_approval":
return "file-read";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,24 @@ describe("runtimeEventToActivities approval details", () => {
expect(activity?.kind).toBe("approval.requested");
expect((activity?.payload as Record<string, unknown> | undefined)?.detail).toBe(detail);
});

it("stamps dynamic tool approvals as command requests", () => {
const event = {
type: "request.opened",
eventId: EventId.make("evt-dynamic-request-opened"),
provider: ProviderDriverKind.make("opencode"),
createdAt: "2026-07-18T00:00:00.000Z",
threadId: ThreadId.make("thread-1"),
requestId: RuntimeRequestId.make("approval-dynamic-1"),
payload: {
requestType: "dynamic_tool_call",
detail: "codegraph_codegraph_explore",
args: {},
},
} satisfies ProviderRuntimeEvent;

const [activity] = runtimeEventToActivities(event);

expect((activity?.payload as Record<string, unknown> | undefined)?.requestKind).toBe("command");
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ function requestKindFromCanonicalRequestType(
switch (requestType) {
case "command_execution_approval":
case "exec_command_approval":
case "dynamic_tool_call":
return "command";
case "file_read_approval":
return "file-read";
Expand Down
Loading
Loading