Skip to content

Commit ad6f97b

Browse files
samsam
authored andcommitted
fix(desktop): honor history capabilities and restrict connection bridge platforms
1 parent a47579a commit ad6f97b

4 files changed

Lines changed: 38 additions & 7 deletions

File tree

‎apps/desktop/src/app/DesktopAppActivation.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,16 @@ export async function startDesktopAppControlServer(input: {
172172
}
173173

174174
if (isConnectionRequestShape(parsed)) {
175+
if (input.directory === null) {
176+
finish(
177+
desktopAppConnectionFailure(
178+
requestIdFromUnknown(parsed),
179+
"invalid-request",
180+
"Desktop connection tools are currently available on macOS and Linux.",
181+
),
182+
);
183+
return;
184+
}
175185
if (!isDesktopAppConnectionRequest(parsed) || input.handleConnection === undefined) {
176186
finish(
177187
desktopAppConnectionFailure(

‎apps/web/src/desktopAppConnection.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ const makeHarness = (
8080
session: yield* SubscriptionRef.make(
8181
Option.some({
8282
client: (fixture.client ?? {}) as unknown as WsRpcProtocolClient,
83-
} as RpcSession),
83+
initialConfig: Effect.succeed({ threadSnapshotPagination: true }),
84+
} as unknown as RpcSession),
8485
),
8586
prepared: yield* SubscriptionRef.make(Option.fromNullishOr(fixture.prepared)),
8687
connect: Effect.void,

‎apps/web/src/desktopAppConnection.ts‎

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,25 @@ interface ThreadWindowInput {
9393
readonly turnLimit?: number | undefined;
9494
}
9595

96+
// Pre-pagination servers reject a window, so `turnLimit` is only sent when the
97+
// connected session advertised the capability.
98+
const supportsThreadPagination = Effect.gen(function* () {
99+
const supervisor = yield* EnvironmentSupervisor;
100+
const session = yield* SubscriptionRef.get(supervisor.session);
101+
if (Option.isNone(session)) return false;
102+
const config = yield* session.value.initialConfig.pipe(Effect.option);
103+
return Option.isSome(config) && config.value.threadSnapshotPagination === true;
104+
});
105+
96106
function firstThreadSnapshot(input: ThreadWindowInput) {
97-
return subscribe(ORCHESTRATION_WS_METHODS.subscribeThread, {
98-
threadId: input.threadId,
99-
...(input.turnLimit !== undefined ? { turnLimit: input.turnLimit } : {}),
100-
}).pipe(
107+
return Stream.unwrap(
108+
Effect.map(supportsThreadPagination, (paginated) =>
109+
subscribe(ORCHESTRATION_WS_METHODS.subscribeThread, {
110+
threadId: input.threadId,
111+
...(paginated && input.turnLimit !== undefined ? { turnLimit: input.turnLimit } : {}),
112+
}),
113+
),
114+
).pipe(
101115
Stream.filter((item) => item.kind === "snapshot"),
102116
Stream.map((item) => item.snapshot),
103117
Stream.runHead,
@@ -121,6 +135,12 @@ function pagedThreadSnapshot(input: ThreadWindowInput & { readonly beforeCursor:
121135
message: `${supervisor.target.label} is not connected.`,
122136
});
123137
}
138+
if (!(yield* supportsThreadPagination)) {
139+
return yield* new BridgeOperationError({
140+
code: "operation-failed",
141+
message: "This environment does not support thread history pages.",
142+
});
143+
}
124144
const snapshot = yield* loader.load(prepared.value, input.threadId, {
125145
turnLimit: input.turnLimit ?? 10,
126146
beforeCursor: input.beforeCursor,

‎docs/user/install.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ command cannot reach the app, start or update the desktop app and try again.
8888
### Let local tools use your connections
8989

9090
The [T3 thread MCP server](https://github.com/samdickson22/t3code-thread-mcp) can use
91-
the desktop app's signed-in connections with `t3code-thread-mcp --desktop`. The
92-
app must be open; the tool sees the environments added in **Settings → Connections**,
91+
the desktop app's signed-in connections with `t3code-thread-mcp --desktop` on
92+
macOS and Linux. The app must be open; the tool sees the environments added in **Settings → Connections**,
9393
including SSH and T3 Connect ones.
9494

9595
This lets local tools create projects (and their directories), start agent work,

0 commit comments

Comments
 (0)