Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

Normalize attachment thread segments to lowercase

Julius Marminge58b932ffb8f2
diff --git a/apps/server/src/attachmentStore.test.ts b/apps/server/src/attachmentStore.test.ts
index 147084c56..8e1bc4218 100644
--- a/apps/server/src/attachmentStore.test.ts
+++ b/apps/server/src/attachmentStore.test.ts
@@ -34,6 +34,15 @@ describe("attachmentStore", () => {
expect(parseThreadSegmentFromAttachmentId(fooBarId)).toBe("foo-bar");
});
+ it("normalizes created thread segments to lowercase", () => {
+ const attachmentId = createAttachmentId("Thread.Foo");
+ expect(attachmentId).toBeTruthy();
+ if (!attachmentId) {
+ return;
+ }
+ expect(parseThreadSegmentFromAttachmentId(attachmentId)).toBe("thread-foo");
+ });
+
it("resolves attachment path by id using the extension that exists on disk", () => {
const stateDir = fs.mkdtempSync(path.join(os.tmpdir(), "t3code-attachment-store-"));
try {
diff --git a/apps/server/src/attachmentStore.ts b/apps/server/src/attachmentStore.ts
index 59b6e499b..248047e91 100644
--- a/apps/server/src/attachmentStore.ts
+++ b/apps/server/src/attachmentStore.ts
@@ -23,6 +23,7 @@ const ATTACHMENT_ID_PATTERN = new RegExp(
export function toSafeThreadAttachmentSegment(threadId: string): string | null {
const segment = threadId
.trim()
+ .toLowerCase()
.replace(/[^a-z0-9_-]+/gi, "-")
.replace(/-+/g, "-")
.replace(/^[-_]+|[-_]+$/g, "")
diff --git a/apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts b/apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts
index ba1b0afdc..741aa16f1 100644
--- a/apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts
+++ b/apps/server/src/orchestration/Layers/ProjectionPipeline.test.ts
@@ -733,7 +733,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
const projectionPipeline = yield* OrchestrationProjectionPipeline;
const eventStore = yield* OrchestrationEventStore;
const now = new Date().toISOString();
- const threadId = ThreadId.makeUnsafe("thread revert.files");
+ const threadId = ThreadId.makeUnsafe("Thread Revert.Files");
const keepAttachmentId = "thread-revert-files-00000000-0000-4000-8000-000000000001";
const removeAttachmentId = "thread-revert-files-00000000-0000-4000-8000-000000000002";
const otherThreadAttachmentId =
@@ -948,7 +948,7 @@ projectionLayer("OrchestrationProjectionPipeline", (it) => {
const projectionPipeline = yield* OrchestrationProjectionPipeline;
const eventStore = yield* OrchestrationEventStore;
const now = new Date().toISOString();
- const threadId = ThreadId.makeUnsafe("thread delete.files");
+ const threadId = ThreadId.makeUnsafe("Thread Delete.Files");
const attachmentId = "thread-delete-files-00000000-0000-4000-8000-000000000001";
const otherThreadAttachmentId =
"thread-delete-files-extra-00000000-0000-4000-8000-000000000002";