Skip to content

Commit 43f1d07

Browse files
committed
Fix cross-environment thread mixing and unstable atom family key
- Add environmentId check to thread filter in ArchivedThreadsPanel to prevent threads from different environments being grouped together when they share the same projectId. - Sort environment IDs before joining in makeArchivedThreadsEnvironmentKey to produce a stable atom family key regardless of input order.
1 parent 98e7c10 commit 43f1d07

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

apps/web/src/components/settings/SettingsPanels.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,10 @@ export function ArchivedThreadsPanel() {
13341334
.map((project) => ({
13351335
project,
13361336
threads: threads
1337-
.filter((thread) => thread.projectId === project.id)
1337+
.filter(
1338+
(thread) =>
1339+
thread.projectId === project.id && thread.environmentId === project.environmentId,
1340+
)
13381341
.toSorted((left, right) => {
13391342
const leftKey = left.archivedAt ?? left.createdAt;
13401343
const rightKey = right.archivedAt ?? right.createdAt;

apps/web/src/lib/archivedThreadsState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export type ArchivedSnapshotEntry = {
1919
const knownArchivedThreadEnvironmentKeys = new Set<string>();
2020

2121
function makeArchivedThreadsEnvironmentKey(environmentIds: ReadonlyArray<EnvironmentId>): string {
22-
return environmentIds.join(ARCHIVED_THREADS_ENVIRONMENT_KEY_SEPARATOR);
22+
return [...environmentIds].sort().join(ARCHIVED_THREADS_ENVIRONMENT_KEY_SEPARATOR);
2323
}
2424

2525
function parseArchivedThreadsEnvironmentKey(key: string): ReadonlyArray<EnvironmentId> {

0 commit comments

Comments
 (0)