From 2e38e49e9b50d4174705a11618eb7f09b7704a67 Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Sun, 22 Nov 2026 08:49:22 +0800 Subject: [PATCH 1/3] Show when queued input changes require the original source Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- apps/presentation/dashboard/src/data/chat.ts | 1 + .../personal-workspace/conversation-queue.tsx | 11 +++++++---- loopx/capabilities/native_chat/queue_api.py | 3 +++ loopx/capabilities/native_chat/queued_admission.py | 10 ++++++++++ loopx/chat_runtime.py | 9 +++++---- tests/presentation/test_chat_turn_queue.py | 4 ++++ tests/test_lark_private_conversations.py | 13 +++++++++++++ 7 files changed, 43 insertions(+), 8 deletions(-) diff --git a/apps/presentation/dashboard/src/data/chat.ts b/apps/presentation/dashboard/src/data/chat.ts index 74c2172e4c..85013ef8e7 100644 --- a/apps/presentation/dashboard/src/data/chat.ts +++ b/apps/presentation/dashboard/src/data/chat.ts @@ -1029,6 +1029,7 @@ const chatQueueSchema = z.object({ preview: z.string(), character_count: z.number().int().nonnegative(), attachment_count: z.number().int().nonnegative(), input_revision: z.number().int().nonnegative().default(0), + input_mutation_allowed: z.boolean().optional(), mutation: z.object({action: z.enum(["edit", "cancel"]), operation_id: z.string().min(1), expected_revision: z.number().int().nonnegative(), input_revision: z.number().int().positive(), message: z.string().optional()}).nullable().optional().default(null), diff --git a/apps/presentation/dashboard/src/features/personal-workspace/conversation-queue.tsx b/apps/presentation/dashboard/src/features/personal-workspace/conversation-queue.tsx index 7b3b361878..9ece7447f6 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/conversation-queue.tsx +++ b/apps/presentation/dashboard/src/features/personal-workspace/conversation-queue.tsx @@ -43,7 +43,8 @@ function QueuedMessage({sessionId, turn, index, targetTurnId, onChange, onInputC const composing = useRef(false); const held = turn.steering?.status === "pending" ? turn.steering : null; const canSteer = !unresolved && !editing && !recovery.failed && Boolean(held || (targetTurnId && !turn.attachment_count)); - const editable = !held && !unresolved && !recovery.failed && turn.origin === "web"; + const sourceEditable = turn.origin === "web" && turn.input_mutation_allowed !== false; + const editable = !held && !unresolved && !recovery.failed && sourceEditable; useEffect(() => {setMessage(null);}, [turn.input_revision]); useEffect(() => {if (editing && message && draft === null) { setDraft(message.message); setEditRevision(message.input_revision); @@ -149,9 +150,11 @@ function QueuedMessage({sessionId, turn, index, targetTurnId, onChange, onInputC : (zh ? "插入本轮 · Command+Enter" : "Steer · Command+Enter")}> {busy ? : }{held ? (zh ? "核对插入" : "Check insertion") : (zh ? "插入本轮" : "Steer")}
- {menu ?
+ aria-label={!sourceEditable + ? (zh ? `编辑或取消不可用:待处理消息 ${index + 1}` : `Editing or cancelling unavailable for queued message ${index + 1}`) + : (zh ? `更多操作:待处理消息 ${index + 1}` : `More actions for queued message ${index + 1}`)} + aria-expanded={menu && editable} onClick={() => setMenu(!menu)}> + {menu && editable ?
diff --git a/loopx/capabilities/native_chat/queue_api.py b/loopx/capabilities/native_chat/queue_api.py index 6f85374c60..8ec5c697be 100644 --- a/loopx/capabilities/native_chat/queue_api.py +++ b/loopx/capabilities/native_chat/queue_api.py @@ -6,6 +6,7 @@ from ...chat_store import CHAT_STORE_SCHEMA_VERSION from ...status_server import is_loopback_host +from .queued_admission import unbound_input_source_denial class ChatQueueRequestMixin: @@ -70,6 +71,7 @@ def _session_queue(self, session_id: str) -> None: self.server.runtime_controller.project_contexts.session_context(session) else: self._session_context(session) + mutable_source = unbound_input_source_denial(session) is None rows: list[dict[str, Any]] = [] for turn in store.queued_turns(session_id, strict=True, include_reserved=True): # Reuse history's exact admission/source checks before truncating; @@ -87,6 +89,7 @@ def _session_queue(self, session_id: str) -> None: "attachment_count": len(turn.get("attachments") or []), "steering": turn.get("_queue_steering"), "input_revision": turn.get("input_revision", 0), + "input_mutation_allowed": mutable_source and turn.get("origin") == "web", "mutation": turn.get("_queue_mutation"), }) self._send_json({"ok": True, "schema_version": CHAT_STORE_SCHEMA_VERSION, diff --git a/loopx/capabilities/native_chat/queued_admission.py b/loopx/capabilities/native_chat/queued_admission.py index ef37a47d7e..a27e63e8c7 100644 --- a/loopx/capabilities/native_chat/queued_admission.py +++ b/loopx/capabilities/native_chat/queued_admission.py @@ -16,6 +16,16 @@ from ...chat_runtime import ChatRuntimeController +def unbound_input_source_denial(session: dict[str, Any]) -> str | None: + """Identify Sessions whose input must pass through their original source.""" + if session.get("steward_context") is not None: + return "bound steward Chat requires its external source admission" + context = session.get("project_context") or {} + if context.get("audience") in {"bound_owner", "bound_group"}: + return "bound project steering requires its external source admission" + return None + + def enqueue_turn(controller: Any, *, session_id: str, client_turn_id: str, message: str, attachments: list[dict[str, Any]] | None, work_dir: Path | None, objective: str, origin: str, external_agent_target: dict[str, Any] | None) -> tuple[dict[str, Any], bool]: diff --git a/loopx/chat_runtime.py b/loopx/chat_runtime.py index 17ffaead95..2b40ea040f 100644 --- a/loopx/chat_runtime.py +++ b/loopx/chat_runtime.py @@ -508,11 +508,12 @@ def _start_accepted_turn_worker( def _require_steering_session(self, session_id: str) -> dict[str, Any]: session = self._load_open_session(session_id) require_managed_agent_session(self, session, Path(session.get("managed_workspace_path") or ".")) - if session.get("steward_context") is not None: - raise ValueError("bound steward Chat requires its external source admission") + from .capabilities.native_chat.queued_admission import unbound_input_source_denial + + denial = unbound_input_source_denial(session) + if denial: + raise ValueError(denial) if session.get("project_context") is not None: - if session["project_context"].get("audience") in {"bound_owner", "bound_group"}: - raise ValueError("bound project steering requires its external source admission") self.project_contexts.session_context(session) if session.get("session_mode") == CHAT_SESSION_MODE_ATTACHED: session = require_current_attached_session(store=self.store, registry_path=self.registry_path, session_id=session_id) diff --git a/tests/presentation/test_chat_turn_queue.py b/tests/presentation/test_chat_turn_queue.py index a2f37d4909..d5fe04cc6f 100644 --- a/tests/presentation/test_chat_turn_queue.py +++ b/tests/presentation/test_chat_turn_queue.py @@ -65,6 +65,10 @@ def test_edit_cancel_and_admission_retries_keep_exact_input_history_and_active_t sid, active, queued, original = held_queue(ordinary) path = f"/api/chat/sessions/{sid}/queue/{queued}/input" before = capture.read_bytes() + code, queue = request(f"/api/chat/sessions/{sid}/queue") + assert code == 200 + pending, = queue["turns"] + assert pending["turn_id"] == queued and pending["input_mutation_allowed"] is True assert request(path)[0] == 404 assert store.load_turn(sid, queued)["message"] == original["message"] # GET never mutates. body = queue_input_body() diff --git a/tests/test_lark_private_conversations.py b/tests/test_lark_private_conversations.py index 7ed0298120..1cf30bb7fe 100644 --- a/tests/test_lark_private_conversations.py +++ b/tests/test_lark_private_conversations.py @@ -7235,6 +7235,19 @@ def request(method, path, body=None): assert status == 202 and pending["status"] == "queued" qid = pending["turn_id"] original_queued = store.load_turn(sid, qid) + queue_status, queue = request("GET", f"{session_path}/queue") + assert queue_status == 200 + queued_input, = queue["turns"] + assert queued_input["turn_id"] == qid and queued_input["origin"] == "web" + assert queued_input["input_mutation_allowed"] is False + for mutation in ( + {"action": "edit", "message": "A different input.", "operation_id": "edit", + "expected_revision": 0}, + {"action": "cancel", "operation_id": "cancel", "expected_revision": 0}, + ): + status, denied = request("POST", f"{session_path}/queue/{qid}/input", mutation) + assert status == 400 and "external source admission" in denied["error"] + assert store.load_turn(sid, qid) == original_queued endpoint = wrong_endpoint = f"{session_path}/queue/{qid}/steer" body = {"target_turn_id": tid, "client_ingress_id": "app-correction"} wrong_body = {"target_turn_id": "old-turn", "client_ingress_id": "wrong-turn"} From 629d152f75eed027a62c429ae2c500c8c42c694d Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Sun, 22 Nov 2026 11:23:39 +0800 Subject: [PATCH 2/3] Keep bound queue drafts readable without blocking steering Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- .../personal-workspace/conversation-queue.tsx | 18 ++++++++++++------ .../attached-host-follow-up.mjs | 11 +++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/apps/presentation/dashboard/src/features/personal-workspace/conversation-queue.tsx b/apps/presentation/dashboard/src/features/personal-workspace/conversation-queue.tsx index 9ece7447f6..b50d1cefab 100644 --- a/apps/presentation/dashboard/src/features/personal-workspace/conversation-queue.tsx +++ b/apps/presentation/dashboard/src/features/personal-workspace/conversation-queue.tsx @@ -42,14 +42,16 @@ function QueuedMessage({sessionId, turn, index, targetTurnId, onChange, onInputC const textarea = useRef(null), menuButton = useRef(null); const composing = useRef(false); const held = turn.steering?.status === "pending" ? turn.steering : null; - const canSteer = !unresolved && !editing && !recovery.failed && Boolean(held || (targetTurnId && !turn.attachment_count)); const sourceEditable = turn.origin === "web" && turn.input_mutation_allowed !== false; + const canSteer = !unresolved && !(sourceEditable && editing) && !recovery.failed + && Boolean(held || (targetTurnId && !turn.attachment_count)); const editable = !held && !unresolved && !recovery.failed && sourceEditable; useEffect(() => {setMessage(null);}, [turn.input_revision]); useEffect(() => {if (editing && message && draft === null) { setDraft(message.message); setEditRevision(message.input_revision); }}, [editing, message, draft]); - useEffect(() => {if (editing && draft !== null) textarea.current?.focus();}, [editing, draft === null]); + useEffect(() => {if (editing && sourceEditable && draft !== null) textarea.current?.focus();}, + [editing, sourceEditable, draft === null]); async function mutate(request: ChatQueueInputRequest) { if (lock.current) return; lock.current = true; setBusy(true); setActionError(""); setMenu(false); @@ -79,6 +81,7 @@ function QueuedMessage({sessionId, turn, index, targetTurnId, onChange, onInputC } finally {lock.current = false; setBusy(false); onInputChanged();} } function save() { + if (!sourceEditable) return; if (draft && [...draft].length > 12000) { setActionError(zh ? "待处理消息最多 12000 个字符,请缩短后保存。" : "Queued messages support up to 12000 characters. Shorten the text before saving."); return; } @@ -121,7 +124,7 @@ function QueuedMessage({sessionId, turn, index, targetTurnId, onChange, onInputC else discard(); return; } - if (editing) { + if (editing && (sourceEditable || event.target === textarea.current)) { if (composerKeyAction({...event, isComposing: event.nativeEvent.isComposing, keyCode: event.nativeEvent.keyCode}, false) === "steer") { event.preventDefault(); event.stopPropagation(); save(); } @@ -161,14 +164,17 @@ function QueuedMessage({sessionId, turn, index, targetTurnId, onChange, onInputC
: null}
{editing ?
{draft === null ?

{failed ? (zh ? "完整消息读取失败" : "Full message unavailable") : (zh ? "正在读取…" : "Reading…")}

- :