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.

feat(ui): route Cmd+W to the page on macOS, and complete the editor checklist

rubenluetke10-beep359f613d6404
diff --git a/docs/code-editor.md b/docs/code-editor.md
index 65d9d5b1b0..f291241aaa 100644
--- a/docs/code-editor.md
+++ b/docs/code-editor.md
@@ -13,14 +13,22 @@ terminals back without closing a file.
| New file / new folder | The buttons in the Folder tab's header, or right-click. The entry goes into the selected folder, next to the selected file, or into the workspace root when nothing is selected. A name with slashes (`src/new.py`) creates the folders on the way |
| Rename | **F2** or right-click |
| Delete | **Del** or right-click; the entry goes to the system trash |
-| See what changed | The **Changes** tab, or **Show changes**: the file against the last commit, editable on the right |
+| Select several | **Ctrl/Cmd+click** adds a row, **Shift+click** selects a range; delete, cut, copy and drag act on the whole selection |
+| Move, copy | Drag rows onto a folder (or the empty space for the root), or **Ctrl+X / Ctrl+C** then **Ctrl+V** on the target. Pasting into the same folder makes a "copy" |
+| Search in all files | **Ctrl+Shift+F** opens the **Search** tab: match case, whole word, regular expressions, include/exclude globs, and **Replace all** (a second click confirms; files with unsaved changes are left out) |
+| See what changed | Coloured marks in the gutter (added, modified, deleted lines against the last commit), the **Changes** tab, or **Show changes**: the file against the last commit, editable on the right |
| Rendered view | **Ctrl+Shift+V** for Markdown, HTML and SVG |
+| Encoding, line endings | Click them in the status bar: reopen or save with another encoding, switch between LF and CRLF |
| Tabs | **Ctrl+W** closes, **Ctrl+Tab** switches, **Ctrl+Shift+T** reopens the last closed tab. A single click opens a preview tab (italic) that the next single click replaces; a double click or an edit keeps it |
Every file type opens:
- Text and code open in the editor (Monaco, bundled locally and loaded only
- when the first file opens).
+ when the first file opens), with completions, hovers and syntax errors for
+ JSON, CSS/SCSS/Less, HTML and TypeScript/JavaScript.
+- Text in other encodings opens too: UTF-16 with a byte-order mark, and
+ legacy code pages (Windows-1252, Cyrillic, Greek, …) detected and saved
+ back in the same encoding.
- PDFs, images, audio and video open in built-in viewers.
- Word, Excel, PowerPoint and e-book files show the text read out of them.
- Binaries and files over 5 MB get a read-only look inside.
@@ -28,6 +36,16 @@ Every file type opens:
Non-text files also offer **Open on this computer** for editing them in their
own app.
+## Nothing typed is lost
+
+- Open tabs and unsaved text survive closing or restarting the app. Unsaved
+ text is backed up a moment after typing pauses (per user, per IDE instance,
+ outside the workspace) and laid back over its file on the next start.
+- If the file changed on disk meanwhile, the restored buffer shows the
+ conflict bar instead of overwriting the newer file.
+- An unsaved buffer also holds off the automatic reload after a new frontend
+ build.
+
## Working beside agents
- When an agent changes a file you have open, a clean buffer follows the disk
@@ -36,31 +54,47 @@ own app.
version** or **Keep mine**. A save never silently overwrites an agent's
edit: every save names the version it was based on, and the server refuses
a mismatch.
-- Saves are atomic and keep the file's line endings, UTF-8 byte-order mark and
- file mode.
+- Saves are atomic and keep the file's line endings, encoding, byte-order
+ mark and file mode. A file that mixes line endings shows a note first,
+ because a save writes one ending throughout.
- Paths inside `.git` are refused, including through a symlink.
+## Platforms
+
+- Windows: verified in the desktop app's WebView2 build.
+- macOS: pywebview's WKWebView host takes some Command shortcuts before the
+ page. `jarvis/ui/macos_editor_keys.py` routes **Cmd+W** to the page so it
+ closes an editor tab instead of the window; **Cmd+Z** reaches the editor
+ through the native undo. Not yet checked on a Mac.
+- Linux: pywebview's GTK and Qt hosts do not intercept keys, so the shortcuts
+ reach the page directly. Not yet checked on a Linux desktop.
+
## Checklist
- [x] New File / New Folder create in the selected folder, or next to the
selected file, or in the workspace root when nothing is selected
-- [ ] Unsaved buffers survive closing or restarting the app (open tabs and
+- [x] Unsaved buffers survive closing or restarting the app (open tabs and
unsaved text come back)
-- [ ] Search in all files (Ctrl+Shift+F)
-- [ ] Edit text files in encodings other than UTF-8 (Windows-1252, UTF-16)
-- [ ] Explorer: drag to move, multi-select, copy and paste entries
-- [ ] Warn before a save turns mixed line endings into one
-- [ ] Verify the shortcuts on macOS (WKWebView may take Cmd+W / Cmd+Z) and
- Linux (WebKitGTK input)
-- [ ] Optional: TypeScript/CSS/HTML language services, a Python language
- server, git change markers in the gutter
+- [x] Search in all files (Ctrl+Shift+F), with replace
+- [x] Edit text files in encodings other than UTF-8 (Windows-1252, UTF-16, …)
+- [x] Explorer: drag to move, multi-select, copy and paste entries
+- [x] Warn before a save turns mixed line endings into one
+- [x] Shortcuts on macOS: Cmd+W routed to the page (code-level; awaiting a
+ check on a real Mac) — Linux needs no routing
+- [x] TypeScript/CSS/HTML language services and git change markers in the
+ gutter
+- [ ] Python language server (needs a bundled server such as Pyright; not
+ started)
## Where it lives
-- Backend: `jarvis/agentic_ide/file_editing.py` and the `/workspaces/{id}/`
- routes `text-file`, `text-file/version`, `head-text`, `file-list`,
- `entries`, `entries/move` and `entries/delete` in
+- Backend: `jarvis/agentic_ide/file_editing.py` (read, save, create, copy,
+ move, delete, encodings), `file_search.py` (search and replace),
+ `editor_backups.py` (open tabs and unsaved text), and the
+ `/workspaces/{id}/` routes `text-file`, `text-file/version`, `head-text`,
+ `file-list`, `search`, `search/replace`, `editor-state`, `entries`,
+ `entries/copy`, `entries/move` and `entries/delete` in
`jarvis/ui/web/agentic_ide_routes.py`.
-- Frontend: `components/agentic/editor/`, `store/codeEditor.ts`, and the
- Folder and Changes tabs in
- `components/agentic/sidePanel/explorer/ExplorerPanel.tsx`.
+- Frontend: `components/agentic/editor/`, `store/codeEditor.ts`, the Folder
+ and Changes tabs in `components/agentic/sidePanel/explorer/ExplorerPanel.tsx`
+ and the Search tab in `components/agentic/sidePanel/search/`.
diff --git a/jarvis/ui/desktop_app.py b/jarvis/ui/desktop_app.py
index b009ba4152..2d4a625796 100644
--- a/jarvis/ui/desktop_app.py
+++ b/jarvis/ui/desktop_app.py
@@ -6214,6 +6214,15 @@ class DesktopApp:
except Exception: # noqa: BLE001, S110 - the drag bridge is never load-bearing
pass
+ # macOS: Cmd+W goes to the page (closes a code-editor tab) instead of
+ # closing the window; a logged no-op everywhere else. Before start().
+ try:
+ from jarvis.ui.macos_editor_keys import install_macos_editor_keys
+
+ install_macos_editor_keys()
+ except Exception: # noqa: BLE001, S110 - key routing is never load-bearing
+ pass
+
# webview.start blocks the main thread. func/args gets called after
# the first load (pywebview-internal), so evaluate_js hits a
# DOM-ready context.
diff --git a/jarvis/ui/macos_editor_keys.py b/jarvis/ui/macos_editor_keys.py
new file mode 100644
index 0000000000..b6a51a16dd
--- /dev/null
+++ b/jarvis/ui/macos_editor_keys.py
@@ -0,0 +1,74 @@
+"""Let the page see Cmd+W on macOS, so it closes an editor tab, not the app.
+
+pywebview's WKWebView host (``webview.platforms.cocoa.BrowserView.WebKitHost``)
+answers a handful of Command shortcuts itself before the page sees the key:
+Cmd+W calls ``performClose_`` on the window. Inside the Agentic IDE's code
+editor, Cmd+W means "close this tab" (as Ctrl+W does on Windows and Linux), and
+closing the whole Jarvis window instead is the opposite of what was asked.
+
+This module wraps the host's ``keyDown_`` so Cmd+W goes to the web content
+like any other key; every other shortcut keeps pywebview's handling. Cmd+Z is
+left alone on purpose: pywebview sends it to the native undo manager, which
+WebKit turns into an ``historyUndo`` input event the editor already honours.
+
+macOS only. On every other platform, or when the pywebview/AppKit internals
+are not what this expects, installing is a logged no-op — the shortcut then
+simply keeps its old meaning. Not verifiable on a non-Mac machine; see
+``docs/code-editor.md``.
+"""
+
+from __future__ import annotations
+
+import logging
+import sys
+from typing import Any
+
+log = logging.getLogger(__name__)
+
+__all__ = ["install_macos_editor_keys", "page_owns_shortcut"]
+
+#: Command shortcuts the page handles itself instead of the window.
+_PAGE_KEYS = frozenset({"w"})
+
+
+def page_owns_shortcut(command: bool, characters: str) -> bool:
+ """True when a Command shortcut must reach the page, not the window."""
+ return command and characters.lower() in _PAGE_KEYS
+
+
+def install_macos_editor_keys() -> bool:
+ """Patch the WKWebView host once; returns whether the patch is active."""
+ if sys.platform != "darwin":
+ return False
+ try:
+ import AppKit # type: ignore[import-not-found, import-untyped] # noqa: N813, PLC0415
+ import webview.platforms.cocoa as cocoa # type: ignore[import-untyped] # noqa: PLC0415
+ except Exception as exc: # noqa: BLE001 — optional desktop internals absent
+ log.warning("macos_editor_keys: WKWebView host unavailable (%s)", exc)
+ return False
+
+ host_class = cocoa.BrowserView.WebKitHost
+ if getattr(host_class, "_jarvis_editor_keys_installed", False):
+ return True
+ try:
+ original_key_down = host_class.keyDown_
+
+ def _patched_key_down(self: Any, event: Any) -> Any:
+ try:
+ command = bool(event.modifierFlags() & AppKit.NSCommandKeyMask)
+ characters = str(event.charactersIgnoringModifiers() or "")
+ if page_owns_shortcut(command, characters):
+ # WKWebView's own keyDown_ hands the event to the page.
+ return super(host_class, self).keyDown_(event)
+ except Exception: # noqa: BLE001 — never break typing on AppKit's thread
+ log.exception("macos_editor_keys: key routing failed; using the default")
+ return original_key_down(self, event)
+
+ host_class.keyDown_ = _patched_key_down # type: ignore[method-assign]
+ host_class._jarvis_editor_keys_original = original_key_down
+ host_class._jarvis_editor_keys_installed = True
+ except Exception as exc: # noqa: BLE001 — pywebview internals changed
+ log.warning("macos_editor_keys: could not route Cmd+W to the page (%s)", exc)
+ return False
+ log.info("macos_editor_keys: Cmd+W now reaches the page")
+ return True
diff --git a/tests/unit/ui/test_macos_editor_keys.py b/tests/unit/ui/test_macos_editor_keys.py
new file mode 100644
index 0000000000..738e0ac90f
--- /dev/null
+++ b/tests/unit/ui/test_macos_editor_keys.py
@@ -0,0 +1,29 @@
+"""Cmd+W reaches the page on macOS; everywhere else the installer is a no-op."""
+
+from __future__ import annotations
+
+import sys
+
+import pytest
+
+from jarvis.ui import macos_editor_keys
+from jarvis.ui.macos_editor_keys import install_macos_editor_keys, page_owns_shortcut
+
+
+def test_only_command_w_is_routed_to_the_page() -> None:
+ assert page_owns_shortcut(True, "w") is True
+ assert page_owns_shortcut(True, "W") is True
+ assert page_owns_shortcut(False, "w") is False
+ assert page_owns_shortcut(True, "z") is False
+ assert page_owns_shortcut(True, "q") is False
+
+
[email protected](sys.platform == "darwin", reason="the no-op path is for other platforms")
+def test_installing_is_a_no_op_off_macos() -> None:
+ assert install_macos_editor_keys() is False
+
+
+def test_missing_pywebview_internals_degrade_quietly(monkeypatch: pytest.MonkeyPatch) -> None:
+ monkeypatch.setattr(macos_editor_keys.sys, "platform", "darwin")
+ monkeypatch.setitem(sys.modules, "AppKit", None) # import fails like on a broken install
+ assert install_macos_editor_keys() is False