fix: gateway auth injection and cumulative diff error handling (#682)
This commit is contained in:
@@ -113,7 +113,8 @@ export function resolvePRPanelTargetGroup(
|
||||
centerGroupId: string,
|
||||
): string {
|
||||
const sessionPanel = api.getPanel(`session:${sessionId}`);
|
||||
return sessionPanel?.group?.id ?? centerGroupId;
|
||||
const resolved = sessionPanel?.group?.id ?? centerGroupId;
|
||||
return resolved;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,14 +142,14 @@ export function useAutoPRPanel() {
|
||||
const api = useDockviewStore.getState().api;
|
||||
if (!api) return;
|
||||
|
||||
const decision = shouldAutoAddPRPanel({
|
||||
const decisionParams = {
|
||||
hasPR,
|
||||
panelExists: !!api.getPanel("pr-detail"),
|
||||
isRestoringLayout: useDockviewStore.getState().isRestoringLayout,
|
||||
isMaximized: useDockviewStore.getState().preMaximizeLayout !== null,
|
||||
wasOffered: wasPRPanelOffered(sessionId),
|
||||
});
|
||||
|
||||
};
|
||||
const decision = shouldAutoAddPRPanel(decisionParams);
|
||||
if (decision === "remove") {
|
||||
api.getPanel("pr-detail")?.api.close();
|
||||
return;
|
||||
|
||||
@@ -27,6 +27,26 @@ import { useArchivedTaskState } from "./task-archived-context";
|
||||
import { useRepositories } from "@/hooks/domains/workspace/use-repositories";
|
||||
import { useWorkspacePRs } from "@/hooks/domains/github/use-task-pr";
|
||||
|
||||
/**
|
||||
* Stabilize a derived array of primary session IDs so the reference only
|
||||
* changes when the actual contents change. This prevents the bulk-subscribe
|
||||
* effect from tearing down and recreating all subscriptions on every kanban
|
||||
* snapshot update.
|
||||
*/
|
||||
function useStablePrimarySessionIds(
|
||||
allTasks: Array<{ primarySessionId?: string | null }>,
|
||||
): string[] {
|
||||
const key = useMemo(
|
||||
() =>
|
||||
allTasks
|
||||
.map((t) => t.primarySessionId)
|
||||
.filter((id): id is string => id != null)
|
||||
.join("\0"),
|
||||
[allTasks],
|
||||
);
|
||||
return useMemo(() => (key ? key.split("\0") : []), [key]);
|
||||
}
|
||||
|
||||
/** Find a task across all workflow snapshots */
|
||||
function findTaskInSnapshots(
|
||||
snapshots: Record<string, { tasks: KanbanState["tasks"] }>,
|
||||
@@ -264,10 +284,7 @@ function useSidebarData(workspaceId: string | null) {
|
||||
|
||||
// Stable list of primary session IDs for the bulk-subscribe effect.
|
||||
// Derived from kanban tasks (always available) rather than sessionsByTaskId (loaded on-demand).
|
||||
const primarySessionIds = useMemo(
|
||||
() => allTasks.map((t) => t.primarySessionId).filter((id): id is string => id != null),
|
||||
[allTasks],
|
||||
);
|
||||
const primarySessionIds = useStablePrimarySessionIds(allTasks);
|
||||
|
||||
return {
|
||||
activeTaskId,
|
||||
@@ -512,13 +529,18 @@ function useSidebarActions(store: StoreApi) {
|
||||
|
||||
function useBulkGitStatusSubscription(primarySessionIds: string[]) {
|
||||
const connectionStatus = useAppStore((state) => state.connection.status);
|
||||
const activeSessionId = useAppStore((state) => state.tasks.activeSessionId);
|
||||
useEffect(() => {
|
||||
if (connectionStatus !== "connected" || primarySessionIds.length === 0) return;
|
||||
const client = getWebSocketClient();
|
||||
if (!client) return;
|
||||
const unsubscribes = primarySessionIds.map((id) => client.subscribeSession(id));
|
||||
// Skip active session — it's already subscribed + focused by the task page hooks
|
||||
const backgroundIds = activeSessionId
|
||||
? primarySessionIds.filter((id) => id !== activeSessionId)
|
||||
: primarySessionIds;
|
||||
const unsubscribes = backgroundIds.map((id) => client.subscribeSession(id));
|
||||
return () => unsubscribes.forEach((u) => u());
|
||||
}, [primarySessionIds, connectionStatus]);
|
||||
}, [primarySessionIds, connectionStatus, activeSessionId]);
|
||||
}
|
||||
|
||||
function useEffectiveSidebarView() {
|
||||
|
||||
Reference in New Issue
Block a user