Skip to content
Draft
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
5 changes: 0 additions & 5 deletions apps/web/src/app/(sandbox)/task/[taskId]/LiveContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,12 @@ import { ProductTips, Startup } from './startup';

interface LiveContentProps {
session: TaskSession;
newTaskHref: string;
onBootStatusChange?: () => void;
onTaskPhaseChange?: (phase: TaskPhase | null) => void;
}

function LiveContent({
session,
newTaskHref,
onBootStatusChange,
onTaskPhaseChange,
}: LiveContentProps) {
Expand All @@ -54,7 +52,6 @@ function LiveContent({
>
<LiveContentInner
session={session}
newTaskHref={newTaskHref}
onBootStatusChange={onBootStatusChange}
onTaskPhaseChange={onTaskPhaseChange}
/>
Expand All @@ -64,7 +61,6 @@ function LiveContent({

function LiveContentInner({
session,
newTaskHref,
onBootStatusChange,
onTaskPhaseChange,
}: LiveContentProps) {
Expand Down Expand Up @@ -271,7 +267,6 @@ function LiveContentInner({
<Startup
runId={bootingTaskRun.id}
initialTaskRun={bootingTaskRun}
newTaskHref={newTaskHref}
onStatusChange={onBootStatusChange}
/>
<ProductTips />
Expand Down
16 changes: 7 additions & 9 deletions apps/web/src/app/(sandbox)/task/[taskId]/page.client.test.tsx

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 2 additions & 28 deletions apps/web/src/app/(sandbox)/task/[taskId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { CircleSlash, TriangleAlert } from '@/components/system';
import {
TaskPayloadKind,
DEFAULT_CODING_HARNESS,
getLinkedEnvironmentIdFromPayload,
type TaskPhase,
} from '@roomote/types';

Expand Down Expand Up @@ -76,24 +75,6 @@ export default function SandboxPage() {
images: session.prompt?.images,
}
: null;
const newTaskSearchParams = new URLSearchParams();

if (startupPrompt?.text) {
newTaskSearchParams.set('prompt', startupPrompt.text);
}

if (task?.model) {
newTaskSearchParams.set('model', task.model);
}

const environmentId = getLinkedEnvironmentIdFromPayload(taskRun?.payload);

if (environmentId) {
newTaskSearchParams.set('environmentId', environmentId);
}

const newTaskQuery = newTaskSearchParams.toString();
const newTaskHref = newTaskQuery ? `/?${newTaskQuery}` : '/';
const shouldRenderBootingTranscript =
sessionState === 'booting' &&
(hasTranscriptHistory || hasVisibleSessionPrompt);
Expand Down Expand Up @@ -291,12 +272,7 @@ export default function SandboxPage() {
<HistoricalContent
session={session}
footer={
taskRun ? (
<SnapshotResumeFailureFooter
taskRun={taskRun}
newTaskHref={newTaskHref}
/>
) : null
taskRun ? <SnapshotResumeFailureFooter taskRun={taskRun} /> : null
}
/>
</HistoricalSandboxProvider>
Expand All @@ -312,7 +288,7 @@ export default function SandboxPage() {
<Startup
runId={taskRun.id}
initialTaskRun={taskRun}
newTaskHref={newTaskHref}
prompt={startupPrompt?.text}
onStatusChange={handleBootStatusChange}
/>
</div>
Expand All @@ -330,7 +306,6 @@ export default function SandboxPage() {
<Startup
runId={taskRun.id}
initialTaskRun={taskRun}
newTaskHref={newTaskHref}
onStatusChange={handleBootStatusChange}
/>
<ProductTips />
Expand All @@ -357,7 +332,6 @@ export default function SandboxPage() {
>
<MemoizedLiveContent
session={session}
newTaskHref={newTaskHref}
onBootStatusChange={handleBootStatusChange}
onTaskPhaseChange={setLiveTaskPhase}
/>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 20 additions & 9 deletions apps/web/src/app/(sandbox)/task/[taskId]/startup/Startup.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
'use client';

import { useCallback } from 'react';
import { useRouter } from 'next/navigation';
import { SSEProvider } from 'react-hooks-sse';

import type { RunStatus as RunStatusValue } from '@roomote/types';
import type { TaskRun } from '@roomote/db';

import { getTaskRunError } from '@/lib/task-run-errors';
import { useReplaceFailedTaskStart } from '@/hooks/task-runs';

import { StartupFailureMessage, StartupSequence } from './StartupMessage';
import { useStartupProgress } from './useStartupProgress';

interface StartupProps {
runId: number;
initialTaskRun?: TaskRun;
newTaskHref: string;
prompt?: string;
onStatusChange?: (status: RunStatusValue) => void;
}

export const Startup = ({
runId,
initialTaskRun,
newTaskHref,
prompt,
onStatusChange,
}: StartupProps) => {
const router = useRouter();
const replaceFailedStart = useReplaceFailedTaskStart({
onSuccess: ({ taskId }) => router.push(`/task/${taskId}`),
});
const eventSource = useCallback(() => {
const eventSource = new EventSource(`/api/task-runs/${runId}/stream`, {
withCredentials: true,
Expand All @@ -39,7 +45,9 @@ export const Startup = ({
<StartupInner
runId={runId}
initialTaskRun={initialTaskRun}
newTaskHref={newTaskHref}
prompt={prompt}
onRetry={() => replaceFailedStart.mutate({ runId })}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

onRetry is now provided for every failed boot, but the session query already exposes canRetryFailedStart because not every failed run is relaunchable. For a run with messages or a non-StandardTask payload, this renders Retry and then replaceFailedStart rejects it as not found. Pass the server-derived eligibility through and omit the action when it is false.

retryPending={replaceFailedStart.isPending}
onStatusChange={onStatusChange}
/>
</SSEProvider>
Expand All @@ -49,14 +57,18 @@ export const Startup = ({
interface StartupInnerProps {
runId: number;
initialTaskRun?: TaskRun;
newTaskHref: string;
prompt?: string;
onRetry: () => void;
retryPending: boolean;
onStatusChange?: (status: RunStatusValue) => void;
}

const StartupInner = ({
runId,
initialTaskRun,
newTaskHref,
prompt,
onRetry,
retryPending,
onStatusChange,
}: StartupInnerProps) => {
const {
Expand All @@ -77,23 +89,22 @@ const StartupInner = ({
logs={showLogs ? sandboxLogs : undefined}
logsConnected={logsConnected}
logsError={logsError}
newTaskHref={newTaskHref}
prompt={prompt}
onRetry={onRetry}
retryPending={retryPending}
/>
);
};

interface SnapshotResumeFailureFooterProps {
taskRun: Pick<TaskRun, 'error' | 'result' | 'status'>;
newTaskHref: string;
}

export const SnapshotResumeFailureFooter = ({
taskRun,
newTaskHref,
}: SnapshotResumeFailureFooterProps) => (
<StartupFailureMessage
status={taskRun.status}
error={getTaskRunError(taskRun)}
newTaskHref={newTaskHref}
/>
);

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading