feat(app): add expand-last thinking display option and format markdown - #3370
feat(app): add expand-last thinking display option and format markdown#3370mcowger wants to merge 7 commits into
Conversation
|
| Filename | Overview |
|---|---|
| packages/app/src/utils/thinking-text-formatter.ts | Adds Markdown normalization, but still rewrites valid adjacent emphasis and does not protect all code delimiter forms. |
| packages/app/src/agent-stream/view.tsx | Implements latest-thought selection and applies formatting and expansion policy to thought items. |
| packages/app/src/components/tool-call-details.tsx | Adds compact Markdown rendering and bottom-following behavior for streamed details. |
| packages/app/src/hooks/use-settings/storage.ts | Introduces the three-state thinking-display setting with legacy-value migration. |
| packages/app/src/screens/settings/appearance/appearance-section.tsx | Replaces the boolean reasoning switch with a localized three-option dropdown. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart LR
A[Model reasoning or tool input] --> B[formatThinkingText]
B --> C[MarkdownRenderer]
C --> D[Thinking or tool-call details]
E[Thinking display setting] --> F[Expansion policy]
F --> D
Reviews (7): Last reviewed commit: "Merge branch 'main' into feat-expand-act..." | Re-trigger Greptile
| return ""; | ||
| } | ||
|
|
||
| // Preserve code blocks (including in-progress streaming code blocks) and inline code spans |
There was a problem hiding this comment.
Code delimiters remain unprotected
When thinking or tool text contains adjacent bold-like characters inside a tilde-fenced block or a code span using multiple backticks, the preservation regex fails to recognize the code region and inserts blank lines into it, causing the rendered content to differ from the model or tool output.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
@boudra Could you review this one? |
|
|
||
| // Separate adjacent bold blocks (e.g. **title1****title2** or **title1** **title2**) | ||
| // Also handles streaming when the second bold tag is opened: **title1****streaming... | ||
| return part.replace(/(\*\*[^*\s\n](?:[^*\n]*?[^*\s\n])?\*\*)\s*(?=\*\*)/g, "$1\n\n"); |
There was a problem hiding this comment.
Adjacent emphasis becomes separate blocks
When model reasoning or tool input contains legitimate adjacent emphasized prose such as Compare **foo** **bar** before continuing., this replacement inserts a blank line between the emphasized words, causing inline prose to render as separate Markdown blocks.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Type of change
Reasoning
Users often want to monitor agent reasoning while it is actively streaming and keep the most recent thinking block visible after it completes, without having every historic block across previous turns permanently expanded. Furthermore, certain models (e.g. Codex) output bold thinking headers without separating newlines (
**title1****title2**), and previously thinking blocks were rendered as raw unformatted text rather than parsed Markdown.This PR adds an Expand Last thinking display detail option so the latest thinking block remains expanded while streaming and stays expanded once complete, collapsing older thinking blocks. It also formats thinking headers cleanly and renders thinking content as rich compact Markdown.
Goals
Expand Lastoption to the thinking display setting alongsideCollapsedandAlways expand.Expand Lastis selected.true->expanded,false->collapsed,expand_active->expand_last).**title1****title2**->**title1**\n\n**title2**) without breaking inline prose markdown.<MarkdownRenderer compact />.Non-goals
QA
storage.test.tsfor boolean flags and enum values (collapsed,expand_last,expanded,expand_active).thinking-text-formatter.test.tsacross adjacent headers, numbered steps, streaming inputs, and inline bold prose.resources.test.ts.typecheck,lint, andformat.Checklist