Skip to content

Commit ac16068

Browse files
committed
Merge branch 'dev' into sqlite2
2 parents 19a41ab + 5c8580a commit ac16068

5 files changed

Lines changed: 56 additions & 7 deletions

File tree

packages/app/e2e/file-tree.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import { test, expect } from "./fixtures"
33
test("file tree can expand folders and open a file", async ({ page, gotoSession }) => {
44
await gotoSession()
55

6-
await page.getByRole("button", { name: "Toggle file tree" }).click()
7-
6+
const toggle = page.getByRole("button", { name: "Toggle file tree" })
87
const treeTabs = page.locator('[data-component="tabs"][data-variant="pill"][data-scope="filetree"]')
8+
9+
if ((await toggle.getAttribute("aria-expanded")) !== "true") await toggle.click()
910
await expect(treeTabs).toBeVisible()
1011

1112
await treeTabs.locator('[data-slot="tabs-trigger"]').nth(1).click()

packages/app/e2e/titlebar-history.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ test("titlebar back/forward navigates between sessions", async ({ page, slug, sd
2929
await expect(page).toHaveURL(new RegExp(`/${slug}/session/${two.id}(?:\\?|#|$)`))
3030
await expect(page.locator(promptSelector)).toBeVisible()
3131

32-
const back = page.getByRole("button", { name: "Go back" })
33-
const forward = page.getByRole("button", { name: "Go forward" })
32+
const back = page.getByRole("button", { name: "Back" })
33+
const forward = page.getByRole("button", { name: "Forward" })
3434

3535
await expect(back).toBeVisible()
3636
await expect(back).toBeEnabled()

packages/app/src/components/file-tree.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
createMemo,
99
For,
1010
Match,
11+
onCleanup,
1112
Show,
1213
splitProps,
1314
Switch,
@@ -123,7 +124,28 @@ export default function FileTree(props: {
123124

124125
createEffect(() => {
125126
const path = props.path
126-
untrack(() => void file.tree.list(path))
127+
const state = { cancelled: false, timer: undefined as number | undefined }
128+
129+
const load = (attempt: number) => {
130+
if (state.cancelled) return
131+
if (file.tree.state(path)?.loaded) return
132+
133+
void untrack(() => file.tree.list(path)).finally(() => {
134+
if (state.cancelled) return
135+
if (file.tree.state(path)?.loaded) return
136+
if (attempt >= 2) return
137+
138+
const wait = Math.min(2000, 250 * 2 ** attempt)
139+
state.timer = window.setTimeout(() => load(attempt + 1), wait)
140+
})
141+
}
142+
143+
load(0)
144+
145+
onCleanup(() => {
146+
state.cancelled = true
147+
if (state.timer !== undefined) clearTimeout(state.timer)
148+
})
127149
})
128150

129151
const nodes = createMemo(() => {

packages/app/src/pages/session.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,33 @@ export default function Page() {
12561256
if (!wants) return
12571257
if (sync.data.session_diff[id] !== undefined) return
12581258

1259-
sync.session.diff(id)
1259+
const state = {
1260+
cancelled: false,
1261+
attempt: 0,
1262+
timer: undefined as number | undefined,
1263+
}
1264+
1265+
const load = () => {
1266+
if (state.cancelled) return
1267+
const pending = sync.session.diff(id)
1268+
if (!pending) return
1269+
pending.catch(() => {
1270+
if (state.cancelled) return
1271+
const attempt = state.attempt + 1
1272+
state.attempt = attempt
1273+
if (attempt > 5) return
1274+
if (state.timer !== undefined) clearTimeout(state.timer)
1275+
const wait = Math.min(10000, 250 * 2 ** (attempt - 1))
1276+
state.timer = window.setTimeout(load, wait)
1277+
})
1278+
}
1279+
1280+
load()
1281+
1282+
onCleanup(() => {
1283+
state.cancelled = true
1284+
if (state.timer !== undefined) clearTimeout(state.timer)
1285+
})
12601286
})
12611287

12621288
const autoScroll = createAutoScroll({

packages/ui/src/components/spinner.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[data-component="spinner"] {
2-
color: var(--text-base);
2+
color: inherit;
33
flex-shrink: 0;
44
width: 18px;
55
aspect-ratio: 1;

0 commit comments

Comments
 (0)