Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export default function ProjectSessionPage() {
}
}, [id]);

const fetchProjectSessions = useCallback(async () => {
const fetchProjectSessions = useCallback(async (fresh?: boolean) => {
if (fetchingProjectSessionsRef.current) return;
const projectId = sessionProjectIdRef.current;
if (!projectId) return;
Expand All @@ -281,8 +281,8 @@ export default function ProjectSessionPage() {
projectSessionsFetchControllerRef.current = controller;
try {
const query = isOrchestrator
? `/api/sessions?project=${encodeURIComponent(projectId)}&fresh=true`
: `/api/sessions?project=${encodeURIComponent(projectId)}&orchestratorOnly=true&fresh=true`;
? `/api/sessions?project=${encodeURIComponent(projectId)}${fresh ? "&fresh=true" : ""}`
: `/api/sessions?project=${encodeURIComponent(projectId)}&orchestratorOnly=true${fresh ? "&fresh=true" : ""}`;
const body = await fetchJsonWithTimeout<ProjectSessionsBody>(query, {
signal: controller.signal,
timeoutMs: PROJECT_SESSIONS_FETCH_TIMEOUT_MS,
Expand Down Expand Up @@ -335,7 +335,7 @@ export default function ProjectSessionPage() {

useEffect(() => {
if (!sessionProjectId) return;
void fetchProjectSessions();
void fetchProjectSessions(true);
}, [fetchProjectSessions, sessionIsOrchestrator, sessionProjectId]);

useEffect(() => {
Expand Down
16 changes: 8 additions & 8 deletions packages/web/src/app/sessions/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ export default function SessionPage() {
}
}, [clearSessionLoadRetry, id, resetSessionLoadFailures]);

const fetchProjectSessions = useCallback(async () => {
const fetchProjectSessions = useCallback(async (fresh?: boolean) => {
if (fetchingProjectSessionsRef.current) return;
const projectId = sessionProjectIdRef.current;
if (!projectId) return;
Expand All @@ -617,8 +617,8 @@ export default function SessionPage() {
projectSessionsFetchControllerRef.current = controller;
try {
const query = isOrchestrator
? `/api/sessions?project=${encodeURIComponent(projectId)}&fresh=true`
: `/api/sessions?project=${encodeURIComponent(projectId)}&orchestratorOnly=true&fresh=true`;
? `/api/sessions?project=${encodeURIComponent(projectId)}${fresh ? "&fresh=true" : ""}`
: `/api/sessions?project=${encodeURIComponent(projectId)}&orchestratorOnly=true${fresh ? "&fresh=true" : ""}`;
const body = await fetchJsonWithTimeout<ProjectSessionsBody>(query, {
signal: controller.signal,
timeoutMs: PROJECT_SIDEBAR_FETCH_TIMEOUT_MS,
Expand Down Expand Up @@ -670,7 +670,7 @@ export default function SessionPage() {
}
}, []);

const fetchSidebarSessions = useCallback(async () => {
const fetchSidebarSessions = useCallback(async (fresh?: boolean) => {
if (fetchingSidebarRef.current) return;
fetchingSidebarRef.current = true;
const controller = new AbortController();
Expand All @@ -679,7 +679,7 @@ export default function SessionPage() {
const body = await fetchJsonWithTimeout<{
sessions?: DashboardSession[];
orchestrators?: DashboardOrchestratorLink[];
} | null>("/api/sessions?fresh=true", {
} | null>(fresh ? "/api/sessions?fresh=true" : "/api/sessions", {
signal: controller.signal,
timeoutMs: PROJECT_SIDEBAR_FETCH_TIMEOUT_MS,
timeoutMessage: `Sidebar sessions request timed out after ${PROJECT_SIDEBAR_FETCH_TIMEOUT_MS}ms`,
Expand Down Expand Up @@ -757,12 +757,12 @@ export default function SessionPage() {

// Initial fetch — load independent sidebar/session data in parallel.
useEffect(() => {
void Promise.all([fetchProjects(), fetchSession(), fetchSidebarSessions()]);
void Promise.all([fetchProjects(), fetchSession(), fetchSidebarSessions(true)]);
}, [fetchProjects, fetchSession, fetchSidebarSessions]);

useEffect(() => {
if (!sessionProjectId) return;
void fetchProjectSessions();
void fetchProjectSessions(true);
}, [fetchProjectSessions, sessionIsOrchestrator, sessionProjectId]);

// Poll frequently enough that sidebar/project session state keeps up with
Expand Down Expand Up @@ -884,7 +884,7 @@ export default function SessionPage() {
setSessionMissing(false);
setLoading(true);
resetSessionLoadFailures();
void Promise.all([fetchProjects(), fetchSession(), fetchSidebarSessions()]);
void Promise.all([fetchProjects(), fetchSession(), fetchSidebarSessions(true)]);
},
}}
secondaryAction={{
Expand Down