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
3 changes: 3 additions & 0 deletions apps/staged/src-tauri/src/actions/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ pub async fn detect_repo_actions(
let context = store
.get_or_create_action_context(&github_repo, subpath.as_deref())
.map_err(|e| format!("Failed to get action context: {e}"))?;
if context.detecting_actions {
return Err("Detection is already in progress for this repository".into());
Comment on lines +119 to +120
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Permit retries when persisted detection flag is stale

This new guard can permanently block action detection after an interrupted run. detecting_actions is stored in SQLite, so if the app is closed/crashes after set_action_context_detecting(..., true) but before mark_action_context_detected, the flag remains true across restart; every later detect_repo_actions call will hit this early return even though no detection is actually running. This creates a stuck repo context that users cannot recover from in settings.

Useful? React with 👍 / 👎.

}
store
.set_action_context_detecting(&context.id, true)
.map_err(|e| format!("Failed to set detection status: {e}"))?;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { onMount, untrack } from 'svelte';
import { onMount, onDestroy, untrack } from 'svelte';
import {
FolderGit2,
Play,
Expand All @@ -22,7 +22,11 @@
import ConfirmDialog from '../../shared/ConfirmDialog.svelte';
import type { ActionContext, ProjectAction } from '../../api/commands';
import * as commands from '../../api/commands';
import { detectRepoActions, type ActionType } from '../actions/actions';
import {
detectRepoActions,
listenToRepoActionsDetection,
type ActionType,
} from '../actions/actions';
import { repoBadgeStore } from '../../stores/repoBadges.svelte';
import { matchesRepoSearch } from './repoContextSearch';

Expand Down Expand Up @@ -66,12 +70,30 @@
let badgeEditHue = $state(0);
let badgeError = $state('');

let unlistenDetection: (() => void) | undefined;

onMount(async () => {
listenToRepoActionsDetection((event) => {
const ctx = selectedContext;
if (!ctx) return;
if (event.githubRepo !== ctx.githubRepo || event.subpath !== (ctx.subpath ?? null)) return;
detecting = event.detecting;
if (!event.detecting) {
loadActions();
}
}).then((unlisten) => {
unlistenDetection = unlisten;
});

await repoBadgeStore.loadAll();
await loadContexts();
await ensureBadgesForContexts(contexts);
});

onDestroy(() => {
unlistenDetection?.();
});

async function ensureBadgesForContexts(ctxs: ActionContext[]) {
if (ctxs.length === 0) return;
await repoBadgeStore.ensureForRepos(
Expand Down Expand Up @@ -256,6 +278,10 @@
loadActions();
});

$effect(() => {
detecting = selectedContext?.detectingActions ?? false;
});

async function detectActions() {
if (!selectedContext) return;

Expand Down