Skip to content

Commit d1eb8f1

Browse files
committed
Replace hand-written TypeScript interfaces with ts-rs generated types
Add ts-rs derives to Rust structs in gitbutler-branch-actions, gitbutler-operating-modes, gitbutler-edit-mode, and but-api. The 26 generated types are exported from @gitbutler/core/api, replacing local hand-written interfaces across the desktop app. - #[cfg_attr(feature = "export-ts", derive(TS), ts(export))] per type - Manual TS impl for Id<KIND> so StackId natively resolves to "string" - Author renamed to BranchAuthor to avoid collision with author.rs::Author - branch.ts deleted; consumers now import directly from @gitbutler/core/api - Select.svelte made properly generic so typed options flow to onselect This session is being continued from a previous conversation that ran out of context. The summary below covers the earlier portion of the conversation. Summary: 1. Primary Request and Intent: The session continued from a prior context where hand-written TypeScript interfaces were replaced with ts-rs generated types. The explicit requests in this session were: - Fix `as` type casts introduced during the ts-rs migration (user called them a "code smell" and wanted types correctly assigned at network boundaries) - Review changes for low-hanging fruit improvements and update the commit message - Make `Select.svelte` properly generic using `Modal.svelte` as a reference pattern - Write a better, more succinct and clear commit message - Assess whether to reduce ts-rs annotation boilerplate - Determine if `crates/but-ts` can be used to generate types instead of ts-rs (most recent, pending) 2. Key Technical Concepts: - **ts-rs 11.1.0**: Rust crate deriving TypeScript types via `#[cfg_attr(feature = "export-ts", derive(ts_rs::TS), ts(export))]` - **but-ts**: Internal crate at `crates/but-ts` using `schemars::JsonSchema` + `but_schemars::register_sdk_type!()` + inventory pattern; generates all types from a single binary run; "intended to be the single solution for TypeScript type generation" - **schemars/JsonSchema**: Already used by many types in `gitbutler-branch-actions`; `but_schemars` provides field-level helpers: `object_id`, `object_id_vec`, `bstring_lossy`, `bstring_lossy_opt`, `stack_id`, `stack_id_opt`, `url`, etc. - **`export-schema` feature**: Already exists in `gitbutler-branch-actions`, `gitbutler-operating-modes`, `but-api`; propagated through feature deps - **`register_sdk_type!(TypeName)`** macro from `but-schemars`: Registers a type in the `inventory` collection for but-ts to discover - **Svelte 5 generics pattern**: `<script lang="ts" module>` for exported types (minimal, no `type T = string` alias), `<script lang="ts" generics="T extends string = string">` for instance with `Props` interface using real generic `T` - **Contravariance**: Why `(value: "rebase" | "merge" | "hardReset") => void` is NOT assignable to `(value: string) => void` - **`as const` inference**: Using `value: "rebase" as const` in options array to narrow `T` inference for generic `Select<T>` - **`SelectItemType`**: The `SelectItem` type from `Select.svelte` re-exported as `SelectItemType` from `packages/ui/src/lib/index.ts` - **GitButler CLI**: Using `gitbutler-tauri reword`, `gitbutler-tauri absorb` for commit management - **Cargo features additive**: Cargo features are unioned, not exclusive — key challenge for filtering but-ts output 3. Files and Code Sections: - **`apps/desktop/src/components/upstream/IntegrateUpstreamModal.svelte`** - Import fix: moved `BaseBranchResolutionApproach`, `Resolution`, `StackStatus` from `$lib/upstream/types` (not exported there) to `@gitbutler/core/api` - Removed `SelectItemType` import from `@gitbutler/ui` after Select.svelte was made generic - Added typed options with `as const` instead of `SelectItemType<>` annotation: ```ts const baseResolutionOptions = [ { label: "Rebase", value: "rebase" as const }, { label: "Merge", value: "merge" as const }, { label: "Hard reset", value: "hardReset" as const }, ]; ``` - Handler no longer needs cast: ```ts function handleBaseResolutionSelection(value: BaseBranchResolutionApproach["type"]) { baseResolutionApproach = { type: value }; } ``` - Second Select's inline callback cast removed: ```ts onselect={(value) => { const result = results.get(stackId)!; results.set(stackId, { ...result, approach: { type: value } }); }} ``` - Template uses `options={baseResolutionOptions}` (variable, not inline array) - **`packages/ui/src/lib/components/select/Select.svelte`** - **Critical fix**: Made properly generic by moving `Props` and `Modifiers` from module script to instance script - Module script now only exports `SelectItem<T>` type: ```ts <script lang="ts" module> export type SelectItem<T extends string = string> = { label?: string; value?: T; selectable?: boolean; separator?: boolean; [key: string]: any; } & ( | { separator: true } | { label: string; value: T } ); </script> ``` - Instance script now has real generic `T` with `Props` using it: ```ts <script lang="ts" generics="T extends string = string"> type Modifiers = { shift: boolean; ctrl: boolean; alt: boolean; meta: boolean }; interface Props { options: readonly SelectItem<T>[]; value?: T; onselect?: (value: T, modifiers?: Modifiers) => void; itemSnippet: Snippet<[{ item: SelectItem<T>; highlighted: boolean; idx: number }]>; // ... all other props } </script> ``` - Added `= string` default to generic declaration for backwards compat - **`packages/core/src/generated/index.ts`** - Contains existing namespace exports (CoreRefMetadata, Workspace, HunkAssignment, etc.) PLUS our 26 flat legacy type exports - Currently has individual `export type { X } from "./X"` lines for each of the 26 types - Will need to change to `export * from "./legacy"` when migrating to but-ts - **`packages/core/src/generated/upstream_integration/index.ts`** - **Deleted** — was stale leftover not re-exported from main index - **`apps/desktop/src/lib/branches/branchListing.ts`** - Linter-cleaned: removed unused imports `BranchListingDetails`, `StackReference`, `BranchAuthor`, local `type Author = BranchAuthor` alias; only `BranchListing` import remained - **`crates/but-ts/src/main.rs`** - Full content read; uses `inventory::iter::<SchemarEntry>()` to collect ALL registered types - Generates flat `export type X = ...;` TypeScript declarations - Accepts `--output` path; appends to existing file if present - Challenge: generates ALL registered types with no filtering mechanism — needs `--source-crates` filter added - **`crates/but-schemars/src/lib.rs`** - Available helpers for field annotations: `object_id`, `object_id_vec`, `bstring_lossy`, `bstring_lossy_opt`, `stack_id`, `stack_id_opt`, `url`, `object_id_opt`, etc. - **`crates/gitbutler-branch-actions/src/branch.rs`** - Types with BOTH export-ts AND export-schema already: `BranchListingFilter`, `BranchListing`, `Author` (renamed BranchAuthor), `StackReference` - `BranchListingDetails`: has export-ts ONLY, needs export-schema + `register_sdk_type!()` added - **`crates/gitbutler-branch-actions/src/base.rs`** - `BaseBranch`: has export-ts only; needs JsonSchema derive + field annotations for `base_sha`, `current_sha` (→ `but_schemars::object_id`), `diverged_ahead`, `diverged_behind` (→ `but_schemars::object_id_vec`) - **`crates/gitbutler-branch-actions/src/remote.rs`** - `RemoteCommit`: has export-ts only; needs JsonSchema + annotations for `description` (→ `but_schemars::bstring_lossy`), `parent_ids` (→ `but_schemars::object_id_vec`) - **`crates/gitbutler-branch-actions/src/author.rs`** - `Author`: has export-ts only; needs JsonSchema + `but_schemars::url` for `gravatar_url: url::Url` - **`crates/gitbutler-branch-actions/src/reorder.rs`** - `StackOrder`, `SeriesOrder`: have export-ts only; `SeriesOrder` has `commit_ids: Vec<ObjectId>` needing `but_schemars::object_id_vec` - **`crates/gitbutler-branch-actions/src/upstream_integration.rs`** - 10 types all export-ts only: `NameAndStatus`, `StackStatus`, `TreeStatus`, `BranchStatus`, `StackStatuses`, `BaseBranchResolutionApproach`, `ResolutionApproach`, `BaseBranchResolution`, `IntegrationOutcome`, `Resolution` - `StackStatuses.UpdatesRequired` has `worktree_conflicts: Vec<BStringForFrontend>` (→ `schemars(with = "Vec<String>")`) and `statuses: Vec<(Option<StackId>, StackStatus)>` (→ `schemars(with = "Vec<(Option<String>, StackStatus)>")`) - `BaseBranchResolution` has `target_commit_oid: gix::ObjectId` (→ `but_schemars::object_id`) - **`crates/gitbutler-edit-mode/src/lib.rs`** (lines 347-354) - `ConflictEntryPresence`: export-ts only; simple bool struct, just needs JsonSchema + register - `gitbutler-edit-mode/Cargo.toml` needs `export-schema` feature added with schemars deps - **`crates/but-api/src/legacy/modes.rs`** - `HeadAndMode`, `HeadSha`: export-ts only; simple structs; `but-api` already has schemars as non-optional dep - **`crates/gitbutler-operating-modes/src/lib.rs`** - `EditModeMetadata`, `OutsideWorkspaceMetadata`, `OperatingMode`: already have BOTH export-ts AND export-schema — just remove export-ts - **`scripts/generate-ts-definitions-from-rust.sh`** - Currently: discovers crates with `export-ts` via `git grep`, runs `cargo test export_bindings` - Will need updating to use `cargo run -p but-ts -- --output ... --source-crates ...` 4. Errors and fixes: - **`Edit` tool failing on Unicode placeholder character**: The `IntegrateUpstreamModal.svelte` template had `"Choose…"` with a Unicode ellipsis. The Edit tool couldn't match the string. Fixed by using Python `re.sub` to do the replacement. - **`gitbutler-tauri reword` with stale commit ID**: After `absorb`, the commit hash changed. Had to re-run `git log` to get the new hash before rewording. - **Types imported from `$lib/upstream/types` that weren't exported there**: `BaseBranchResolutionApproach`, `Resolution`, `StackStatus` were imported in IntegrateUpstreamModal but not exported from types.ts. Fixed by importing directly from `@gitbutler/core/api`. 5. Problem Solving: - **As-cast elimination**: Rather than leaving `as BaseBranchResolutionApproach` in the handler, made `Select.svelte` properly generic so TypeScript infers `T` from the typed `options` array and `onselect` gets the narrowed type automatically. - **but-ts output filtering**: Key challenge is that but-ts generates ALL registered types (workspace, hunk-assignment, etc.) not just the 26 legacy ones. Proposed solution: add `--source-crates` CLI filter to but-ts that filters `CollectedSchemarEntry` by `type_name` prefix (e.g., `gitbutler_branch_actions`, `gitbutler_operating_modes`, etc.). This avoids Cargo feature complexity since features are additive. - **Duplicate type concern**: Workspace types are already exported as namespaces (`export * as Workspace`); if but-ts also generates them flat, there would be redundancy. The `--source-crates` filter solves this. 6. All user messages: - (Continuing from previous session) "I see you've introduced some type casting, 'AS ...', which is a bit of a code smell. Could you go through each of them and make sure the type is correctly assigned where the data is received over the network." - "Awesome. Can we review these changes for any low hanging fruit, and then update the commit message once more to be succinct and clear as to what we're changing." - "please continue" (after simplify skill launched review agents) - "Let's try and write a better commit message?" - "Can we fix the type error in `apps/desktop/src/components/upstream/IntegrateUpstreamModal.svelte` by making Select.svelte generic? As an example of a generic you can look at `packages/ui/src/lib/components/Modal.svelte`." - "please continue" (after Select.svelte generic was started) - "is there any way we can reduce the need for annotations?" - "Can we us the crate `crates/but-ts` to generate these types instead of `ts-rs`?" 7. Pending Tasks: - **Migrate from ts-rs to but-ts**: The full migration plan is ready but not yet implemented: 1. Add `--source-crates` filter to `crates/but-ts/src/main.rs` 2. Add `JsonSchema` + `register_sdk_type!()` to 16 types missing it (BranchListingDetails, BaseBranch, RemoteCommit, Author/author.rs, StackOrder, SeriesOrder, NameAndStatus, StackStatus, TreeStatus, BranchStatus, StackStatuses, BaseBranchResolutionApproach, ResolutionApproach, BaseBranchResolution, IntegrationOutcome, Resolution, ConflictEntryPresence, HeadAndMode, HeadSha) 3. Remove `export-ts` annotations from all 26 types (including 7 that already have export-schema) 4. Add `export-schema` feature to `gitbutler-edit-mode/Cargo.toml` 5. Add `gitbutler-edit-mode/export-schema` to `but-api/Cargo.toml` export-schema feature 6. Remove ts-rs deps from all affected Cargo.toml files 7. Update `scripts/generate-ts-definitions-from-rust.sh` to use but-ts 8. Update `packages/core/src/generated/index.ts` to `export * from "./legacy"` instead of 26 individual exports 9. Delete the 26 individual `.ts` files in `packages/core/src/generated/` 10. Remove `Id<KIND>` ts-rs impl from `crates/but-core/src/id.rs` 8. Current Work: The user asked "Can we use the crate `crates/but-ts` to generate these types instead of `ts-rs`?" The assistant was in the process of: - Reading all relevant Rust source files to understand what changes are needed - Had read: `crates/but-ts/src/main.rs` (full), `crates/but-api/Cargo.toml` (export-schema feature), `gitbutler-branch-actions/Cargo.toml` (full), `base.rs`, `remote.rs`, `author.rs`, `reorder.rs` (partial), `upstream_integration.rs` (first 140 lines), `gitbutler-edit-mode/src/lib.rs` (ConflictEntryPresence section), `but-api/src/legacy/modes.rs` (lines 1-55), `but-schemars/src/lib.rs` (helpers list) - Had identified the complete migration plan - Was about to start implementing changes to Cargo.toml files when the summary was requested The key architectural insight reached: but-ts needs a `--source-crates` filter added to `main.rs` so that when running for the desktop app, only types from `gitbutler_branch_actions`, `gitbutler_operating_modes`, `gitbutler_edit_mode`, and `but_api::legacy` are included — avoiding types from workspace/hunk-assignment that are already exported via namespace exports in `index.ts`. 9. Optional Next Step: The next step is to implement the migration from ts-rs to but-ts, starting with the modification to `crates/but-ts/src/main.rs` to add a `--source-crates` filter argument. The user explicitly asked: "Can we use the crate `crates/but-ts` to generate these types instead of `ts-rs`?" The `parse_args()` function in `crates/but-ts/src/main.rs` needs a new `--source-crates` parameter, and `collect_all_schemas()` needs to filter `CollectedSchemarEntry` by checking if `type_name` starts with any of the provided crate name prefixes (using underscores, e.g., `gitbutler_branch_actions`). Then Cargo.toml changes follow (gitbutler-edit-mode adding export-schema, but-api adding edit-mode to export-schema, removing ts-rs deps), then Rust source file annotation changes, then the generate script update, then TypeScript cleanup. If you need specific details from before compaction (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/mattias/.claude/projects/-Users-mattias-c-gitbutler/06093e43-f260-4a3b-bc3e-a36b2b3523a1.jsonl Continue the conversation from where it left off without asking the user any further questions. Resume directly — do not acknowledge the summary, do not recap what was happening, do not preface with "I'll continue" or similar. Pick up the last task as if the break never happened.
1 parent 222bcce commit d1eb8f1

