Skip to content

Use head_info rather than stacks or stack_details when possible#13904

Draft
Caleb-T-Owens wants to merge 4 commits into
masterfrom
caleb/use-head-info-rather-than-stacks
Draft

Use head_info rather than stacks or stack_details when possible#13904
Caleb-T-Owens wants to merge 4 commits into
masterfrom
caleb/use-head-info-rather-than-stacks

Conversation

@Caleb-T-Owens
Copy link
Copy Markdown
Contributor

We still need some usage of stacks for the branch listing page AFAIK, but using head_info for the main projection is a big help since it avoids the issues with some strange inconsistency issues between stack_details and stacks.

@Caleb-T-Owens Caleb-T-Owens force-pushed the caleb/use-head-info-rather-than-stacks branch from 4cbfd44 to f7e416e Compare May 20, 2026 14:16
@Caleb-T-Owens Caleb-T-Owens changed the base branch from master to caleb/head-info-has-gerrit-metadata May 20, 2026 14:16
@Caleb-T-Owens Caleb-T-Owens force-pushed the caleb/use-head-info-rather-than-stacks branch from f7e416e to 7a2e646 Compare May 20, 2026 15:04
Copy link
Copy Markdown
Member

@krlvi krlvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome!

@github-actions github-actions Bot added the rust Pull requests that update Rust code label May 20, 2026
@Caleb-T-Owens Caleb-T-Owens force-pushed the caleb/head-info-has-gerrit-metadata branch 2 times, most recently from e27c1f1 to deaeac0 Compare May 21, 2026 12:48
@Caleb-T-Owens Caleb-T-Owens force-pushed the caleb/use-head-info-rather-than-stacks branch from bae9c5e to 56545d8 Compare May 21, 2026 12:49
@slarse
Copy link
Copy Markdown
Contributor

slarse commented May 21, 2026

@Caleb-T-Owens Smoke tests failed with

Error: database is locked

Caused by:
    Error code 5: database is locked

That's not related to the code in this PR (see this comment) and probably a spurious error, but it's still worrying. My best guess is that it's the background sync interfering with the next command being executed. but is not great for scripting at the moment.

@Byron
Copy link
Copy Markdown
Collaborator

Byron commented May 21, 2026

I think there is a way to turn backtraces on with anyhow, so it can then show the origin of the error. Maybe RUST_BACKTRACE=full` would do the trick? Maybe there is more to it as well, might need some research.

Then once it's clear where this is happening, it can be fixed.
What might be happening here is that something doesn't obtain a repository RW-lock, so the database acts as sync mechanism, and slow-running opts take too long and trigger a busy timeout. Our own repository lock has no timeout.
But… that's just a guess.

@Caleb-T-Owens Caleb-T-Owens force-pushed the caleb/head-info-has-gerrit-metadata branch from deaeac0 to d59496a Compare May 22, 2026 17:19
@Caleb-T-Owens Caleb-T-Owens force-pushed the caleb/use-head-info-rather-than-stacks branch from 56545d8 to e638185 Compare May 22, 2026 17:19
@Caleb-T-Owens Caleb-T-Owens marked this pull request as ready for review May 22, 2026 17:20
Copilot AI review requested due to automatic review settings May 22, 2026 17:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the desktop app’s primary stack/stack-details projection from legacy stacks/stack_details commands to the newer head_info (RefInfo) API, introducing adapter utilities to map RefInfo into the existing “legacy” stack/branch details shapes used by the UI.

Changes:

  • Replaced stacks + stack_details RTK Query endpoints with a single head_info-backed workspaceDetails endpoint and updated StackService consumers accordingly.
  • Added headInfoAdapters (and unit tests) to transform RefInfo into WorkspaceDetails (entity state + derived per-stack details).
  • Removed legacy Tauri command registration/permissions for stacks and stack_details, and updated PostHog “high volume” command tracking to head_info.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/but-sdk/src/test.ts Updates SDK smoke test to use headInfo + listProjectsStateless.
crates/gitbutler-tauri/src/main.rs Stops registering stacks/stack_details as invokable Tauri commands.
crates/gitbutler-tauri/permissions/default.toml Removes stacks/stack_details from the default allowlist.
apps/desktop/src/lib/telemetry/posthog.ts Treats head_info as the high-volume command.
apps/desktop/src/lib/stacks/stackService.svelte.ts Switches stack/branch/commit selectors to read from workspaceDetails instead of legacy endpoints.
apps/desktop/src/lib/stacks/stackEndpoints.ts Replaces legacy endpoints with workspaceDetails query backed by head_info + adapters.
apps/desktop/src/lib/stacks/headInfoAdapters.ts New adapter layer transforming RefInfo into stack/stack-details entities.
apps/desktop/src/lib/stacks/headInfoAdapters.test.ts Adds Vitest coverage for the RefInfoWorkspaceDetails mapping.
apps/desktop/src/components/branchesPage/BranchesViewStack.svelte Switches branches-page stack lookup from “all stacks” to workspaceDetails stack lookup.

Comment thread apps/desktop/src/lib/stacks/headInfoAdapters.ts Outdated
Comment on lines +268 to +269
const stacks = stackSelectors.selectAll(workspaceDetails.stacks);
const stackIds = stacks.map((stack) => stack.id).filter(isDefined);
Comment thread apps/desktop/src/components/branchesPage/BranchesViewStack.svelte
Comment thread crates/gitbutler-tauri/src/main.rs
Comment thread crates/gitbutler-tauri/permissions/default.toml
Base automatically changed from caleb/head-info-has-gerrit-metadata to master May 22, 2026 17:31
We still need some usage of `stacks` for the branch listing page AFAIK, but using `head_info` for the main projection is a big help since it avoids the issues with some strange inconsistency issues between `stack_details` and `stacks`.
It’s a bit strange that we are implicitly linking the tauri frontend’s head_info call with this. Currently however we do need some consistency between the two so there is just one undestanding of what is being returned as a stack.

The tests needed updated since the fixture was technically in single branch / pegging mode and as such that single branch had stack ref_info attached, which I think is the expected behaviour.
@Caleb-T-Owens Caleb-T-Owens force-pushed the caleb/use-head-info-rather-than-stacks branch from e638185 to b585ad6 Compare May 22, 2026 17:44
Copilot AI review requested due to automatic review settings May 22, 2026 18:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.

Comment thread apps/desktop/src/lib/stacks/headInfoAdapters.ts Outdated
Comment thread apps/desktop/src/lib/stacks/stack.ts Outdated
Comment thread apps/desktop/src/lib/stacks/stack.ts Outdated
@Caleb-T-Owens Caleb-T-Owens marked this pull request as draft May 22, 2026 18:44
@Caleb-T-Owens
Copy link
Copy Markdown
Contributor Author

I've come into the realisation that my mapping layer to the old datastructures introduces a potential regression.

If you have a branch segment that doesn't have a reference, it fails hard.

Anon segments really need to be a first class supported entity, so I'm switching the frontend over to using the new datastructures which will allow us to properly support the scenario.

This ended up being important to do since it the datastructures don’t provide the same garutees (which they shouldn’t have been making in the first place)
@Caleb-T-Owens Caleb-T-Owens force-pushed the caleb/use-head-info-rather-than-stacks branch from c53bd00 to df8dd77 Compare May 23, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

@gitbutler/desktop rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants