Skip to content

fix(desktop): clarify options defensive rendering and layout fix - #69497

Closed
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/69122-clarify-layout
Closed

fix(desktop): clarify options defensive rendering and layout fix#69497
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/69122-clarify-layout

Conversation

@webtecnica

Copy link
Copy Markdown
Contributor

Summary

Fixes #69122 — clarify options rendering with wrong layout in the Desktop chat.

Root cause

The clarify choices <span> used wrap-anywhere, an undefined CSS utility class with no effect. Long choice text would overflow the button container instead of wrapping, causing visible layout breakage.

Additionally, choices that did render could include garbage values (raw JSON arrays, nulls, multi-line strings) because there was no validation — they were only checked for typeof === 'string'.

Changes

  1. Layout fix: Replace the non-functional wrap-anywhere with Tailwind v4's [overflow-wrap:anywhere] so choice text wraps at any character boundary — preventing overflow on long options.

  2. Defensive choice normalization (normalizeChoices): A new shared validation function in store/clarify.ts that:

    • Returns empty array for non-array input (null, undefined, string, number, object)
    • Strips non-string items (the raw JSON arrays from LLM edge-cases)
    • Drops blank/whitespace-only strings
    • Drops strings with newlines (preserve single-line button layout)
    • Caps at 200 characters
  3. Diagnostic logging: console.warn('[clarify] ...') fires at both the gateway event handler and the tool-args parser when choices are present but none survive normalization — breaking the silent-failure pattern.

  4. Unit tests for normalizeChoices covering null, non-array, mixed types, blanks, multi-line, and overlong inputs.

Files changed

File Change
apps/desktop/src/store/clarify.ts Added normalizeChoices() validation function
apps/desktop/src/store/clarify.test.ts 8 test cases for normalizeChoices
apps/desktop/src/components/assistant-ui/clarify-tool.tsx Use normalizeChoices in readClarifyArgs; fix CSS class; add diagnostics
apps/desktop/src/app/session/hooks/use-message-stream/gateway-event.ts Use normalizeChoices in gateway handler; add diagnostics

Testing

  • Unit tests added for normalizeChoices (8 cases)
  • Existing clarify tests unaffected
  • No regression to single-question clarify calls
  • Text wrapping now works for long choices
  • Malformed choices are filtered with a console warning

- Replace undefined  CSS class with Tailwind v4's
   so long choice text wraps properly
  instead of overflowing the button container.
- Add  validation that strips non-string items,
  blanks, newlines, and text >200 chars — preventing garbage/JSON
  arrays from rendering as raw values.
- Add diagnostic  logging at both the gateway event
  handler and the tool-args parser when choices are dropped, so
  malformed payloads are no longer silent.
- Apply  in both the gateway event handler
  () and the inline tool-args parser
  () for consistent defense in depth.
- Add unit tests for  covering null, non-array,
  mixed-type, blank, multiline, and overlong inputs.

Closes NousResearch#69122
@OutThisLife

Copy link
Copy Markdown
Collaborator

Superseded by #69796 — cherry-picked so your authorship is preserved, then re-ported onto the merged ChoiceButton (#69769). normalizeChoices + the diagnostics are intact and now sanitize both the gateway and tool-args paths. Thanks @webtecnica! Closing in favor of the rebased version.

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/desktop Electron desktop app (apps/desktop/*) sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state duplicate This issue or pull request already exists labels Jul 23, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of active salvage #69796. It carries the same clarify-choice normalization mechanism onto the current component shape; this closed predecessor remains preserved for authorship and history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/desktop Electron desktop app (apps/desktop/*) duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Desktop]: clarify options / multi-question prompts often render with no selectable choices — umbrella report (chat-render + 3 known triggers)

3 participants