Skip to content

Extend collapsible message UI to assistant responses and keep only the latest expanded#23

Closed
Hong-Seungmin wants to merge 6 commits into11me:masterfrom
Hong-Seungmin:dev
Closed

Extend collapsible message UI to assistant responses and keep only the latest expanded#23
Hong-Seungmin wants to merge 6 commits into11me:masterfrom
Hong-Seungmin:dev

Conversation

@Hong-Seungmin
Copy link
Copy Markdown

Motivation

The existing message-collapsing UI was originally focused on user messages, but it needed to be extended consistently to assistant responses as well.

From a UX perspective, keeping every assistant response expanded would reduce readability and make the conversation view feel dense. To balance readability and screen efficiency, the intended behavior is to keep only the most recent assistant response expanded by default.

We also needed to make the implementation more resilient to ChatGPT DOM variations, since assistant messages do not always include .user-message-bubble-color. This required stronger container discovery logic.

Changes

  • Expanded the collapsing target selector from user-only elements to a new COLLAPSIBLE_ROOT_SELECTOR that includes both user and assistant messages.
  • Improved the initial state logic for assistant messages by introducing isLatestAssistantRoot and shouldStartExpanded, so that only the latest assistant root starts expanded.
  • Added normalizeAssistantExpansion() to normalize assistant message states after batch processing, ensuring that only the most recent assistant response remains expanded while earlier responses are collapsed.
  • Improved support for assistant-side DOM variations by using deriveBubbleContainer(), allowing the toggle UI to be attached and removed reliably even when the bubble class is missing.
  • Preserved the existing collapse behavior, including clamp, fade, toggle, and scroll position retention.

Testing

  • Type check: npm run build:types
  • Unit tests: npm test

Additional and updated tests were added for the following scenarios:

  • long assistant messages start expanded by default
  • when multiple assistant messages exist, only the latest one is expanded
  • when a new assistant response arrives, the previous response is automatically collapsed and the latest response remains expanded

Notes

  • This work was developed with Codex (GPT-5.2-Codex).

@11me
Copy link
Copy Markdown
Owner

11me commented Feb 27, 2026

Hey, thanks for PR, have you tested this manually in chrome and firefox?

@Hong-Seungmin Hong-Seungmin deleted the dev branch March 3, 2026 04:51
@Hong-Seungmin Hong-Seungmin restored the dev branch March 3, 2026 04:51
@Hong-Seungmin Hong-Seungmin deleted the dev branch March 3, 2026 04:55
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.

2 participants