• Mohamed Aziz Mejri's avatar
    Persist todos across chat turns (#2713) · dd7718f3
    Mohamed Aziz Mejri 提交于
    ## Summary
    Add persistence layer for todos so they survive across multiple turns in
    a chat session. Todos are now saved to disk after each update and
    automatically loaded and injected into the conversation context when a
    new turn begins.
    
    ## Key Changes
    - **New module `todo_persistence.ts`**: Provides utilities to save,
    load, and delete todo JSON files stored in `.dyad/todos/<chatId>.json`
      - `getTodosFilePath()`: Constructs the file path for a chat's todos
    - `saveTodos()`: Persists todos to disk with metadata (updatedAt
    timestamp)
    - `loadTodos()`: Loads previously saved todos, gracefully handling
    missing or corrupted files
      - `deleteTodos()`: Removes the todos file when all todos are completed
    
    - **Updated `local_agent_handler.ts`**: 
      - Load persisted todos at the start of each turn
    - Emit loaded todos to the renderer immediately so the UI reflects them
    - Initialize the agent context with persisted todos instead of an empty
    array
    - Inject a synthetic system message reminding the LLM of incomplete
    todos from the previous turn, following the same pattern as existing
    todo reminder logic
      - Ensure `.dyad/` directory is gitignored (idempotent operation)
    
    - **Updated `update_todos.ts`**:
      - Persist todos to disk after each tool execution
      - Delete the todos file when all todos are marked as completed
    
    ## Implementation Details
    - Todos are stored as JSON with an `updatedAt` timestamp for potential
    future use
    - File I/O errors are logged as warnings but don't interrupt the agent
    flow (graceful degradation)
    - The synthetic message injection for persisted todos only occurs if
    there are incomplete todos, avoiding unnecessary context pollution
    - The `.dyad/` gitignore step is idempotent and aligns with existing
    patterns in the codebase
    
    <!-- devin-review-badge-begin -->
    
    ---
    
    <a href="https://app.devin.ai/review/dyad-sh/dyad/pull/2713"
    target="_blank">
      <picture>
    <source media="(prefers-color-scheme: dark)"
    srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1">
    <img
    src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1"
    alt="Open with Devin">
      </picture>
    </a>
    <!-- devin-review-badge-end -->
    
    ---------
    Co-authored-by: 's avatarClaude <noreply@anthropic.com>
    Co-authored-by: 's avatarMohamed Aziz Mejri <mohamedazizmejri@Mohameds-Mac-mini.local>
    dd7718f3
名称
最后提交
最后更新
..
azure 正在载入提交数据...
backups 正在载入提交数据...
engine 正在载入提交数据...
gateway 正在载入提交数据...
images 正在载入提交数据...
import-app 正在载入提交数据...
security-review 正在载入提交数据...
1.md 正在载入提交数据...
2.md 正在载入提交数据...
3.md 正在载入提交数据...
4.md 正在载入提交数据...
5.md 正在载入提交数据...
6.md 正在载入提交数据...
add-supabase.md 正在载入提交数据...
basic.md 正在载入提交数据...
chat1.md 正在载入提交数据...
chat2.md 正在载入提交数据...
console-logs.md 正在载入提交数据...
context-limit-response.md 正在载入提交数据...
create-error.md 正在载入提交数据...
create-multiple-errors.md 正在载入提交数据...
create-ts-errors-complex.md 正在载入提交数据...
create-ts-errors.md 正在载入提交数据...
create-unfixable-ts-errors.md 正在载入提交数据...
dyad-write-angle.md 正在载入提交数据...
edit-made-with-dyad.md 正在载入提交数据...
execute-sql-1.md 正在载入提交数据...
execute-sql-no-description.md 正在载入提交数据...
generate-supabase-client.md 正在载入提交数据...
multi-page.md 正在载入提交数据...
network-requests.md 正在载入提交数据...
no-code-response.md 正在载入提交数据...
partial-write.md 正在载入提交数据...
rename-edit.md 正在载入提交数据...
version-integrity-add-edit-delete.md 正在载入提交数据...
version-integrity-move-file.md 正在载入提交数据...
write-index-2.md 正在载入提交数据...
write-index.md 正在载入提交数据...