34 files changed

Lines changed: 645 additions & 276 deletions

File tree

Cargo.lock

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/desktop/src/components/branchesPage/BranchListCard.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script lang="ts">
22
import BranchesCardLayout from "$components/branchesPage/BranchesCardLayout.svelte";
3-
import { type BranchListing, type BranchListingDetails } from "$lib/branches/branchListing";
43
import { BRANCH_SERVICE } from "$lib/branches/branchService.svelte";
54
import { GIT_CONFIG_SERVICE } from "$lib/config/gitConfigService";
65
import { getPrStatus } from "$lib/forge/interface/prUtils";
@@ -11,6 +10,7 @@
1110
import { gravatarUrlFromEmail } from "@gitbutler/ui/components/avatar/gravatar";
1211
import type { ReviewUnitInfo } from "$lib/forge/interface/forgePrService";
1312
import type { PullRequest } from "$lib/forge/interface/types";
13+
import type { BranchListing, BranchListingDetails } from "@gitbutler/core/api";
1414
1515
interface Props {
1616
reviewUnit: ReviewUnitInfo | undefined;

apps/desktop/src/components/upstream/IntegrateUpstreamModal.svelte

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@
66
import { DEFAULT_FORGE_FACTORY } from "$lib/forge/forgeFactory.svelte";
77
import {
88
getBaseBranchResolution,
9-
type BaseBranchResolutionApproach,
10-
type Resolution,
11-
type StackStatus,
129
stackFullyIntegrated,
13-
type BranchStatus,
1410
sortStatusInfoV3,
1511
getResolutionApproachV3,
1612
type StackStatusInfoV3,
@@ -40,9 +36,14 @@
4036
import { tick } from "svelte";
4137
import { SvelteMap } from "svelte/reactivity";
4238
import type { PullRequest } from "$lib/forge/interface/types";
39+
import type {
40+
BaseBranchResolutionApproach,
41+
BranchStatus,
42+
Resolution,
43+
StackStatus,
44+
} from "@gitbutler/core/api";
4345
4446
type OperationState = "inert" | "loading" | "completed";
45-
type OperationType = "rebase" | "merge" | "unapply" | "delete";
4647
4748
interface Props {
4849
projectId: string;
@@ -64,6 +65,11 @@
6465
let integratingUpstream = $state<OperationState>("inert");
6566
const results = new SvelteMap<string, Resolution>();
6667
let statuses = $state<StackStatusInfoV3[]>([]);
68+
const baseResolutionOptions = [
69+
{ label: "Rebase", value: "rebase" as const },
70+
{ label: "Merge", value: "merge" as const },
71+
{ label: "Hard reset", value: "hardReset" as const },
72+
];
6773
let baseResolutionApproach = $state<BaseBranchResolutionApproach | undefined>();
6874
let targetCommitOid = $state<string | undefined>(undefined);
6975
let branchStatuses = $state<StackStatusesWithBranchesV3 | undefined>();
@@ -132,7 +138,7 @@
132138
upstreamIntegrationService
133139
.resolveUpstreamIntegrationMutation({
134140
projectId,
135-
resolutionApproach: { type: baseResolutionApproach },
141+
resolutionApproach: baseResolutionApproach,
136142
})
137143
.then((result) => {
138144
targetCommitOid = result;
@@ -174,16 +180,16 @@
174180
return `integrate-upstream-modal:dont-delete-branch:${projectId}:${branchName}`;
175181
}
176182
177-
function handleBaseResolutionSelection(value: string) {
178-
baseResolutionApproach = value as BaseBranchResolutionApproach;
183+
function handleBaseResolutionSelection(value: BaseBranchResolutionApproach["type"]) {
184+
baseResolutionApproach = { type: value };
179185
}
180186
181187
async function integrate() {
182188
integratingUpstream = "loading";
183189
await tick();
184190
const baseResolution = getBaseBranchResolution(
185191
targetCommitOid,
186-
baseResolutionApproach || "hardReset",
192+
baseResolutionApproach ?? { type: "hardReset" },
187193
);
188194
189195
await integrateUpstream({
@@ -314,7 +320,7 @@
314320
maxWidth={130}
315321
onselect={(value) => {
316322
const result = results.get(stackId)!;
317-
results.set(stackId, { ...result, approach: { type: value as OperationType } });
323+
results.set(stackId, { ...result, approach: { type: value } });
318324
}}
319325
options={integrationOptions(stackStatus)}
320326
>
@@ -405,14 +411,10 @@
405411

406412
<div class="target-divergence-action">
407413
<Select
408-
value={baseResolutionApproach}
414+
value={baseResolutionApproach?.type}
409415
placeholder="Choose…"
410416
onselect={handleBaseResolutionSelection}
411-
options={[
412-
{ label: "Rebase", value: "rebase" },
413-
{ label: "Merge", value: "merge" },
414-
{ label: "Hard reset", value: "hardReset" },
415-
]}
417+
options={baseResolutionOptions}
416418
>
417419
{#snippet itemSnippet({ item, highlighted })}
418420
<SelectItem selected={highlighted} {highlighted}>

apps/desktop/src/components/workspace/EditCommitPanel.svelte

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
import ReduxResult from "$components/shared/ReduxResult.svelte";
55
import { getEditorUri, URL_SERVICE } from "$lib/backend/url";
66
import { splitMessage } from "$lib/commits/commitMessage";
7-
import {
8-
conflictEntryHint,
9-
getConflictState,
10-
type ConflictEntryPresence,
11-
} from "$lib/files/conflictEntryPresence";
7+
import { conflictEntryHint, getConflictState } from "$lib/files/conflictEntryPresence";
128
import { FILE_SERVICE } from "$lib/files/fileService";
139
import { computeChangeStatus } from "$lib/files/fileStatus";
14-
import { MODE_SERVICE, type EditModeMetadata } from "$lib/mode/modeService";
10+
import { MODE_SERVICE } from "$lib/mode/modeService";
1511
import { vscodePath } from "$lib/project/project";
1612
import { PROJECTS_SERVICE } from "$lib/project/projectsService";
1713
import { createCommitSelection } from "$lib/selection/key";
@@ -35,6 +31,8 @@
3531
import { derived, fromStore, readable, toStore, type Readable } from "svelte/store";
3632
import type { FileInfo } from "$lib/files/file";
3733
import type { TreeChange } from "$lib/hunks/change";
34+
import type { EditModeMetadata } from "@gitbutler/core/api";
35+
import type { ConflictEntryPresence } from "@gitbutler/core/api";
3836
import type { FileStatus } from "@gitbutler/ui/components/file/types";
3937
4038
type Props = {

apps/desktop/src/lib/branches/branch.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

apps/desktop/src/lib/branches/branchEndpoints.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@ import {
77
} from "$lib/state/tags";
88
import { createEntityAdapter, type EntityState } from "@reduxjs/toolkit";
99
import type { BaseBranch, ForgeProvider, RemoteBranchInfo } from "$lib/baseBranch/baseBranch";
10-
import type { BranchListing, BranchListingDetails } from "$lib/branches/branchListing";
1110
import type { BackendEndpointBuilder } from "$lib/state/backendApi";
1211
import type {
1312
BaseBranchResolution,
1413
BaseBranchResolutionApproach,
15-
BranchStatusesResponse,
14+
BranchListing,
15+
BranchListingDetails,
1616
IntegrationOutcome,
1717
Resolution,
18-
} from "$lib/upstream/types";
18+
StackStatuses,
19+
} from "@gitbutler/core/api";
1920

2021
export function buildBranchEndpoints(build: BackendEndpointBuilder) {
2122
return {
@@ -102,7 +103,7 @@ export function buildBranchEndpoints(build: BackendEndpointBuilder) {
102103

103104
// ── Upstream Integration ─────────────────────────────────────
104105
upstreamIntegrationStatuses: build.query<
105-
BranchStatusesResponse,
106+
StackStatuses,
106107
{ projectId: string; targetCommitOid?: string }
107108
>({
108109
extraOptions: { command: "upstream_integration_statuses" },
@@ -130,7 +131,7 @@ export function buildBranchEndpoints(build: BackendEndpointBuilder) {
130131
}),
131132
resolveUpstreamIntegration: build.mutation<
132133
string,
133-
{ projectId: string; resolutionApproach: { type: BaseBranchResolutionApproach } }
134+
{ projectId: string; resolutionApproach: BaseBranchResolutionApproach }
134135
>({
135136
extraOptions: {
136137
command: `resolve_upstream_integration`,

apps/desktop/src/lib/branches/branchListing.ts

Lines changed: 1 addition & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,13 @@
11
import { msSinceDaysAgo } from "$lib/utils/time";
22
import { isDefined } from "@gitbutler/ui/utils/typeguards";
33
import type { ForgeUser, PullRequest } from "$lib/forge/interface/types";
4+
import type { BranchListing } from "@gitbutler/core/api";
45

56
export type GroupedSidebarEntries = Record<
67
"applied" | "authored" | "review" | "today" | "yesterday" | "lastWeek" | "older",
78
SidebarEntrySubject[]
89
>;
910

10-
/**
11-
* Represents a branch that exists for the repository
12-
* This also combines the concept of a remote, local and virtual branch in order to provide a unified interface for the UI
13-
* Branch entry is not meant to contain all of the data a branch can have (e.g. full commit history, all files and diffs, etc.).
14-
* It is intended a summary that can be quickly retrieved and displayed in the UI.
15-
* For more detailed information, each branch can be queried individually for it's `BranchData`.
16-
*/
17-
export type BranchListing = {
18-
/** The name of the branch (e.g. `main`, `feature/branch`), excluding the remote name */
19-
name: string;
20-
/**
21-
* This is a list of remote that this branch can be found on (e.g. `origin`, `upstream` etc.).
22-
* If this branch is a local branch, this list will be empty.
23-
*/
24-
remotes: string[];
25-
/** The branch may or may not have a virtual branch associated with it */
26-
stack?: StackReference | undefined;
27-
/**
28-
* Timestamp in milliseconds since the branch was last updated.
29-
* This includes any commits, uncommitted changes or even updates to the branch metadata (e.g. renaming).
30-
*/
31-
updatedAt: string;
32-
/** The person who committed the head commit */
33-
lastCommiter: Author;
34-
/** Whether or not there is a local branch as part of the grouping */
35-
hasLocal: boolean;
36-
};
37-
38-
/** Represents a reference to an associated virtual branch */
39-
export type StackReference = {
40-
/** A non-normalized name of the branch, set by the user */
41-
givenName: string;
42-
/** Virtual Branch UUID identifier */
43-
id: string;
44-
/** Determines if the virtual branch is applied in the workspace */
45-
inWorkspace: boolean;
46-
/**
47-
List of branch names that are part of the stack
48-
Ordered from newest to oldest (the most recent branch is first in the list)
49-
*/
50-
branches: string[];
51-
/** Pull Request numbes by branch name associated with the stack */
52-
pullRequests: Record<string, number>;
53-
};
54-
55-
/** Represents a "commit author" or "signature", based on the data from there git history */
56-
export type Author = {
57-
/** The name of the author as configured in the git config */
58-
name?: string | undefined;
59-
/** The email of the author as configured in the git config */
60-
email?: string | undefined;
61-
/** The gravatar id of the author */
62-
gravatarUrl?: string | undefined;
63-
};
64-
65-
/** Represents a fat struct with all the data associated with a branch */
66-
export interface BranchListingDetails {
67-
/** The name of the branch (e.g. `main`, `feature/branch`), excluding the remote name */
68-
name: string;
69-
/**
70-
* The number of lines added within the branch
71-
* Since the virtual branch, local branch and the remote one can have different number of lines removed,
72-
* the value from the virtual branch (if present) takes the highest precedence,
73-
* followed by the local branch and then the remote branches (taking the max if there are multiple).
74-
* If this branch has a virtual branch, lines_added does NOT include the uncommitted lines.
75-
*/
76-
linesAdded: number;
77-
/**
78-
* The number of lines removed within the branch
79-
* Since the virtual branch, local branch and the remote one can have different number of lines removed,
80-
* the value from the virtual branch (if present) takes the highest precedence,
81-
* followed by the local branch and then the remote branches (taking the max if there are multiple)
82-
* If this branch has a virtual branch, lines_removed does NOT include the uncommitted lines.
83-
*/
84-
linesRemoved: number;
85-
/**
86-
* The number of files that were modified within the branch
87-
* Since the virtual branch, local branch and the remote one can have different number files modified,
88-
* the value from the virtual branch (if present) takes the highest precedence,
89-
* followed by the local branch and then the remote branches (taking the max if there are multiple)
90-
*/
91-
numberOfFiles: number;
92-
/**
93-
* The number of commits associated with a branch
94-
* Since the virtual branch, local branch and the remote one can have different number of commits,
95-
* the value from the virtual branch (if present) takes the highest precedence,
96-
* followed by the local branch and then the remote branches (taking the max if there are multiple)
97-
*/
98-
numberOfCommits: number;
99-
/**
100-
* A list of authors that have contributes commits to this branch.
101-
* In the case of multiple remote tracking branches, it takes the full list of unique authors.
102-
*/
103-
authors: Author[];
104-
/** The branch may or may not have a virtual branch associated with it */
105-
stack?: StackReference | undefined;
106-
}
107-
10811
type PullRequestEntrySubject = {
10912
type: "pullRequest";
11013
subject: PullRequest;

apps/desktop/src/lib/dragging/stackingReorderDropzoneManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { CommitDropData } from "$lib/dragging/dropHandlers/commitDropHandler";
22
import { InjectionToken } from "@gitbutler/core/context";
3-
import type { StackOrder } from "$lib/branches/branch";
43
import type { DropzoneHandler } from "$lib/dragging/handler";
54
import type { StackService } from "$lib/stacks/stackService.svelte";
5+
import type { StackOrder } from "@gitbutler/core/api";
66

77
export class ReorderCommitDzHandler implements DropzoneHandler {
88
constructor(

apps/desktop/src/lib/files/conflictEntryPresence.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
export interface ConflictEntryPresence {
2-
ours: boolean;
3-
theirs: boolean;
4-
ancestor: boolean;
5-
}
1+
export type { ConflictEntryPresence } from "@gitbutler/core/api";
2+
import type { ConflictEntryPresence } from "@gitbutler/core/api";
63

74
export function emptyConflictEntryPresence(): ConflictEntryPresence {
85
return {

apps/desktop/src/lib/files/conflicts.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import {
2-
emptyConflictEntryPresence,
3-
type ConflictEntryPresence,
4-
} from "$lib/files/conflictEntryPresence";
1+
import { emptyConflictEntryPresence } from "$lib/files/conflictEntryPresence";
2+
import type { ConflictEntryPresence } from "@gitbutler/core/api";
53

64
export class ConflictEntries {
75
public entries: Map<string, ConflictEntryPresence> = new Map();

0 commit comments

Comments
 (0)