Skip to content

Wire up workspace_integrate_upstream API for stack rebase and upstream integration#13678

Draft
mtsgrd wants to merge 1 commit into
masterfrom
add-rebase-stack-modal
Draft

Wire up workspace_integrate_upstream API for stack rebase and upstream integration#13678
mtsgrd wants to merge 1 commit into
masterfrom
add-rebase-stack-modal

Conversation

@mtsgrd
Copy link
Copy Markdown
Contributor

@mtsgrd mtsgrd commented May 6, 2026

Summary

  • Adopt the workspace_integrate_upstream API for upstream integration in the desktop app
  • Refactor IntegrateUpstreamModal from imperative fetching to reactive query subscriptions with ReduxResult
  • Expose bottom_selector on StackStatus so the frontend can construct BottomUpdate selectors
  • Add e2e tests for "leave as is" behavior and branch base assertions

Test plan

  • All 7 upstream integration e2e tests pass
  • "Leave as is" test verifies branch base is unchanged while rebased branches advance
  • Manual: open integrate modal, verify per-stack resolution picker works (rebase/merge/leave as is)

🤖 Generated with Claude Code

@mtsgrd mtsgrd force-pushed the add-rebase-stack-modal branch from 36effc6 to 7c228ad Compare May 7, 2026 14:57
@mtsgrd mtsgrd changed the title [wip] Add stack-level rebase context menu item Wire up workspace_integrate_upstream API for stack rebase and upstream integration May 8, 2026
@mtsgrd mtsgrd force-pushed the add-rebase-stack-modal branch from 7c228ad to 93001e3 Compare May 8, 2026 13:42
@github-actions github-actions Bot added the rust Pull requests that update Rust code label May 8, 2026
@mtsgrd mtsgrd force-pushed the add-rebase-stack-modal branch 2 times, most recently from 90da8d5 to 576b1a6 Compare May 8, 2026 14:12
@mtsgrd
Copy link
Copy Markdown
Contributor Author

mtsgrd commented May 8, 2026

@Caleb-T-Owens is the new API ready for the svelte app to migrate?

@mtsgrd mtsgrd force-pushed the add-rebase-stack-modal branch 7 times, most recently from 94ff5eb to 0915fca Compare May 12, 2026 16:55
@github-actions github-actions Bot added the CLI The command-line program `but` label May 12, 2026
@mtsgrd mtsgrd force-pushed the add-rebase-stack-modal branch 2 times, most recently from 3432a4a to f21d42c Compare May 12, 2026 19:27
**`IntegrateUpstreamModal` refactor:**
- Migrated from old Resolution API to `BottomUpdate[]` API
- Imperative status fetch → reactive `useQuery` subscription
  (auto-invalidates on background fetch)
- Wrapped statuses section in `<ReduxResult>` for loading/error handling

**Backend (`upstream_integration.rs`):**
- Exposed `bottom_selector` on `StackStatus` for building
  `BottomUpdate`s

**E2E tests:**
- "Leave as is" preserves branch base while other branches advance
- Helpers: `openIntegrateModal()`, `integrationRow()`, `getBranchBase()`

**Cleanup:**
- Merged `UpstreamIntegrationService` into `stackService` — upstream
  status queries and mutations now live alongside other stack operations
- Removed `StackStatusesWithBranchesV3` type and
  `getBaseBranchResolution` (joining now happens in the modal)
- Deleted old `integrate_upstream` endpoint and dead code in
  `branchEndpoints.ts`

Return stack status entries instead of full stack objects

The API already returns status entries keyed by stack ID, so adjust the
component to use those entries directly instead of trying to join with a
separate stacks list. This simplifies logic, avoids relying on
getStackName/getStack lookup, and fixes incorrect data assumptions
implied by combineWithStacks. Changes: parse status entries from the
API, sort by integration state and branch name, update resolution kind
handling, build BottomUpdate payloads from stack IDs, and update the
template to iterate over status entries.

Accept Option<StackId> throughout upstream status handling

Revert earlier change that propagated StackId instead of Option<StackId>
and instead update codepaths to continue accepting Optional stack IDs
while preserving the optimizations made. Many functions, data
structures, iterations and tests were adjusted to use StackStatus with
an optional stack_id field (or to pattern-match the existing Option
inside loops) so we can keep nullable stack identifiers at the
API/schema boundary while simplifying internal handling and avoiding
unwraps. Changes include: UI Svelte component iteration and resolution
handling, Rust CLI/status/pull modules iteration and lookups, the
StackStatus struct and serialization/schema updates, callers of
get_stack_status to pass stack_id through, and numerous tests updated to
reference status.stack_id instead of tuple-based (Option, Status)
indexing.

Use but-graph for workspace upstream statuses

Replace legacy upstream integration path with a new implementation that
uses the but-graph workspace projection to compute per-stack upstream
integration statuses and worktree conflicts. This moves logic out of
gitbutler-branch-actions into a new workspace/upstream_statuses module,
updates callers to invoke the new function, and makes
StackStatus::create public to support the new flow. The change avoids
the old stack_details_v3 path and performs trial rebases and three-way
merges against the graph-derived workspace to determine conflicts and
integration state.

Remove legacy upstream integration APIs and code

Remove all callers and implementations of the legacy integrate_upstream
and upstream statuses APIs. These endpoints and helper functions have
been deleted from the server, tauri bindings, tests, and the
gitbutler-branch-actions crate; upstream integration status computation
and workspace integration are now handled by the newer workspace APIs
(e.g. but_api::workspace::workspace_integrate_upstream and
but_api::workspace::upstream_statuses). This cleans up dead legacy code,
removes unused types and tests, and updates call sites to use the new
workspace-oriented APIs.

Move upstream integration types into but-api workspace

Move the upstream integration types into but-api::workspace and update
all callers to import them from the new location. This removes the
legacy re-export from gitbutler-branch-actions and converts the
workspace module to expose a dedicated upstream_integration submodule.
The change updates imports across but, but-api, and
gitbutler-branch-actions (including virtual_branches, status, and pull
command code) to reference
but_api::workspace::upstream_integration::{...} and wires
upstream_statuses to use the relocated types.
@mtsgrd mtsgrd force-pushed the add-rebase-stack-modal branch from f21d42c to 2fe9438 Compare May 12, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLI The command-line program `but` @gitbutler/desktop rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant