Skip to content

feat: Compact CoT display#2954

Open
RoyBA wants to merge 3 commits into
Chainlit:mainfrom
RoyBA:feat/compact-cot-display
Open

feat: Compact CoT display#2954
RoyBA wants to merge 3 commits into
Chainlit:mainfrom
RoyBA:feat/compact-cot-display

Conversation

@RoyBA

@RoyBA RoyBA commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds two new [UI] config options (cot_display and show_step_details) that give app developers control over how Chain of Thought steps are displayed in the chat interface.

ezgif-2cbe8b40b7b3e27d

Motivation

When an agent uses many tools sequentially, the default "list" display creates a long vertical stack of individual step accordions. This can overwhelm users who only care about the final result. The new compact mode provides a ChatGPT-style collapsible summary.

New Config Options

Added to .chainlit/config.toml under [UI]:

Option Values Default Description
cot_display "list" | "compact" "list" list = current behavior (each step as its own accordion). compact = all steps collapsed into one summary line.
show_step_details true | false true When false, steps render as flat labels without expandable input/output.

Compact Mode Behavior

  • Shows animated "Using {tool_name}" label while the run is active
  • Shows "Used N steps" (or "Used N tools" in tool_call cot mode) when complete
  • Clicking expands to reveal individual steps in a bordered list
  • Only activates when there are 2+ visible steps (single steps render normally)
  • Includes avatar matching the Message component pattern
  • Works with nested agent architectures (LangChain, LangGraph, LlamaIndex) where tools are wrapped under intermediate run steps

Changes

Backend:

  • config.py — Added cot_display and show_step_details to UISettings model + TOML template
  • translations/*.json — Added usedSteps and usedTools keys to all 23 language files

Frontend:

  • messageContext.ts / MessageContext.tsx — Added cotDisplay and showStepDetails to context
  • MessagesContainer/index.tsx / ReadOnlyThread.tsx — Wire config values into context
  • Messages/index.tsx — Compact mode branching logic for CL_RUN_NAMES handler
  • Messages/CompactSteps.tsx — New component for compact step summary
  • Messages/Message/Step.tsx — Respect showStepDetails to render flat label

Types:

  • libs/react-client/src/types/config.ts — Added TS types for new config fields

Testing

  • Backend: 784 tests pass (4 pre-existing failures unrelated to this PR)
  • Frontend: 32 unit tests pass
  • ESLint: Clean
  • Prettier: Clean
  • Manual: Tested with a 5-tool sequential demo app and a LangGraph ReAct agent in both list and compact modes

Backward Compatibility

Both options default to the existing behavior (list / true). No breaking changes — apps without these config keys behave identically to before.

⚠️ Translations: Existing apps with local .chainlit/translations/ files will see lint warnings for the new usedSteps/usedTools keys on startup. This only affects users who opt into cot_display = "compact". To pick up the new keys, delete the local .chainlit/translations/ folder and restart — Chainlit will regenerate it from the updated source. This follows the same pattern as all prior translation additions in this project.


Summary by cubic

Adds a compact Chain of Thought display with a toggle to hide step details, plus improved nested step counting and smoother “Using …” timing. This reduces chat clutter and lets apps control how tool runs are shown.

  • New Features

    • [UI] config: cot_display = "list" | "compact" (default "list"), show_step_details = true | false (default true).
    • Compact mode: shows “Using {tool}” until the assistant answer starts, then “Used N steps/tools”. Click to expand. Activates only when 2+ visible steps (counts nested). Works with nested agent steps.
    • Frontend: new CompactSteps component; context adds cotDisplay and showStepDetails; steps respect showStepDetails; ReadOnlyThread now respects features.latex and dataPersistence.
    • Backend/types/translations: UISettings adds fields; TS types updated; new i18n keys usedSteps/usedTools; Dutch usedTools wording updated to “hulpmiddelen”.
  • Migration

    • No breaking changes. Defaults keep the current UI.
    • To enable: set [UI] cot_display = "compact" (and optionally show_step_details = false) in .chainlit/config.toml.
    • If you have a local .chainlit/translations/ folder, delete it to regenerate and pick up usedSteps/usedTools.

Written for commit b3983ed. Summary will update on new commits.

Review in cubic

RoyBA added 2 commits June 10, 2026 17:06
Add two new UI configuration options for controlling Chain of Thought
step rendering:

- `cot_display`: "list" (default, current behavior) or "compact"
  (collapses all steps into a single summary accordion line like
  "Using search_web" / "Used 5 tools")
- `show_step_details`: boolean (default true). When false, steps
  render as flat labels without expandable input/output details.

New CompactSteps component groups step-type children under one
accordion with an animated "Using X" label while running and a
"Used N steps/tools" summary when complete.

Includes translations for all 23 supported languages.
- Add countVisibleSteps helper that walks the full step subtree,
  fixing compact mode not activating when tools are nested under
  intermediate agent/run steps (e.g. LangGraph, LangChain).
- In CompactSteps, use collectVisible for recursive count/naming
  and pass all step-type children to <Messages> so existing skip
  logic drills through intermediates to reach tools.
- Switch showUsing signal from isRunning to !hasAnswer (presence of
  assistant_message in subtree), preventing both the flash between
  sequential tools and the stale "Using" label during answer streaming.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2 issues found across 32 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread frontend/src/components/ReadOnlyThread.tsx
Comment thread backend/chainlit/translations/nl.json Outdated
…middelen'

feat(ReadOnlyThread): add support for latex and dataPersistence features
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 10, 2026
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 14 days with no activity.

@github-actions github-actions Bot added stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed and removed stale Issue has not had recent activity or appears to be solved. Stale issues will be automatically closed labels Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant