feat: 詳細ビューの Ctrl+C で実行中のターンを中断できるようにする - #89
Merged
Conversation
走り出したセッションを止める手段が破棄(d)しかなく、「やめたいのはターンだけで worktree と会話は残したい」(Claude Code の Ctrl+C と同じ期待)に応えられていなかった。 Session.interrupt() は以前からあったが UI から呼ばれておらず、素直に呼ぶと CLI の 打ち切り result(is_error: true)が failed に分類されて再開できなくなっていた。 - STATUS_META に interruptible を追加(running / awaiting_* = ターンが生きている区間。 awaiting_* は「動いていないが中断できる」ので active とは別フラグ) - Session.interrupt(): SDK の応答を待たず先に interrupted を確定(体感 + 分類)。 Query.interrupt() は best-effort。許可待ちで押された場合は既存の commit() 経路が canUseTool を deny で閉じる(未応答の tool_use は後の resume を壊す) - sdk-parse: terminal_reason='aborted_streaming' を interrupted に分類(実測フィクスチャ 準拠。文言ではなく構造で判定し、CLI の内部診断はログに出さない) - SessionManager.interrupt(id) はストアの現在値で判定して連打を吸収(resume と同じ) - 詳細ビューは pending ガードより前で Ctrl+C を処理(許可/質問ダイアログ中も中断できる)。 案内は detail.cancelHint(実行中)⇄ resume.oneKeyHint(中断後)で入れ替え
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
セッション詳細ビューで
Ctrl+Cを押すと、そのセッションが実行中のターンを中断できるようにしました(現行の Claude Code のCtrl+Cと同じ操作感)。中断されたセッションは失敗ではなく「中断」として残るので、そのままCtrl+R/ 追加指示で同じ会話の続きから再開できます。これまで走っているセッションを止める手段は破棄(
d)だけで、「やめたいのはターンだけ、worktree と会話は残したい」に応える出口がありませんでした。Session.interrupt()は元からありましたが UI から呼ばれておらず、しかも素直に呼ぶとfailedに落ちて再開できないという問題がありました(CLI は打ち切ったターンをis_error: trueの result で閉じるため)。変更点
core/status-meta.tsSTATUS_METAにinterruptibleを追加(running/awaiting_permission/awaiting_input)+isInterruptible()。awaiting_*は「動いていないが中断できる」のでactiveとは別フラグcore/session.tsinterrupt()を「ターンだけをやめる」操作として整備。SDK の応答を待たず先にinterruptedを確定 →Query.interrupt()は best-effort(reject を握り潰す)core/sdk-parse.tsterminal_reason: 'aborted_streaming'(= 中断された result)をinterrupted(resumable) に分類。文言ではなく構造で判定し、ログにはUSER_INTERRUPT_DETAILを書く(CLI の[ede_diagnostic] …は出さない)core/session-manager.tsinterrupt(id): Promise<boolean>がストアの現在値で対象を判定(連打の吸収はresume()と同じ理由で core 側)ui/session-detail.tsxCtrl+Cをpendingガードより前で処理(許可/質問ダイアログ表示中も中断できる)。案内はdetail.cancelHint(実行中)⇄resume.oneKeyHint(中断後)で同じ 1 行を入れ替えcore/i18n.tsdetail.cancelHint(ja / en 対)設計上のポイント
is_error: trueなので診断が無いとfailedになる。先にinterruptedを立てておけば、result 側は既存のロールアップガード(isResumable)でコストだけを拾う。sdk-parse側のaborted_streaming判定は保険。中断のあとに assistant メッセージが挟まって status がrunningに戻ってもfailedにならない。2 経路とも同じ文言を使うのでtoInterruptedの重複畳み込みが効き、ログは 1 行だけ。n(拒否)は「そのツール 1 回を断る」だけなので、作業自体をやめる出口が他にない。toInterruptedがpendingPermissionを落とすことで、既存のcommit()経路が canUseTool の promise を deny で閉じる(未応答のtool_useで終わる transcript は後の resume を壊すため)。Ctrl+Cにすると、選択行を取り違えたときに別の走っているセッションを止めてしまうため、中断は詳細ビュー限定の操作にしました。テスト計画
core/status-meta.spec.ts:isInterruptibleの全ステータス表core/session.spec.ts: 中断でinterruptedになる /aborted_streamingの result でfailedに落ちない・ログが 1 行 / 終端状態では no-op / 保留中の許可を deny で閉じるcore/session-manager.spec.ts: 対象(running・awaiting_*)と非対象(creating・completed・interrupted・failed・archived)の表 + 未知 idcore/sdk-parse.spec.ts: 実採取フィクスチャ(session-interrupt.jsonl)がinterruptedになる(従来はfailed)tests/app.test.tsx:Ctrl+Cでinterrupted+ 案内が再開へ入れ替わる / 許可ダイアログ表示中の中断(deny も飛ぶ)lint/typecheck/test(カバレッジ閾値込み)/buildすべて緑Ctrl+C→ 「中断」バッジ +Ctrl+Rで続きから再開できること、質問ダイアログ中のCtrl+Cドキュメント
README.md(「実行中の作業を中断する(Ctrl+C)」節)/docs/ARCHITECTURE.md(状態機械 + 「ユーザーによる中断」節)/docs/TECH_NOTES.md(interrupt の実測フィールド)/docs/TASKS.md(Phase 24)/.claude/rules/session-domain.md/.claude/rules/ink-components.md/.claude/skills/add-session-status/SKILL.md(7 フィールド化)🤖 Generated with Claude Code