fix(app): default review tab to the branch diff on feature branches#8
Draft
stroopc-owner wants to merge 1 commit into
Draft
fix(app): default review tab to the branch diff on feature branches#8stroopc-owner wants to merge 1 commit into
stroopc-owner wants to merge 1 commit into
Conversation
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.
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
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. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jsonversion 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) inpackages/app/src/pages/session.tsx. After a Forge task commits and pushes, its real changes live inHEAD, sogitmode 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.opencodedir (packages/opencode/src/config/config.ts).InstallationVersionis the running CLI version (1.17.11), so npm rewrites the monorepo's committed.opencode/package.jsonfrom^1.14.18to 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 (newchangesTouchedflag) and only overridden when the chosen mode is no longer available.Pure ordering/resolution logic is extracted to
reviewChangeOptions/resolveReviewChangeModeinsession/helpers.tsso 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.oxlinton changed files → 0 errors.Note (not fixed here)
The
.opencode/package.jsonstartup rewrite lives in the owner monorepo tooling; pinning@opencode-ai/pluginthere would stop the drift at its source. Filed separately — this PR only fixes the review-tab base so the correct diff shows regardless.