Skip to content

Fix empty answers from pending user-input auto-advance#114

Merged
Emanuele-web04 merged 3 commits into
Emanuele-web04:mainfrom
Marve10s:fix/pending-user-input-stale-advance
May 14, 2026
Merged

Fix empty answers from pending user-input auto-advance#114
Emanuele-web04 merged 3 commits into
Emanuele-web04:mainfrom
Marve10s:fix/pending-user-input-stale-advance

Conversation

@Marve10s

@Marve10s Marve10s commented May 14, 2026

Copy link
Copy Markdown
Contributor

Problem

When an agent asks questions in interactive/plan mode and the user picks an answer, the provider often receives empty answers instead of the selected ones.

Cause

In ComposerPendingUserInputPanel.tsx, handleOptionSelection was a useCallback whose setTimeout(..., 200) auto-advance callback captured onAdvance at creation time. On selecting a single-select option:

  1. onToggleOption schedules the state update with the pick.
  2. The 200ms timer is armed, closing over the pre-pick onAdvance.
  3. React re-renders with the answer — but the already-armed timer still holds the stale onAdvance, whose activePendingResolvedAnswers is null/partial.
  4. Timer fires and submits the stale closure → empty answers.

Fix

Mirrors the working implementation in the upstream reference repo:

  • Track the latest onAdvance in onAdvanceRef, kept current via an effect.
  • Make handleOptionSelection a useEffectEvent so it always sees current props/state.
  • The deferred timer calls onAdvanceRef.current(), so the submit always uses up-to-date answer state.

Scoped to a single file; no behavior change for multi-select or keyboard paths.

The single-select auto-advance timer captured onAdvance in a useCallback
closure, so the deferred 200ms submit fired with a stale
activePendingResolvedAnswers and sent empty answers to the provider.

Track the latest onAdvance in a ref and make handleOptionSelection a
useEffectEvent so the deferred submit always uses current answer state.
@github-actions github-actions Bot added size:M vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels May 14, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13433c4bd4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx
Marve10s added 2 commits May 14, 2026 14:56
A manual Next/Submit landing inside the 200ms auto-advance window left an
outstanding timer that fired against the latest onAdvance, skipping a
question or submitting a second time. Re-key the cleanup effect on the
active question id and isResponding so the timer is cancelled whenever the
prompt moves on without it.
@github-actions github-actions Bot added size:L and removed size:M labels May 14, 2026
@Marve10s Marve10s changed the title Fix empty answers from pending user-input auto-advance Fix Kilo and OpenCode transcript handling May 14, 2026
@Marve10s Marve10s changed the title Fix Kilo and OpenCode transcript handling Fix empty answers from pending user-input auto-advance May 14, 2026
@Emanuele-web04 Emanuele-web04 merged commit 226f8f1 into Emanuele-web04:main May 14, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants