Skip to content

Commit d6a63e5

Browse files
fix(mobile): preserve thread file scope across renders
1 parent a74f1ab commit d6a63e5

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎apps/mobile/src/features/threads/useThreadFileLinks.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from "@t3tools/shared/markdownLinks";
88
import { collectThreadFilePaths, createThreadFilePathIndex } from "@t3tools/shared/threadFilePaths";
99
import { Atom } from "effect/reactivity";
10-
import { createContext, useContext, useLayoutEffect, useRef, useState } from "react";
10+
import { createContext, useContext, useLayoutEffect, useMemo, useRef, useState } from "react";
1111

1212
import { projectEnvironment } from "../../state/projects";
1313
import { useEnvironmentScope, usePreparedConnection } from "../../state/session";
@@ -60,7 +60,10 @@ export function useThreadFileLinks(ref: ScopedThreadRef, cwd: string | null) {
6060
const current = generation.current;
6161
return () => generation.current === current;
6262
};
63-
const scope = { environmentId, threadId, cwd, connection, canRead, enabled };
63+
const scope = useMemo(
64+
() => ({ environmentId, threadId, cwd, connection, canRead, enabled }),
65+
[environmentId, threadId, cwd, connection, canRead, enabled],
66+
);
6467
return { ...scope, index, capture, scope };
6568
}
6669

‎apps/web/src/components/ChatMarkdown.assets.browser.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ let allowMetadata = false;
8181
const metadataResults = Atom.family((_key: string) =>
8282
Atom.make<AsyncResult.AsyncResult<FilesystemEntryMetadata | null, Error>>(
8383
AsyncResult.initial(true),
84-
),
84+
).pipe(Atom.keepAlive),
8585
);
8686
function metadataAtom(path: string) {
8787
return metadataResults(JSON.stringify([threadRef.environmentId, threadRef.threadId, path]));

0 commit comments

Comments
 (0)