batch3 T5 review fixes: backoff off-by-one + activeSession shape + headers

- useUserEvents: double delay before scheduling, producing 1/2/4/8/16/30s
- useSidebar: activeSessionProjectId -> activeSession {session_id,project_id}
  so consumers can verify URL match and ignore stale values
- api.panes.create/update: drop redundant Content-Type (request helper sets)
- useUserEvents: minimal type guard on incoming WS frame before emit

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-15 15:28:11 +00:00
parent 8f0e1245d8
commit e82e5670ee
3 changed files with 13 additions and 17 deletions

View File

@@ -13,7 +13,7 @@ let sharedError: string | null = null;
let sharedLoading: boolean = true;
let initialized = false;
let fetchInFlight: Promise<void> | null = null;
let activeSessionProjectId: string | null = null;
let activeSession: { session_id: string; project_id: string } | null = null;
const subscribers = new Set<() => void>();
function notify(): void {
@@ -150,7 +150,7 @@ sessionEvents.subscribe((event) => {
// session_loaded updates activeSessionProjectId regardless of whether
// sharedData is populated yet — notify so subscribers can re-read.
if (event.type === 'session_loaded') {
activeSessionProjectId = event.project_id;
activeSession = { session_id: event.session_id, project_id: event.project_id };
notify();
return;
}
@@ -165,11 +165,11 @@ interface Snapshot {
data: SidebarResponse | null;
error: string | null;
loading: boolean;
activeSessionProjectId: string | null;
activeSession: { session_id: string; project_id: string } | null;
}
function snapshot(): Snapshot {
return { data: sharedData, error: sharedError, loading: sharedLoading, activeSessionProjectId };
return { data: sharedData, error: sharedError, loading: sharedLoading, activeSession };
}
export function useSidebar(): {
@@ -177,7 +177,7 @@ export function useSidebar(): {
error: string | null;
loading: boolean;
retry: () => void;
activeSessionProjectId: string | null;
activeSession: { session_id: string; project_id: string } | null;
} {
const [state, setState] = useState<Snapshot>(snapshot);
@@ -199,5 +199,5 @@ export function useSidebar(): {
void load();
};
return { data: state.data, error: state.error, loading: state.loading, retry, activeSessionProjectId: state.activeSessionProjectId };
return { data: state.data, error: state.error, loading: state.loading, retry, activeSession: state.activeSession };
}