Skip to content
Merged
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
22 changes: 22 additions & 0 deletions apps/mobile/src/state/connection-transport-coordinator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,28 @@ jest.mock("@opencode2-mobile/opencode-adapter", () => ({
typeof error === "object" && error !== null && "_tag" in error ? "UNAUTHORIZED" : "UNREACHABLE",
}));

test("passes project snapshot cancellation in the request-options argument", async () => {
const stream = createEventStream();
const snapshots = createSnapshotClient(true);
const coordinator = createCoordinator({
eventClient: { event: { subscribe: stream.subscribe } } as never,
restClient: snapshots.client,
});

coordinator.start();
await flush();

expect(snapshots.client.project.list).toHaveBeenCalledWith(undefined, {
signal: expect.any(AbortSignal),
});
expect(snapshots.client.project.list).toHaveBeenCalledWith(
undefined,
stream.subscribe.mock.calls[0]?.[0],
);
coordinator.stop();
expect(stream.subscribe.mock.calls[0]?.[0]?.signal?.aborted).toBe(true);
});

test("buffers events until authoritative snapshots are installed", async () => {
const stream = createEventStream();
const snapshots = createSnapshotClient();
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/src/state/connection-transport-coordinator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class ConnectionTransportCoordinator {
const requestOptions = { signal: controller.signal };
void Promise.all([
this.options.restClient.server.status(requestOptions),
this.options.restClient.project.list(requestOptions),
this.options.restClient.project.list(undefined, requestOptions),
this.options.restClient.session.active(requestOptions),
])
.then(([health, projects, activeSessions]) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/opencode-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"typecheck": "tsc -p tsconfig.json"
},
"dependencies": {
"@opencode/client": "2.0.26"
"@opencode/client": "2.0.27"
},
"devDependencies": {
"@opencode2-mobile/test-fixtures": "workspace:*",
Expand Down
15 changes: 15 additions & 0 deletions packages/opencode-adapter/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
listOpenCodeModels,
listOpenCodePermissionRequests,
listOpenCodeProjectSessions,
listOpenCodeProjects,
listOpenCodeSessionInbox,
listOpenCodeSessions,
listOpenCodeSkills,
Expand All @@ -61,6 +62,20 @@ import {
waitForOpenCodeSession,
} from "./index";

describe("project listing", () => {
it("forwards cancellation as request options without adding project filters", async () => {
const fixture = createFakeOpenCodeApi();
const fetch = vi.fn<typeof globalThis.fetch>(fixture.fetch);
const client = createOpenCodeClient({ baseUrl: "http://fake.invalid", fetch });
const signal = new AbortController().signal;

await expect(listOpenCodeProjects(client, { signal })).resolves.toEqual([]);

expect(fetch.mock.calls[0]?.[1]?.signal).toBe(signal);
expect(fixture.requests).toEqual([{ method: "GET", path: "/api/project", query: {} }]);
});
});

describe("location MCP controls", () => {
it("lists and connects/disconnects at the exact location without changing other locations", async () => {
const fixture = createFakeOpenCodeApi({
Expand Down
4 changes: 2 additions & 2 deletions packages/opencode-adapter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {

import { ensurePromiseWithResolvers } from "./promise-with-resolvers";

export const openCodeClientContractVersion = "2.0.26";
export const openCodeClientContractVersion = "2.0.27";

export type OpenCodeClientOptions = {
authorization?: string;
Expand Down Expand Up @@ -354,7 +354,7 @@ export async function listOpenCodeProjects(
client: OpenCodeClient,
options?: OpenCodeRequestOptions,
) {
const projects = await client.project.list(options);
const projects = await client.project.list(undefined, options);
if (!Array.isArray(projects) || !projects.every(isValidProject)) {
throw new Error("MALFORMED_PROJECT_LIST");
}
Expand Down
139 changes: 2 additions & 137 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading