Skip to content

fix(app): default review tab to the branch diff on feature branches#8

Draft
stroopc-owner wants to merge 1 commit into
devfrom
review-branch-default
Draft

fix(app): default review tab to the branch diff on feature branches#8
stroopc-owner wants to merge 1 commit into
devfrom
review-branch-default

Conversation

@stroopc-owner

Copy link
Copy Markdown

Problem

The Forge review tab showed the wrong git changes for a session on a pushed feature branch (reported: Forge task tsk-LlkvyXEfseuI, related to owner/Coder#614). The tab surfaced only an unrelated .opencode/package.json version bump, not the task's actual committed work.

Root cause: the review-tab change mode defaulted to git (working tree vs HEAD = uncommitted changes only) in packages/app/src/pages/session.tsx. After a Forge task commits and pushes, its real changes live in HEAD, so git mode shows nothing from them — only leftover working-tree drift.

That drift is itself expected: on startup opencode runs Npm.install(dir, { add: [{ name: '@opencode-ai/plugin', version: InstallationVersion }] }) for each .opencode dir (packages/opencode/src/config/config.ts). InstallationVersion is the running CLI version (1.17.11), so npm rewrites the monorepo's committed .opencode/package.json from ^1.14.18 to the pinned resolved version — which is what appeared as the "only" change.

Fix

Prefer the branch diff (current branch vs default branch = the session's committed work) as the auto-default review mode when a branch option is available, instead of git. An explicit user selection is preserved (new changesTouched flag) and only overridden when the chosen mode is no longer available.

Pure ordering/resolution logic is extracted to reviewChangeOptions / resolveReviewChangeMode in session/helpers.ts so it is unit-testable.

Tests

  • packages/app/src/pages/session/helpers.test.ts: 11 new cases covering option ordering (feature branch, default branch, missing metadata, no-git) and default resolution (auto-select branch, preserve explicit choice, fall back when unavailable, empty options).
  • bun test src/pages/session/helpers.test.ts → 21 pass / 0 fail.
  • bun typecheck → exit 0. oxlint on changed files → 0 errors.

Note (not fixed here)

The .opencode/package.json startup rewrite lives in the owner monorepo tooling; pinning @opencode-ai/plugin there would stop the drift at its source. Filed separately — this PR only fixes the review-tab base so the correct diff shows regardless.

The review tab defaulted to git mode (working tree vs HEAD), so a
session on a pushed feature branch showed only uncommitted drift (e.g.
opencode rewriting .opencode/package.json to pin @opencode-ai/plugin on
startup) instead of the branch's committed work. Prefer the branch diff
(branch vs default branch) as the auto-default when a branch option is
available, while preserving an explicit user selection.
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

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.

1 participant