daemon: seed repo volume via CopyToContainer (host-path bind bug → empty workspace); web: spawn poll reads fresh session list

This commit is contained in:
Raphael Westphal
2026-08-18 16:55:58 +02:00
parent 1cc5d9a978
commit 55be4b2a38
6 changed files with 82 additions and 50 deletions
+19 -14
View File
@@ -203,11 +203,29 @@ describe("SpawnView spawn+poll", () => {
it("spawns, polls until online, then navigates to the chat", async () => {
const posts: Array<[string, RequestInit | undefined]> = [];
let sessionsOnline = false; // flipped after the first poll tick
mockFetchJson((url, init) => {
if (init?.method === "POST" && url.endsWith("/api/spawn")) {
posts.push([url, init]);
return { sessionId: "new-1", containerId: "abc123def456" };
}
if (url.endsWith("/api/sessions"))
return sessionsOnline
? [
{
id: "new-1",
name: "spawned",
cwd: "/w",
model: "m",
provider: "p",
agent: true,
repo: "g/proj",
startedAt: 1,
online: true,
lastEventAt: 1,
},
]
: [];
if (url.endsWith("/api/spawn/status")) return [];
if (url.endsWith("/api/gitlab/status"))
return { connected: true, baseUrl: "https://gl", username: "alice" };
@@ -239,20 +257,7 @@ describe("SpawnView spawn+poll", () => {
expect(screen.queryByTestId("chat-route")).toBeNull();
// session comes online -> next tick navigates
store.sessions = [
{
id: "new-1",
name: "spawned",
cwd: "/w",
model: "m",
provider: "p",
agent: true,
repo: "g/proj",
startedAt: 1,
online: true,
lastEventAt: 1,
},
];
sessionsOnline = true;
await act(async () => {
vi.advanceTimersByTime(1500);
});
+3 -3
View File
@@ -1,6 +1,6 @@
import { useEffect, useRef, useState } from "react";
import { useNavigate } from "react-router-dom";
import type { GitlabStatus, Repo, SpawnJob, SpawnResponse } from "./protocol";
import type { GitlabStatus, Repo, SessionListItem, SpawnJob, SpawnResponse } from "./protocol";
import { Route } from "./protocol";
import { errMessage, fetchJson } from "./api";
import type { SessionsStore } from "./store";
@@ -115,9 +115,9 @@ export default function SpawnView({ store, pushToast }: Props) {
}
void (async () => {
try {
await fetchJson<SpawnJob[]>(Route.SpawnStatus).catch(() => undefined);
const list = await fetchJson<SessionListItem[]>(Route.Sessions);
const s = list.find((x) => x.id === sessionId);
await store.refresh();
const s = store.sessions.find((x) => x.id === sessionId);
if (s !== undefined && s.online) {
if (timerRef.current !== null) window.clearInterval(timerRef.current);
timerRef.current = null;