Skip to content

Fix singleSelect freeform answer showing [object Object] after reload#299235

Merged
meganrogge merged 3 commits intomainfrom
copilot/fix-askquestion-tool-bug
Mar 4, 2026
Merged

Fix singleSelect freeform answer showing [object Object] after reload#299235
meganrogge merged 3 commits intomainfrom
copilot/fix-askquestion-tool-bug

Conversation

Copy link
Contributor

Copilot AI commented Mar 4, 2026

A singleSelect freeform answer is stored as { selectedValue: undefined, freeformValue: "text" }. JSON.stringify strips undefined-valued keys, so after persistence round-trip the object becomes { freeformValue: "text" }. On reload, formatAnswerForSummary only checked for the selectedValue key via hasKey, which no longer matched — falling through to String(answer)[object Object].

Added a fallback hasKey check for freeformValue in the singleSelect branch of formatAnswerForSummary, so the freeform text is correctly extracted even when selectedValue was stripped during serialization.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • redirector.gvt1.com
    • Triggering command: /proc/self/exe /proc/self/exe --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=none --no-sandbox --crashpad-handler-pid=7181 --enable-crash-reporter=3cf0207a-6bd9-4fc5-8a8c-1884b8a03b95,no_channel --user-data-dir=/tmp/vscode-tests-1772644255208 --shared-files=v8_context_snapshot_data:100 --field-trial-handle=3,i,15345232657927160293,9761341827535063693,262144 --enable-features=PdfUseShowSaveFilePicker --disable-features=LocalNetworkAccessChecks,ScreenAIOCREnabled,SpareRendererForSitePerProcess,TraceSiteInstanceGetProcessCreation --variations-seed-version --trace-process-track-uuid=3190708989122997041 (dns block)
    • Triggering command: .build/electron/code-oss .build/electron/code-oss test/unit/electron/index.js --crash-reporter-directory=/home/REDACTED/work/vscode/vscode/.build/crashes src/vs/workbench/contrib/chat/test/browser/widget/chatContentParts/chatQuestionCarouselPart.test.ts /tmp/server-99.xkm (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>askQuestion tool: Single-select freeform answer turns into [object Object] after window reload</issue_title>
<issue_description>Type: Bug

  1. Enable the askQuestion tool in Copilot chat
  2. Ask the model to present a single-select question with freeform input allowed (e.g. I want to test ask_question tool. ask "question?" with choices "A", "B". allow freeform input.)
  3. Type a freeform answer instead of selecting a predefined option, then submit
  4. Confirm the answer summary displays correctly (e.g. question?: free input)
  5. Run "Developer: Reload Window" command or restart VSCode

Expected: The answer summary still shows the text I typed.

Actual: The answer summary shows [object Object].

Before reload: Image Image

After reload:
Image

Root Cause (by Opus 4.6):

A singleSelect freeform answer is stored as { selectedValue: undefined, freeformValue: "text" }. When this is persisted via JSON.stringify, keys with undefined values are stripped, producing { freeformValue: "text" }.

On reload, formatAnswerForSummary checks for the selectedValue key using hasKey(answer, { selectedValue: true }), which no longer matches after the JSON round-trip. The answer object then falls through to String(answer), producing [object Object].

private formatAnswerForSummary(question: IChatQuestion, answer: unknown): string {
switch (question.type) {
case 'text':
return String(answer);
case 'singleSelect': {
if (typeof answer === 'object' && answer !== null && hasKey(answer, { selectedValue: true })) {

VS Code version: Code - Insiders 1.110.0-insider (Universal) (f5927e7, 2026-02-28T04:37:38.428Z)
OS version: Darwin arm64 25.2.0
Modes:

System Info
Item Value
CPUs Apple M2 (8 x 2400)
GPU Status 2d_canvas: enabled
GPU0: VENDOR= 0x106b [Google Inc. (Apple)], DEVICE=0x0000 [ANGLE (Apple, ANGLE Metal Renderer: Apple M2, Version 26.2 (Build 25C56))], DRIVER_VENDOR=Apple, DRIVER_VERSION=26.2 ACTIVE
Machine model name: Mac
Machine model version: 14.7
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: enabled_on
trees_in_viz: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) 2, 2, 5
Memory (System) 24.00GB (0.11GB free)
Process Argv --crash-reporter-id 985d0cbc-0204-4921-ac17-a9e137367a95
Screen Reader no
VM 0%
Extensions (3)
Extension Author (truncated) Version
copilot-chat Git 0.38.2026022801
batch-rename-extension Jan 0.0.6
remote-containers ms- 0.446.0
A/B Experiments
vsliv368:30146709
pythonvspyt551:31249597
nativeloc1:31118317
dwcopilot:31158714
dwoutputs:31242946
copilot_t_ci:31333650
g012b348:31231168
pythonrdcb7:31268811
pythonpcpt1:31399616
6518g693:31302842
6abeh943:31336334
envsactivate1:31349248
editstats-enabled:31346256
cloudbuttont:31366566
3efgi100_wstrepl:31403338
56b7f661:31457055
use-responses-api:31390341
je187915:31401257
cp_cls_t_966_ss:31454198
chatvisible:31417128
inlinechat_v2_hd992725:31445440
ge8j1254_inline_auto_hint_haiku:31426887
a5gib710:31434435
7ig2g208:31429686
preserve_tokens:31444547
cp_cls_c_1081:31454833
copilot-nes-oct-trt:31432609
ia-use-proxy-models-svc:31446143
a43f0575b:31442821
e9c30283:31453065
subagent_3ccgc321:31457743
9c05b404_max_request_50:31468594
idci7584:31454084
edit_mode_hidden:31453871
nes-ftch-ctrl:31458523
nes_chat_context_enabled:31451401
showstats:31452402
e3e4d672:31454087
864ei723_large_tool_results_to_disk:31455802
showingstats:31457201
ei9d7968:31462942
b1f5h706:31455228
7ef87755:31455235
nes-extended-on:31455475
regwelcome:31461167
nes-sp-off:31468471
ah:31460422
quick_suggest_off_75197330:31462668
2ab5e849:31461281
67jbj424:31464192
7e884298:31462391
nes-rcnt-edit:31468468
bg_compact_c:31466297
t-some:31466503
i2gc6536:31469069

Edit: I also confirmed that this issue does not occur with text (freeform) questions or multi-select questions (their text answers display correctly after a window reload)</issue_description>

Com...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits March 4, 2026 17:16
… reload

When a singleSelect freeform answer is stored as { selectedValue: undefined,
freeformValue: "text" }, JSON.stringify strips the undefined selectedValue key.
On reload, hasKey(answer, { selectedValue: true }) fails and the answer falls
through to String(answer), producing [object Object].

Add a fallback check for the freeformValue key so that after JSON round-trip
the freeform text is still correctly extracted and displayed.

Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
…tected

Co-authored-by: meganrogge <29464607+meganrogge@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bug in askQuestion tool for freeform answers Fix singleSelect freeform answer showing [object Object] after reload Mar 4, 2026
@meganrogge meganrogge added this to the 1.111.0 milestone Mar 4, 2026
@meganrogge meganrogge marked this pull request as ready for review March 4, 2026 17:20
Copilot AI review requested due to automatic review settings March 4, 2026 17:20
@meganrogge meganrogge enabled auto-merge (squash) March 4, 2026 17:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug where a singleSelect freeform answer submitted in a chat question carousel displays as [object Object] after a window reload.

Root cause: When submitting a freeform answer, the answer is stored as { selectedValue: undefined, freeformValue: "text" }. Because JSON.stringify silently drops undefined-valued keys, the persisted form becomes { freeformValue: "text" }. On reload, formatAnswerForSummary's singleSelect branch only matched the selectedValue key, so it fell through to String(answer)[object Object].

Fix: A second hasKey check for freeformValue is added as a fallback in the singleSelect branch, covering the post-serialization state where selectedValue has been stripped.

Changes:

  • Added fallback hasKey(answer, { freeformValue: true }) check in the singleSelect branch of formatAnswerForSummary

@meganrogge meganrogge merged commit 48661ac into main Mar 4, 2026
24 checks passed
@meganrogge meganrogge deleted the copilot/fix-askquestion-tool-bug branch March 4, 2026 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

askQuestion tool: Single-select freeform answer turns into [object Object] after window reload

4 participants