Skip to content

feat: add uncommitted scope to All Changes diff - #1726

Open
liyown wants to merge 2 commits into
LodyAI:mainfrom
liyown:feat/1664-all-changes-diff-scope
Open

liyown wants to merge 2 commits into
LodyAI:mainfrom
liyown:feat/1664-all-changes-diff-scope

Conversation

@liyown

@liyown liyown commented Oct 19, 2026 •

Copy link
Copy Markdown

Related issue

Closes #1664

Problem / pressure

The workspace All Changes diff compared merge-base(base, HEAD) with disk, so
work that had already been committed on the branch stayed in the diff after a
commit. The UI never named the base, so users could not tell branch-cumulative
changes from edits that were still uncommitted. Deferred files also re-resolved
the base independently, which made a scoped view impossible to keep consistent.

Summary

  • Add an optional branch | uncommitted scope to the batched All Changes diff
    and to the per-file open-current-diff request.
  • uncommitted compares HEAD with disk, including staged, unstaged and
    untracked non-ignored files.
  • Non-Git worktrees and repositories without a commit return explicit
    not_a_git_worktree / no_commits reasons instead of silently falling back
    to an untracked-only list.
  • Uncommitted mode never falls back to session diff-store snapshots.
  • Show a scope control and the resolved base in the All Changes header. The
    control is gated by the codeCollabAllChangesScope protocol capability.
  • The Changes sidebar list stays branch-cumulative; the diff view renders only
    the file set returned by the selected scope.

Visual explanation

flowchart LR
  UI["All Changes header<br/>scope: branch | uncommitted"] --> HOOK[useSessionAllChangesDiffData]
  HOOK -->|"batch + scope"| PROVIDER[CodeCollabSessionFileProvider]
  PROVIDER --> RPC[loro-streams-rpc]
  RPC --> SERVICE[CodeCollabV2Service]
  SERVICE -->|branch| MB["merge-base(base, HEAD) -> disk + untracked"]
  SERVICE -->|uncommitted| HEAD["HEAD -> disk: staged + unstaged + untracked"]
  SERVICE -->|"no Git / no HEAD"| ERR[explicit unavailable]
  HOOK -->|"deferred + scope"| DEFER[useSessionConversationDiffData]
  DEFER -->|"open-current-diff + scope"| SERVICE
Loading

Before / after

Before After
The All Changes base was never named. The header shows the scope and the resolved base (HEAD · abcdef1, Branch base · 1234567, or Session changes).
Committed branch work remained in the only diff view. A second scope shows only uncommitted changes; committing clears that view.
A repository without HEAD silently listed only untracked files. It reports an explicit no_commits state.
Deferred per-file reads always used the branch base. Deferred reads carry the same scope and never mix bases.

Test plan

  • pnpm --dir apps/cli exec vitest run — 4392 passed, 4 skipped on the merged base.
  • pnpm --dir packages/components exec vitest run tests/code-collab-session-file-provider-v2.test.ts tests/session-conversation-diff-panel.test.tsx tests/use-session-conversation-diff-data.test.tsx — 41 passed.
  • pnpm --filter @lody/components typecheck, pnpm --filter @lody/shared typecheck, pnpm --filter @lody/loro-streams-rpc typecheck — passed.
  • pnpm --filter lody typecheck fails on origin/main (796f42c) in apps/cli/src/lib/loro/doc.ts because the pinned loro-repo@0.23.2 type has no runLegacy / acquireScopeLegacy. The same failure reproduces on a clean origin/main checkout and is unrelated to this change.
  • pnpm lint:i18n, oxlint, oxfmt --check, pnpm run docs check, pnpm check:code-collab-imports, pnpm check:platform-boundaries — passed.
  • Storybook: toggled AllChangesScopeSwitch in a browser; the base label changed to HEAD · abcdef1 and the file set shrank to the uncommitted entries.
  • The full components suite still has one unrelated pre-existing failure in tests/boot-shell.test.tsx, reproduced on clean origin/main with the changes stashed.

Context handoff

Original user prompt

Show original prompt
https://github.com/LodyAI/Lody/issues/1664

Shared conversation

Status: unavailable
Reason: Claude desktop app (Code tab) — the author reports that surface cannot publish a public conversation link.

刘耀文 added 2 commits October 19, 2026 15:53
Thread an optional branch/uncommitted scope through the batched and
per-file Code Collab diff requests. Uncommitted compares HEAD with disk,
reports explicit non-Git/unborn states, and never falls back to turn
evidence snapshots. The diff header shows the scope and resolved base,
gated by the codeCollabAllChangesScope capability.

Refs LodyAI#1664

Model: claude-sonnet-5[1m]

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] 明确工作区 diff 比较基准并支持仅查看未提交修改

1 participant