Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/desktop/src/components/BranchCommitList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
} else {
laneState.selection.set({ branchName, commitId, upstream, previewOpen: true });
}
projectState.stackId.set(stackId);
onselect?.();
}

Expand Down
9 changes: 1 addition & 8 deletions apps/desktop/src/components/CreateBranchModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
import dependentBranchSvg from '$components/stackTabs/assets/dependent-branch.svg?raw';
import newStackSvg from '$components/stackTabs/assets/new-stack.svg?raw';
import { STACK_SERVICE } from '$lib/stacks/stackService.svelte';
import { UI_STATE } from '$lib/state/uiState.svelte';
import { sleep } from '$lib/utils/sleep';
import { inject } from '@gitbutler/core/context';

import {
Expand All @@ -28,7 +26,6 @@

let { projectId, stackId }: Props = $props();
const stackService = inject(STACK_SERVICE);
const uiState = inject(UI_STATE);
const [createNewStack, stackCreation] = stackService.newStack;
const [createNewBranch, branchCreation] = stackService.newBranch;

Expand Down Expand Up @@ -84,14 +81,10 @@

async function addNew() {
if (createRefType === 'stack') {
const stack = await createNewStack({
await createNewStack({
projectId,
branch: { name: slugifiedRefName }
});
// Why is there a timing thing going on here? Without sleep you end
// up on stacks[0] after creating a new one.
await sleep(50);
uiState.project(projectId).stackId.set(stack.id);
createRefModal?.close();
} else {
if (!selectedStackId || !slugifiedRefName) {
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/src/components/FeedItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
{getDisplayNameForWorkflowKind(action.kind)}:
</span>

<FeedItemKind type="workflow" {projectId} kind={action.kind} />
<FeedItemKind type="workflow" kind={action.kind} />
</div>
{:else if isFeedMessage(action)}
{#if action.type === 'assistant'}
Expand Down Expand Up @@ -237,7 +237,7 @@
{#if action.toolCalls.length > 0}
<div class="action-item__content-tool-calls">
{#each action.toolCalls as toolCall}
<FeedItemKind type="tool-call" {projectId} {toolCall} />
<FeedItemKind type="tool-call" {toolCall} />
{/each}
</div>
{/if}
Expand Down
7 changes: 1 addition & 6 deletions apps/desktop/src/components/FeedItemKind.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import type { WorkflowKind } from '$lib/actions/types';

interface BaseProps {
projectId: string;
type: 'workflow' | 'tool-call';
}

Expand All @@ -23,30 +22,26 @@

type Props = WorkflowProps | ToolCallProps;

const { projectId, ...rest }: Props = $props();
const { ...rest }: Props = $props();
const uiState = inject(UI_STATE);

let isExpanded = $state(false);

function selectCommit(stackId: string, branchName: string, commitId: string) {
const projectState = uiState.project(projectId);
const laneState = uiState.lane(stackId);
laneState.selection.set({
branchName,
commitId,
previewOpen: true
});
projectState.stackId.set(stackId);
}

function selectBranch(stackId: string, branchName: string) {
const projectState = uiState.project(projectId);
const laneState = uiState.lane(stackId);
laneState.selection.set({
branchName,
previewOpen: true
});
projectState.stackId.set(stackId);
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/components/FeedStreamMessage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<p class="vibing">Vibing</p>
<div class="stream-message__tool-calls">
{#each toolCalls as toolCall, index (index)}
<FeedItemKind type="tool-call" {projectId} {toolCall} />
<FeedItemKind type="tool-call" {toolCall} />
{/each}
</div>
{/if}
Expand Down
1 change: 0 additions & 1 deletion apps/desktop/src/components/NewCommitView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
branch: { name: finalBranchName, order: 0 }
});
finalStackId = stack.id;
projectState.stackId.set(finalStackId);
finalBranchName = stack.heads[0]?.name; // Updated to access the name property
uiState.global.draftBranchName.set(undefined);
}
Expand Down
8 changes: 2 additions & 6 deletions apps/desktop/src/lib/stacks/createAiStack.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ export function useCreateAiStack(projectId: Reactive<string>) {
}
});

// Because the ui state is updated asyncly, we need to let some time
// pass. This is far from a good solution to this problem.
await sleep(50);
uiState.project(pid).stackId.set(stack.id);
if (!stack.id) return;

const lane = uiState.lane(stack.id);
lane.selection.set({ codegen: true, branchName: stack.heads[0]?.name, previewOpen: true });

// I strongly dislike this sleep
// Because the ui state is updated asyncly, we need to let some time
// pass. This is far from a good solution to this problem.
await sleep(50);
focusClaudeInput(stack.id);
}
Expand Down
3 changes: 0 additions & 3 deletions apps/desktop/src/lib/stacks/macros.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ export default class StackMacros {
commitId: outcome.newCommit,
previewOpen: true
});

this.uiState.project(this.projectId).stackId.set(stack.id);
}
}

Expand Down Expand Up @@ -124,6 +122,5 @@ export default class StackMacros {
commitId: newCommitId,
previewOpen
});
this.uiState.project(this.projectId).stackId.set(destinationStackId);
}
}
7 changes: 0 additions & 7 deletions apps/desktop/src/lib/state/uiState.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export type ExclusiveAction =

