GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): t3_thread_send_attachments says why a send was refused (… · pingdotgg/t3code@6ef2c05

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/server/src/mcp
    • OrchestratorMcpService.ts
    • toolkits
      • attachment
        • handlers.ts
      • core.test.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/server/src/mcp/OrchestratorMcpService.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/mcp/OrchestratorMcpService.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,13 @@ export class OrchestratorMcpService extends Context.Service<
240240
OrchestratorMcpServiceShape
241241
>()("t3/mcp/OrchestratorMcpService") {}
242242

243-
const isThreadManagementError = Schema.is(ThreadManagementService.ThreadManagementError);
243+
export const isThreadManagementError = Schema.is(ThreadManagementService.ThreadManagementError);
244244

245245
function failure(code: OrchestratorMcpFailure["code"], message: string): OrchestratorMcpFailure {
246246
return new OrchestratorMcpFailure({ code, message });
247247
}
248248

249-
function threadManagementFailure(error: unknown): OrchestratorMcpFailure {
249+
export function threadManagementFailure(error: unknown): OrchestratorMcpFailure {
250250
if (!isThreadManagementError(error)) return failure("orchestration_error", errorMessage(error));
251251
switch (error._tag) {
252252
case "ThreadManagementThreadNotFoundError":
Collapse file

‎apps/server/src/mcp/toolkits/attachment/handlers.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/mcp/toolkits/attachment/handlers.ts
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import * as Upload from "../../../assets/AttachmentUpload.ts";
1212
import * as Claims from "../../../orchestration-v2/AttachmentClaims.ts";
1313
import * as ThreadMessageIntake from "../../../orchestration-v2/ThreadMessageIntake.ts";
1414
import * as McpToolAccess from "../../McpToolAccess.ts";
15-
import { newCommandId, readThread, unavailable } from "../../threadAccess.ts";
15+
import { isThreadManagementError, threadManagementFailure } from "../../OrchestratorMcpService.ts";
16+
import { dispatchFailure, newCommandId, readThread, unavailable } from "../../threadAccess.ts";
1617
import { AttachmentToolkit } from "./tools.ts";
1718

1819
export function resolveAttachmentReferences(
@@ -118,7 +119,9 @@ export const layer = McpToolAccess.toLayer(
118119
code: "orchestration_error",
119120
message: error.message,
120121
})
121-
: unavailable(),
122+
: isThreadManagementError(error)
123+
? threadManagementFailure(error)
124+
: dispatchFailure(error),
122125
),
123126
);
124127
return {
Collapse file

‎apps/server/src/mcp/toolkits/core.test.ts‎

Copy file name to clipboardExpand all lines: apps/server/src/mcp/toolkits/core.test.ts
+94Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1420,6 +1420,100 @@ it.effect("only the caller that prepared a pending upload can discard it", () =>
14201420
),
14211421
);
14221422

1423+
const sendTargetId = ThreadId.make("send-target-thread");
1424+
const sendCommand = {
1425+
commandId: CommandId.make("mcp-core-send"),
1426+
commandType: "message.dispatch",
1427+
};
1428+
1429+
it.effect.each([
1430+
{
1431+
outcome: "says that the missing workspace could not be recreated",
1432+
refusal: new ThreadManagement.ThreadManagementWorktreeRestoreError({
1433+
threadId: sendTargetId,
1434+
cause: new Error("The branch no longer exists."),
1435+
}),
1436+
reply: {
1437+
_tag: "OrchestratorMcpFailure",
1438+
code: "thread_not_sendable",
1439+
message:
1440+
"Couldn't recreate the missing workspace of thread send-target-thread, so the message was not sent. The branch no longer exists.",
1441+
},
1442+
},
1443+
{
1444+
outcome: "passes on the text reason of an orchestrator rejection",
1445+
refusal: new OrchestratorCommandRejectedError({
1446+
...sendCommand,
1447+
cause: "Thread send-target-thread is deleted.",
1448+
}),
1449+
reply: {
1450+
_tag: "OrchestratorMcpFailure",
1451+
code: "orchestration_error",
1452+
message: "Thread send-target-thread is deleted.",
1453+
},
1454+
},
1455+
{
1456+
outcome: "keeps an internal dispatch cause private",
1457+
refusal: new OrchestratorDispatchError({
1458+
...sendCommand,
1459+
cause: new Error("private-storage-path"),
1460+
}),
1461+
reply: {
1462+
_tag: "OrchestratorMcpFailure",
1463+
code: "orchestration_error",
1464+
message: "The operation could not be completed.",
1465+
},
1466+
},
1467+
])("t3_thread_send_attachments $outcome", ({ refusal, reply }) => {
1468+
const stored = ChatImageAttachment.make({
1469+
type: "image",
1470+
id: "owned-image",
1471+
name: "original.png",
1472+
mimeType: "image/png",
1473+
sizeBytes: 12,
1474+
});
1475+
return Effect.gen(function* () {
1476+
const server = yield* McpServer.McpServer;
1477+
const result = yield* server
1478+
.callTool({
1479+
name: "t3_thread_send_attachments",
1480+
arguments: { threadId: sendTargetId, message: "See the file.", attachments: [stored] },
1481+
})
1482+
.pipe(
1483+
Effect.provideService(McpInvocationContext.McpInvocationContext, scope),
1484+
Effect.provideService(McpSchema.McpServerClient, client),
1485+
);
1486+
expect(declaredFailure(result)).toEqual(reply);
1487+
}).pipe(
1488+
Effect.provide(
1489+
McpHttpServer.layerAttachmentToolkit.pipe(
1490+
Layer.provideMerge(McpHttpServer.layerInProcessMcpServer),
1491+
Layer.provide(
1492+
Layer.mock(ThreadManagement.ThreadManagementService)({
1493+
getThreadShell: (id) => Effect.succeed(McpToolAccessTestkit.liveThreadShell(id)),
1494+
getProjectThreadRecords: () =>
1495+
Effect.succeed({
1496+
...McpToolAccessTestkit.idleThreadProjection(
1497+
McpToolAccessTestkit.liveThreadShell(sendTargetId),
1498+
),
1499+
messages: [{ attachments: [stored] }],
1500+
} as never),
1501+
sendToThread: () => Effect.fail(refusal),
1502+
}),
1503+
),
1504+
Layer.provide(AssetSigner.layer.pipe(Layer.provideMerge(ServerSecretStore.layer))),
1505+
Layer.provide(ServerConfig.layerTest(process.cwd(), { prefix: "t3-mcp-attachment-" })),
1506+
Layer.provide(
1507+
DocumentText.layer.pipe(
1508+
Layer.provideMerge(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer)),
1509+
),
1510+
),
1511+
Layer.provide(NodeCrypto.layer),
1512+
),
1513+
),
1514+
);
1515+
});
1516+
14231517
it.effect(
14241518
"t3_thread_list settled:false with an empty statuses list lists the unsettled threads",
14251519
() => {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.