ring-cli 0.17.6__tar.gz → 0.18.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. {ring_cli-0.17.6 → ring_cli-0.18.0}/PKG-INFO +1 -1
  2. {ring_cli-0.17.6 → ring_cli-0.18.0}/pyproject.toml +1 -1
  3. {ring_cli-0.17.6 → ring_cli-0.18.0}/pyproject.toml.orig +1 -1
  4. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/cli.py +35 -12
  5. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/hook.py +89 -1
  6. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/hook_protocol.py +4 -1
  7. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/locale/en/LC_MESSAGES/ring.mo +0 -0
  8. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/locale/en/LC_MESSAGES/ring.po +3 -0
  9. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/locale/ring.pot +114 -110
  10. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/registry.py +5 -1
  11. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/sources/__init__.py +3 -0
  12. ring_cli-0.18.0/src/ring/terminal.py +215 -0
  13. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/tui.py +14 -3
  14. {ring_cli-0.17.6 → ring_cli-0.18.0}/LICENSE +0 -0
  15. {ring_cli-0.17.6 → ring_cli-0.18.0}/README.en.md +0 -0
  16. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/__init__.py +0 -0
  17. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/__main__.py +0 -0
  18. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/agent_notify.py +0 -0
  19. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/commands/__init__.py +0 -0
  20. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/commands/_args.py +0 -0
  21. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/commands/completion.py +0 -0
  22. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/commands/digest.py +0 -0
  23. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/commands/doctor.py +0 -0
  24. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/commands/focus.py +0 -0
  25. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/commands/gc.py +0 -0
  26. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/commands/hook.py +0 -0
  27. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/commands/quiet.py +0 -0
  28. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/commands/stats.py +0 -0
  29. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/config.py +0 -0
  30. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/focus/__init__.py +0 -0
  31. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/focus/applescript.py +0 -0
  32. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/focus/base.py +0 -0
  33. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/focus/iterm2.py +0 -0
  34. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/focus/kitty.py +0 -0
  35. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/focus/linux_wm.py +0 -0
  36. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/focus/neovim.py +0 -0
  37. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/focus/terminal.py +0 -0
  38. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/focus/tmux.py +0 -0
  39. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/focus/trace.py +0 -0
  40. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/fsutil.py +0 -0
  41. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/gc.py +0 -0
  42. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/i18n.py +0 -0
  43. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/ipc.py +0 -0
  44. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/labels.py +0 -0
  45. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/notify/__init__.py +0 -0
  46. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/notify/base.py +0 -0
  47. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/notify/command.py +0 -0
  48. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/notify/notify_send.py +0 -0
  49. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/notify/ntfy.py +0 -0
  50. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/notify/osascript_notifier.py +0 -0
  51. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/notify/terminal_notifier.py +0 -0
  52. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/notify/webhook.py +0 -0
  53. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/notify_queue.py +0 -0
  54. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/osascript.py +0 -0
  55. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/pathutil.py +0 -0
  56. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/payload_log.py +0 -0
  57. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/permission.py +0 -0
  58. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/plugins.py +0 -0
  59. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/ps_parse.py +0 -0
  60. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/question_detect.py +0 -0
  61. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/sources/base.py +0 -0
  62. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/sources/claude_code.py +0 -0
  63. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/sources/codex.py +0 -0
  64. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/sources/hook_registry.py +0 -0
  65. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/sources/local_llm.py +0 -0
  66. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/stats.py +0 -0
  67. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/subproc.py +0 -0
  68. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/tmux_scan.py +0 -0
  69. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/transcript.py +0 -0
  70. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/waiting.py +0 -0
  71. {ring_cli-0.17.6 → ring_cli-0.18.0}/src/ring/watcher.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ring-cli
3
- Version: 0.17.6
3
+ Version: 0.18.0
4
4
  Summary: RiNG — Realtime Instance Notification Grid for active agent CLI sessions.
5
5
  Keywords: claude-code,codex,ollama,llama-cpp,tui,dashboard,session,monitor,rich
6
6
  Author: Wei Lee
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ring-cli"
3
- version = "0.17.6"
3
+ version = "0.18.0"
4
4
  description = "RiNG — Realtime Instance Notification Grid for active agent CLI sessions."
5
5
  readme = "README.en.md"
6
6
  requires-python = ">=3.13"
@@ -2,7 +2,7 @@
2
2
  # import 的 module(見 [tool.uv.build-backend] module-name)與 CLI 指令仍是 `ring`。
3
3
  [project]
4
4
  name = "ring-cli"
5
- version = "0.17.6"
5
+ version = "0.18.0"
6
6
  description = "RiNG — Realtime Instance Notification Grid for active agent CLI sessions."
