# Enhanced File Panel — tasks

## Tasks

- [ ] 1. **Server: whitespace param** — Add `ignoreWhitespace` param to `getGitDiff()` in
  `apps/server/src/services/git_diff.ts`. Append `-w` to git diff argv when true.
  Add `whitespace=1` query param to `GET /api/projects/:id/git/diff` route.

- [ ] 2. **Server: write_file endpoint** — Add `POST /api/projects/:id/write_file` with
  pathGuard validation and atomic file write. Wire client in `api/client.ts`.

- [ ] 3. **Server tests** — Add tests for whitespace param and write_file endpoint.
  (`apps/server/src/services/__tests__/git_diff.test.ts` + new write tests)

- [ ] 4. **Frontend: useDiffPreferences hook** — Create `useDiffPreferences.ts` with
  localStorage persistence for layout, wrapLines, hideWhitespace.

- [ ] 5. **Frontend: GitDiffView toolbar** — Add toolbar row with Layout toggle,
  Hide whitespace toggle, Wrap lines toggle, Expand/Collapse all, Refresh.

- [ ] 6. **Frontend: diff layout utilities** — Create `utils/diff-layout.ts` with
  `buildNumberedDiffHunks()`, `buildSplitDiffRows()`, `buildUnifiedDiffLines()`.

- [ ] 7. **Frontend: DiffSplitView component** — Side-by-side renderer with two aligned
  columns, Shiki highlighting per side, thin divider.

- [ ] 8. **Frontend: Integrate split layout in GitDiffView** — Branch render path based
  on `layout` preference. Wire collapse/expand state to all files.

- [ ] 9. **Frontend: Inline comment store** — Create `stores/useDiffCommentStore.ts`
  with Zustand + localStorage persistence. CRUD operations.

- [ ] 10. **Frontend: InlineReviewGutterCell + InlineReviewEditor** — Gutter cells
  with "+" on hover, editor textarea anchored below the target line.

- [ ] 11. **Frontend: InlineReviewThread** — Comment thread display below diff lines.
  Collapsible, shows body + timestamp + edit/delete.

- [ ] 12. **Frontend: Integrate comments in GitDiffView** — Wire gutter cells,
  editor, and thread into the diff line rendering.

- [ ] 13. **Frontend: File editing in RightRail** — Double-click file → inline
  textarea → Save/Cancel → write_file API → tree refresh.

- [ ] 14. **Build + smoke test** — Verify `pnpm -C apps/web build` and
  `pnpm -C apps/server build`. Run all QA scenarios.
