GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(server): cached refs include a newly checked-out external branch by StiensWout · Pull Request #36626 · pingdotgg/t3code

fix(server): cached refs include a newly checked-out external branch #36626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
juliusmarminge merged 3 commits into pingdotgg:main from StiensWout:t3/fix-current-branch-ref-cache
Nov 14, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix(server): cached refs include a newly checked-out external branch #36626

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit Hold shift + click to select a range
ff9bf31
fix(server): cached branch lists include a branch created outside T3 …
StiensWout Nov 14, 2026
2a4afa9
refactor(server): reuse branchExists for the unlisted current branch
StiensWout Nov 14, 2026
2a7e779
Merge origin/main into t3/fix-current-branch-ref-cache
juliusmarminge Nov 14, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Next Next commit
fix(server): cached branch lists include a branch created outside T3 …
…Code

listRefs overlaid the freshly read HEAD only onto branches already in the
cached snapshot, so a branch created and checked out outside T3 Code went
missing until the snapshot refreshed. The current branch is now listed as
current even when the snapshot predates it, once HEAD has a commit.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: GPT 6.1 Sol <[email protected]>
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

@StiensWout @claude @codex
3 people committed Nov 14, 2026
commit ff9bf3182bc77779cf75e7fdb6287c6cd20d9fb1

There are no files selected for viewing

19 changes: 19 additions & 0 deletions 19 apps/server/src/vcs/GitVcsDriverCore.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,25 @@ it.effect("follows a checkout made outside the driver after refs were cached", (
).pipe(Effect.provide(layerTest)),
);

it.effect("includes a newly created external branch after refs were cached", () =>
Effect.scoped(
Effect.gen(function* () {
const cwd = yield* makeTmpDir();
const { initialBranch } = yield* initRepoWithCommit(cwd);
const driver = yield* GitVcsDriver.GitVcsDriver;
yield* driver.listRefs({ cwd });

yield* git(cwd, ["switch", "-c", "feature/outside"]);

const refs = (yield* driver.listRefs({ cwd })).refs;
const previous = refs.find((ref) => ref.name === initialBranch);
assert.isTrue(refs.find((ref) => ref.name === "feature/outside")?.current);
assert.isFalse(previous?.current);
assert.isNull(previous?.worktreePath ?? null);
}),
).pipe(Effect.provide(layerTest)),
);

it.effect.each(["on a branch", "detached", "unborn"] as const)(
"reads only the repository root for review requests that ignore the branch when %s",
(state) =>
Expand Down
35 changes: 34 additions & 1 deletion 35 apps/server/src/vcs/GitVcsDriverCore.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ interface GitRepositoryPaths {
}

interface GitRefsSnapshot {
readonly defaultBranch: string | null;
readonly localBranches: ReadonlyArray<VcsRef>;
readonly remoteBranches: ReadonlyArray<VcsRef>;
readonly hasPrimaryRemote: boolean;
Expand Down Expand Up @@ -4387,6 +4388,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
: left.ref.name.localeCompare(right.ref.name);

return {
defaultBranch,
localBranches: localBranches.toSorted(byRecencyThenName).map(({ ref }) => ref),
remoteBranches: remoteBranches.toSorted(byRecencyThenName).map(({ ref }) => ref),
hasPrimaryRemote: remoteNames.length > 0,
Expand Down Expand Up @@ -4497,6 +4499,20 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
yield* Cache.invalidate(repositoryPathsCache, repositoryPathsCacheKey);
});

const headHasCommit = (cwd: string) =>
executeGit(
"GitVcsDriver.listRefs.headCommit",
cwd,
["rev-parse", "--verify", "--quiet", "HEAD"],
{
timeoutMs: 5_000,
allowNonZeroExit: true,
},
).pipe(
Effect.map((result) => result.exitCode === 0),
Effect.orElseSucceed(() => false),
);

const listRefs: GitVcsDriver.GitVcsDriver["Service"]["listRefs"] = Effect.fn("listRefs")(
function* (input) {
const repositoryPaths = yield* resolveRepositoryPaths(input.cwd, input.refresh === true).pipe(
Expand Down Expand Up @@ -4527,7 +4543,23 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
{ concurrency: 2 },
);
const { worktreeRoot } = repositoryPaths;
const localBranches = snapshot.localBranches.map((ref) => {
// A branch created outside T3 Code after the snapshot is listed until the next refresh.
// An unborn HEAD names a branch that does not exist yet, so it needs a commit to count.
const currentBranchUnlisted =
currentBranch !== null && !snapshot.localBranches.some((ref) => ref.name === currentBranch);
const unlistedCurrentBranch: ReadonlyArray<VcsRef> =
currentBranchUnlisted && (yield* headHasCommit(input.cwd))
? [
{
name: currentBranch,
current: true,
isRemote: false,
isDefault: currentBranch === snapshot.defaultBranch,
worktreePath: worktreeRoot,
},
]
: [];
const listedBranches = snapshot.localBranches.map((ref) => {
const current = ref.name === currentBranch;
return {
...ref,
Expand All @@ -4542,6 +4574,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
current,
};
});
const localBranches = [...unlistedCurrentBranch, ...listedBranches];
const combinedBranches = input.includeMatchingRemoteRefs
? [...localBranches, ...snapshot.remoteBranches]
: dedupeRemoteBranchesWithLocalMatches([...localBranches, ...snapshot.remoteBranches]);
Expand Down
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.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.