Skip to content

fix(antigravity): show queued sends and add a shared agent rules editor - #448

Open
yuga-hashimoto wants to merge 4 commits into
mainfrom
fix/antigravity-busy-and-interject
Open

yuga-hashimoto wants to merge 4 commits into
mainfrom
fix/antigravity-busy-and-interject

Conversation

@yuga-hashimoto

@yuga-hashimoto yuga-hashimoto commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

概要

  • Antigravity は1ターン=1プロセスのため実行中の送信は強制キューになるが、その経路が送信メッセージを画面に追加しておらず「送信が消えた」ように見えていた。キュー時点で吹き出しを表示し、drain 時に二重表示しないよう修正。
  • 実行中でも Send できるように(sendBehavior == "queue" または forcesQueue のランタイム)。あわせて、これまで Chat に渡っていなかった sendBehavior 設定を配線。
  • 実行中チャットを開き直したとき isRunning が false になり、次の送信が「割り込み」として agy のプロセスを殺していた問題を修正(実行中ならキューに回す)。
  • サイドメニューの実行中スピナーが、チャットを切り替えた時点で消えていた問題を修正(実行終了はランタイム自身の idle / watchdog に任せる)。
  • main の PR fix(antigravity): run multiple sessions in parallel #446(起動ウィンドウだけを排他するゲート)に追従し、AntigravityRuntime.send を per-session lock に変更。同一チャットの次の送信は前のターン完了まで待ち、別チャットは並行のまま。
  • 共通エージェント指示の配布先に Codex (root/.codex/AGENTS.md) を追加。
  • 設定 → チャット に「共通ルール」画面を追加。AndCode 共通コンテキストの閲覧(読み取り専用)と、ユーザー追記の編集を可能にし、OpenCode / Claude Code / Antigravity / Codex の各指示ファイルへ次回ランタイム起動時にまとめて反映する。

検証

この環境ではビルド/テストを実行しない方針(JIT が使えず Gradle が極端に遅い)のため、ローカルゲートは未実行です。CI にビルドとテストを任せます。ChatViewModelTest の新規3件は変更前にローカルで通過済みです。origin/main を取り込み済みです。

Pre-PR review

判定: APPROVE

ブロッカー

なし

提案(非ブロッキング)

  • AntigravityRuntime.kt:79 — sessionLocks はセッションごとに ReentrantLock を保持したまま削除されません。チャット数に比例する程度の軽微なリークです(実害は小)。気になるなら withSessionLock の finally で、待機者/保有者がいないときだけ sessionLocks.remove(sessionId, lock) する余地はありますが、必須ではありません。
  • AntigravityRuntime.kt:620-634 — 新しい per-session 直列化にはユニットテストがありません(send() は PRoot 実プロセス依存で単体化が難しいため妥当)。挙動はチャット層のキュー系テストで間接的に守られていますが、可能なら抽象化した lock ヘルパのテストがあると安心です。
  • 前回見送りと承知の2件(retainUserTexts の id 化、bundled のオフスレッド読み込み)は引き続き非ブロッキングです。

チェック済み項目

  • マージ結果の確認: origin/main = a960fad2(PR fix(antigravity): run multiple sessions in parallel #446/feat(drawer): show each chat's pull request state in the sidebar #447 取り込み後)。origin/main..fix/antigravity-busy-and-interject = 93b8bedb(merge)/9de1fb15/b78f0baa/5c3b24e6。コンフリクトは AntigravityRuntime.kt のみで、他は自動マージ。git show/git diff origin/main で解決後の全体を確認。
  • PR fix(antigravity): run multiple sessions in parallel #446 との整合: AntigravityProcessGate は main 版と完全一致(serialize/SEND_MAX_WAIT_MS は存在せず、exclusive/acquireThenRelease/withoutPipe/readWithTimeout のみ)。ブランチ側に serialize 参照は残っておらず、他ファイルも main のまま(grep で確認)。コンパイル破綻なし。
  • per-session 直列化の正しさ: send() 全体を withSessionLock(sessionId) で包み、effectiveConversationId(:253)と prepareAntigravityPrompt(:258)をロック取得後に計算。別セッションは各自のロック+短い起動グレース(acquireThenRelease :284, 2.5s)だけを共有し並行可。kill しない方針と一致。
  • デッドロック/解放: abort はセッションロックを取らないため lock 順序の逆転なし。withSessionLock は private inline(private メンバ sessionLocks を参照可)で、return@runCatching(:405/:412)は inline 展開により内側のプロセス後始末 finally→ロック解放 finally の順で確実に通る(tryLock 失敗時は try に入る前に throw するので二重 unlock なし)。別セッション同時送信でも詰まらない。
  • プロセス後始末の順序: 内側 try/finally(:419-425 の processes.remove(sessionId, process)+terminate)がロック解放より先に走るため、同一セッションの次送信が processes 登録を上書きした後に前ターンが誤って消す競合は起きない。processes[sessionId] はスタートアップグレース前(:309)に登録され、abort/abortAll がグレース中も停止可能。
  • busy 経路: acquireThenRelease が null(ゲート60s待ち)のときはプロセス未起動で error(...) → runCatching の onFailure が SessionError+SessionIdle を emit。プロセスリークなし。
  • 既存修正の保持: HEAD で retainUserTexts 全10箇所、fromQueue 3分岐(offline :1535 / queue :1569 / normal :1580 いずれも if (fromQueue))、isSessionRunning(本体 :684/:1134、Koin ViewModelModule.kt:31)が健在。マージで欠落なし。
  • ビルド設定: kotlinOptions に allWarningsAsErrors は無く、turnError 未読(main 由来の既存)等の警告でビルドは落ちない。java.util.concurrent.locks.ReentrantLock/TimeUnit は完全修飾で import 不要、ConcurrentHashMap は既存 import 済み。

Antigravity runs each turn as a one-shot process, so a send while it is running is queued rather than interrupting. That path dropped the message from the screen entirely, which read as if the send had been swallowed. Draw the bubble when it is queued and send it without adding a second copy when the queue drains.\n\nAlso: open a chat whose run is still in flight as running, so a send there queues behind it instead of killing the process; keep a navigated-away run's drawer spinner until the runtime reports its own idle; and wire the send-behavior setting into the chat, which had been read only at its default.
The common AndCode context is written into each agent's native instruction file, but there was no way to see or extend it from the app and Codex was not covered at all. Add root/.codex/AGENTS.md to the installed targets, and add a Settings screen that shows the bundled context and stores the user's own addition. The addition is appended once and written to OpenCode, Claude Code, Antigravity and Codex together on the next runtime start.
- Pass isSessionRunning through the Koin ChatViewModel binding too, so both construction paths stay in step.\n- Do not re-add a drained queued bubble if the connection dropped and the send fell into the offline branch.\n- Correct the Antigravity kill comment now that a same-session supersede no longer kills the process.
…and-interject

# Conflicts:
#	app/src/main/java/com/yugahashimoto/andcode/runtime/local/AntigravityRuntime.kt

This branch has not been deployed

No deployments
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.

1 participant