Merge pull request #2524 from Gujiassh/fix/session-todo-filename-match

fix(session-manager): match todo filenames exactly
This commit is contained in:
YeonGyu-Kim
2026-03-25 13:22:39 +09:00
committed by GitHub
2 changed files with 21 additions and 1 deletions

View File

@@ -168,6 +168,26 @@ describe("session-manager storage", () => {
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 () => {
// when
const info = await getSessionInfo("ses_nonexistent")

View File

@@ -277,7 +277,7 @@ export async function readSessionTodos(sessionID: string): Promise<TodoItem[]> {
try {
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) {
try {