Repository navigation
feat: summarize initial prompt to generate task title in background #2363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1e4e3c2
3aa89ae
b84b4f6
d798435
592f4b2
1e7530d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -421,4 +421,65 @@ describe("TaskHistoryStore real cross-host locking", () => { | |
| await fs.rm(storagePath, { recursive: true, force: true }) | ||
| } | ||
| }) | ||
|
|
||
| it("preserves a manual rename committed by another store over a stale-cache generated title", async () => { | ||
| const storagePath = await fs.mkdtemp(path.join(os.tmpdir(), "task-history-generated-title-")) | ||
| const storeA = new TaskHistoryStore(storagePath) | ||
| const storeB = new TaskHistoryStore(storagePath) | ||
| const filePath = path.join(storagePath, "tasks", "shared-task", "history_item.json") | ||
|
|
||
| try { | ||
| await storeA.initialize() | ||
| await storeA.upsert(item("shared-task")) | ||
| // storeB hydrates its cache before the rename, so its cached copy | ||
| // never sees the manual title. | ||
| await storeB.initialize() | ||
|
|
||
| // The manual rename commits to disk through store A before store | ||
| // B attempts the generated-title write. | ||
| await storeA.atomicReadAndUpdate("shared-task", (current) => ({ ...current, title: "Manual Title" })) | ||
|
|
||
| const result = await storeB.setGeneratedTitleIfUnset("shared-task", "Generated Title") | ||
|
|
||
| expect(result.applied).toBe(false) | ||
| expect(result.item.title).toBe("Manual Title") | ||
| // The stale cache is refreshed with the authoritative disk record. | ||
| expect(storeB.get("shared-task")?.title).toBe("Manual Title") | ||
| expect(JSON.parse(await fs.readFile(filePath, "utf8"))).toMatchObject({ title: "Manual Title" }) | ||
| } finally { | ||
| storeA.dispose() | ||
| storeB.dispose() | ||
| await fs.rm(storagePath, { recursive: true, force: true }) | ||
| } | ||
| }) | ||
|
|
||
| it("applies the generated title onto the locked disk record when no disk title exists", async () => { | ||
| const storagePath = await fs.mkdtemp(path.join(os.tmpdir(), "task-history-generated-title-apply-")) | ||
| const storeA = new TaskHistoryStore(storagePath) | ||
| const storeB = new TaskHistoryStore(storagePath) | ||
| const filePath = path.join(storagePath, "tasks", "shared-task", "history_item.json") | ||
|
|
||
| try { | ||
| await storeA.initialize() | ||
| await storeA.upsert(item("shared-task")) | ||
| await storeB.initialize() | ||
|
|
||
| // Another host persists an unrelated field; storeB's cache stays | ||
| // stale, so the apply must read the locked disk record. | ||
| await storeA.atomicReadAndUpdate("shared-task", (current) => ({ ...current, totalCost: 42 })) | ||
|
|
||
| const result = await storeB.setGeneratedTitleIfUnset("shared-task", "Generated Title") | ||
|
|
||
| expect(result.applied).toBe(true) | ||
| expect(result.item).toMatchObject({ title: "Generated Title", totalCost: 42 }) | ||
| expect(JSON.parse(await fs.readFile(filePath, "utf8"))).toMatchObject({ | ||
| title: "Generated Title", | ||
| totalCost: 42, | ||
| }) | ||
| } finally { | ||
| storeA.dispose() | ||
| storeB.dispose() | ||
| await fs.rm(storagePath, { recursive: true, force: true }) | ||
| } | ||
| }) | ||
|
Comment on lines
+425
to
+484
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: Zoo-Code-Org/Zoo-Code
Length of output: 14584
Script executed:
Repository: Zoo-Code-Org/Zoo-Code
Length of output: 43193
Script executed:
Repository: Zoo-Code-Org/Zoo-Code
Length of output: 28288
Script executed:
Repository: Zoo-Code-Org/Zoo-Code
Length of output: 12380
Validate the locked record before applying a generated title.
If the disk record is malformed or belongs to another task, this merge writes it back and replaces the valid cached entry with it. Validate the record against
historyItemSchemaand check its ID before using it.GitHub Check: mutation-diff
[warning] 1248-1248: Mutation test advisory
src/core/task-persistence/TaskHistoryStore.ts:1248: NoCoverage BooleanLiteral mutant (replacement: false). See the job summary for the complete list and resolution guidance.
[warning] 1230-1230: Mutation test advisory
src/core/task-persistence/TaskHistoryStore.ts:1230: 5 mutation test gaps; example: Survived ConditionalExpression mutant (replacement: true). See the job summary for the complete list and resolution guidance.