refactor: remove unreachable code and redundant tests (#6729)
* refactor: prune unreachable runtime and WebUI paths * test: drop duplicate cases and assertions for obsolete selectors
This commit is contained in:
1 parent
b9b491e74c
commit
51fa1a7f74
20 files changed
+32
-163
No files matched your search
@@ -557,11 +557,11 @@ class SubagentManager:
|
|||||||
|
|
||||||
def _build_tools(
|
def _build_tools(
|
||||||
self,
|
self,
|
||||||
workspace: Path | None = None,
|
*,
|
||||||
tools_config: ToolsConfig | None = None,
|
tools_config: ToolsConfig | None = None,
|
||||||
exec_manager: ExecSessionManager | None = None,
|
exec_manager: ExecSessionManager | None = None,
|
||||||
) -> ToolRegistry:
|
) -> ToolRegistry:
|
||||||
root = self.workspace if workspace is None else workspace
|
root = self.workspace
|
||||||
registry = ToolRegistry()
|
registry = ToolRegistry()
|
||||||
cfg = tools_config if tools_config is not None else self._subagent_tools_config()
|
cfg = tools_config if tools_config is not None else self._subagent_tools_config()
|
||||||
ctx = ToolContext(
|
ctx = ToolContext(
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ from nanobot.channels.contracts import (
|
|||||||
resolve_channel_action_target,
|
resolve_channel_action_target,
|
||||||
)
|
)
|
||||||
from nanobot.channels.outbox import RETRY_SECONDS, DeliveryOutbox
|
from nanobot.channels.outbox import RETRY_SECONDS, DeliveryOutbox
|
||||||
from nanobot.channels.registry import channel_default_enabled
|
|
||||||
from nanobot.config.schema import Config
|
from nanobot.config.schema import Config
|
||||||
from nanobot.security.workspace_access import WorkspaceScopeResolver
|
from nanobot.security.workspace_access import WorkspaceScopeResolver
|
||||||
from nanobot.security.workspace_policy import resolve_allowed_path
|
from nanobot.security.workspace_policy import resolve_allowed_path
|
||||||
@@ -174,14 +173,10 @@ class ChannelManager:
|
|||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
*,
|
*,
|
||||||
config: Config | None = None,
|
default_enabled: bool,
|
||||||
default_sections: dict[str, Any] | None = None,
|
default_sections: dict[str, Any] | None = None,
|
||||||
default_enabled: bool | None = None,
|
|
||||||
) -> Any:
|
) -> Any:
|
||||||
config = config or self.config
|
section = getattr(self.config.channels, name, None)
|
||||||
section = getattr(config.channels, name, None)
|
|
||||||
if default_enabled is None:
|
|
||||||
default_enabled = channel_default_enabled(name)
|
|
||||||
if section is not None or not default_enabled:
|
if section is not None or not default_enabled:
|
||||||
return section
|
return section
|
||||||
if default_sections is None:
|
if default_sections is None:
|
||||||
|
|||||||
@@ -514,7 +514,6 @@ class QQChannel(BaseChannel):
|
|||||||
file_type=file_type,
|
file_type=file_type,
|
||||||
file_data=file_data_b64,
|
file_data=file_data_b64,
|
||||||
file_name=filename,
|
file_name=filename,
|
||||||
srv_send_msg=False,
|
|
||||||
)
|
)
|
||||||
if not media_obj:
|
if not media_obj:
|
||||||
self.logger.error("media upload failed: empty response")
|
self.logger.error("media upload failed: empty response")
|
||||||
@@ -608,7 +607,6 @@ class QQChannel(BaseChannel):
|
|||||||
file_type: int,
|
file_type: int,
|
||||||
file_data: str,
|
file_data: str,
|
||||||
file_name: str | None = None,
|
file_name: str | None = None,
|
||||||
srv_send_msg: bool = False,
|
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
if not self._client:
|
if not self._client:
|
||||||
raise RuntimeError("QQ client not initialized")
|
raise RuntimeError("QQ client not initialized")
|
||||||
@@ -624,7 +622,7 @@ class QQChannel(BaseChannel):
|
|||||||
id_key: chat_id,
|
id_key: chat_id,
|
||||||
"file_type": file_type,
|
"file_type": file_type,
|
||||||
"file_data": file_data,
|
"file_data": file_data,
|
||||||
"srv_send_msg": srv_send_msg,
|
"srv_send_msg": False,
|
||||||
}
|
}
|
||||||
# Only pass file_name for non-image types (file_type=4).
|
# Only pass file_name for non-image types (file_type=4).
|
||||||
# Passing file_name for images causes QQ client to render them as
|
# Passing file_name for images causes QQ client to render them as
|
||||||
|
|||||||
@@ -405,11 +405,6 @@ class SignalChannel(BaseChannel):
|
|||||||
content: str,
|
content: str,
|
||||||
media: list[str] | None = None,
|
media: list[str] | None = None,
|
||||||
metadata: dict[str, Any] | None = None,
|
metadata: dict[str, Any] | None = None,
|
||||||
session_key: str | None = None,
|
|
||||||
is_dm: bool = False,
|
|
||||||
authorization_id: str | None = None,
|
|
||||||
require_existing_session: bool = False,
|
|
||||||
session_generation: str | None = None,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Publish only an inbound message whose Signal policy has already been checked.
|
"""Publish only an inbound message whose Signal policy has already been checked.
|
||||||
|
|
||||||
@@ -421,7 +416,6 @@ class SignalChannel(BaseChannel):
|
|||||||
``super()._handle_message`` instead, which goes through
|
``super()._handle_message`` instead, which goes through
|
||||||
``is_allowed`` and issues a pairing code.
|
``is_allowed`` and issues a pairing code.
|
||||||
"""
|
"""
|
||||||
del authorization_id
|
|
||||||
meta = metadata or {}
|
meta = metadata or {}
|
||||||
if self.supports_streaming:
|
if self.supports_streaming:
|
||||||
meta = {**meta, "_wants_stream": True}
|
meta = {**meta, "_wants_stream": True}
|
||||||
@@ -433,9 +427,6 @@ class SignalChannel(BaseChannel):
|
|||||||
content=content,
|
content=content,
|
||||||
media=media or [],
|
media=media or [],
|
||||||
metadata=meta,
|
metadata=meta,
|
||||||
session_key_override=session_key,
|
|
||||||
session_generation=session_generation,
|
|
||||||
require_existing_session=require_existing_session,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -778,7 +769,6 @@ class SignalChannel(BaseChannel):
|
|||||||
"is_group": is_group_message,
|
"is_group": is_group_message,
|
||||||
"group_id": group_id,
|
"group_id": group_id,
|
||||||
},
|
},
|
||||||
is_dm=not is_group_message,
|
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
await self._stop_typing(chat_id)
|
await self._stop_typing(chat_id)
|
||||||
|
|||||||
@@ -80,10 +80,6 @@ def test_sanitize_filename_keeps_chinese_chars() -> None:
|
|||||||
assert _sanitize_filename("文件(1).jpg") == "文件(1).jpg"
|
assert _sanitize_filename("文件(1).jpg") == "文件(1).jpg"
|
||||||
|
|
||||||
|
|
||||||
def test_sanitize_filename_empty_input() -> None:
|
|
||||||
assert _sanitize_filename("") == "unnamed"
|
|
||||||
|
|
||||||
|
|
||||||
def test_sanitize_filename_empty_or_dots_fallback() -> None:
|
def test_sanitize_filename_empty_or_dots_fallback() -> None:
|
||||||
assert _sanitize_filename("...") == "unnamed"
|
assert _sanitize_filename("...") == "unnamed"
|
||||||
assert _sanitize_filename("..", fallback="fallback.txt") == "fallback.txt"
|
assert _sanitize_filename("..", fallback="fallback.txt") == "fallback.txt"
|
||||||
|
|||||||
@@ -2239,18 +2239,14 @@ class WeixinChannel(BaseChannel):
|
|||||||
to_user_id: str,
|
to_user_id: str,
|
||||||
text: str,
|
text: str,
|
||||||
context_token: str,
|
context_token: str,
|
||||||
*,
|
|
||||||
client_id: str | None = None,
|
|
||||||
run_id: str = "",
|
|
||||||
) -> None:
|
) -> None:
|
||||||
options = _SEND_OPTIONS.get()
|
options = _SEND_OPTIONS.get()
|
||||||
self._ensure_context_budget(
|
self._ensure_context_budget(
|
||||||
context_token,
|
context_token,
|
||||||
reserve=options.reserve_budget if options else 0,
|
reserve=options.reserve_budget if options else 0,
|
||||||
)
|
)
|
||||||
client_id = client_id or (options.client_id if options else None)
|
client_id = (options.client_id if options else None) or f"nanobot-{uuid.uuid4().hex[:12]}"
|
||||||
client_id = client_id or f"nanobot-{uuid.uuid4().hex[:12]}"
|
run_id = options.run_id if options else ""
|
||||||
run_id = run_id or (options.run_id if options else "")
|
|
||||||
|
|
||||||
item_list: list[dict[str, Any]] = []
|
item_list: list[dict[str, Any]] = []
|
||||||
if text:
|
if text:
|
||||||
@@ -2284,11 +2280,6 @@ class WeixinChannel(BaseChannel):
|
|||||||
to_user_id: str,
|
to_user_id: str,
|
||||||
media_path: str,
|
media_path: str,
|
||||||
context_token: str,
|
context_token: str,
|
||||||
*,
|
|
||||||
client_id: str | None = None,
|
|
||||||
file_key: str | None = None,
|
|
||||||
aes_key_raw: bytes | None = None,
|
|
||||||
run_id: str = "",
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Upload a local file to WeChat CDN and send it as a media message.
|
"""Upload a local file to WeChat CDN and send it as a media message.
|
||||||
|
|
||||||
@@ -2327,16 +2318,14 @@ class WeixinChannel(BaseChannel):
|
|||||||
item_key = "file_item"
|
item_key = "file_item"
|
||||||
|
|
||||||
options = _SEND_OPTIONS.get()
|
options = _SEND_OPTIONS.get()
|
||||||
aes_key_raw = aes_key_raw or (options.aes_key_raw if options else None)
|
aes_key_raw = (options.aes_key_raw if options else None) or os.urandom(16)
|
||||||
aes_key_raw = aes_key_raw or os.urandom(16)
|
|
||||||
aes_key_hex = aes_key_raw.hex()
|
aes_key_hex = aes_key_raw.hex()
|
||||||
|
|
||||||
# Compute encrypted size: PKCS7 padding to 16-byte boundary
|
# Compute encrypted size: PKCS7 padding to 16-byte boundary
|
||||||
# Matches aesEcbPaddedSize: Math.ceil((size + 1) / 16) * 16
|
# Matches aesEcbPaddedSize: Math.ceil((size + 1) / 16) * 16
|
||||||
padded_size = ((raw_size + 1 + 15) // 16) * 16
|
padded_size = ((raw_size + 1 + 15) // 16) * 16
|
||||||
|
|
||||||
file_key = file_key or (options.file_key if options else None)
|
file_key = (options.file_key if options else None) or os.urandom(16).hex()
|
||||||
file_key = file_key or os.urandom(16).hex()
|
|
||||||
upload_body: dict[str, Any] = {
|
upload_body: dict[str, Any] = {
|
||||||
"filekey": file_key,
|
"filekey": file_key,
|
||||||
"media_type": upload_type,
|
"media_type": upload_type,
|
||||||
@@ -2408,9 +2397,8 @@ class WeixinChannel(BaseChannel):
|
|||||||
media_item["len"] = str(raw_size)
|
media_item["len"] = str(raw_size)
|
||||||
|
|
||||||
# Send each media item as its own message (matching reference plugin)
|
# Send each media item as its own message (matching reference plugin)
|
||||||
client_id = client_id or (options.client_id if options else None)
|
client_id = (options.client_id if options else None) or f"nanobot-{uuid.uuid4().hex[:12]}"
|
||||||
client_id = client_id or f"nanobot-{uuid.uuid4().hex[:12]}"
|
run_id = options.run_id if options else ""
|
||||||
run_id = run_id or (options.run_id if options else "")
|
|
||||||
item_list: list[dict[str, Any]] = [
|
item_list: list[dict[str, Any]] = [
|
||||||
{"type": item_type, item_key: media_item}
|
{"type": item_type, item_key: media_item}
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import re
|
|||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from datetime import datetime
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
from typing import TYPE_CHECKING, Any, TypeVar, cast, overload
|
from typing import TYPE_CHECKING, Any, TypeVar, cast, overload
|
||||||
@@ -351,11 +350,6 @@ def build_image_content_blocks(
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
def timestamp() -> str:
|
|
||||||
"""Current ISO timestamp."""
|
|
||||||
return datetime.now().isoformat()
|
|
||||||
|
|
||||||
|
|
||||||
_UNSAFE_CHARS = re.compile(r'[<>:"/\\|?*]')
|
_UNSAFE_CHARS = re.compile(r'[<>:"/\\|?*]')
|
||||||
_TOOL_RESULTS_DIR = ".nanobot/tool-results"
|
_TOOL_RESULTS_DIR = ".nanobot/tool-results"
|
||||||
_TOOL_RESULT_RETENTION_SECS = 7 * 24 * 60 * 60
|
_TOOL_RESULT_RETENTION_SECS = 7 * 24 * 60 * 60
|
||||||
|
|||||||
@@ -108,10 +108,6 @@ def _records_from_entries(
|
|||||||
for position, fact in entries]
|
for position, fact in entries]
|
||||||
|
|
||||||
|
|
||||||
def turn_records(history: HistoryReader, ordinal: int) -> list[dict[str, Any]]:
|
|
||||||
return _records_from_entries(history, ordinal, history.read_entries(ordinal))
|
|
||||||
|
|
||||||
|
|
||||||
def turn_record_page(
|
def turn_record_page(
|
||||||
history: HistoryReader, ordinal: int, *, start: int, end: int, reverse: bool,
|
history: HistoryReader, ordinal: int, *, start: int, end: int, reverse: bool,
|
||||||
max_records: int, max_bytes: int, allow_oversized: bool = False,
|
max_records: int, max_bytes: int, allow_oversized: bool = False,
|
||||||
|
|||||||
@@ -658,39 +658,36 @@ def _display_name_for(name: str, preset: McpPreset | None = None) -> str:
|
|||||||
return preset.display_name if preset is not None else name
|
return preset.display_name if preset is not None else name
|
||||||
|
|
||||||
|
|
||||||
def _action_message(action: str, preset: McpPreset, *, ok: bool = True) -> dict[str, Any]:
|
def _action_message(action: Literal["enable", "remove"], preset: McpPreset) -> dict[str, Any]:
|
||||||
verb = {
|
|
||||||
"enable": "Enabled",
|
|
||||||
"remove": "Removed",
|
|
||||||
"test": "Checked",
|
|
||||||
}.get(action, "Updated")
|
|
||||||
payload: dict[str, Any] = {
|
|
||||||
"ok": ok,
|
|
||||||
"message": f"{verb} MCP preset for {preset.display_name}.",
|
|
||||||
}
|
|
||||||
if action == "enable":
|
if action == "enable":
|
||||||
payload["installed"] = True
|
return {
|
||||||
payload["verification"] = ["config_present"]
|
"ok": True,
|
||||||
elif action == "remove":
|
"message": f"Enabled MCP preset for {preset.display_name}.",
|
||||||
payload["removed"] = True
|
"installed": True,
|
||||||
payload["verification"] = ["config_absent"]
|
"verification": ["config_present"],
|
||||||
return payload
|
}
|
||||||
|
return {
|
||||||
|
"ok": True,
|
||||||
|
"message": f"Removed MCP preset for {preset.display_name}.",
|
||||||
|
"removed": True,
|
||||||
|
"verification": ["config_absent"],
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def _server_action_message(action: str, name: str, *, ok: bool = True) -> dict[str, Any]:
|
def _server_action_message(
|
||||||
|
action: Literal["custom", "tools", "remove", "reconnect"], name: str,
|
||||||
|
) -> dict[str, Any]:
|
||||||
verb = {
|
verb = {
|
||||||
"custom": "Saved",
|
"custom": "Saved",
|
||||||
"import": "Imported",
|
|
||||||
"import-cursor": "Imported",
|
|
||||||
"tools": "Updated tools for",
|
"tools": "Updated tools for",
|
||||||
"remove": "Removed",
|
"remove": "Removed",
|
||||||
"reconnect": "Retried connection for",
|
"reconnect": "Retried connection for",
|
||||||
}.get(action, "Updated")
|
}[action]
|
||||||
payload: dict[str, Any] = {
|
payload: dict[str, Any] = {
|
||||||
"ok": ok,
|
"ok": True,
|
||||||
"message": f"{verb} MCP server {name}.",
|
"message": f"{verb} MCP server {name}.",
|
||||||
}
|
}
|
||||||
if action in {"custom", "import", "import-cursor"}:
|
if action == "custom":
|
||||||
payload["installed"] = True
|
payload["installed"] = True
|
||||||
payload["verification"] = ["config_present"]
|
payload["verification"] = ["config_present"]
|
||||||
elif action == "remove":
|
elif action == "remove":
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ from nanobot.webui.history import (
|
|||||||
initialize_history,
|
initialize_history,
|
||||||
record_from_fact,
|
record_from_fact,
|
||||||
turn_record_page,
|
turn_record_page,
|
||||||
turn_records,
|
|
||||||
)
|
)
|
||||||
from nanobot.webui.metadata import WEBUI_MESSAGE_SOURCE_METADATA_KEY, WEBUI_TURN_METADATA_KEY
|
from nanobot.webui.metadata import WEBUI_MESSAGE_SOURCE_METADATA_KEY, WEBUI_TURN_METADATA_KEY
|
||||||
from nanobot.webui.outbound_wire import project_tool_events
|
from nanobot.webui.outbound_wire import project_tool_events
|
||||||
@@ -943,16 +942,9 @@ def has_pending_tool_calls(
|
|||||||
"file_edit",
|
"file_edit",
|
||||||
}:
|
}:
|
||||||
return True
|
return True
|
||||||
if ev in {WEBUI_FORK_MARKER_EVENT}:
|
|
||||||
continue
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def has_unfinished_transcript_tail(session_key: str, *, history: HistoryReader) -> bool:
|
|
||||||
count = history.turn_count
|
|
||||||
return bool(count and has_pending_tool_calls(turn_records(history, count - 1)))
|
|
||||||
|
|
||||||
|
|
||||||
def completed_turn_ids(lines: list[dict[str, Any]]) -> list[str]:
|
def completed_turn_ids(lines: list[dict[str, Any]]) -> list[str]:
|
||||||
"""Return stable identities for turns with an explicitly persisted completion."""
|
"""Return stable identities for turns with an explicitly persisted completion."""
|
||||||
completed: list[str] = []
|
completed: list[str] = []
|
||||||
|
|||||||
@@ -90,14 +90,6 @@ class TestHistoryWithCursor:
|
|||||||
assert data["cursor"] == cursor
|
assert data["cursor"] == cursor
|
||||||
assert data["content"] == expected_content
|
assert data["content"] == expected_content
|
||||||
|
|
||||||
def test_read_unprocessed_history(self, store):
|
|
||||||
store.append_history("event 1")
|
|
||||||
store.append_history("event 2")
|
|
||||||
store.append_history("event 3")
|
|
||||||
entries = store.read_unprocessed_history(since_cursor=1)
|
|
||||||
assert len(entries) == 2
|
|
||||||
assert entries[0]["cursor"] == 2
|
|
||||||
|
|
||||||
def test_read_unprocessed_history_returns_all_when_cursor_zero(self, store):
|
def test_read_unprocessed_history_returns_all_when_cursor_zero(self, store):
|
||||||
store.append_history("event 1")
|
store.append_history("event 1")
|
||||||
store.append_history("event 2")
|
store.append_history("event 2")
|
||||||
@@ -189,21 +181,6 @@ class TestHistoryWithCursor:
|
|||||||
entries = store.read_unprocessed_history(since_cursor=0)
|
entries = store.read_unprocessed_history(since_cursor=0)
|
||||||
assert [entry["cursor"] for entry in entries] == list(range(21, 101))
|
assert [entry["cursor"] for entry in entries] == list(range(21, 101))
|
||||||
|
|
||||||
def test_write_entries_uses_atomic_write(self, tmp_path):
|
|
||||||
store = MemoryStore(tmp_path)
|
|
||||||
store.append_history("event 1")
|
|
||||||
store.append_history("event 2")
|
|
||||||
store.append_history("event 3")
|
|
||||||
entries = store.read_unprocessed_history(since_cursor=0)
|
|
||||||
|
|
||||||
tmp_path_obj = store.history_file.with_suffix(".jsonl.tmp")
|
|
||||||
assert not tmp_path_obj.exists()
|
|
||||||
|
|
||||||
store._write_entries(entries)
|
|
||||||
|
|
||||||
assert not tmp_path_obj.exists()
|
|
||||||
assert store.history_file.exists()
|
|
||||||
|
|
||||||
def test_write_entries_cleans_up_tmp_on_exception(self, tmp_path, monkeypatch):
|
def test_write_entries_cleans_up_tmp_on_exception(self, tmp_path, monkeypatch):
|
||||||
store = MemoryStore(tmp_path)
|
store = MemoryStore(tmp_path)
|
||||||
store.append_history("event 1")
|
store.append_history("event 1")
|
||||||
|
|||||||
@@ -129,12 +129,6 @@ def test_responses_declaration_routes_other_models(provider):
|
|||||||
assert provider._should_use_responses_api("gpt-4o", None) is True
|
assert provider._should_use_responses_api("gpt-4o", None) is True
|
||||||
|
|
||||||
|
|
||||||
def test_circuit_opens_after_threshold(provider):
|
|
||||||
for _ in range(_RESPONSES_FAILURE_THRESHOLD):
|
|
||||||
provider._record_responses_failure("gpt-5", None)
|
|
||||||
assert provider._should_use_responses_api("gpt-5", None) is False
|
|
||||||
|
|
||||||
|
|
||||||
def test_circuit_does_not_affect_other_models(provider):
|
def test_circuit_does_not_affect_other_models(provider):
|
||||||
for _ in range(_RESPONSES_FAILURE_THRESHOLD):
|
for _ in range(_RESPONSES_FAILURE_THRESHOLD):
|
||||||
provider._record_responses_failure("gpt-5", None)
|
provider._record_responses_failure("gpt-5", None)
|
||||||
|
|||||||
@@ -2307,16 +2307,6 @@ def test_sanitize_name_noop_for_already_clean_names() -> None:
|
|||||||
assert _sanitize_name("mcp_server_tool") == "mcp_server_tool"
|
assert _sanitize_name("mcp_server_tool") == "mcp_server_tool"
|
||||||
|
|
||||||
|
|
||||||
def test_tool_wrapper_sanitizes_name() -> None:
|
|
||||||
tool_def = SimpleNamespace(
|
|
||||||
name="My Tool",
|
|
||||||
description="tool with spaces",
|
|
||||||
inputSchema={"type": "object", "properties": {}},
|
|
||||||
)
|
|
||||||
wrapper = MCPToolWrapper(SimpleNamespace(call_tool=None), "srv", tool_def)
|
|
||||||
assert wrapper.name == "mcp_srv_My_Tool"
|
|
||||||
|
|
||||||
|
|
||||||
def test_resource_wrapper_sanitizes_name() -> None:
|
def test_resource_wrapper_sanitizes_name() -> None:
|
||||||
resource_def = SimpleNamespace(
|
resource_def = SimpleNamespace(
|
||||||
name="PostgreSQL System Information",
|
name="PostgreSQL System Information",
|
||||||
|
|||||||
@@ -348,36 +348,6 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.kv-cache-not-reused {
|
|
||||||
background: hsl(var(--usage-token) / 0.84);
|
|
||||||
}
|
|
||||||
|
|
||||||
.kv-cache-reused {
|
|
||||||
background-color: hsl(var(--usage-token) / 0.1);
|
|
||||||
background-image: repeating-linear-gradient(
|
|
||||||
135deg,
|
|
||||||
hsl(var(--usage-token) / 0.46) 0,
|
|
||||||
hsl(var(--usage-token) / 0.46) 1px,
|
|
||||||
transparent 1px,
|
|
||||||
transparent 4px
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
.dark .kv-cache-not-reused {
|
|
||||||
background: hsl(var(--usage-token) / 0.92);
|
|
||||||
}
|
|
||||||
|
|
||||||
.dark .kv-cache-reused {
|
|
||||||
background-color: hsl(var(--usage-token) / 0.15);
|
|
||||||
background-image: repeating-linear-gradient(
|
|
||||||
135deg,
|
|
||||||
hsl(var(--usage-token) / 0.58) 0,
|
|
||||||
hsl(var(--usage-token) / 0.58) 1px,
|
|
||||||
transparent 1px,
|
|
||||||
transparent 4px
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
.composer-model-badge::before {
|
.composer-model-badge::before {
|
||||||
content: "";
|
content: "";
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ export function UpdateFlowProvider({ client, token, enabled, canSettleHandoff =
|
|||||||
</div> : blocked ? ownerInstructions : null}
|
</div> : blocked ? ownerInstructions : null}
|
||||||
<div className={`mt-6 grid shrink-0 ${done || blocked ? "grid-cols-1" : "grid-cols-2"} gap-2.5`}>
|
<div className={`mt-6 grid shrink-0 ${done || blocked ? "grid-cols-1" : "grid-cols-2"} gap-2.5`}>
|
||||||
{!done && !blocked && <Button variant="secondary" onClick={close}>
|
{!done && !blocked && <Button variant="secondary" onClick={close}>
|
||||||
{t(done || failed || error || blocked ? "updates.close" : busy ? "updates.hide" : "updates.cancel")}
|
{t(failed || error ? "updates.close" : busy ? "updates.hide" : "updates.cancel")}
|
||||||
</Button>}
|
</Button>}
|
||||||
<Button variant="accent" className="min-w-0 whitespace-normal" disabled={!blocked && busy} aria-busy={busy}
|
<Button variant="accent" className="min-w-0 whitespace-normal" disabled={!blocked && busy} aria-busy={busy}
|
||||||
onClick={blocked ? close : primary}>
|
onClick={blocked ? close : primary}>
|
||||||
|
|||||||
@@ -1143,7 +1143,6 @@ describe("App layout", () => {
|
|||||||
"text-[var(--temporary-control-active)]",
|
"text-[var(--temporary-control-active)]",
|
||||||
);
|
);
|
||||||
expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
|
expect(screen.queryByRole("tooltip")).not.toBeInTheDocument();
|
||||||
expect(screen.queryByTestId("temporary-chat-outline")).not.toBeInTheDocument();
|
|
||||||
fireEvent.click(temporaryToggle);
|
fireEvent.click(temporaryToggle);
|
||||||
expect(temporaryToggle).toHaveAttribute("aria-pressed", "false");
|
expect(temporaryToggle).toHaveAttribute("aria-pressed", "false");
|
||||||
expect(within(temporaryToggle).getByTestId("temporary-chat-icon")).toHaveClass(
|
expect(within(temporaryToggle).getByTestId("temporary-chat-icon")).toHaveClass(
|
||||||
@@ -2380,7 +2379,6 @@ describe("App layout", () => {
|
|||||||
expect(screen.getByTestId("sidebar-brand-row")).toHaveClass("pt-3");
|
expect(screen.getByTestId("sidebar-brand-row")).toHaveClass("pt-3");
|
||||||
expect(screen.getByTestId("sidebar-brand-mark")).toHaveClass("mt-5");
|
expect(screen.getByTestId("sidebar-brand-mark")).toHaveClass("mt-5");
|
||||||
expect(screen.getByRole("separator", { name: "Resize sidebar" })).toHaveAttribute("aria-valuenow", "272");
|
expect(screen.getByRole("separator", { name: "Resize sidebar" })).toHaveAttribute("aria-valuenow", "272");
|
||||||
expect(screen.queryByTestId("host-sidebar-toggle")).not.toBeInTheDocument();
|
|
||||||
expect(
|
expect(
|
||||||
screen.getByRole("navigation", { name: "Sidebar navigation" }),
|
screen.getByRole("navigation", { name: "Sidebar navigation" }),
|
||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
|
|||||||
@@ -672,7 +672,6 @@ describe("Automation task list and detail sheet", () => {
|
|||||||
expect(header).toHaveClass("bg-foreground/[0.025]");
|
expect(header).toHaveClass("bg-foreground/[0.025]");
|
||||||
expect(header).not.toHaveClass("border-b");
|
expect(header).not.toHaveClass("border-b");
|
||||||
expect(header?.querySelector(".automation-calendar-weekdays")).toBeInTheDocument();
|
expect(header?.querySelector(".automation-calendar-weekdays")).toBeInTheDocument();
|
||||||
expect(calendar.querySelector(".automation-meta-row")).toBeNull();
|
|
||||||
expect(calendar.querySelector(":scope > details")).toBeNull();
|
expect(calendar.querySelector(":scope > details")).toBeNull();
|
||||||
expect(screen.queryByRole("button", { name: /Paused backlog review/ })).not.toBeInTheDocument();
|
expect(screen.queryByRole("button", { name: /Paused backlog review/ })).not.toBeInTheDocument();
|
||||||
expect(calendar).not.toHaveTextContent("·");
|
expect(calendar).not.toHaveTextContent("·");
|
||||||
|
|||||||
@@ -1346,11 +1346,10 @@ describe("MessageBubble", () => {
|
|||||||
reasoningStreaming: true,
|
reasoningStreaming: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { container } = render(<MessageBubble message={message} />);
|
render(<MessageBubble message={message} />);
|
||||||
|
|
||||||
const preview = screen.getByText("Step 1: parse intent. Step 2: compute.");
|
const preview = screen.getByText("Step 1: parse intent. Step 2: compute.");
|
||||||
expect(preview).toBeInTheDocument();
|
expect(preview).toBeInTheDocument();
|
||||||
expect(container.querySelector(".reasoning-sheen-stripe")).not.toBeInTheDocument();
|
|
||||||
expect(preview).toHaveClass("streaming-text-sheen");
|
expect(preview).toHaveClass("streaming-text-sheen");
|
||||||
expect(preview).toHaveAttribute(
|
expect(preview).toHaveAttribute(
|
||||||
"data-sheen-text",
|
"data-sheen-text",
|
||||||
|
|||||||
@@ -1556,7 +1556,6 @@ describe("ThreadComposer", () => {
|
|||||||
expect(screen.getByRole("button", { name: "Switch directory" })).toBeEnabled();
|
expect(screen.getByRole("button", { name: "Switch directory" })).toBeEnabled();
|
||||||
rerender(composer(false, "thread", true));
|
rerender(composer(false, "thread", true));
|
||||||
expect(screen.queryByRole("button", { name: "Switch directory" })).not.toBeInTheDocument();
|
expect(screen.queryByRole("button", { name: "Switch directory" })).not.toBeInTheDocument();
|
||||||
expect(container.querySelector(".thread-composer-workspace-label")).not.toBeInTheDocument();
|
|
||||||
const accessAfterLock = screen.getByRole("button", { name: "Workspace access mode: Full Access" });
|
const accessAfterLock = screen.getByRole("button", { name: "Workspace access mode: Full Access" });
|
||||||
await user.click(accessAfterLock);
|
await user.click(accessAfterLock);
|
||||||
await user.click(screen.getByRole("menuitemradio", { name: "Default Permission" }));
|
await user.click(screen.getByRole("menuitemradio", { name: "Default Permission" }));
|
||||||
@@ -1894,7 +1893,6 @@ describe("ThreadComposer", () => {
|
|||||||
|
|
||||||
expect(input).toHaveValue("@Blender ");
|
expect(input).toHaveValue("@Blender ");
|
||||||
expect(screen.getByTestId("composer-cli-mention-blender")).toHaveTextContent("@Blender");
|
expect(screen.getByTestId("composer-cli-mention-blender")).toHaveTextContent("@Blender");
|
||||||
expect(screen.queryByTestId("composer-cli-app-tray")).not.toBeInTheDocument();
|
|
||||||
expect(onSend).not.toHaveBeenCalled();
|
expect(onSend).not.toHaveBeenCalled();
|
||||||
expect(screen.queryByRole("listbox", { name: "Mentions" })).not.toBeInTheDocument();
|
expect(screen.queryByRole("listbox", { name: "Mentions" })).not.toBeInTheDocument();
|
||||||
|
|
||||||
@@ -2750,7 +2748,6 @@ describe("ThreadComposer", () => {
|
|||||||
expect(token.className).not.toContain("mx-");
|
expect(token.className).not.toContain("mx-");
|
||||||
expect(token).toHaveClass("text-foreground");
|
expect(token).toHaveClass("text-foreground");
|
||||||
expect(token.style.textShadow).toBe("");
|
expect(token.style.textShadow).toBe("");
|
||||||
expect(screen.queryByTestId("composer-cli-app-tray")).not.toBeInTheDocument();
|
|
||||||
const logo = screen.getByTestId("composer-cli-mention-logo-gimp");
|
const logo = screen.getByTestId("composer-cli-mention-logo-gimp");
|
||||||
expect(logo.className).toContain("top-1/2");
|
expect(logo.className).toContain("top-1/2");
|
||||||
expect(logo.className).toContain("left-0");
|
expect(logo.className).toContain("left-0");
|
||||||
|
|||||||
@@ -2145,7 +2145,6 @@ describe("ThreadShell", () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const badge = await screen.findByRole("button", { name: "Choose model" });
|
const badge = await screen.findByRole("button", { name: "Choose model" });
|
||||||
expect(screen.queryByTestId("composer-model-setup-icon")).not.toBeInTheDocument();
|
|
||||||
expect(badge.querySelector('[data-needs-setup="true"]')).toHaveClass(
|
expect(badge.querySelector('[data-needs-setup="true"]')).toHaveClass(
|
||||||
"composer-model-pill-setup",
|
"composer-model-pill-setup",
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user