Fix singleSelect freeform answer showing [object Object] after reload#299235
Fix singleSelect freeform answer showing [object Object] after reload#299235meganrogge merged 3 commits intomainfrom
Conversation
… 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>
There was a problem hiding this comment.
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 thesingleSelectbranch offormatAnswerForSummary
A singleSelect freeform answer is stored as
{ selectedValue: undefined, freeformValue: "text" }.JSON.stringifystripsundefined-valued keys, so after persistence round-trip the object becomes{ freeformValue: "text" }. On reload,formatAnswerForSummaryonly checked for theselectedValuekey viahasKey, which no longer matched — falling through toString(answer)→[object Object].Added a fallback
hasKeycheck forfreeformValuein thesingleSelectbranch offormatAnswerForSummary, so the freeform text is correctly extracted even whenselectedValuewas 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/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).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
askQuestiontool in Copilot chatI want to test ask_question tool. ask "question?" with choices "A", "B". allow freeform input.)question?: free input)Expected: The answer summary still shows the text I typed.
Actual: The answer summary shows
[object Object].Before reload:
After reload:

Root Cause (by Opus 4.6):
A singleSelect freeform answer is stored as
{ selectedValue: undefined, freeformValue: "text" }. When this is persisted viaJSON.stringify, keys withundefinedvalues are stripped, producing{ freeformValue: "text" }.On reload,
formatAnswerForSummarychecks for theselectedValuekey usinghasKey(answer, { selectedValue: true }), which no longer matches after the JSON round-trip. The answer object then falls through toString(answer), producing[object Object].vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatQuestionCarouselPart.ts
Lines 1216 to 1222 in 25edeb0
vscode/src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatQuestionCarouselPart.ts
Line 1232 in 25edeb0
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
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
Extensions (3)
A/B Experiments
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...
[object Object]after window reload #298574💡 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.