Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): pending user-input Submit bypasses normal-send guards #9319

ClosedImBIOS(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/9319/headopened View on GitHub

Enabled Submit on the Input badge did nothing: the button enables on isComplete/canAdvance (ComposerPrimaryActions.tsx:147), but submitComposer (ChatComposer.tsx:1890) blocked on noProviderAvailable || isSendDisabled and ChatView.onSend (ChatView.tsx:5037) blocked on isSendBusy || isConnecting || threadDetailLoading || sendInFlight before reaching the pending branch. All silent, no toast.

Pending answers are a lightweight thread.user-input.respond — no provider, send context, or images needed — so route them first in both places. Only missing thread and environment-unavailable still block.

Fixes #9318. Distinct from #5454 (server No-session stuck, still open with #7987/#7463 open).

Verified by code-path inspection (no node_modules in sandbox, so no vp test run; existing composerSubmission.test.ts: pending-user-input dispatches on separate path covers the draft layer, this aligns the composer/view guards with it).

Built with Muse Spark via OpenCode.


Note

Medium Risk Changes OpenCode inventory parsing and model/agent option handling across server and shared code, plus composer send routing; localized web guard reorder but touches a critical submit path.

Overview Adds shared stripTerminalEscapes / sanitizeTerminalValue and applies them wherever OpenCode CLI stdout or model option strings are parsed or sent, so OSC title sequences and ANSI color codes no longer corrupt agent names, model slugs, skills JSON, or --version probes (avoiding Agent not found on polluted ids).

OpenCode paths updated: CLI parsers (parseModelsCliOutput, parseAgentListCliOutput, parseSkillsCliOutput), provider capability building, sendTurn / text-generation prompts (agent/variant), plus getProviderOptionStringSelectionValue, custom model slugs, and trimOrNull in shared model helpers. New parser tests cover polluted stdout.

Web (#9318): Pending user-input answers use thread.user-input.respond, so ChatComposer.submitComposer and ChatView.onSend handle activePendingProgress before normal-send guards (isSendBusy, connecting, provider availability). Submit/Next on the Input badge no longer stalls silently when a turn is busy.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit e2821521945cd752881d5447ec08697df421d594. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Fix pending user-input Submit to bypass normal-send guards and strip terminal escapes from OpenCode CLI output

  • Pending user-input submissions in ChatComposer and ChatView now dispatch through the pending-input path before provider-availability, send-busy, loading, and in-flight guards, so they are not blocked by an ordinary provider turn in progress.
  • Adds a shared stripTerminalEscapes sanitizer and sanitizeTerminalValue helper in packages/shared, exported via the stripTerminalEscapes subpath.
  • OpenCode CLI parsers (parseModelsCliOutput, parseAgentListCliOutput, parseSkillsCliOutput) and capability/status builders now strip terminal escape sequences from captured output before parsing or option construction, so polluted CLI output yields clean provider, model, agent, variant, and version identifiers.
  • Model-option accessors (getProviderOptionStringSelectionValue, normalizeCustomModelSlug, trimOrNull) now sanitize terminal escapes and whitespace before returning values, returning undefined/null for empty sanitized results.
  • Risk: getProviderOptionStringSelectionValue now returns undefined for non-string or empty-after-sanitize values where it previously returned the raw value; downstream consumers in OpenCodeAdapter and OpenCodeTextGeneration already handle undefined.
📊 Macroscope summarized e282152. 8 files reviewed, 3 issues evaluated, 0 issues filtered, 1 comment posted

🗂️ Filtered Issues

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. @@ -0,0 +1,17 @@
      1+/**
      2+ * Strip terminal escape sequences from captured CLI stdout.
      3+ *
      4+ * OpenCode's CLI (and potentially other provider CLIs) can emit OSC title
      5+ * sequences (`ESC ]0;<title> BEL` / `ESC \`) and ANSI CSI color codes directly
      6+ * to stdout, even when stdout is a pipe. When T3 Code captures that output
      7+ * via `ChildProcessSpawner`, those bytes pollute structured parsing — e.g.
      8+ * `opencode agent list` becomes `\x1b]0;t3code: ready\x07build (primary)`
      9+ * instead of `build (primary)`, causing the agent inventory to store a
      10+ * polluted id that later fails with `Agent not found`.
      11+ *
      12+ * This is defensive for any provider CLI; the regexes are intentionally
      13+ * permissive and also handle Ghostty/Zsh title integrations that can leak
      14+ * through `shell: true` spawns.
      15+ */
      16+const OSC_RE = /\x1b\].*?(?:\x07|\x1b\\)/g;
      17+const CSI_RE = /\x1b\[[0-9;?]*[ -/]*[@-~]/g;
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟠 High src/stripTerminalEscapes.ts:17

      stripTerminalEscapes leaves standard escape content in captured output, so affected agent headers and skills JSON remain corrupted and parsing fails. CHARSET_RE does not consume ESC */ESC +/ESC -/ESC ./ESC / designations, CSI_RE does not match colon-delimited parameters such as \x1b[38:2::255:0:0m, and SINGLE_ESC_RE removes only the DCS/PM/APC introducer and terminator while leaving payloads such as payload. Extend charset and CSI matching, and consume DCS/PM/APC strings through their ESC \ terminator before applying single-escape cleanup.

      🤖 Copy this AI Prompt to have your agent fix this:
      In file @packages/shared/src/stripTerminalEscapes.ts around line 17:
      
      `stripTerminalEscapes` leaves standard escape content in captured output, so affected agent headers and skills JSON remain corrupted and parsing fails. `CHARSET_RE` does not consume `ESC *`/`ESC +`/`ESC -`/`ESC .`/`ESC /` designations, `CSI_RE` does not match colon-delimited parameters such as `\x1b[38:2::255:0:0m`, and `SINGLE_ESC_RE` removes only the DCS/PM/APC introducer and terminator while leaving payloads such as `payload`. Extend charset and CSI matching, and consume DCS/PM/APC strings through their `ESC \` terminator before applying single-escape cleanup.
    3. Verification (worktree t3code-0c23097b, node v24.19.0, pnpm 11.10.0):

      • pnpm install done — node_modules exists.
      • vp test run apps/web/src/components/chat/composerSubmission.test.ts apps/web/src/components/chat/ComposerPrimaryActions.test.tsx apps/web/src/pendingUserInput.test.ts → 3 files, 37 tests passed.
      • vp test run apps/web/src/components/ChatView.logic.test.ts apps/web/src/components/chat/ComposerPendingUserInputPanel.test.tsx → 2 files, 40 tests passed.
      • vp run --filter @t3tools/web typecheck → clean (tsgo --noEmit).

      No repo-wide checks per contributing guide; change is web-only (ChatComposer + ChatView guard reorder). Mobile onSubmitUserInput already bypasses send guards, no change needed there.

    4. Approvability

      Verdict: Would Approve

      Macroscope's review found this PR approvable — This is a bounded bug fix that restores the existing pending-input response path and removes terminal escape pollution from OpenCode data without schema or infrastructure changes. An unresolved High-severity finding flags incomplete handling of less-common escape sequences, so that correctness risk should be considered separately.

      Not approved because:

      • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. Note: GPT-6 on behalf of shivam (@shivamhwp).

      Please rebase the pending-input change onto the current composer and update its disabled state too. All three ComposerPrimaryActions call sites in ChatComposer now pass noProviderAvailable through isEnvironmentUnavailable. A connected thread with a complete pending answer therefore still has a disabled Next/Submit button when no provider is available, even after these handler changes. Exempt pending answers from that provider-availability condition in the footer and both compact layouts, while retaining the environment, project-selection, answer-completeness and response-in-flight checks.

      During the rebase, preserve the current submission intent and keep the newer settings-hydration and feedback-upload guards on ordinary provider sends. Please split the OpenCode terminal-escape parsing and shared model sanitization into a separate PR. They are independent of #9318. The missing-session failure in #5454 also remains separate.

    6. Note

      This comment is posted by Julius' dot

      Closing under the one problem rule. The ChatComposer and ChatView changes fix pending answer submission for #9318, while the OpenCode parsers and shared model sanitizer independently fix terminal escape pollution in provider identifiers. The pending answer path does not use those parser changes. Split the OpenCode sanitization into a separate PR and keep this branch focused on pending input, then request reconsideration.

    7. juliusmarminge closed this

Sign in to join this conversation.