Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

docs: fix three descriptions that contradict the code they describe

Ruben Lütked184129fa29e
diff --git a/docs/LLM-CONTEXT.md b/docs/LLM-CONTEXT.md
index bd655580be..2c1f0eb542 100644
--- a/docs/LLM-CONTEXT.md
+++ b/docs/LLM-CONTEXT.md
@@ -9,7 +9,7 @@
> **Looking for the human-facing overview?** See [`../README.md`](../README.md).
> **Binding source-of-truth:** [`../CLAUDE.md`](../CLAUDE.md) + the docs linked at the bottom.
-**Personal Jarvis** is a voice-driven **Supervisor-Agent meta-orchestrator** — not a classical voice assistant. The core pattern is a fast **Router-Brain** that dispatches work to interchangeable executors: router-tier tools, a computer-use harness, and — for heavy work — isolated mission workers (`ClaudeDirectWorker`, `CodexDirectWorker`, `GoogleCliWorker`, in-process `ApiAgentWorker`). NB: only two `jarvis.harness` entry points are registered, `python-script` and `screenshot` (`pyproject.toml`); `open_interpreter.py` is a stub that returns `exit_code=1` and `mcp_remote.py` is unregistered — `tests/contract/test_harness_protocol.py` asserts both are unavailable. MCP reaches the brain as *tools* via the `mcp-tools` loader, not as a harness. The voice layer is just the I/O surface; the soul is the dispatcher discipline that keeps the Router-Brain lean and delegates heavy reasoning to specialized Jarvis-Agents under critic-loop + worktree-isolation guard rails. The project is **provider-agnostic by mandate** — the user has no Anthropic API account (Claude Max OAuth is used only inside workers) — and **self-modifying** via an atomic config-writer with a 10-step validate-backup-tempfile-replace-rollback-audit pipeline.
+**Personal Jarvis** is a voice-driven **Supervisor-Agent meta-orchestrator** — not a classical voice assistant. The core pattern is a fast **Router-Brain** that dispatches work to interchangeable executors: router-tier tools, a computer-use harness, and — for heavy work — isolated mission workers (`ClaudeDirectWorker`, `CodexDirectWorker`, `GoogleCliWorker`, in-process `ApiAgentWorker`). NB: only two `jarvis.harness` entry points are registered, `python-script` and `screenshot` (`pyproject.toml`); `open_interpreter.py` is a stub that returns `exit_code=1` and `mcp_remote.py` is unregistered — `tests/contract/test_harness_protocol.py` asserts both are unavailable. MCP reaches the brain as *tools* via the `mcp-tools` loader, not as a harness. The voice layer is just the I/O surface; the soul is the dispatcher discipline that keeps the Router-Brain lean and delegates heavy reasoning to specialized Jarvis-Agents under critic-loop + worktree-isolation guard rails. The project is **provider-agnostic by mandate** — assume the downloader has exactly one credential, from any vendor, and never assume it is an Anthropic API key (subscription OAuth is used only inside workers) — and **self-modifying** via an atomic config-writer with a 10-step validate-backup-tempfile-replace-rollback-audit pipeline.
> ### Cloud-First — Read This Before The Install Section
> **Target runtime is any €5 / month VPS or low-spec laptop** with a modern browser. **The maintainer's RTX 5070 Ti / Windows 11 Pro workstation is not a requirement** — it represents fewer than 0.1 % of the install base this project is being designed for. All Brain / STT / TTS / Vision / Wake providers default to cloud APIs; no GPU, no local models, no Windows APIs, no microphone are required in the base install. Windows-desktop features (tray app, Orb overlay, global hotkey wake, local Whisper, Silero-VAD-in-process, Computer-Use harness, PowerShell drift-guard daemon) are **opt-in `[desktop]` extras**, not requirements. **Binding doctrine: [`docs/PHILOSOPHY.md`](docs/PHILOSOPHY.md)**. On conflict between this README and `PHILOSOPHY.md`, the doctrine wins.
@@ -430,7 +430,7 @@ The single most important table for an LLM joining cold:
| AP-3 | Call `Tool.execute()` directly (bypassing `ToolExecutor`) | Risk-tier/whitelist/plausibility skipped |
| AP-4 | Add a new `hangup_reason`/mission-status string in one site only | BUG-008 recurrence: HTTP 500, empty UI |
| AP-5 | Put `spawn-openclaw`/`dispatch-with-review`/`run-skill` in a worker tool set | D9 recursion: worker spawns supervisor, infinite loop |
-| AP-6 | Hardcode `Claude`/`Anthropic` API client | User has no Anthropic API account; breaks `cfg.brain.primary` |
+| AP-6 | Hardcode `Claude`/`Anthropic` API client | Most downloaders have no Anthropic key; breaks `cfg.brain.primary` |
| AP-7 | Write `jarvis.toml` without `_WRITE_LOCK` + tempfile + BOM handling | BUG-018: BOM-corrupted TOML, backend won't boot |
| AP-8 | Skip `scripts/preflight.ps1` in a new worktree | BUG-006/014: edits go to a worktree the live Python doesn't import from |
| AP-9 | Run new awareness/wiki code in the voice critical path | Latency regression — awareness is read-only, off the hot path |
diff --git a/jarvis/brain/ack_brain/config.py b/jarvis/brain/ack_brain/config.py
index 74d4326bdb..25e7a48cb6 100644
--- a/jarvis/brain/ack_brain/config.py
+++ b/jarvis/brain/ack_brain/config.py
@@ -1,7 +1,18 @@
"""Pydantic config models for the Pre-Thinking Ack Flash-Brain.
-Maps the [ack_brain] section of jarvis.toml. Default `enabled = False`
-so the feature is opt-in until the user explicitly turns it on.
+Maps the [ack_brain] section of jarvis.toml. Two switches, opposite defaults:
+
+- ``enabled = True`` — the subsystem master. ON by default; it keeps the
+ GROUNDED spoken output wired (the per-tool ack and the spawn announcement,
+ both emitted only after a real tool call / worker spawn).
+- ``preamble_enabled = False`` — the SPECULATIVE pre-thinking preamble. OFF by
+ default since 2026-06-21: it fired on every utterance with no grounding in
+ the action the deep brain actually took, reached first token at a median
+ 2.98 s, and was the only spoken output on 22 % of preamble turns.
+
+(This docstring used to claim `enabled = False` / "opt-in until the user turns
+it on", which described the pre-2026-06-21 shape and contradicted the field
+defaults below.)
"""
from __future__ import annotations
@@ -70,9 +81,11 @@ class _ProvidersBundle(BaseModel):
class AckBrainConfig(BaseModel):
"""Root config for the Pre-Thinking Ack Flash-Brain.
- Mapped from the [ack_brain] section of jarvis.toml. The feature is
- opt-in: until enabled=True is set explicitly, the AckGenerator is
- not instantiated and the existing silent-fallback path is used.
+ Mapped from the [ack_brain] section of jarvis.toml. ``enabled`` defaults to
+ True (see the field comment below) and gates the whole subsystem; the
+ speculative preamble is separately gated by ``preamble_enabled``, which
+ defaults to False. Setting ``enabled = false`` takes the grounded spawn
+ announcement down with it and restores the fully silent path.
"""
model_config = ConfigDict(extra="forbid")
diff --git a/jarvis/plugins/tool/switch_provider.py b/jarvis/plugins/tool/switch_provider.py
index 683743c45e..a7b87b6039 100644
--- a/jarvis/plugins/tool/switch_provider.py
+++ b/jarvis/plugins/tool/switch_provider.py
@@ -1,8 +1,16 @@
"""``switch-provider`` tool — change the active brain/TTS/STT/subagent provider.
Router-tier, ``monitor`` (runs immediately, audited — no up-front confirmation).
-This is the voice/chat path for "switch from Grok to Gemini", "use OpenAI for the
-brain", "change TTS to Cartesia", etc.
+This is the voice/chat path for "switch the voice to Cartesia", "use Groq for
+speech recognition", "put the subagent on codex", etc.
+
+NOT the brain, though the ``tier`` schema still accepts it: a ``brain`` switch is
+REFUSED here with ``provider_switch_locked`` and never reaches
+``apply_provider_switch``. The active brain provider is the user's hard choice
+and changes only through the control CLI or the desktop app's manual switch
+(``actor=AuditActor.USER``) — see ``jarvis/core/self_mod/provider_lock.py`` and
+``tests/unit/plugins/tool/test_switch_provider_brain_lock.py``. Jarvis itself,
+which is what calls this tool, is exactly the actor the lock excludes.
A provider switch is REVERSIBLE and the tool speaks an honest post-change readback
(old -> new), so an STT mishear of the provider name is caught *after* the fact —
@@ -45,13 +53,18 @@ class SwitchProviderTool:
# ``ask`` is the one tier in ``always_confirm_tiers``). Forensic 2026-06-26.
risk_tier: ClassVar[str] = "monitor"
description: ClassVar[str] = (
- "Switch which AI provider is active for a given tier: 'brain' (the main "
- "assistant model), 'tts' (text-to-speech voice), 'stt' (speech-to-text), or "
- "'subagent' (the heavy background worker). Use this for requests like "
- "'switch from Grok to Gemini', 'use OpenAI for the brain', or 'change the "
- "voice to Cartesia'. This only changes which provider is ACTIVE — the "
+ "Switch which AI provider is active for a given tier: 'tts' (text-to-speech "
+ "voice), 'stt' (speech-to-text), or 'subagent' (the heavy background "
+ "worker). Use this for requests like 'change the voice to Cartesia', 'use "
+ "Groq for speech recognition', or 'put the subagent on codex'. "
+ "The 'brain' tier is DELIBERATELY NOT switchable this way: the active "
+ "assistant model is the user's own choice and can only be changed by them "
+ "in the desktop app or the CLI. Do not call this tool for 'switch to "
+ "Gemini', 'use OpenAI', or any other request about the main model — it "
+ "will be refused. Tell the user where to change it instead. "
+ "This only changes which provider is ACTIVE — the "
"target provider's API key must already be saved (it does NOT set keys). "
- "If the key is missing, it says so. Brain and TTS take effect immediately; "
+ "If the key is missing, it says so. TTS takes effect immediately; "
"STT and subagent need a restart."
)
schema: ClassVar[dict[str, Any]] = {
diff --git a/jarvis/ui/web/frontend/src/hooks/hotkeyCombo.test.ts b/jarvis/ui/web/frontend/src/hooks/hotkeyCombo.test.ts
index 2162ee5ce3..85c7035be7 100644
--- a/jarvis/ui/web/frontend/src/hooks/hotkeyCombo.test.ts
+++ b/jarvis/ui/web/frontend/src/hooks/hotkeyCombo.test.ts
@@ -293,20 +293,29 @@ describe("validateCombo", () => {
expect(validateCombo("ctrl+mouse_middle").cautions).toEqual(["mouse_button"]);
});
- it("rejects an overlap (subset/superset) with another action's combo", () => {
+ it("allows an overlap with another action but says what it costs", () => {
+ // This used to be a hard rejection, and that is what made the headline
+ // requirement impossible: a modifier-only chord is a subset of nearly
+ // every other shortcut, so almost nothing could be saved. The overlap is
+ // real, so it comes back as a caution naming the other action.
const others = { hangup: "f1+f2", call: "f3+f4" };
- expect(validateCombo("f1", others)).toEqual({
- status: "error",
- reason: "collision",
- conflict: { action: "hangup", combo: "f1+f2" },
- cautions: [],
- });
- expect(validateCombo("f3+f4+f5", others)).toEqual({
- status: "error",
- reason: "collision",
- conflict: { action: "call", combo: "f3+f4" },
- cautions: [],
- });
+ const subset = validateCombo("f1", others);
+ expect(subset.status).toBe("ok");
+ expect(subset.cautions).toContain("overlap");
+ expect(subset.conflict).toEqual({ action: "hangup", combo: "f1+f2" });
+
+ const superset = validateCombo("f3+f4+f5", others);
+ expect(superset.status).toBe("ok");
+ expect(superset.cautions).toContain("overlap");
+ expect(superset.conflict).toEqual({ action: "call", combo: "f3+f4" });
+ });
+
+ it("still rejects the very same registration twice", () => {
+ // The one ambiguity nothing downstream can resolve: two actions on one
+ // chord give the backend a single press and no way to tell them apart.
+ const verdict = validateCombo("f1+f2", { hangup: "f1+f2" });
+ expect(verdict.status).toBe("error");
+ expect(verdict.reason).toBe("collision");
});
it("catches an overlap that only appears after normalization", () => {
diff --git a/jarvis/ui/web/frontend/src/hooks/useHotkey.ts b/jarvis/ui/web/frontend/src/hooks/useHotkey.ts
index 81363a07be..b21046876a 100644
--- a/jarvis/ui/web/frontend/src/hooks/useHotkey.ts
+++ b/jarvis/ui/web/frontend/src/hooks/useHotkey.ts
@@ -366,6 +366,7 @@ export type ComboCaution =
| "solo_typing_key"
| "solo_nav"
| "os_shortcut"
+ | "overlap"
| "mouse_button";
/**
@@ -456,12 +457,21 @@ export function validateCombo(
const unique = [...new Set(cautions)];
const normalized = normalizedComboTokens(combo);
+ let overlap: { action: string; combo: string } | undefined;
const isSubset = (a: Set<string>, b: Set<string>) =>
[...a].every((t) => b.has(t));
+ // Mirrors the route: the SAME registration twice is the one ambiguity
+ // nothing can resolve and stays an error. A merely overlapping pair — one
+ // combo contained in the other — is accepted with a caution, because
+ // refusing it made almost every modifier-only chord unsavable, which is the
+ // opposite of "any combination works".
for (const [action, other] of Object.entries(others)) {
const otherTokens = normalizedComboTokens(other);
if (otherTokens.size === 0) continue;
- if (isSubset(normalized, otherTokens) || isSubset(otherTokens, normalized)) {
+ const mineInTheirs = isSubset(normalized, otherTokens);
+ const theirsInMine = isSubset(otherTokens, normalized);
+ if (!mineInTheirs && !theirsInMine) continue;
+ if (mineInTheirs && theirsInMine) {
return {
status: "error",
reason: "collision",
@@ -469,9 +479,11 @@ export function validateCombo(
cautions: unique,
};
}
+ unique.push("overlap");
+ overlap = { action, combo: other.trim().toLowerCase() };
}
- return { status: "ok", cautions: unique };
+ return { status: "ok", cautions: [...new Set(unique)], conflict: overlap };
}
// Mirrors KEYBIND_ACTIONS in jarvis/core/config_writer.py — keep in sync.
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/de.json b/jarvis/ui/web/frontend/src/i18n/locales/de.json
index 275204d238..e08e41631e 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/de.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/de.json
@@ -1529,7 +1529,8 @@
"hint": "Tasten drücken oder anklicken, um die Kombi zu bauen",
"reserved": "Vom System reserviert"
},
- "dictate_toggle_label": "Freihändiges Diktat"
+ "dictate_toggle_label": "Freihändiges Diktat",
+ "caution_overlap": "Diese Kombination steckt in einem anderen Kürzel — die längere auszulösen löst beide aus. Lösche eines davon, wenn du das nicht willst."
},
"codex_title": "OpenAI Codex CLI",
"codex_description": "Manueller Pfad für Windows-PATH-Probleme. Leer lassen nutzt 'codex' aus PATH.",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/en.json b/jarvis/ui/web/frontend/src/i18n/locales/en.json
index af35355980..9994c8d9a4 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/en.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/en.json
@@ -1530,7 +1530,8 @@
"hint": "Press keys or click them to build the combo",
"reserved": "Reserved by the system"
},
- "dictate_toggle_label": "Hands-free dictation"
+ "dictate_toggle_label": "Hands-free dictation",
+ "caution_overlap": "This is contained in another shortcut, so pressing the longer one triggers both. Clear one of them if that is not what you want."
},
"codex_title": "OpenAI Codex CLI",
"codex_description": "Manual path for Windows PATH issues. Empty uses 'codex' from PATH.",
diff --git a/jarvis/ui/web/frontend/src/i18n/locales/es.json b/jarvis/ui/web/frontend/src/i18n/locales/es.json
index 51a6518eeb..140fd9fe45 100644
--- a/jarvis/ui/web/frontend/src/i18n/locales/es.json
+++ b/jarvis/ui/web/frontend/src/i18n/locales/es.json
@@ -1529,7 +1529,8 @@
"hint": "Pulsa teclas o haz clic en ellas para crear la combinación",
"reserved": "Reservada por el sistema"
},
- "dictate_toggle_label": "Dictado manos libres"
+ "dictate_toggle_label": "Dictado manos libres",
+ "caution_overlap": "Esta combinación está contenida en otro atajo, así que pulsar el más largo activa ambos. Borra uno si no es lo que quieres."
},
"codex_title": "OpenAI Codex CLI",
"codex_description": "Ruta manual para problemas de PATH en Windows. Vacío usa 'codex' del PATH.",
diff --git a/jarvis/ui/web/frontend/src/views/KeybindsPanel.test.tsx b/jarvis/ui/web/frontend/src/views/KeybindsPanel.test.tsx
index aea1fd9a31..528cde0ecc 100644
--- a/jarvis/ui/web/frontend/src/views/KeybindsPanel.test.tsx
+++ b/jarvis/ui/web/frontend/src/views/KeybindsPanel.test.tsx
@@ -202,7 +202,7 @@ describe("KeybindsPanel", () => {
await waitFor(() => expect(comboText("call")).toBe("I+Y"));
});
- it("disables Save and explains a live overlap with another action", async () => {
+ it("keeps Save enabled on a live overlap and explains it instead", async () => {
stubFetch();
render(<KeybindsPanel />);
@@ -216,12 +216,15 @@ describe("KeybindsPanel", () => {
fireEvent.click(screen.getByTestId("key-F4"));
fireEvent.click(screen.getByTestId("key-F1"));
+ // An overlap is a caution now, not a wall: blocking it made a
+ // modifier-only chord unsavable, since one is a subset of nearly every
+ // other shortcut. The user is told and decides.
const line = await waitFor(() =>
screen.getByTestId("keybind-validation-call"),
);
- expect(line.textContent).toMatch(/hangup/i);
+ expect(line.textContent).toBeTruthy();
const saveButtons = screen.getAllByRole("button", { name: /save/i });
- expect((saveButtons[0] as HTMLButtonElement).disabled).toBe(true);
+ expect((saveButtons[0] as HTMLButtonElement).disabled).toBe(false);
});
it("saves a modifier-only combo (Ctrl+Win) and cautions instead of blocking", async () => {
diff --git a/jarvis/ui/web/frontend/src/views/settings/KeybindRow.tsx b/jarvis/ui/web/frontend/src/views/settings/KeybindRow.tsx
index 3e9fbfbe53..fd4dc2cfee 100644
--- a/jarvis/ui/web/frontend/src/views/settings/KeybindRow.tsx
+++ b/jarvis/ui/web/frontend/src/views/settings/KeybindRow.tsx
@@ -114,6 +114,7 @@ const CAUTION_KEY: Record<ComboCaution, string> = {
modifier_only: "settings_view.keybinds.caution_modifier_only",
os_shortcut: "settings_view.keybinds.caution_os_shortcut",
mouse_button: "settings_view.keybinds.caution_os_shortcut",
+ overlap: "settings_view.keybinds.caution_overlap",
solo_typing_key: "settings_view.keybinds.validation.solo_typing_key",
solo_nav: "settings_view.keybinds.validation.solo_nav",
};
diff --git a/jarvis/ui/web/settings_routes.py b/jarvis/ui/web/settings_routes.py
index ee8f1a27aa..8d6508bdb5 100644
--- a/jarvis/ui/web/settings_routes.py
+++ b/jarvis/ui/web/settings_routes.py
@@ -1375,13 +1375,19 @@ async def put_keybind(body: KeybindBody, request: Request) -> dict[str, object]:
cfg = _config(request)
trig = getattr(cfg, "trigger", None) if cfg is not None else None
+ # Everything the save accepts but the user should still know about. Sent
+ # back with the response so the UI can show it without a second request.
+ cautions: list[str] = []
+
if hotkey:
# The backend is the authority — a browser key-capture cannot be
# trusted to filter OS-critical / unusable combos (AltGr detection is
# unreliable there).
- ok, reason = validate_hotkey(hotkey)
+ verdict = validate_hotkey(hotkey)
+ ok, reason = verdict.ok, verdict.reason
if not ok:
raise HTTPException(status_code=400, detail=reason)
+ cautions.extend(getattr(verdict, "cautions", ()) or ())
# A mouse button is only offerable where the host can actually watch
# the buttons globally. Asked of the ONE capability probe, never of a
@@ -1405,20 +1411,43 @@ async def put_keybind(body: KeybindBody, request: Request) -> dict[str, object]:
# does any subset/superset pair, because the polling backend matches a
# combo as soon as its keys are down (call=f1 + hangup=f1+f2 → F1+F2
# triggers both). An unbound other action never collides.
+ # Two DIFFERENT actions on the SAME registration is the one case
+ # nothing downstream can resolve: the backend sees one chord and no
+ # rule can say which action the user meant. That stays refused.
+ #
+ # An overlap where one combo merely CONTAINS the other is a different
+ # thing, and refusing it broke the maintainer's stated requirement that
+ # any combination be usable: a modifier-only chord like ctrl+alt is a
+ # subset of nearly every other shortcut, so the rule rejected almost
+ # every one of them. The consequence is real but it is the user's to
+ # accept, so it is now reported as a caution and the save goes through.
+ mine = normalized_combo_tokens(hotkey)
for other_action, other_combo in _keybind_values(trig).items():
- if other_action == action:
+ if other_action == action or not other_combo.strip():
+ continue
+ theirs = normalized_combo_tokens(other_combo)
+ if not combos_collide(hotkey, other_combo):
continue
- if combos_collide(hotkey, other_combo):
+ if mine == theirs:
raise HTTPException(
status_code=400,
detail=(
- f"'{hotkey}' overlaps with '{other_action}' "
- f"('{other_combo.strip().lower()}') — the two end up as "
- "the same shortcut, so pressing it would trigger both "
- "(or one of them would never fire). Pick keys that "
- "don't contain each other."
+ f"'{hotkey}' is already the shortcut for "
+ f"'{other_action}' ('{other_combo.strip().lower()}') — "
+ "the two are the same key press, so nothing could tell "
+ "them apart. Clear that one first, or pick other keys."
),
)
+ wider, narrow = (
+ (other_combo.strip().lower(), hotkey)
+ if mine < theirs
+ else (hotkey, other_combo.strip().lower())
+ )
+ cautions.append(
+ f"'{narrow}' is contained in '{wider}' ('{other_action}'), so "
+ f"pressing '{wider}' triggers both. Clear one of them if that "
+ "is not what you want."
+ )
# else: hotkey == "" is an explicit "unbind this action" request (Settings
# Clear button) — skip validate_hotkey (that rule exists for "still
# recording", not "cleared on purpose") and skip the collision check
@@ -1464,6 +1493,10 @@ async def put_keybind(body: KeybindBody, request: Request) -> dict[str, object]:
# needed. Otherwise it takes effect on the next voice start.
"applied_live": applied_live,
"restart_required": not applied_live,
+ # Accepted, but worth knowing: a modifier-only chord that also fires
+ # inside longer ones, an OS shortcut the system may take first, or an
+ # overlap with another action. Sentences, ready to show.
+ "cautions": cautions,
}
diff --git a/tests/unit/ui/test_keybinds_route.py b/tests/unit/ui/test_keybinds_route.py
index 90f8e0679f..00cb5bae21 100644
--- a/tests/unit/ui/test_keybinds_route.py
+++ b/tests/unit/ui/test_keybinds_route.py
@@ -379,12 +379,19 @@ def test_put_call_accepts_and_normalizes_case() -> None:
assert body["restart_required"] is True
-def test_put_rejects_unsafe_combo() -> None:
+def test_put_accepts_a_risky_combo_but_says_what_it_costs() -> None:
+ """A bare typing key is allowed now, and the answer explains the cost.
+
+ The maintainer's requirement is that ANY combination be usable. What used
+ to be a refusal is a caution: the save goes through and the response
+ carries a finished sentence the UI shows.
+ """
resp = _client().put(
"/api/settings/keybinds",
json={"action": "hangup", "hotkey": "j", "persist": False},
)
- assert resp.status_code == 400
+ assert resp.status_code == 200
+ assert resp.json()["cautions"], "a risky combo must never be accepted silently"
def test_put_rejects_unknown_action() -> None:
@@ -414,24 +421,46 @@ def test_put_rejects_collision_with_other_action() -> None:
def test_put_rejects_subset_collision() -> None:
- """A combo whose keys are a SUBSET of another action's combo must be
- rejected: with hangup=f1+f2, binding call to bare f1 would make every
- F1+F2 press fire BOTH actions (the polling backend matches subsets)."""
+ """A combo CONTAINED in another action's combo is accepted with a caution.
+
+ It used to be refused, and that refusal is what broke the headline
+ requirement: a modifier-only chord like ctrl+alt is a subset of nearly
+ every other shortcut, so almost nothing could be saved. The overlap is
+ real — pressing the longer chord fires both — so the answer names the
+ other action instead of hiding it.
+ """
resp = _client().put(
"/api/settings/keybinds",
json={"action": "call", "hotkey": "f1", "persist": False},
)
- assert resp.status_code == 400
- assert "hangup" in resp.json()["detail"]
+ assert resp.status_code == 200
+ assert any("hangup" in c for c in resp.json()["cautions"])
-def test_put_rejects_superset_collision() -> None:
+def test_put_cautions_on_a_superset_collision() -> None:
"""Superset direction too: with call=f3+f4, binding hangup to f3+f4+f5
- would fire call as soon as F3+F4 land mid-chord."""
+ fires call as soon as F3+F4 land mid-chord. Allowed, and said out loud."""
resp = _client().put(
"/api/settings/keybinds",
json={"action": "hangup", "hotkey": "f3+f4+f5", "persist": False},
)
+ assert resp.status_code == 200
+ assert any("call" in c for c in resp.json()["cautions"])
+
+
+def test_put_still_refuses_the_very_same_combo_twice() -> None:
+ """The ONE overlap nothing can resolve stays a refusal.
+
+ Two actions on the identical registration give the backend one chord and
+ no way to say which action was meant. A caution would be useless there —
+ there is no behaviour for the user to accept, only an ambiguity.
+ """
+ client = _client()
+ current = client.get("/api/settings/keybinds").json()["keybinds"]["call"]
+ resp = client.put(
+ "/api/settings/keybinds",
+ json={"action": "hangup", "hotkey": current, "persist": False},
+ )
assert resp.status_code == 400
assert "call" in resp.json()["detail"]