Skip to content
Open
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
6 changes: 4 additions & 2 deletions apps/desktop/cypress/e2e/support/mock/changes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export function isGetCommitChangesParams(args: unknown): args is GetCommitChange

export type GetBranchChangesParams = {
projectId: string;
stackId?: string;
stackId?: string | null;
branch: string;
};

Expand All @@ -157,7 +157,9 @@ export function isGetBranchChangesParams(args: unknown): args is GetBranchChange
args !== null &&
'projectId' in args &&
typeof args['projectId'] === 'string' &&
(typeof (args as any).stackId === 'string' || (args as any).stackId === undefined) &&
(typeof (args as any).stackId === 'string' ||
(args as any).stackId === undefined ||
(args as any).stackId === null) &&
'branch' in args &&
typeof args['branch'] === 'string'
);
Expand Down
22 changes: 15 additions & 7 deletions apps/desktop/src/lib/stacks/stackService.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -602,11 +602,12 @@ export class StackService {
* If the branch is part of a stack and if the stackId is provided, this will include only the changes up to the next branch in the stack.
* Otherwise, if stackId is not provided, this will include all changes as compared to the target branch
*/
branchChanges(args: { projectId: string; stackId?: string; branch: BranchRef }) {
branchChanges(args: { projectId: string; stackId?: string | null; branch: BranchRef }) {
return this.api.endpoints.branchChanges.useQuery(
{
projectId: args.projectId,
stackId: args.stackId,
// Handle case where URL parameters convert null to "null" string
stackId: args.stackId === 'null' ? null : args.stackId,
branch: args.branch
},
{
Expand All @@ -618,11 +619,17 @@ export class StackService {
);
}

branchChange(args: { projectId: string; stackId?: string; branch: BranchRef; path: string }) {
branchChange(args: {
projectId: string;
stackId?: string | null;
branch: BranchRef;
path: string;
}) {
return this.api.endpoints.branchChanges.useQuery(
{
projectId: args.projectId,
stackId: args.stackId,
// Handle case where URL parameters convert null to "null" string
stackId: args.stackId === 'null' ? null : args.stackId,
branch: args.branch
},
{ transform: (result) => changesSelectors.selectById(result.changes, args.path) }
Expand All @@ -631,14 +638,15 @@ export class StackService {

async branchChangesByPaths(args: {
projectId: string;
stackId?: string;
stackId?: string | null;
branch: BranchRef;
paths: string[];
}) {
const result = await this.api.endpoints.branchChanges.fetch(
{
projectId: args.projectId,
stackId: args.stackId,
// Handle case where URL parameters convert null to "null" string
stackId: args.stackId === 'null' ? null : args.stackId,
branch: args.branch
},
{ transform: (result) => selectChangesByPaths(result.changes, args.paths) }
Expand Down Expand Up @@ -1185,7 +1193,7 @@ function injectEndpoints(api: ClientState['backendApi'], uiState: UiState) {
}),
branchChanges: build.query<
{ changes: EntityState<TreeChange, string>; stats: TreeStats },
{ projectId: string; stackId?: string; branch: BranchRef }
{ projectId: string; stackId?: string | null; branch: BranchRef }
>({
extraOptions: { command: 'changes_in_branch' },
query: (args) => args,
Expand Down
12 changes: 10 additions & 2 deletions apps/desktop/src/routes/[projectId]/workspace/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@
const stackId = $derived(projectState.stackId.current);

// Check for stackId in URL query parameters
const urlStackId = $derived(page.url.searchParams.get('stackId'));
// Note: URLSearchParams.get() returns strings, so "null" becomes the string "null"
// We need to convert it back to actual null for proper API handling
const urlStackId = $derived(
(() => {
const param = page.url.searchParams.get('stackId');
// Convert string "null" back to actual null
return param === 'null' ? null : param;
})()
);
let scrollToStackId = $state<string | undefined>(undefined);

const firstStackResult = $derived(stackService.stackAt(projectId, 0));
Expand All @@ -29,7 +37,7 @@
});

$effect(() => {
if (urlStackId) {
if (urlStackId !== null) {
projectState.stackId.set(urlStackId);
scrollToStackId = urlStackId;
} else if (stackId === undefined && firstStack) {
Expand Down
Loading