Skip to content

feat: collapse chat reasoning and tool calls into one expandable row#87

Merged
yuga-hashimoto merged 1 commit into
mainfrom
claude/worktree-setup-7wztrh
Jul 25, 2026
Merged

feat: collapse chat reasoning and tool calls into one expandable row#87
yuga-hashimoto merged 1 commit into
mainfrom
claude/worktree-setup-7wztrh

Conversation

@yuga-hashimoto

@yuga-hashimoto yuga-hashimoto commented Jul 25, 2026

Copy link
Copy Markdown
Owner

概要

エージェントが1ターンで多数のツールを呼ぶと、「思考」「bash …」「read …」のカードが1件ずつ積み上がり、肝心の回答本文がスクロールの遥か下に埋もれていた。

Claude のチャットと同じように、連続する思考/ツール実行を 1行のサマリに集約し、タップするとボトムシートで全ステップを確認できるようにした。

Before / After

Before — パーツごとに1カード

🔧 bash  git tag --sort=-versi…  完了 ⌄
🧠 思考                              ⌄
🔧 bash  gh run watch 30156…     完了 ⌄
🧠 思考                              ⌄
🔧 read  workspace/openco…       完了 ⌄
🧠 思考                              ⌄
🧠 思考                              ⌄

リリース番号も確認したところ…

After — 1行に集約、タップでボトムシート

✦ 3件のコマンドを実行しました、4件の…  ›

リリース番号も確認したところ…

✦ 2件のファイルを編集しました        ›

以上で対応完了です。

実行中は件数に畳まず、進行中のステップ名を出したままにする:

⟳ bash  gh run watch 30156…   実行中  ›
   ↓ 完了後
✦ 3件のコマンドを実行しました、4件の…    ›

変更点

  • AssistantActivityGroup.kt(新規) — 純粋関数のグルーピング/集計。groupAssistantTimeline() が本文テキストを区切りとして連続する Reasoning/Tool/Patch を1グループに畳む。ストリーミング開始時に来る空テキストパートは区切りにしない(区切りにすると1件ずつ分断される)。グループIDは先頭パートのIDなので、runが伸びても Compose の key が安定する。
  • AssistantActivityRow.kt(新規) — 集約行とボトムシート。シートの中身は既存の ReasoningCard / ToolCard / PatchCard をそのまま再利用しているので、入力/出力の展開や出力の切り詰め表示は従来どおり。
  • AssistantTimelinemessage.parts を直接回す代わりにグルーピング結果を描画。
  • シート状態は画面側(ChatHomeScreen / OpenCodeChatScreen)に持ち上げた。LazyColumn の item 内に置くと、開いたまま item が画面外に出た瞬間に破棄されてしまうため。
  • シートはパーツのスナップショットではなくグループIDを保持し、findActivityParts() で毎回 state.messages から引き直す。実行中のグループを開くと新しいステップがそのまま流れ込む。
  • ツールアイコンを固定の Build から種別マップ(Terminal / Visibility / Description / Hub)に変更。
  • 文字列を10キー追加。i18n-check.yml がキー一致を検査するため、8ロケール全部に入れた。リポジトリは plurals リソースを一切使っていないので、慣習どおり %1$d プレースホルダの通常の string リソースで統一。

テスト

AssistantActivityGroupTest.kt を新規追加(10ケース):

  • 連続ツールが1グループに畳まれる / 本文テキストで分割される
  • 空・空白のみのテキストパートでは分割されない
  • グループIDが先頭パートIDと一致し、runが伸びても変わらない
  • カテゴリ別カウント、ChatPart.Patch を編集として数える
  • 実行中は最初の in-flight ツールを返す、エラーを含む run にフラグが立つ
  • findActivityParts() がメッセージ横断でグループを解決する

ローカル実行結果

コマンド 結果
./gradlew spotlessCheck
./gradlew :app:testDebugUnitTest ✅ 10/10
./gradlew :app:lintDebug ✅ 0 errors
./gradlew :app:assembleDebug

lintDebugPluralsCandidate の警告が6件増えるが、これは既存の %1$d + 単語の文字列(values/strings.xml の 174 / 388-390 / 553-554 行など)と同じパターンで、リポジトリが plurals リソースを使っていない方針に合わせたもの。エラーは0件。

未実施

実機/エミュレータでの目視確認(実行中 → 畳まれる → タップでシートが開く → シートを開いたままチャットが伸びても閉じない)は行えていない。ロジックはユニットテストで担保しているが、見た目の最終確認は別途必要。

A turn with many tool calls used to stack one card per part, burying the
answer text far below the fold. Consecutive reasoning/tool/patch parts now
collapse into a single summary row ("Ran 12 commands, read 22 files"), split
only by body text so the narrative order of the answer survives.

Tapping the row opens a bottom sheet with every step, reusing the existing
ReasoningCard/ToolCard/PatchCard so input, output and truncation rendering
stay as they were. The sheet holds the group id rather than a snapshot and
re-resolves it against current messages, so a run that is still executing
keeps streaming steps into an open sheet.

While a step is in flight the row names that step instead of showing counts,
so the user can still see what the agent is doing right now.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01X45Xeoa1CPeUbr5XxdHXXV
@yuga-hashimoto
yuga-hashimoto marked this pull request as ready for review July 25, 2026 16:08
@yuga-hashimoto
yuga-hashimoto merged commit 9e8d18f into main Jul 25, 2026
3 checks passed
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