@devries-cameron20 / t3code Mirror · read-only / commits / b52518f85f
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 25, 16:00 UTC

Flatten attachment paths with message-prefixed filenames

- Write projected attachments under the thread directory using `messageSegment-fileName` - Avoid nested per-message folders while preserving unique, deterministic file paths - Update projection pipeline tests to match new attachment URLs and on-disk paths

Julius Marminge committed Feb 27, 2026 at 21:12 UTC b52518f85fa3f11a6a405e3bebaf908ebdc5add7
2 files changed +12 -18
apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts
+9 -16
@@ -230,7 +230,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
230 name: "example.png",
231 mimeType: "image/png",
232 sizeBytes: 5,
233 - dataUrl: "/attachments/thread-attachments/message-attachments/0.png",
233 + dataUrl: "/attachments/thread-attachments/message-attachments-0.png",
234 },
235 ]);
236
@@ -238,8 +238,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
238 stateDir,
239 "attachments",
240 "thread-attachments",
241 - "message-attachments",
242 - "0.png",
241 + "message-attachments-0.png",
242 );
243 assert.equal(fs.existsSync(attachmentPath), true);
244 assert.deepEqual(fs.readFileSync(attachmentPath), Buffer.from("SGVsbG8=", "base64"));
@@ -325,7 +324,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
324 name: "untrusted.exe",
325 mimeType: "image/x-unknown",
326 sizeBytes: 5,
328 - dataUrl: "/attachments/thread-attachments-safe/message-attachments-safe/0.bin",
327 + dataUrl: "/attachments/thread-attachments-safe/message-attachments-safe-0.bin",
328 },
329 {
330 type: "image",
@@ -340,8 +339,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
339 stateDir,
340 "attachments",
341 "thread-attachments-safe",
343 - "message-attachments-safe",
344 - "0.bin",
342 + "message-attachments-safe-0.bin",
343 );
344 assert.equal(fs.existsSync(firstAttachmentPath), true);
345 assert.deepEqual(fs.readFileSync(firstAttachmentPath), Buffer.from("SGVsbG8=", "base64"));
@@ -350,8 +348,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
348 stateDir,
349 "attachments",
350 "thread-attachments-safe",
353 - "message-attachments-safe",
354 - "1.png",
351 + "message-attachments-safe-1.png",
352 );
353 assert.equal(fs.existsSync(secondAttachmentPath), false);
354 fs.rmSync(stateDir, { recursive: true, force: true });
@@ -614,8 +611,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
611 stateDir,
612 "attachments",
613 "thread-overwrite",
617 - "message-overwrite",
618 - "0.png",
614 + "message-overwrite-0.png",
615 );
616 assert.equal(fs.existsSync(attachmentPath), true);
617 assert.deepEqual(fs.readFileSync(attachmentPath), Buffer.from("V29ybGQ=", "base64"));
@@ -753,8 +749,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
749 stateDir,
750 "attachments",
751 "thread-rollback",
756 - "message-rollback",
757 - "0.png",
752 + "message-rollback-0.png",
753 );
754 assert.equal(fs.existsSync(attachmentPath), false);
755 yield* sql`DROP TRIGGER IF EXISTS fail_thread_messages_projection_state_update`;
@@ -945,15 +940,13 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
940 stateDir,
941 "attachments",
942 "thread-revert-files",
948 - "message-keep",
949 - "0.png",
943 + "message-keep-0.png",
944 );
945 const removePath = path.join(
946 stateDir,
947 "attachments",
948 "thread-revert-files",
955 - "message-remove",
956 - "0.png",
949 + "message-remove-0.png",
950 );
951 assert.equal(fs.existsSync(keepPath), true);
952 assert.equal(fs.existsSync(removePath), true);
apps/server/src/orchestration/Layers/ProjectionPipeline.ts
+3 -2
@@ -140,8 +140,9 @@ const materializeAttachmentsForProjection = Effect.fn(function* (input: {
140 ...attachment,
141 mimeType: parsed.mimeType,
142 })}`;
143 - const relativePath = `${threadSegment}/${messageSegment}/${fileName}`;
144 - const absolutePath = path.join(attachmentsRootDir, threadSegment, messageSegment, fileName);
143 + const uniqueFileName = `${messageSegment}-${fileName}`;
144 + const relativePath = `${threadSegment}/${uniqueFileName}`;
145 + const absolutePath = path.join(attachmentsRootDir, threadSegment, uniqueFileName);
146 input.stageFileWrite({ absolutePath, bytes });
147
148 return {