@devries-cameron20 / t3code Mirror · read-only / commits / 8f6c3b209d
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 23, 01:45 UTC

fix(web): loading no longer shifts the Files tree (#13904)

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>

İlkay Dinç committed Oct 19, 2026 at 22:26 UTC 8f6c3b209db2a38094fcf367b26cb364d92b85f4
2 files changed +71 -4
apps/web/src/components/files/FileBrowserPanel.browser.test.tsx
+63 -3
@@ -1,3 +1,5 @@
1 +import "../../index.css";
2 +
3 import { EnvironmentId, type ProjectEntry } from "@t3tools/contracts";
4 import { act, type ReactNode } from "react";
5 import { createRoot, type Root } from "react-dom/client";
@@ -7,6 +9,8 @@ import FileBrowserPanel from "./FileBrowserPanel";
9
10 const files = vi.hoisted(() => ({
11 directoryEntries: [] as ProjectEntry[],
12 + directoryReady: true,
13 + directoryPending: false,
14 searchEntries: [] as ProjectEntry[],
15 searchPending: false,
16 searchError: null as string | null,
@@ -21,9 +25,9 @@ vi.mock("./useDirectoryEntries", () => ({
25 loadingDirectories: files.loadingDirectories,
26 load: files.load,
27 refresh: files.refresh,
24 - ready: true,
28 + ready: files.directoryReady,
29 error: null,
26 - isPending: false,
30 + isPending: files.directoryPending,
31 }),
32 }));
33 vi.mock("~/state/queries", () => ({
@@ -101,6 +105,25 @@ describe("Files panel search", () => {
105 );
106 }
107
108 + function expectVisibleLoadingStatus() {
109 + const status = container!.querySelector<HTMLElement>('[role="status"]');
110 + expect(status?.textContent).toBe("Loading files…");
111 + expect(status!.checkVisibility()).toBe(true);
112 + const bounds = status!.getBoundingClientRect();
113 + expect(bounds.width).toBeGreaterThan(1);
114 + expect(bounds.height).toBeGreaterThan(1);
115 + }
116 +
117 + function rowTop(path: string) {
118 + const row = container!
119 + .querySelector("file-tree-container")
120 + ?.shadowRoot!.querySelector(`[data-item-path="${CSS.escape(path)}"]`);
121 + expect(row, `visible row ${path}`).not.toBeNull();
122 + const bounds = row!.getBoundingClientRect();
123 + expect(bounds.height).toBeGreaterThan(0);
124 + return bounds.top;
125 + }
126 +
127 beforeEach(() => {
128 vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
129 files.directoryEntries = [
@@ -108,6 +131,8 @@ describe("Files panel search", () => {
131 { path: "src/app.ts", kind: "file" },
132 { path: "package.json", kind: "file" },
133 ];
134 + files.directoryReady = true;
135 + files.directoryPending = false;
136 files.searchEntries = [];
137 files.searchPending = false;
138 files.searchError = null;
@@ -121,6 +146,41 @@ describe("Files panel search", () => {
146 vi.unstubAllGlobals();
147 });
148
149 + it("keeps visible rows stationary during loading while showing initial loading status", async () => {
150 + const entries = files.directoryEntries;
151 + files.directoryEntries = [];
152 + files.directoryReady = false;
153 + files.directoryPending = true;
154 + await render();
155 + expect(visiblePaths()).toEqual([]);
156 + expectVisibleLoadingStatus();
157 +
158 + files.directoryEntries = entries;
159 + files.directoryReady = true;
160 + files.directoryPending = false;
161 + await render();
162 + expect(visiblePaths()).toEqual(["src/", "package.json"]);
163 + const initialTop = rowTop("package.json");
164 +
165 + files.directoryPending = true;
166 + await render();
167 + expect(rowTop("package.json")).toBe(initialTop);
168 +
169 + files.directoryPending = false;
170 + await search("pack");
171 + expect(visiblePaths()).toEqual(["package.json"]);
172 + const filteredTop = rowTop("package.json");
173 +
174 + files.searchPending = true;
175 + await search("package");
176 + expect(visiblePaths()).toEqual(["package.json"]);
177 + expect(rowTop("package.json")).toBe(filteredTop);
178 +
179 + files.searchPending = false;
180 + await render();
181 + expect(rowTop("package.json")).toBe(filteredTop);
182 + });
183 +
184 it("shows no matching files instead of the full tree when a filename is absent", async () => {
185 await render();
186 expect(visiblePaths()).toEqual(["src/", "package.json"]);
@@ -150,7 +210,7 @@ describe("Files panel search", () => {
210 files.searchPending = true;
211 await search("settings.ts");
212 expect(visiblePaths()).toEqual([]);
153 - expect(hasMessage("Loading files…")).toBe(true);
213 + expectVisibleLoadingStatus();
214 expect(hasMessage("No matching files.")).toBe(false);
215
216 files.searchEntries = [{ path: "config/settings.ts", kind: "file" }];
apps/web/src/components/files/FileBrowserPanel.tsx
+8 -1
@@ -561,7 +561,14 @@ export default function FileBrowserPanel({
561 </div>
562 ) : null}
563 {(!ready || pathSearch.isPending) && (
564 - <div role="status" className="px-3 py-1 text-xs text-muted-foreground">
564 + <div
565 + role="status"
566 + className={
567 + entries.length > 0 && !hasNoSearchMatches
568 + ? "sr-only"
569 + : "px-3 py-1 text-xs text-muted-foreground"
570 + }
571 + >
572 Loading files…
573 </div>
574 )}