Skip to content

Commit f8f10d5

Browse files
committed
refactor(context): add wait for summary snapshot rebuild and clean up PTY check
1 parent 30d9974 commit f8f10d5

4 files changed

Lines changed: 23 additions & 5 deletions

File tree

src/cccc/daemon/context/context_ops.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import json
1616
import logging
1717
import threading
18+
import time
1819
from enum import Enum
1920
from pathlib import Path
2021
from typing import Any, Dict, List, Optional, Set, Tuple
@@ -888,6 +889,21 @@ def _run() -> None:
888889
return True
889890

890891

892+
def _wait_for_summary_snapshot_rebuild(group_id: str, *, timeout_s: float = 1.0) -> bool:
893+
gid = str(group_id or "").strip()
894+
if not gid:
895+
return True
896+
deadline = time.monotonic() + max(0.0, float(timeout_s))
897+
while True:
898+
with _SUMMARY_REBUILD_LOCK:
899+
in_flight = gid in _SUMMARY_REBUILD_IN_FLIGHT
900+
if not in_flight:
901+
return True
902+
if time.monotonic() >= deadline:
903+
return False
904+
time.sleep(0.01)
905+
906+
891907
def _get_summary_context_fast(storage: ContextStorage, *, group_id: str) -> Dict[str, Any]:
892908
snapshot = storage.load_summary_snapshot()
893909
basis = storage.summary_basis()

src/cccc/daemon/group/group_lifecycle_ops.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from ...kernel.runtime import runtime_start_preflight_error
1616
from ...runners import headless as headless_runner
1717
from ...runners import pty as pty_runner
18-
from ...runners.platform_support import pty_support_error_message
1918
from ...util.conv import coerce_bool
2019
from ..actors.actor_profile_runtime import resolve_linked_actor_before_start
2120
from ..pet.review_scheduler import cancel_pet_review, request_pet_review
@@ -145,8 +144,6 @@ def handle_group_start(
145144
},
146145
)
147146
if runner_effective != "headless":
148-
if not bool(getattr(pty_runner, "PTY_SUPPORTED", False)):
149-
raise RuntimeError(pty_support_error_message() or "PTY runner is not supported in this environment.")
150147
try:
151148
mcp_ready = bool(ensure_mcp_installed(runtime, cwd))
152149
except Exception as e:

src/cccc/daemon/ops/template_ops.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from ...util.conv import coerce_bool
3636
from ..actors.actor_profile_runtime import actor_profile_ref
3737
from ..actors.actor_profile_store import get_actor_profile, get_actor_profile_by_ref
38-
from ..context.context_ops import _schedule_summary_snapshot_rebuild
38+
from ..context.context_ops import _schedule_summary_snapshot_rebuild, _wait_for_summary_snapshot_rebuild
3939
from ..messaging.delivery import THROTTLE, clear_preamble_sent
4040

4141

@@ -648,6 +648,10 @@ def group_template_import_replace(args: Dict[str, Any]) -> DaemonResponse:
648648
_schedule_summary_snapshot_rebuild(group.group_id)
649649
except Exception:
650650
pass
651+
try:
652+
_wait_for_summary_snapshot_rebuild(group.group_id, timeout_s=1.0)
653+
except Exception:
654+
pass
651655

652656
return DaemonResponse(
653657
ok=True,

src/cccc/kernel/pet_task_proposals.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def _normalize_compare_text(value: Any) -> str:
5757

5858

5959
def _quoted_task_title(value: Any) -> str:
60-
return f'"{str(value or "").replace("\"", "\\\"")}"'
60+
escaped = str(value or "").replace('"', '\\"')
61+
return f'"{escaped}"'
6162

6263

6364
def _build_task_proposal_message(action: Dict[str, Any]) -> str:

0 commit comments

Comments
 (0)