fix: address PR #1300 review follow-up comments
This commit is contained in:
parent
db340fad88
commit
89efcbe1ec
|
|
@ -8,6 +8,7 @@ import {
|
|||
readMetadataRaw,
|
||||
readCanonicalLifecycle,
|
||||
readArchivedMetadataRaw,
|
||||
mutateMetadata,
|
||||
writeMetadata,
|
||||
updateMetadata,
|
||||
deleteMetadata,
|
||||
|
|
@ -212,6 +213,29 @@ describe("updateMetadata", () => {
|
|||
expect(meta!.status).toBe("pr_open");
|
||||
expect(meta!.summary).toBeUndefined();
|
||||
});
|
||||
|
||||
it("returns the normalized record that is actually persisted", () => {
|
||||
writeMetadata(dataDir, "upd-5", {
|
||||
worktree: "/tmp/w",
|
||||
branch: "main",
|
||||
status: "working",
|
||||
summary: "doing stuff",
|
||||
});
|
||||
|
||||
const next = mutateMetadata(dataDir, "upd-5", (existing) => ({
|
||||
...existing,
|
||||
summary: "",
|
||||
pr: "https://github.com/org/repo/pull/5",
|
||||
}));
|
||||
|
||||
expect(next).toEqual({
|
||||
worktree: "/tmp/w",
|
||||
branch: "main",
|
||||
status: "working",
|
||||
pr: "https://github.com/org/repo/pull/5",
|
||||
});
|
||||
expect(readMetadataRaw(dataDir, "upd-5")).toEqual(next);
|
||||
});
|
||||
});
|
||||
|
||||
describe("readCanonicalLifecycle", () => {
|
||||
|
|
|
|||
|
|
@ -193,6 +193,12 @@ function applyMetadataUpdates(
|
|||
return next;
|
||||
}
|
||||
|
||||
function normalizeMetadataRecord(data: Record<string, string>): Record<string, string> {
|
||||
return Object.fromEntries(
|
||||
Object.entries(data).filter(([, value]) => value !== undefined && value !== ""),
|
||||
);
|
||||
}
|
||||
|
||||
export function mutateMetadata(
|
||||
dataDir: string,
|
||||
sessionId: SessionId,
|
||||
|
|
@ -208,7 +214,7 @@ export function mutateMetadata(
|
|||
return null;
|
||||
}
|
||||
|
||||
const next = updater({ ...existing });
|
||||
const next = normalizeMetadataRecord(updater({ ...existing }));
|
||||
|
||||
mkdirSync(dirname(path), { recursive: true });
|
||||
atomicWriteFileSync(path, serializeMetadata(next));
|
||||
|
|
|
|||
|
|
@ -1854,6 +1854,11 @@ html.light .xterm .xterm-viewport:hover::-webkit-scrollbar-thumb:active {
|
|||
background: var(--color-status-ready);
|
||||
}
|
||||
|
||||
.session-detail-tone--idle {
|
||||
color: var(--color-status-idle);
|
||||
background: var(--color-status-idle);
|
||||
}
|
||||
|
||||
.session-detail-tone--attention {
|
||||
color: var(--color-status-attention);
|
||||
background: var(--color-status-attention);
|
||||
|
|
|
|||
|
|
@ -131,6 +131,8 @@ function activityToneClass(activityColor: string): string {
|
|||
return "session-detail-tone--working";
|
||||
case "var(--color-status-ready)":
|
||||
return "session-detail-tone--ready";
|
||||
case "var(--color-status-idle)":
|
||||
return "session-detail-tone--idle";
|
||||
case "var(--color-status-attention)":
|
||||
return "session-detail-tone--attention";
|
||||
case "var(--color-status-error)":
|
||||
|
|
|
|||
Loading…
Reference in New Issue