fix(todo): make Todo id field optional for OpenCode beta compatibility

- Make id field optional in all Todo interfaces (TodoInfo, Todo, TodoItem)
- Fix null-unsafe comparisons in todo-sync.ts to handle missing ids
- Add test case for todos without id field preservation
- All tests pass and typecheck clean
This commit is contained in:
YeonGyu-Kim
2026-02-14 17:41:40 +09:00
parent b7a2a066dd
commit ed098925b5
14 changed files with 180 additions and 98 deletions
@@ -44,7 +44,7 @@ export async function formatSessionList(sessionIDs: string[]): Promise<string> {
export function formatSessionMessages(
messages: SessionMessage[],
includeTodos?: boolean,
todos?: Array<{ id: string; content: string; status: string }>
todos?: Array<{ id?: string; content: string; status: string }>
): string {
if (messages.length === 0) {
return "No messages found in this session."
+5 -5
View File
@@ -73,8 +73,8 @@ export async function getAllSessions(): Promise<string[]> {
return [...new Set(sessions)]
}
export function getMessageDir(sessionID: string): string {
if (!existsSync(MESSAGE_STORAGE)) return ""
export function getMessageDir(sessionID: string): string | null {
if (!existsSync(MESSAGE_STORAGE)) return null
const directPath = join(MESSAGE_STORAGE, sessionID)
if (existsSync(directPath)) {
@@ -89,14 +89,14 @@ export function getMessageDir(sessionID: string): string {
}
}
} catch {
return ""
return null
}
return ""
return null
}
export function sessionExists(sessionID: string): boolean {
return getMessageDir(sessionID) !== ""
return getMessageDir(sessionID) !== null
}
export async function readSessionMessages(sessionID: string): Promise<SessionMessage[]> {
+4 -4
View File
@@ -34,10 +34,10 @@ export interface SessionInfo {
}
export interface TodoItem {
id: string
content: string
status: "pending" | "in_progress" | "completed" | "cancelled"
priority?: string
id?: string;
content: string;
status: "pending" | "in_progress" | "completed" | "cancelled";
priority?: string;
}
export interface SearchResult {