Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

refactor: render keyboard-shortcut hints through the shared modKey helper (#3897)

[._.]/ Adam Eivy59abebb38ace
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 93044f4c03..b35bb34ade 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -59,3 +59,4 @@
- The unused `toolUseLocalModelFilter` export was removed from the client's provider helpers. It offered to hide non-tool-capable local models from a picker, but nothing ever called it, and the approach it represented was already settled the other way: agent and coding pickers annotate each option (`🔧 tool use` / `⚠ no known tool use`) and warn below the select rather than filtering, because the underlying heuristic is a positive allowlist — a non-match means "not a recognized tool-caller", not a proven negative, so filtering would make a newer tool-capable family unselectable. The rationale now lives on the annotation helper that survived.
- Deleting or uploading a SongBook attachment no longer crashes when the attachment presence lookup failed on page load. That failure parks the attachment state on a `'failed'` sentinel string so the synced list still renders with presence unknown, but both mutation handlers treated it as an array: the delete handler called `.find()` on it and threw `TypeError: prev.find is not a function`, leaving the row on screen, and the upload handler spread the string into six single-character rows. Both now check for an array first, falling back to the record's own synced list on upload and leaving presence genuinely unknown on delete rather than stamping a false "not on this machine" pill.
- Uploading several SongBook attachments at once no longer stops at the first failure. The upload loop awaited each file without catching, so one rejected read or a single server error broke out of the loop: the remaining files in the selection were never attempted, and the one generic "Upload failed" toast gave no clue which file failed or that anything had been skipped. Each file's read-and-upload now catches on its own, toasting a message that names the file, and the batch continues so the successful files still land.
+- Keyboard-shortcut hints across the client now render the right modifier for the machine they're on. `client/src/utils/platform.js` had exported `isMac` and a `modKey` (`⌘` / `Ctrl`) label since it was written but nothing imported either, so five hints hardcoded a glyph instead: the 404 page and the Ask composer advertised `⌘K` / `⌘/Ctrl + Enter` to Windows and Linux users, the OpenClaw composer printed both forms side by side, the Writers Room save button's tooltip said `Ctrl/Cmd+S`, and the digital-twin enrichment prompt said `Ctrl+Enter` on a Mac. All five now read `modKey`, which prefers `navigator.userAgentData.platform` over the deprecated `navigator.platform` and degrades to non-Mac when neither exists — behaviour the module now has tests for.
diff --git a/client/src/components/digital-twin/NextActionBanner.jsx b/client/src/components/digital-twin/NextActionBanner.jsx
index 631391161d..5858a65440 100644
--- a/client/src/components/digital-twin/NextActionBanner.jsx
+++ b/client/src/components/digital-twin/NextActionBanner.jsx
@@ -16,6 +16,7 @@ import BrailleSpinner from '../BrailleSpinner';
import { writeClipboardSilently } from '../../lib/clipboard';
import { ENRICHMENT_CATEGORIES } from './constants';
import ScaleInput from './ScaleInput';
+import { modKey } from '../../utils/platform';
const DIMENSION_LABELS = {
openness: 'Openness',
@@ -377,7 +378,7 @@ export default function NextActionBanner({ gaps, status, traits, onRefresh }) {
</button>
</div>
{question.questionType !== 'scale' && (
- <div className="text-xs text-gray-600 mt-1">Ctrl+Enter to submit</div>
+ <div className="text-xs text-gray-600 mt-1">{modKey}+Enter to submit</div>
)}
</>
) : (
diff --git a/client/src/components/writers-room/WorkEditor.jsx b/client/src/components/writers-room/WorkEditor.jsx
index ee84e79551..f4e8786ff8 100644
--- a/client/src/components/writers-room/WorkEditor.jsx
+++ b/client/src/components/writers-room/WorkEditor.jsx
@@ -61,6 +61,7 @@ import useImageGenQueue from '../../hooks/useImageGenQueue';
import useLiveSuggest from '../../hooks/useLiveSuggest';
import useSidebarResize from '../../hooks/useSidebarResize';
import useTokenPopover from '../../hooks/useTokenPopover';
+import { modKey } from '../../utils/platform';
const ANALYSIS_KIND = { SCRIPT: 'script', CHARACTERS: 'characters', PLACES: 'places', OBJECTS: 'objects', EVALUATE: 'evaluate', FORMAT: 'format' };
const DRAWER = { VERSIONS: 'versions', HISTORY: 'history', POLISH: 'polish', VOICE: 'voice' };
@@ -788,7 +789,7 @@ export default function WorkEditor({ work, onChange, onToggleExercise, exerciseO
className={`flex items-center gap-1 px-3 py-1 min-h-[44px] sm:min-h-0 text-xs rounded ${
dirty && !saving ? 'bg-port-accent text-white hover:bg-port-accent/80' : 'bg-port-bg text-gray-500'
}`}
- title={dirty ? 'Save (Ctrl/Cmd+S)' : 'Up to date'}
+ title={dirty ? `Save (${modKey}S)` : 'Up to date'}
>
<Save size={12} /> {saving ? 'Saving…' : dirty ? 'Save' : 'Saved'}
</button>
diff --git a/client/src/pages/Ask.jsx b/client/src/pages/Ask.jsx
index 70cabe734e..2a3f800ebc 100644
--- a/client/src/pages/Ask.jsx
+++ b/client/src/pages/Ask.jsx
@@ -7,6 +7,7 @@ import toast from '../components/ui/Toast';
import ConfirmButtonPair from '../components/ui/ConfirmButtonPair';
import { useConfirmDelete } from '../hooks/useConfirmDelete';
import useMounted from '../hooks/useMounted';
+import { modKey } from '../utils/platform';
// Mirrors the server-side ID_RE in askConversations.js (9-char base36 ms +
// 8-char hex suffix) so this regex stays in lockstep with the production
@@ -724,7 +725,7 @@ export default function Ask() {
{streaming ? 'Streaming…' : 'Send'}
</button>
</div>
- <div className="mt-1.5 text-xs text-gray-500">⌘/Ctrl + Enter to send</div>
+ <div className="mt-1.5 text-xs text-gray-500">{modKey} + Enter to send</div>
</form>
</main>
</div>
diff --git a/client/src/pages/NotFound.jsx b/client/src/pages/NotFound.jsx
index 2c4f20b741..394be8170c 100644
--- a/client/src/pages/NotFound.jsx
+++ b/client/src/pages/NotFound.jsx
@@ -1,5 +1,6 @@
import { Link, useLocation, useNavigate } from 'react-router';
import { Compass, ArrowLeft, LayoutDashboard } from 'lucide-react';
+import { modKey } from '../utils/platform';
// Catch-all for unknown routes. This used to be a bare `<Navigate to="/" />`,
// which silently deposited the user on the Dashboard after the page-loader
@@ -37,7 +38,7 @@ export default function NotFound() {
</Link>
</div>
<p className="mt-4 text-xs text-gray-500">
- Press <kbd className="px-1 py-0.5 rounded bg-port-bg border border-port-border">⌘K</kbd> to search every page by name.
+ Press <kbd className="px-1 py-0.5 rounded bg-port-bg border border-port-border">{modKey}K</kbd> to search every page by name.
</p>
</div>
</div>
diff --git a/client/src/pages/OpenClaw.jsx b/client/src/pages/OpenClaw.jsx
index 992533d7bd..e5ab1373a8 100644
--- a/client/src/pages/OpenClaw.jsx
+++ b/client/src/pages/OpenClaw.jsx
@@ -39,6 +39,7 @@ import * as coreApi from '../services/api';
import { formatDateTime } from '../utils/formatters';
import { useOpenClawAttachments, OPENCLAW_ATTACHMENT_ACCEPT } from '../hooks/useOpenClawAttachments';
import { useOpenClawStream } from '../hooks/useOpenClawStream';
+import { modKey } from '../utils/platform';
function getRuntimeState(status) {
if (!status?.configured) {
@@ -650,7 +651,7 @@ export default function OpenClaw() {
<div className="mt-3 flex flex-wrap items-center justify-between gap-3">
<div className="flex flex-wrap items-center gap-2 text-xs text-gray-500">
<span>
- {status?.configured && selectedSessionId ? 'Stream via PortOS · ⌘↵ / Ctrl↵ to send' : 'Select a configured session to send.'}
+ {status?.configured && selectedSessionId ? `Stream via PortOS · ${modKey}↵ to send` : 'Select a configured session to send.'}
</span>
<FilePickerButton
multiple
diff --git a/client/src/utils/platform.js b/client/src/utils/platform.js
index 911c4d8d69..88d7ff9dea 100644
--- a/client/src/utils/platform.js
+++ b/client/src/utils/platform.js
@@ -1,4 +1,12 @@
-/** Platform detection — provides isMac flag and modifier key label for keyboard shortcuts */
+/**
+ * Platform detection — the single source of truth for "is this a Mac?" in the client.
+ *
+ * Browsers are mid-migration from the deprecated `navigator.platform` to
+ * `navigator.userAgentData.platform`, so both are consulted (new API first) and
+ * a missing `navigator` (unit tests, SSR) degrades to non-Mac rather than
+ * throwing. Import `modKey` instead of hardcoding `⌘` / `Ctrl` in shortcut
+ * hints — a hardcoded glyph lies to half the users.
+ */
export const isMac = typeof navigator !== 'undefined' &&
(/mac|iphone|ipad|ipod/i.test(navigator.userAgentData?.platform ?? navigator.platform ?? ''));
diff --git a/client/src/utils/platform.test.js b/client/src/utils/platform.test.js
new file mode 100644
index 0000000000..421e0750a4
--- /dev/null
+++ b/client/src/utils/platform.test.js
@@ -0,0 +1,56 @@
+import { describe, it, expect, afterEach, vi } from 'vitest';
+
+// `isMac`/`modKey` are evaluated once at module load, so every case has to
+// reset the module registry and re-import after stubbing `navigator`.
+async function loadPlatform(navigatorStub) {
+ vi.resetModules();
+ if (navigatorStub === undefined) vi.stubGlobal('navigator', undefined);
+ else vi.stubGlobal('navigator', navigatorStub);
+ return import('./platform.js');
+}
+
+describe('platform', () => {
+ afterEach(() => {
+ vi.unstubAllGlobals();
+ vi.resetModules();
+ });
+
+ it('detects macOS from userAgentData.platform', async () => {
+ const { isMac, modKey } = await loadPlatform({ userAgentData: { platform: 'macOS' }, platform: 'Win32' });
+ expect(isMac).toBe(true);
+ expect(modKey).toBe('⌘');
+ });
+
+ it('prefers userAgentData over the legacy navigator.platform', async () => {
+ const { isMac } = await loadPlatform({ userAgentData: { platform: 'Windows' }, platform: 'MacIntel' });
+ expect(isMac).toBe(false);
+ });
+
+ it('falls back to navigator.platform when userAgentData is absent', async () => {
+ const { isMac, modKey } = await loadPlatform({ platform: 'MacIntel' });
+ expect(isMac).toBe(true);
+ expect(modKey).toBe('⌘');
+ });
+
+ it.each(['iPhone', 'iPad', 'iPod'])('treats %s as a Mac-family platform', async (platform) => {
+ const { isMac } = await loadPlatform({ platform });
+ expect(isMac).toBe(true);
+ });
+
+ it('reports non-Mac platforms with the Ctrl modifier label', async () => {
+ const { isMac, modKey } = await loadPlatform({ platform: 'Linux x86_64' });
+ expect(isMac).toBe(false);
+ expect(modKey).toBe('Ctrl');
+ });
+
+ it('does not throw when navigator is unavailable (SSR / node context)', async () => {
+ const { isMac, modKey } = await loadPlatform(undefined);
+ expect(isMac).toBe(false);
+ expect(modKey).toBe('Ctrl');
+ });
+
+ it('treats a navigator with neither platform field as non-Mac', async () => {
+ const { isMac } = await loadPlatform({});
+ expect(isMac).toBe(false);
+ });
+});