Skip to content

A desktop coding agent with free access to frontier models.

TypeScript

fix: project changes wait for a ready start

ogsamratb87e73e4735a
diff --git a/apps/server/src/session-archive/lifecycle.test.ts b/apps/server/src/session-archive/lifecycle.test.ts
index d648db15..1ca193dd 100644
--- a/apps/server/src/session-archive/lifecycle.test.ts
+++ b/apps/server/src/session-archive/lifecycle.test.ts
@@ -764,6 +764,32 @@ describe("ProjectArchiveLifecycle", () => {
await subject.stop({ finals: false });
});
+ test("a path touched while the folder policy is unavailable gets its base once the policy answers", async () => {
+ const archiver = new FakeArchiver();
+ archiver.baseDue = true;
+ archiver.final = async () => queued("base");
+ const { subject } = lifecycle(archiver, { touchedBaseDelayMs: 10 });
+ const root = await tempDir("root");
+ const outage: CaptureResult = { status: "skipped", reason: "unavailable", detail: "policy_unavailable" };
+ let serverUp = false;
+ archiver.base = async () => (serverUp ? skipped("unchanged") : outage);
+ subject.sessionStarted({ sessionId: "ses_policy_0003", root, engine: engine().reader });
+ await subject.settled();
+ subject.pathTouched("ses_policy_0003", "a.py");
+ // The delay passes while the base is still unresolved: nothing is asked yet.
+ await new Promise((resolve) => setTimeout(resolve, 30));
+ await subject.settled();
+ expect(archiver.finals()).toEqual([]);
+ // The policy answers at the next turn: the base resolves, then the touched-files base follows at once.
+ serverUp = true;
+ subject.turnCompleted("ses_policy_0003", messages(1));
+ await subject.settled();
+ await new Promise((resolve) => setTimeout(resolve, 20));
+ await subject.settled();
+ expect(archiver.finals()).toEqual(["final ses_policy_0003 first_touch"]);
+ await subject.stop({ finals: false });
+ });
+
test("a folder policy that is really off still ends the session's archiving: no base asked again", async () => {
const archiver = new FakeArchiver();
const { subject } = lifecycle(archiver);
diff --git a/apps/server/src/session-archive/lifecycle.ts b/apps/server/src/session-archive/lifecycle.ts
index 378f8794..16a430a3 100644
--- a/apps/server/src/session-archive/lifecycle.ts
+++ b/apps/server/src/session-archive/lifecycle.ts
@@ -497,7 +497,8 @@ export class ProjectArchiveLifecycle {
* it is taken touchedBaseDelayMs after the first touched path, once the session's root is known.
*/
private armTouchedBase(sessionId: string, record: SessionRecord): void {
- if (!record.root || record.touchedBase || record.firstTouchedAt === undefined || !this.archiver.touchedBaseDue) return;
+ // Not while the start is unresolved (record.start is back after a folder policy outage): resolve() arms it.
+ if (!record.root || record.start || record.touchedBase || record.firstTouchedAt === undefined || !this.archiver.touchedBaseDue) return;
const live = () => this.active && !this.consentOff && this.sessions.get(sessionId) === record && Boolean(record.root);
const timer = setTimeout(() => {
record.touchedBase = true;