fix: stabilize scheduled runs and background task tracking (#365)

* fix: stabilize scheduled runs and background task tracking

* fix: complete scheduled runs and harden background task status

- Route directory-less OpenCode session events (session.execution.*,
  session.usage.updated) to backend listeners by remembering each
  session's directory in the SSE aggregator, so scheduled runs finish
  and failure push notifications fire; browser delivery is unchanged.
- Resolve background shell status from the transcript completion notice
  when OpenCode no longer lists the shell, keep the first terminal
  status so a kill is not reported as completed, and share one status
  icon and colour mapping between the transcript and background bar.
- Reconcile child sessions only while unknown or running, trigger it
  from the EventProvider alone, refresh children that drop to unknown
  after a poll, and forget deleted sessions.
- Fetch the model list and default concurrently while waiting for the
  schedule model, share configured-model selection, and consolidate
  schedule startup cancellation cleanup.
- Reduce background work re-renders, prune shell exit records, remove
  dead exports, and document background work in the chat guide.

* fix: hide finished background tasks and clip long dialog titles
This commit is contained in:
Chris Scott authored and GitHub committed 2026-09-28 23:55:01 -04:00
1 parent e80016cc22
commit 304f636516
35 files changed
+4272 -254

No files matched your search

+24 -2
View File
@@ -23,8 +23,9 @@ import type { ModelRef, SessionInfo } from "@opencode-manager/shared/opencode";
import { parseNetworkError, isGatewayTimeout } from "../lib/opencode-errors";
import { showToast } from "../lib/toast";
import { useSendErrorStore } from "../stores/sendErrorStore";
import { useSessionStatus } from "../stores/sessionStatusStore";
import { invalidateSessionListCaches, sessionTranscriptQueryKey } from "../lib/queryInvalidation";
import { useSessionStatus, useChildLifecycleForSession } from "../stores/sessionStatusStore";
import { isRunningLifecycle } from "../lib/backgroundWork";
import { childSessionReconciliationQueryKey, invalidateSessionListCaches, sessionTranscriptQueryKey } from "../lib/queryInvalidation";
import { buildPinnedSessionKeys, buildSessionKey } from "../lib/sessionKey";
import { toggleSessionPin } from "../api/sessionPins";
import { SESSION_PINS_QUERY_KEY } from "./useSessionPins";
@@ -147,6 +148,27 @@ export const useSession = (sessionID: string | undefined, directory?: string) =>
return useQuery(sessionQueryOptions(sessionID, directory));
};
export const useChildSessionReconciliation = (sessionID: string | undefined) => {
const lifecycle = useChildLifecycleForSession(sessionID)
useQuery({
queryKey: childSessionReconciliationQueryKey(sessionID),
queryFn: async () => {
const token = useSessionStatus.getState().beginStatusSnapshot();
try {
const session = await getSession(sessionID!);
useSessionStatus.getState().applySessionSnapshot(sessionID!, session, token);
return session;
} finally {
useSessionStatus.getState().endStatusSnapshot(token);
}
},
enabled: !!sessionID && isRunningLifecycle(lifecycle),
staleTime: 5_000,
refetchOnWindowFocus: false,
refetchOnReconnect: false,
});
};
export const useCreateSession = (
directory?: string,
onSuccess?: (session: { id: string }) => void,