Skip to content
Merged
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

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

Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ import { toast } from 'sonner';
import { useTRPCClient } from '@/trpc/client';
import type { PendingTaskUserInputRequest } from './hooks';

import {
useSandboxClient,
useSandboxPendingUserInputRequests,
useSandboxTaskPhase,
} from './hooks';
import { useSandboxClient, useSandboxPendingUserInputRequests } from './hooks';
import {
buildAnswersForRequest,
OTHER_VALUE,
Expand Down Expand Up @@ -96,7 +92,6 @@ export function PendingUserInputRequestStateProvider({
}) {
const client = useSandboxClient();
const trpcClient = useTRPCClient();
const taskPhase = useSandboxTaskPhase();
const requests = useSandboxPendingUserInputRequests();

const [drafts, setDrafts] = useState<RequestDrafts>({});
Expand Down Expand Up @@ -154,14 +149,18 @@ export function PendingUserInputRequestStateProvider({
);
}, [requests]);

// Visibility tracks the live pending requests themselves, not the task
// phase: a queued/steered follow-up can flip the reported phase back to
// running while the harness turn is still blocked inside the question
// tool, and phase-gating here made the question unanswerable in that
// state. The runtime clears pending requests on answer, cancel, and
// turn teardown, so the list is self-correcting.
const visibleRequests = useMemo(
() =>
taskPhase === 'waiting_for_user_input'
? requests.filter(
(request) => resolvedRequestIds[request.requestId] !== true,
)
: [],
[requests, resolvedRequestIds, taskPhase],
requests.filter(
(request) => resolvedRequestIds[request.requestId] !== true,
),
[requests, resolvedRequestIds],
);

const requestEntries = useMemo<PendingRequestEntry[]>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,10 @@ export const PromptInput = forwardRef<PromptInputHandle, PromptInputProps>(
async (message: PromptInputMessage) => {
const text = message.text.trim();
const hasAttachments = (message.files?.length ?? 0) > 0;
// Keyed off the live pending request rather than the task phase:
// the phase can report running while the turn is still blocked on
// the question, and a message here must answer it, not steer.
const shouldAnswerPendingFreeText =
taskPhase === 'waiting_for_user_input' &&
Boolean(pendingUserInputState?.activeFreeTextRequest) &&
!hasAttachments;

Expand Down Expand Up @@ -453,7 +455,6 @@ export const PromptInput = forwardRef<PromptInputHandle, PromptInputProps>(
pendingUserInputState,
sending,
handlePromptChange,
taskPhase,
scrollToBottom,
handleMessageSent,
cloudJob,
Expand Down