Merge pull request #2524 from Gujiassh/fix/session-todo-filename-match
fix(session-manager): match todo filenames exactly
This commit is contained in:
@@ -168,6 +168,26 @@ describe("session-manager storage", () => {
|
|||||||
expect(todos).toEqual([])
|
expect(todos).toEqual([])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test("readSessionTodos only reads the exact session todo file", async () => {
|
||||||
|
// given
|
||||||
|
writeFileSync(
|
||||||
|
join(TEST_TODO_DIR, "ses_1.json"),
|
||||||
|
JSON.stringify([{ id: "todo_exact", content: "Exact match", status: "pending" }]),
|
||||||
|
)
|
||||||
|
writeFileSync(
|
||||||
|
join(TEST_TODO_DIR, "ses_10.json"),
|
||||||
|
JSON.stringify([{ id: "todo_collision", content: "Wrong session", status: "completed" }]),
|
||||||
|
)
|
||||||
|
|
||||||
|
// when
|
||||||
|
const todos = await readSessionTodos("ses_1")
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(todos).toHaveLength(1)
|
||||||
|
expect(todos[0].id).toBe("todo_exact")
|
||||||
|
expect(todos[0].content).toBe("Exact match")
|
||||||
|
})
|
||||||
|
|
||||||
test("getSessionInfo returns null for non-existent session", async () => {
|
test("getSessionInfo returns null for non-existent session", async () => {
|
||||||
// when
|
// when
|
||||||
const info = await getSessionInfo("ses_nonexistent")
|
const info = await getSessionInfo("ses_nonexistent")
|
||||||
|
|||||||
@@ -277,7 +277,7 @@ export async function readSessionTodos(sessionID: string): Promise<TodoItem[]> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const allFiles = await readdir(TODO_DIR)
|
const allFiles = await readdir(TODO_DIR)
|
||||||
const todoFiles = allFiles.filter((f) => f.includes(sessionID) && f.endsWith(".json"))
|
const todoFiles = allFiles.filter((f) => f === `${sessionID}.json`)
|
||||||
|
|
||||||
for (const file of todoFiles) {
|
for (const file of todoFiles) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user