Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf: opening a thread loads 85% less data #24899

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/24899/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 16 changed files with 30 additions and 1 deletion (loading 13).

x
0 of 16 viewed, 16 left
9 additions and 0 deletionsapps/mobile/src/features/threads/use-composer-command-menu.tsModified
View file
@@ -59,6 +59,8 @@
import { matchesSlashSkillQuery } from "./composerSlashSkillSearch";
​
const WORKSPACE_SNAPSHOT_RETRY_COOLDOWN_MS = 10_000;
+// A cwd that never scans, such as a deleted worktree, would otherwise retry forever.
+const WORKSPACE_SNAPSHOT_MAX_ATTEMPTS = 3;
​
function composerSelectionAtEnd(draftMessage: string): ComposerEditorSelection {
return { start: draftMessage.length, end: draftMessage.length };
@@ -252,6 +254,7 @@
// Record client request time to enforce TTL even when the client clock runs ahead of the server.
const workspaceRefreshKeyRef = useRef<{ key: string; requestedAt: number } | null>(null);
+ const failedRefreshesRef = useRef<{ key: string; count: number } | null>(null);
const [workspaceRefreshRetry, setWorkspaceRefreshRetry] = useState<{
key: string;
notBefore: number;
@@ -307,6 +310,11 @@
workspaceRefreshKeyRef.current = request;
const retryLater = () => {
if (workspaceRefreshKeyRef.current !== request) return;
+ const failed = failedRefreshesRef.current;
+ const count = failed?.key === key ? failed.count + 1 : 1;
+ failedRefreshesRef.current = { key, count };
+ // Keeping the request marker lets the TTL hold off the next scan.
+ if (count >= WORKSPACE_SNAPSHOT_MAX_ATTEMPTS) return;
workspaceRefreshKeyRef.current = null;
setWorkspaceRefreshRetry({