export type ProjectUiState = {
exclusiveAction: ExclusiveAction | undefined;
stackId: string | undefined;
branchesSelection: BranchesSelection;
showActions: boolean;
branchesToPoll: string[];
Expand Down Expand Up @@ -171,7 +170,6 @@ export class UiState {
readonly project = this.buildScopedProps<ProjectUiState>(this.scopesCache.projects, {
exclusiveAction: undefined,
branchesSelection: {},
stackId: undefined,
showActions: false,
branchesToPoll: [],
selectedClaudeSession: undefined,
Expand Down Expand Up @@ -459,11 +457,6 @@ export function updateStaleProjectState(
) {
const projectState = uiState.project(projectId);

// Unselect the current stack if it is not in the list of stack IDs
if (projectState.stackId.current && !stackIds.includes(projectState.stackId.current)) {
projectState.stackId.set(undefined);
}

if (projectState.exclusiveAction.current) {
updateExclusiveActionState(
projectState.exclusiveAction.current,
Expand Down
1 change: 0 additions & 1 deletion apps/desktop/src/lib/testing/mockUiState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const MOCK_STACK_UI_STATE: StackState = {
const MOCK_PROJECT_UI_STATE: ProjectUiState = {
exclusiveAction: undefined,
branchesSelection: { branchName: 'test' },
stackId: undefined,
showActions: false,
branchesToPoll: [],
selectedClaudeSession: undefined,
Expand Down
10 changes: 0 additions & 10 deletions apps/desktop/src/routes/[projectId]/workspace/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,26 @@
import WorkspaceView from '$components/WorkspaceView.svelte';
import { MODE_SERVICE } from '$lib/mode/modeService';
import { STACK_SERVICE } from '$lib/stacks/stackService.svelte';
import { UI_STATE } from '$lib/state/uiState.svelte';
import { inject } from '@gitbutler/core/context';

const modeService = inject(MODE_SERVICE);

const projectId = $derived(page.params.projectId!);
const mode = $derived(modeService.mode({ projectId }));
const uiState = inject(UI_STATE);
const stackService = inject(STACK_SERVICE);
const projectState = $derived(uiState.project(projectId));
const stackId = $derived(projectState.stackId.current);

// Check for stackId in URL query parameters
const urlStackId = $derived(page.url.searchParams.get('stackId'));
let scrollToStackId = $state<string | undefined>(undefined);

const firstStackQuery = $derived(stackService.stackAt(projectId, 0));
const firstStack = $derived(firstStackQuery.response);

// Read all local commits in the workspace for the given project
$effect(() => {
stackService.allLocalCommits(projectId);
});

$effect(() => {
if (urlStackId) {
projectState.stackId.set(urlStackId);
scrollToStackId = urlStackId;
} else if (stackId === undefined && firstStack) {
projectState.stackId.set(firstStack.id);
}
});

Expand Down
Loading