Thanks to visit codestin.com
Credit goes to github.com

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
23 changes: 1 addition & 22 deletions staged/src/lib/BranchCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
let unlistenStatus: UnlistenFn | null = null;
let unlistenActionStatus: UnlistenFn | null = null;

// Set up event listeners immediately (synchronously) at module level
listen<{
sessionId: string;
status: string;
Expand All @@ -135,48 +136,27 @@
}
}).then((unlisten) => {
unlistenStatus = unlisten;
console.log('[BranchCard] Session status listener registered for:', branch.id);
});

listen<ActionStatusEvent>('action_status', (event) => {
const payload = event.payload;
console.log('[BranchCard] Received action_status event:', payload);

// Only process events for this branch
if (payload.branchId !== branch.id) {
console.log(
'[BranchCard] Ignoring event for different branch:',
payload.branchId,
'vs',
branch.id
);
return;
}

console.log(
'[BranchCard] Processing action_status for branch:',
branch.id,
'status:',
payload.status
);

const existingIndex = runningActions.findIndex((a) => a.executionId === payload.executionId);

if (payload.status === 'running') {
if (existingIndex === -1) {
console.log('[BranchCard] Adding running action:', payload.actionName);
runningActions.push({
executionId: payload.executionId,
actionId: payload.actionId,
actionName: payload.actionName,
status: 'running',
startedAt: payload.startedAt ?? Date.now(),
});
console.log(
'[BranchCard] runningActions now:',
runningActions.length,
runningActions.map((a) => a.actionName)
);
}
} else {
// Action completed/failed/stopped - update status
Expand Down Expand Up @@ -214,7 +194,6 @@
}
}).then((unlisten) => {
unlistenActionStatus = unlisten;
console.log('[BranchCard] Action status listener registered for:', branch.id);
});

onMount(() => {
Expand Down
13 changes: 3 additions & 10 deletions staged/src/lib/NewBranchModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@
const baseBranch = selectedBaseBranch ?? undefined;
const branch = await commands.createBranch(project.id, branchName.trim(), baseBranch);

console.log('[NewBranchModal] Branch created:', branch.id, branch.branchName);

// Capture values before modal closes
const branchId = branch.id;
const projectId = project.id;
Expand All @@ -153,14 +151,9 @@
// Wait for BranchCard to be created and listeners to be set up
// The BranchCard sets up listeners at module level, but the component needs to be created first
setTimeout(() => {
console.log('[NewBranchModal] Starting prerun actions for branch:', branchId);
runPrerunActions(branchId, projectId)
.then((executionIds) => {
console.log('[NewBranchModal] Prerun actions started, execution IDs:', executionIds);
})
.catch((e) => {
console.error('[NewBranchModal] Failed to run prerun actions:', e);
});
runPrerunActions(branchId, projectId).catch((e) => {
console.error('[NewBranchModal] Failed to run prerun actions:', e);
});
}, 150);
} else {
const wsName = workspaceName(branchName.trim());
Expand Down