7
7
  readme = "README.en.md"
8
8
  requires-python = ">=3.13"
@@ -40,6 +40,7 @@ from ring.notify_queue import flush_if_due
40
40
  from ring.plugins import load_plugins
41
41
  from ring.registry import Session, Status, running_agent_pids
42
42
  from ring.sources import discover_sessions
43
+ from ring.terminal import TERMINAL_LABEL_MAX, show_terminal_column, terminal_labels
43
44
 
44
45
  try:
45
46
  from rich.box import SIMPLE_HEAD
@@ -174,7 +175,9 @@ def _status_text(s: Session) -> str:
174
175
  return f"{s.status.marker} {status_label(s.status)}{suffix}"
175
176
 
176
177
 
177
- def _rich_renderable(sessions: list[Session], show_legend: bool, show_tool: bool = True) -> Group:
178
+ def _rich_renderable(
179
+ sessions: list[Session], show_legend: bool, show_tool: bool = True, show_terminal: bool = False
180
+ ) -> Group:
178
181
  pids = running_agent_pids()
179
182
  blocks: list[Any] = [Text(_header(len(sessions), len(pids)), style="bold")]
180
183
  if show_legend:
@@ -190,11 +193,14 @@ def _rich_renderable(sessions: list[Session], show_legend: bool, show_tool: bool
190
193
  table.add_column(_("專案"), style=_COLORS["project"], no_wrap=True)
191
194
  table.add_column(_("進度"), justify="right", no_wrap=True)
192
195
  table.add_column(_("閒置"), justify="right", no_wrap=True)
196
+ if show_terminal:
197
+ table.add_column(_("終端"), no_wrap=True, max_width=TERMINAL_LABEL_MAX)
193
198
  table.add_column(_("去哪"), style=_COLORS["location"], no_wrap=True, min_width=16, max_width=_LOC_MAX)
194
199
  # action 可能很長:給 max_width 上限,否則 no_wrap 會吃掉整列寬度、把其他欄壓成 0。
195
200
  table.add_column(_("動作"), no_wrap=True, overflow="ellipsis", max_width=50)
196
201
 
197
202
  labels = load_labels()
203
+ term_labels = terminal_labels(sessions) if show_terminal else {}
198
204
  for s in sessions:
199
205
  status_cell = Text(_status_text(s), style=_STATUS_STYLE[s.status])
200
206
  progress = f"{s.todo[0]}/{s.todo[1]}" if s.todo else "·"
@@ -203,7 +209,10 @@ def _rich_renderable(sessions: list[Session], show_legend: bool, show_tool: bool
203
209
  cells: list[Any] = [status_cell]
204
210
  if show_tool:
205
211
  cells.append(provider_label(s.provider))
206
- cells += [project_cell, progress, _rel(s.idle_for), loc_cell, s.last_action]
212
+ cells += [project_cell, progress, _rel(s.idle_for)]
213
+ if show_terminal:
214
+ cells.append(Text(term_labels[s.session_id])) # Text:標籤來自使用者環境,不可當 markup 解析
215
+ cells += [loc_cell, s.last_action]
207
216
  table.add_row(*cells)
208
217
 
209
218
  blocks.append(table)
@@ -211,7 +220,9 @@ def _rich_renderable(sessions: list[Session], show_legend: bool, show_tool: bool
211
220
 
212
221
 
213
222
  # ----------------------------------------------------------------------------- plain fallback
214
- def _render_plain(sessions: list[Session], show_legend: bool, show_tool: bool = True) -> str:
223
+ def _render_plain(
224
+ sessions: list[Session], show_legend: bool, show_tool: bool = True, show_terminal: bool = False
225
+ ) -> str:
215
226
  pids = running_agent_pids()
216
227
  lines = [_header(len(sessions), len(pids))]
217
228
  if show_legend:
@@ -222,6 +233,7 @@ def _render_plain(sessions: list[Session], show_legend: bool, show_tool: bool =
222
233
  return "\n".join(lines)
223
234
 
224
235
  labels = load_labels()
236
+ term_labels = terminal_labels(sessions) if show_terminal else {}
225
237
  rows = [
226
238
  (
227
239
  s.status.marker,
@@ -232,6 +244,7 @@ def _render_plain(sessions: list[Session], show_legend: bool, show_tool: bool =
232
244
  _rel(s.idle_for),
233
245
  _middle_truncate(s.location, _LOC_MAX),
234
246
  s.last_action[:48],
247
+ term_labels.get(s.session_id, ""),
235
248
  )
236
249
  for s in sessions
237
250
  ]
@@ -241,15 +254,20 @@ def _render_plain(sessions: list[Session], show_legend: bool, show_tool: bool =
241
254
  w_prog = max(len(c_prog), *(len(r[4]) for r in rows))
242
255
  w_ago = max(len(c_idle), 3, *(len(r[5]) for r in rows))
243
256
  w_loc = max(len(c_loc), *(len(r[6]) for r in rows))
257
+ c_term = _("終端")
258
+ w_term = max(len(c_term), *(len(r[8]) for r in rows))
244
259
  tool_h = f"{c_tool:<{w_tool}} " if show_tool else ""
245
- header = f" {tool_h}{c_proj:<{w_proj}} {c_prog:>{w_prog}} {c_idle:>{w_ago}} {c_loc:<{w_loc}} {c_act}"
260
+ term_h = f"{c_term:<{w_term}} " if show_terminal else ""
261
+ header = (
262
+ f" {tool_h}{c_proj:<{w_proj}} {c_prog:>{w_prog}} {c_idle:>{w_ago}} {term_h}{c_loc:<{w_loc}} {c_act}"
263
+ )
246
264
  lines += ["", header]
247
- for marker, kind_icon, tool, project, prog, ago, loc, action in rows:
265
+ for marker, kind_icon, tool, project, prog, ago, loc, action, term in rows:
248
266
  tool_c = f"{tool:<{w_tool}} " if show_tool else ""
267
+ term_c = f"{term:<{w_term}} " if show_terminal else ""
249
268
  marker_c = f"{marker}{kind_icon}"
250
- lines.append(
251
- f" {marker_c:<2} {tool_c}{project:<{w_proj}} {prog:>{w_prog}} {ago:>{w_ago}} 📍{loc:<{w_loc}} {action}"
252
- )
269
+ head = f" {marker_c:<2} {tool_c}{project:<{w_proj}} {prog:>{w_prog}} {ago:>{w_ago}}"
270
+ lines.append(f"{head} {term_c}📍{loc:<{w_loc}} {action}")
253
271
  return "\n".join(lines)
254
272
 
255
273
 
@@ -280,6 +298,8 @@ def render_json(sessions: list[Session]) -> str:
280
298
  "location": s.location,
281
299
  "tmux_target": s.tmux_target,
282
300
  "tty": s.tty,
301
+ "terminal": s.terminal,
302
+ "terminal_id": s.terminal_id,
283
303
  "idle_seconds": round(s.idle_for, 1),
284
304
  "last_active": s.last_active,
285
305
  "last_action": s.last_action,
@@ -314,10 +334,11 @@ def render_oneline(sessions: list[Session]) -> str:
314
334
  # ----------------------------------------------------------------------------- entry
315
335
  def print_snapshot(sessions: list[Session], show_legend: bool) -> None:
316
336
  show_tool = show_tool_column(sessions)
337
+ show_terminal = show_terminal_column(sessions)
317
338
  if HAVE_RICH:
318
- Console().print(_rich_renderable(sessions, show_legend, show_tool))
339
+ Console().print(_rich_renderable(sessions, show_legend, show_tool, show_terminal))
319
340
  else:
320
- print(_render_plain(sessions, show_legend, show_tool))
341
+ print(_render_plain(sessions, show_legend, show_tool, show_terminal))
321
342
 
322
343
 
323
344
  def _format_config_value(value: object) -> str:
@@ -433,7 +454,7 @@ def watch(interval: float, count: int, show_all: bool, show_legend: bool) -> int
433
454
  sys.stdout.write("\033[2J\033[H")
434
455
  sessions = board(show_all)
435
456
  _watch_flush_if_due(sessions)
436
- print(_render_plain(sessions, show_legend, show_tool_column(sessions)))
457
+ print(_render_plain(sessions, show_legend, show_tool_column(sessions), show_terminal_column(sessions)))
437
458
  print(f"\n{footer_text}")
438
459
  sys.stdout.flush()
439
460
  frames += 1
@@ -449,7 +470,9 @@ def watch(interval: float, count: int, show_all: bool, show_legend: bool) -> int
449
470
  while True:
450
471
  sessions = board(show_all)
451
472
  _watch_flush_if_due(sessions)
452
- body = _rich_renderable(sessions, show_legend, show_tool_column(sessions))
473
+ body = _rich_renderable(
474
+ sessions, show_legend, show_tool_column(sessions), show_terminal_column(sessions)
475
+ )
453
476
  live.update(Group(body, Text(f"\n{footer_text}", style=_MUTED)), refresh=True)
454
477
  frames += 1
455
478
  if count and frames >= count:
@@ -21,6 +21,7 @@ Agent CLI 在各事件把一段 JSON 從 stdin 餵進來。我們據此 upsert
21
21
  一般 Notification → 🟡 跑完停著;但既有狀態已是 🔴 時保住 🔴——Claude Code
22
22
  閒置滿 60 秒送的 idle_prompt 不是「使用者回應了」的證據
23
23
  (見 _notification_keeps_waiting)
24
+ SubagentStop → 只清該 subagent 名下的等待與暫存摘要(需帶 agent_id)
24
25
  SessionEnd → 刪檔(乾淨離場)
25
26
  """
26
27
 
@@ -53,6 +54,7 @@ from ring.registry import (
53
54
  unhide_session,
54
55
  )
55
56
  from ring.stats import log_transition
57
+ from ring.terminal import detect_terminal_info
56
58
  from ring.transcript import _extract_todo, _latest_action, _tail_records
57
59
  from ring.waiting import (
58
60
  FOREGROUND_OWNER,
@@ -246,6 +248,74 @@ def _record_session_state(data: dict[str, Any], selected_provider: str) -> None:
246
248
  _ring_waiting_now(*notification)
247
249
 
248
250
 
251
+ def _apply_subagent_stop(
252
+ path: Path, event: NormalizedHookEvent, prev_row: dict[str, Any], owner: str
253
+ ) -> tuple[NormalizedHookEvent, dict[str, Any], str] | None:
254
+ """SubagentStop 只做一件事:移除已收工 subagent 名下殘留的等待與暫存摘要。
255
+
256
+ 沒有既有 row、沒有 agent ID(Claude Code 內部 agent 無法對應 owner)、或該 owner 名下
257
+ 沒有東西可清時,一律不寫檔——不建列、不復活已離場 session、不刷新活動欄位。
258
+ 有東西可清時只改 waiting_requests/pending_permissions 與因此變動的 status 及其衍生欄位;
259
+ last_event、last_event_owner、last_action、last_active、heartbeat 維持原值。
260
+ """
261
+ if not prev_row or owner in (FOREGROUND_OWNER, UNKNOWN_OWNER):
262
+ return None
263
+ requests = read_waiting_requests(prev_row)
264
+ raw_pending = prev_row.get("pending_permissions")
265
+ pending_list = raw_pending if isinstance(raw_pending, list) else []
266
+ owns_pending = any(isinstance(item, dict) and item.get("owner") == owner for item in pending_list)
267
+ if owner not in requests and not owns_pending:
268
+ return None
269
+ requests.pop(owner, None)
270
+ row = dict(prev_row)
271
+ if isinstance(raw_pending, list):
272
+ row["pending_permissions"] = [
273
+ item for item in pending_list if not (isinstance(item, dict) and item.get("owner") == owner)
274
+ ]
275
+ row["waiting_requests"] = {key: asdict(request) for key, request in requests.items()}
276
+ prev_status = str(prev_row.get("status", ""))
277
+ status_value = prev_status
278
+ if prev_status == Status.WAITING.value:
279
+ for key in ("waiting_kind", "waiting_agent_id", "waiting_detail", "waiting_for"):
280
+ row.pop(key, None)
281
+ if requests:
282
+ selected = primary_wait(requests)
283
+ if selected.kind:
284
+ row["waiting_kind"] = selected.kind
285
+ if selected.owner.startswith("agent:"):
286
+ row["waiting_agent_id"] = selected.owner.removeprefix("agent:")
287
+ if selected.detail:
288
+ row["waiting_detail"] = selected.detail
289
+ if selected.waiting_for:
290
+ row["waiting_for"] = selected.waiting_for
291
+ else:
292
+ status_value = _status_without_waits(prev_row, event.provider).value
293
+ row["status"] = status_value
294
+ try:
295
+ atomic_write_text(path, json.dumps(row))
296
+ except OSError:
297
+ return None
298
+ if prev_status != status_value:
299
+ log_transition(event.session_id, event.provider, event.cwd, status_value)
300
+ return None
301
+
302
+
303
+ def _status_without_waits(prev_row: dict[str, Any], provider: str) -> Status:
304
+ """還原「主 session 在等待之外本來的狀態」:前景最後一筆事件經既有正規化得出;
305
+ 最後事件明確來自 subagent 或無法判定時取 WORKING;升級前的舊 row 沒有 last_event_owner
306
+ 欄位,當時的 last_event 都是前景事件,視同前景。"""
307
+ last_event = prev_row.get("last_event")
308
+ if (
309
+ prev_row.get("last_event_owner", FOREGROUND_OWNER) == FOREGROUND_OWNER
310
+ and isinstance(last_event, str)
311
+ and last_event
312
+ ):
313
+ normalized = adapter_for(provider).normalize({"hook_event_name": last_event, "session_id": "-"})
314
+ if normalized is not None and normalized.status in (Status.IDLE, Status.WORKING):
315
+ return normalized.status
316
+ return Status.WORKING
317
+
318
+
249
319
  def _update_session_state(
250
320
  path: Path, event: NormalizedHookEvent, data: dict[str, Any], process_names: tuple[str, ...]
251
321
  ) -> tuple[NormalizedHookEvent, dict[str, Any], str] | None:
@@ -254,6 +324,8 @@ def _update_session_state(
254
324
  prev_status = str(prev_row["status"]) if "status" in prev_row else None
255
325
  owner = event_owner(data)
256
326
  is_subagent_event = owner != FOREGROUND_OWNER
327
+ if event.event == "SubagentStop":
328
+ return _apply_subagent_stop(path, event, prev_row, owner)
257
329
  if is_subagent_event:
258
330
  # Subagent SessionEnd 不是 host session 的結束。
259
331
  if event.status is Status.ENDED:
@@ -405,6 +477,22 @@ def _update_session_state(
405
477
  if tty:
406
478
  payload["tty"] = tty
407
479
 
480
+ # terminal 種類/視窗識別:同 tmux_pane,subagent 事件與取不到時沿用前值。
481
+ previous_terminal = str(prev_row.get("terminal", "")) if same_binding else ""
482
+ previous_terminal_id = str(prev_row.get("terminal_id", "")) if same_binding else ""
483
+ if is_subagent_event:
484
+ terminal, terminal_id = previous_terminal, previous_terminal_id
485
+ else:
486
+ terminal, terminal_id = detect_terminal_info()
487
+ if not terminal:
488
+ terminal, terminal_id = previous_terminal, previous_terminal_id
489
+ elif not terminal_id and terminal == previous_terminal:
490
+ terminal_id = previous_terminal_id # 同一種 terminal 這次沒拿到 id:沿用前值
491
+ if terminal:
492
+ payload["terminal"] = terminal
493
+ if terminal_id:
494
+ payload["terminal_id"] = terminal_id
495
+
408
496
  # waiting 通知冷卻(防翻轉轟炸):hook 是短命 process,冷卻狀態持久化在 registry row
409
497
  # 的 waiting_notified_at(上次 waiting 通知的 epoch 時間戳)。離開 WAITING 也要把時間戳
410
498
  # 帶進新 row(payload 每次重建,不帶會遺失),快速翻回 WAITING 時才判得出「還在冷卻期」。
@@ -489,7 +577,7 @@ def _as_epoch(v: Any) -> float | None:
489
577
  _PENDING_DETAIL_TTL = 120.0
490
578
 
491
579
  # 這些事件代表權限已放行(工具跑完)或回合已推進(新輸入 / 回合結束)→ 清掉暫存。
492
- _PENDING_DETAIL_CLEAR_EVENTS = {"PostToolUse", "UserPromptSubmit", "Stop", "SessionEnd"}
580
+ _PENDING_DETAIL_CLEAR_EVENTS = {"PostToolUse", "UserPromptSubmit", "Stop", "SubagentStop", "SessionEnd"}
493
581
 
494
582
 
495
583
  def _pending_permission_details(
@@ -101,7 +101,9 @@ class CommonHookAdapter:
101
101
  explicit_requires_action = _explicit_requires_action(data)
102
102
  if event == "SessionEnd":
103
103
  status = Status.ENDED
104
- elif event in {"SessionStart", "UserPromptSubmit"}:
104
+ elif event in {"SessionStart", "UserPromptSubmit", "SubagentStop"}:
105
+ # SubagentStop 由 hook 端的 _apply_subagent_stop 短路處理(只清該 subagent 的等待),
106
+ # 不會依這裡的 WORKING 寫入 row;此值僅讓事件通過正規化。
105
107
  status = Status.WORKING
106
108
  elif explicit_requires_action is not None:
107
109
  status = Status.WAITING if explicit_requires_action else Status.IDLE
@@ -361,5 +363,6 @@ HOOK_EVENTS = (
361
363
  "PreToolUse",
362
364
  "PostToolUse",
363
365
  "Stop",
366
+ "SubagentStop",
364
367
  "SessionEnd",
365
368
  )
@@ -57,6 +57,9 @@ msgstr "idle"
57
57
  msgid "去哪"
58
58
  msgstr "go to"
59
59
 
60
+ msgid "終端"
61
+ msgstr "terminal"
62
+
60
63
  msgid "動作"
61
64
  msgstr "action"
62
65