• 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
名称
最后提交
最后更新
.agents 正在载入提交数据...
.claude 正在载入提交数据...
.cursor/rules 正在载入提交数据...
.devcontainer 正在载入提交数据...
.github 正在载入提交数据...
.husky 正在载入提交数据...
.storybook 正在载入提交数据...
assets 正在载入提交数据...
docs 正在载入提交数据...
drizzle 正在载入提交数据...
e2e-tests 正在载入提交数据...
makers 正在载入提交数据...
packages/@dyad-sh 正在载入提交数据...
plans 正在载入提交数据...
rules 正在载入提交数据...
scaffold 正在载入提交数据...
scripts 正在载入提交数据...
shared 正在载入提交数据...
src 正在载入提交数据...
testing 正在载入提交数据...
tools 正在载入提交数据...
worker 正在载入提交数据...
workers/tsc 正在载入提交数据...
.cursorignore 正在载入提交数据...
.env.example 正在载入提交数据...
.eslintrc.json 正在载入提交数据...
.gitattributes 正在载入提交数据...
.gitignore 正在载入提交数据...
.npmrc 正在载入提交数据...
.oxfmtrc.json 正在载入提交数据...
.oxlintrc.json 正在载入提交数据...
.prettierignore 正在载入提交数据...
.prettierrc 正在载入提交数据...
AGENTS.md 正在载入提交数据...
CLA.md 正在载入提交数据...
CLAUDE.md 正在载入提交数据...
CONTRIBUTING.md 正在载入提交数据...
LICENSE 正在载入提交数据...
README.md 正在载入提交数据...
SECURITY.md 正在载入提交数据...
biome.json 正在载入提交数据...
components.json 正在载入提交数据...
drizzle.config.ts 正在载入提交数据...
forge.config.ts 正在载入提交数据...
forge.env.d.ts 正在载入提交数据...
index.html 正在载入提交数据...
lint-staged.config.js 正在载入提交数据...
merge.config.ts 正在载入提交数据...
package-lock.json 正在载入提交数据...
package.json 正在载入提交数据...
playwright.config.ts 正在载入提交数据...
tsconfig.app.json 正在载入提交数据...
tsconfig.json 正在载入提交数据...
tsconfig.node.json 正在载入提交数据...
vite.main.config.mts 正在载入提交数据...
vite.preload.config.mts 正在载入提交数据...
vite.renderer.config.mts 正在载入提交数据...
vite.worker.config.mts 正在载入提交数据...
vitest.config.ts 正在载入提交数据...
windowsSign.ts 正在载入提交数据...