fix: PG cell-edit serialization + recent-connections startup race (#6)
Release / windows (push) Failing after 18m10s
Release / linux (push) Successful in 19m10s

This commit was merged in pull request #6.
This commit is contained in:
2026-09-01 04:23:07 +00:00
parent 7a66b70c26
commit 7bd4e8d05f
13 changed files with 240 additions and 59 deletions
@@ -225,6 +225,33 @@ describe("favorites / recents / move-selection", () => {
expect(commands.recordRecentConnection).toHaveBeenCalledWith("c1");
});
it("loadAll refreshes recents once connections are known (startup race fix)", async () => {
const conn = makeConn({ id: "c1", name: "Prod" });
vi.spyOn(commands, "getConnections").mockResolvedValue([conn]);
vi.spyOn(commands, "getFolders").mockResolvedValue([]);
vi.spyOn(commands, "getTags").mockResolvedValue([]);
vi.spyOn(commands, "getRecentConnections").mockResolvedValue([
{ connection_id: "c1", opened_at: "2026-08-02T00:00:00Z" },
]);
// Simulate the app-shell mount: loadAll fires and populates connections.
await useConnectionStore.getState().loadAll();
// The recent strip must now show the connection that was opened previously.
expect(commands.getRecentConnections).toHaveBeenCalledWith(8);
expect(useConnectionStore.getState().recent).toEqual([conn]);
});
it("loadRecent maps cached recent ids against the current connection list", async () => {
const conn = makeConn({ id: "c1", name: "Prod" });
useConnectionStore.setState({ connections: [conn] });
vi.spyOn(commands, "getRecentConnections").mockResolvedValue([
{ connection_id: "c1", opened_at: "2026-08-02T00:00:00Z" },
]);
await useConnectionStore.getState().loadRecent();
expect(useConnectionStore.getState().recent).toEqual([conn]);
});
describe("duplicateConnection", () => {
it("copies fields with a '(copy)' name and favorite false", async () => {
const src = makeConn({ id: "c1", name: "Prod", folder_id: "f1", tag_ids: ["t1"], favorite: true });
+3
View File
@@ -46,6 +46,9 @@ export const useConnectionStore = create<ConnectionState>((set, get) => ({
set((s) => ({ connections: [...s.connections].sort((a, b) => Number(b.favorite) - Number(a.favorite)) }));
// Also load tag order
get().loadTagOrder();
// Refresh recents once connections are known so the recent strip is not
// computed against an empty list (avoids a startup race with loadRecent).
get().loadRecent().catch(() => {});
} catch (e) {
set({ loading: false, error: e instanceof Error ? e.message : String(e) });
}