Fix archived agent reload failures
Unarchive provider storage before clearing Paseo's archived flag so failed native restores keep the snapshot archived. Keep initial history sync errors visible instead of falling back to the loading state.
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { AgentScreenMissingState } from "@/hooks/use-agent-screen-state-machine";
|
||||
import {
|
||||
clearHistorySyncErrorAfterSuccessfulSync,
|
||||
reconcileMissingAgentStateWithPresentAgent,
|
||||
} from "./agent-panel-load-state";
|
||||
|
||||
describe("reconcileMissingAgentStateWithPresentAgent", () => {
|
||||
it("clears lookup-only states once the agent record is present", () => {
|
||||
expect(reconcileMissingAgentStateWithPresentAgent({ kind: "resolving" })).toEqual({
|
||||
kind: "idle",
|
||||
});
|
||||
expect(
|
||||
reconcileMissingAgentStateWithPresentAgent({
|
||||
kind: "not_found",
|
||||
message: "Agent not found: agent-1",
|
||||
}),
|
||||
).toEqual({ kind: "idle" });
|
||||
});
|
||||
|
||||
it("preserves history sync errors while the agent record is present", () => {
|
||||
const state: AgentScreenMissingState = {
|
||||
kind: "error",
|
||||
message: "Failed to get logs: session is archived",
|
||||
};
|
||||
|
||||
expect(reconcileMissingAgentStateWithPresentAgent(state)).toBe(state);
|
||||
});
|
||||
});
|
||||
|
||||
describe("clearHistorySyncErrorAfterSuccessfulSync", () => {
|
||||
it("clears a sync error after a later successful refresh", () => {
|
||||
expect(
|
||||
clearHistorySyncErrorAfterSuccessfulSync({
|
||||
kind: "error",
|
||||
message: "Failed to get logs: session is archived",
|
||||
}),
|
||||
).toEqual({ kind: "idle" });
|
||||
});
|
||||
|
||||
it("leaves non-error states alone", () => {
|
||||
const state: AgentScreenMissingState = { kind: "resolving" };
|
||||
|
||||
expect(clearHistorySyncErrorAfterSuccessfulSync(state)).toBe(state);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user