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

address review (claude): scope the focus ring, un-vacuum the clear tests, widen the guards

[._.]/ Adam Eivy432e6367091b
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 80fc096a4a..57a9821514 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -105,7 +105,7 @@
## Fixed
- **"Choose a file" buttons now open the file picker from a remote browser** — the Screenshot and Attach buttons on the task form, Browse Files on the Uploads page, and ~20 other upload buttons across PortOS did nothing when you clicked them from another machine over the tailnet. Each one was a plain button whose click handler reached over and *programmatically* clicked a hidden `<input type="file">` — a synthetic click that several browsers refuse to honor, most notably Safari/WebKit when PortOS is running as an installed (standalone) app rather than a normal tab, which is exactly how it tends to get opened on a second machine or a tablet. Every one of those triggers is now a real `<label>` bound to its file input, so the browser opens the picker itself with no scripting involved. Three related annoyances went with it: every file picker in the app is now reachable by keyboard and screen reader (they were hidden from both, including six that already opened fine); re-picking the *same* file after a failed upload now works everywhere; and the Attach picker no longer greys out every file on iOS/iPadOS, where an extension-only filter isn't understood.
-- **Uploads now state the real size limit instead of failing past ~41MB** — the Uploads page advertised a 100MB maximum and task attachments 50MB, but files are sent base64-encoded inside a JSON body, and the server's 55MB body cap means anything past roughly 41MB was rejected by the body parser before the size check ever ran — so a 60MB file produced an opaque failure rather than a limit message. Every upload path (general uploads, task attachments, SongBook attachments, screenshots) now derives its cap from the body limit itself, so the advertised number is always one the server can actually accept.
+- **Uploads now state the real size limit instead of failing past ~41MB** — the Uploads page advertised a 100MB maximum and task attachments 50MB, but files are sent base64-encoded inside a JSON body, and the server's 55MB body cap means anything past roughly 41MB was rejected by the body parser before the size check ever ran — so a 60MB file produced an opaque failure rather than a limit message. Every base64-in-JSON upload path (general uploads, task attachments, SongBook attachments) now derives its cap from the body limit itself, so the advertised number is always one the server can actually accept. Screenshots keep their own deliberately smaller 10MB cap, now shared between client and server instead of being written twice.
- **Installing or removing an Ollama model now refreshes provider model pickers instantly** — the Ollama provider (and any Claude/Codex/Gemini CLI running against a local Ollama daemon) picks up the change immediately instead of waiting for a manual "Refresh Models" click on the AI Providers page. The scheduled-task model picker also stays in sync automatically, no app restart required.
- **Hugging Face models with a custom quant scheme no longer produce an uninstallable Ollama id** — `quantFromFilename` matched a standard quant anywhere at the end of a GGUF filename, so a repo-specific scheme suffix bled into a bogus tag (`BTL-3-Compact-AVQ2.gguf` → `Q2`) and the resulting `hf.co/<repo>:Q2` pull failed with Ollama's `400 The specified tag is not a valid quantization scheme`. The quant now has to be its own trailing token (start-of-name or after a `-`/`_`/`.`); when nothing parses, the install id falls back to the bare repo, which Ollama resolves through its `latest` manifest.
- **CoS task cards no longer render a wall of prompt text** — a task's `context`, `blockedReason`/`blocker`, and challenge `reason` are now clamped to two lines with a Show more/Show less toggle, matching the description. Orchestrator tasks (e.g. the Creative Director production plan) store their entire prompt in `metadata.context`, so one pending task previously rendered as thousands of pixels of unclamped text the user had to scroll past to reach the rest of the queue; auto-blocked tasks had the same problem with LLM/stderr-derived block reasons, and a challenge reason is free text a worker agent writes to argue its case. The clamp+toggle (measured overflow, so the toggle only appears when the text actually spills) is extracted from `TaskItem` into a shared `client/src/components/ui/CollapsibleText.jsx`. Editing a task's context also moves from a single-line `<input>` to a bounded scrolling `<textarea>`, which was unusable for a multi-thousand-character prompt.
diff --git a/client/src/a11yConventions.test.js b/client/src/a11yConventions.test.js
index d9270b1b90..e261cbc7b0 100644
--- a/client/src/a11yConventions.test.js
+++ b/client/src/a11yConventions.test.js
@@ -38,6 +38,15 @@ function trackedJsxFiles() {
return out.trim().split('\n').filter(f => f.endsWith('.jsx') && !f.includes('.test.'));
}
+// Same, but including plain `.js` — hooks and services hold JSX and refs too
+// (the OpenClaw composer's file-input ref lived in `hooks/useOpenClawAttachments.js`),
+// so a rule that only scans `.jsx` has a hole exactly where a shared helper
+// would reintroduce the pattern for many call sites at once.
+function trackedSourceFiles() {
+ const out = execSync('git ls-files src', { cwd: CLIENT_ROOT, encoding: 'utf8' });
+ return out.trim().split('\n').filter(f => /\.jsx?$/.test(f) && !f.includes('.test.'));
+}
+
/**
* Slice out the full opening tag starting at `index`, tolerating `>` inside
* JSX expression containers (`className={`a > b`}`) by tracking brace depth.
@@ -119,36 +128,46 @@ describe('a11y conventions', () => {
// (sr-only input + a real <label for>); this test is what stops the old
// idiom from creeping back in one component at a time.
const offenders = [];
- for (const file of trackedJsxFiles()) {
+ for (const file of trackedSourceFiles()) {
const src = readFileSync(join(CLIENT_ROOT, file), 'utf8');
const re = /<input\b/g;
let m;
while ((m = re.exec(src))) {
const tag = openingTagAt(src, m.index, '<input'.length);
- if (!tag || !/type="file"/.test(tag)) continue;
- const hidden = /className="[^"]*\bhidden\b[^"]*"/.test(tag);
+ // Match against the whole opening tag, not a quoted-attribute-shaped
+ // regex: `type='file'` / `type={'file'}` and a `hidden` arriving via a
+ // template literal or ternary (`className={cond ? 'hidden' : ''}`) are
+ // the same bug, and a quote-specific pattern waves them through.
+ if (!tag || !/\btype\s*=\s*[{'"]*\s*['"]?file\b/.test(tag)) continue;
+ const hidden = /\bhidden\b/.test(tag) || /display:\s*['"]?none/.test(tag);
const ariaHidden = /aria-hidden/.test(tag);
- const untabbable = /tabIndex=\{-1\}/.test(tag);
+ const untabbable = /tabIndex\s*=\s*\{\s*-1\s*\}/.test(tag);
if (!hidden && !ariaHidden && !untabbable) continue;
offenders.push(`${file}:${lineOf(src, m.index)}`);
}
}
- expect(offenders, `File input hidden from keyboard/AT — use components/ui/FilePickerButton.jsx (sr-only input + native <label for> activation), never className="hidden" / aria-hidden / tabIndex={-1}:\n${offenders.join('\n')}`).toEqual([]);
+ expect(offenders, `File input hidden from keyboard/AT — use components/ui/FilePickerButton.jsx (sr-only input + native <label for> activation), never className="hidden" / aria-hidden / tabIndex={-1} / display:none:\n${offenders.join('\n')}`).toEqual([]);
});
+ // A programmatic ref click is legitimate for a synthesized <a download> — the
+ // rule below is about file inputs, so real non-input uses get an escape hatch
+ // (mirroring MODAL_BACKDROP_ALLOWLIST) rather than a misleading failure.
+ const REF_CLICK_ALLOWLIST = new Set([]);
+
it('never opens a file picker with a programmatic ref click', () => {
// The other half of the same bug: even a correctly-focusable input is
// unopenable in those engines if a button reaches over and clicks it.
const offenders = [];
- for (const file of trackedJsxFiles()) {
+ for (const file of trackedSourceFiles()) {
+ if (REF_CLICK_ALLOWLIST.has(file)) continue;
const src = readFileSync(join(CLIENT_ROOT, file), 'utf8');
- const re = /\.current\??\.click\(\)/g;
+ const re = /\.current\s*\??\.\s*click\(\)/g;
let m;
while ((m = re.exec(src))) {
offenders.push(`${file}:${lineOf(src, m.index)}`);
}
}
- expect(offenders, `Programmatic .click() on a ref — if it targets a file input the picker never opens in WebKit/PWA. Use components/ui/FilePickerButton.jsx:\n${offenders.join('\n')}`).toEqual([]);
+ expect(offenders, `Programmatic .click() on a ref — if it targets a file input the picker never opens in WebKit/PWA; use components/ui/FilePickerButton.jsx. If the ref is genuinely NOT a file input (e.g. a synthesized <a download>), add the file to REF_CLICK_ALLOWLIST above with a comment:\n${offenders.join('\n')}`).toEqual([]);
});
it('gives every role="switch" an aria-checked state', () => {
diff --git a/client/src/components/brain/tabs/ImportTab.jsx b/client/src/components/brain/tabs/ImportTab.jsx
index aac504ed74..e49f776cfc 100644
--- a/client/src/components/brain/tabs/ImportTab.jsx
+++ b/client/src/components/brain/tabs/ImportTab.jsx
@@ -398,7 +398,6 @@ function StepUpload({ uploading, fileMeta, onFile, onBack }) {
onChange={(e) => onFile(e.target.files?.[0])}
onDragOver={(e) => e.preventDefault()}
onDrop={handleDrop}
- ariaLabel="Choose a ChatGPT export file to import"
className="block border-2 border-dashed border-port-border rounded-lg p-8 text-center hover:border-port-accent hover:bg-port-card/40 transition-colors"
>
<FileJson size={32} className="text-gray-500 mx-auto mb-3" aria-hidden="true" />
diff --git a/client/src/components/meatspace/tabs/GenomeTab.jsx b/client/src/components/meatspace/tabs/GenomeTab.jsx
index 7e83431633..922599aa60 100644
--- a/client/src/components/meatspace/tabs/GenomeTab.jsx
+++ b/client/src/components/meatspace/tabs/GenomeTab.jsx
@@ -56,6 +56,7 @@ async function parseZipText(arrayBuffer, ext = '.txt') {
}
import * as api from '../../../services/api';
import { ATTACHMENT_MAX_FILE_SIZE } from '../../../utils/fileUpload';
+import { formatBytes } from '../../../utils/formatters';
import GenomeCategoryCard from '../GenomeCategoryCard';
import EpigeneticTracker from '../EpigeneticTracker';
import ProvenanceChip from '../../ui/ProvenanceChip';
@@ -193,7 +194,7 @@ export default function GenomeTab() {
const handleFileUpload = useCallback(async (file) => {
if (!file) return;
if (file.size > ATTACHMENT_MAX_FILE_SIZE) {
- toast.error('File too large (max 50MB)');
+ toast.error(`File too large (max ${formatBytes(ATTACHMENT_MAX_FILE_SIZE)})`);
return;
}
@@ -370,7 +371,6 @@ export default function GenomeTab() {
onDrop={handleDrop}
onDragOver={handleDragOver}
onDragLeave={handleDragLeave}
- ariaLabel="Upload your 23andMe raw data file"
className="block border-2 border-dashed border-port-border rounded-lg p-12 text-center transition-colors hover:border-gray-500"
>
{uploading ? (
diff --git a/client/src/components/ui/FilePickerButton.jsx b/client/src/components/ui/FilePickerButton.jsx
index c34cac3ed3..4543d2f107 100644
--- a/client/src/components/ui/FilePickerButton.jsx
+++ b/client/src/components/ui/FilePickerButton.jsx
@@ -76,7 +76,14 @@ const FilePickerButton = forwardRef(function FilePickerButton({
};
return (
- <>
+ // `display: contents` wrapper, NOT a fragment: Tailwind compiles `peer-*` to
+ // the GENERAL sibling combinator (`.peer:focus-visible ~ *`), so with a bare
+ // fragment two pickers in one row (see TaskAddForm's Screenshot + Attach)
+ // would light up BOTH labels when either input is focused — the first
+ // input's `~ *` reaches the second label. Scoping each input/label pair to
+ // its own DOM parent cuts that reach, and `contents` generates no box, so
+ // the label is still a direct flex/grid item of the caller's container.
+ <span className="contents">
<input
id={inputId}
name={name}
@@ -96,7 +103,7 @@ const FilePickerButton = forwardRef(function FilePickerButton({
>
{children}
</label>
- </>
+ </span>
);
});
diff --git a/client/src/components/ui/FilePickerButton.test.jsx b/client/src/components/ui/FilePickerButton.test.jsx
index 4fb9b22450..5a7661771e 100644
--- a/client/src/components/ui/FilePickerButton.test.jsx
+++ b/client/src/components/ui/FilePickerButton.test.jsx
@@ -2,11 +2,27 @@ import { describe, it, expect, vi } from 'vitest';
import { render, screen, fireEvent } from '@testing-library/react';
import FilePickerButton from './FilePickerButton';
+/**
+ * Simulate picking files, modelling the DOM coupling the component exists to
+ * work around: setting `value = ''` also EMPTIES `files`. jsdom doesn't
+ * implement that link (and its `value` is `''` from birth), so asserting
+ * `input.value === ''` against a plain jsdom input passes whether or not the
+ * component ever clears it — a vacuous test. Wiring the setter here means the
+ * assertions below fail if the clear is removed or fires too early.
+ */
const pick = (input, files) => {
- Object.defineProperty(input, 'files', { value: files, configurable: true });
+ let current = files;
+ Object.defineProperty(input, 'files', { configurable: true, get: () => current });
+ Object.defineProperty(input, 'value', {
+ configurable: true,
+ get: () => (current.length ? `C:\\fakepath\\${current[0].name}` : ''),
+ set: (v) => { if (v === '') current = []; },
+ });
fireEvent.change(input);
};
+const flush = () => new Promise((resolve) => setTimeout(resolve, 0));
+
const file = (name) => new File(['x'], name, { type: 'image/png' });
describe('FilePickerButton', () => {
@@ -36,13 +52,16 @@ describe('FilePickerButton', () => {
expect(input.multiple).toBe(true);
});
- it('clears the input after a sync handler so the same file can be re-picked', () => {
+ it('clears the input after a sync handler so the same file can be re-picked', async () => {
const onChange = vi.fn();
render(<FilePickerButton onChange={onChange} ariaLabel="Pick">Pick</FilePickerButton>);
const input = screen.getByLabelText('Pick');
pick(input, [file('a.png')]);
expect(onChange).toHaveBeenCalledTimes(1);
+ expect(input.value).not.toBe(''); // not cleared yet — the clear is a microtask
+ await flush();
expect(input.value).toBe('');
+ expect(input.files.length).toBe(0);
});
it('waits for an async handler to settle before clearing the input', async () => {
@@ -54,10 +73,17 @@ describe('FilePickerButton', () => {
render(<FilePickerButton onChange={onChange} multiple ariaLabel="Pick">Pick</FilePickerButton>);
const input = screen.getByLabelText('Pick');
pick(input, [file('a.png'), file('b.png')]);
- // Still readable mid-flight — clearing `value` would empty `files`.
+
+ // Let any premature clear land before the handler settles. A component that
+ // cleared synchronously (or with `.finally()` off a resolved promise) would
+ // have emptied `files` by now and `seen` would come back [0].
+ await flush();
+ expect(input.files.length).toBe(2);
+
release();
- await Promise.resolve();
- expect(seen).toEqual([2]);
+ await flush();
+ expect(seen).toEqual([2]); // the handler read the files it was given
+ expect(input.files.length).toBe(0); // …and only then were they cleared
});
it('clears the input on a rejecting handler without an unhandled rejection', () => {
@@ -70,7 +96,7 @@ describe('FilePickerButton', () => {
render(<FilePickerButton onChange={onChange} ariaLabel="Pick">Pick</FilePickerButton>);
const input = screen.getByLabelText('Pick');
pick(input, [file('a.png')]);
- return new Promise((resolve) => setTimeout(resolve, 0)).then(() => {
+ return flush().then(() => {
process.off('unhandledRejection', unhandled);
expect(unhandled).not.toHaveBeenCalled();
expect(input.value).toBe('');
diff --git a/client/src/utils/fileUpload.js b/client/src/utils/fileUpload.js
index e5930666d9..06fd392528 100644
--- a/client/src/utils/fileUpload.js
+++ b/client/src/utils/fileUpload.js
@@ -55,8 +55,13 @@ export const JSON_UPLOAD_MAX_FILE_SIZE = 41 * 1024 * 1024;
*/
export const IMAGE_ACCEPT = 'image/png,image/jpeg,image/webp';
-// Default max file size: 10MB
-const DEFAULT_MAX_FILE_SIZE = 10 * 1024 * 1024;
+/**
+ * Max screenshot size. Screenshots are pasted/dragged UI captures, so this sits
+ * well below the wire limit by product choice, not by encoding math. Mirror of
+ * `MAX_SCREENSHOT_BYTES` in `server/lib/uploadLimits.js`; `uploadLimits.test.js`
+ * keeps the two in step.
+ */
+export const SCREENSHOT_MAX_FILE_SIZE = 10 * 1024 * 1024;
/**
* Read a File as a base64 string (without the data URL prefix)
@@ -88,7 +93,7 @@ export function readFileAsBase64(file) {
*/
export async function processScreenshotUploads(files, options = {}) {
const {
- maxFileSize = DEFAULT_MAX_FILE_SIZE,
+ maxFileSize = SCREENSHOT_MAX_FILE_SIZE,
onSuccess,
onError
} = options;
diff --git a/server/lib/uploadLimits.test.js b/server/lib/uploadLimits.test.js
index 77a3d2065b..adf9de1787 100644
--- a/server/lib/uploadLimits.test.js
+++ b/server/lib/uploadLimits.test.js
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest';
-import { readFileSync } from 'node:fs';
+import { readFileSync, readdirSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
import {
@@ -58,13 +58,41 @@ describe('uploadLimits', () => {
it('is the only place per-route upload caps are written', () => {
// A route that re-derives its own byte cap is how uploads.js and
- // attachments.js drifted to unreachable 100MB/50MB claims.
- for (const route of ['uploads.js', 'attachments.js', 'brainSongbook.js', 'screenshots.js']) {
- const src = read(`../routes/${route}`);
- expect(src, `${route} should import its cap from lib/uploadLimits.js`)
- .toContain("from '../lib/uploadLimits.js'");
- expect(src, `${route} re-derives a raw byte cap instead of importing one`)
- .not.toMatch(/const MAX_(FILE_SIZE|ATTACHMENT_SIZE)\s*=\s*\d+\s*\*/);
+ // attachments.js drifted to unreachable 100MB/50MB claims. Discover the
+ // routes rather than listing them, so a NEW upload route added later is
+ // covered too — a hardcoded list would leave it unguarded.
+ // Detect the base64-in-JSON transport specifically — decoding a base64 body
+ // or handing one to saveBase64Upload. Routes that take RAW bytes via
+ // express.raw() (imageClean.js) carry their own limit and are correctly out
+ // of scope: no ×4/3 inflation applies to them.
+ const routesDir = join(HERE, '../routes');
+ const uploadRoutes = readdirSync(routesDir)
+ .filter((f) => f.endsWith('.js') && !f.endsWith('.test.js'))
+ .filter((f) => /Buffer\.from\([^)]*'base64'\)|saveBase64Upload/
+ .test(readFileSync(join(routesDir, f), 'utf8')));
+ expect(uploadRoutes.length, 'no upload routes discovered — did the detection heuristic break?')
+ .toBeGreaterThanOrEqual(4);
+
+ for (const route of uploadRoutes) {
+ const src = readFileSync(join(routesDir, route), 'utf8');
+ // Assert the route USES a shared constant (positive), rather than
+ // pattern-matching for the absence of one literal spelling — a route
+ // could hardcode `= 52428800` under any name and slip past that.
+ expect(src, `${route} must take its cap from lib/uploadLimits.js`)
+ .toMatch(/MAX_BASE64_UPLOAD_BYTES|MAX_SCREENSHOT_BYTES/);
+ // Belt-and-braces: no raw MB-shaped byte literal left in an upload route.
+ expect(src, `${route} still hardcodes a raw byte cap`)
+ .not.toMatch(/=\s*\d+\s*\*\s*1024\s*\*\s*1024/);
}
});
+
+ it('matches the client mirror of the screenshot cap', () => {
+ // Screenshots have their own (smaller, product-chosen) cap. It is mirrored
+ // client-side too, so it needs the same drift guard as the wire limit —
+ // otherwise raising one side silently leaves the other rejecting.
+ const clientSrc = read('../../client/src/utils/fileUpload.js');
+ const match = clientSrc.match(/SCREENSHOT_MAX_FILE_SIZE = (\d+) \* 1024 \* 1024/);
+ expect(match, 'client screenshot mirror not found — did SCREENSHOT_MAX_FILE_SIZE move?').toBeTruthy();
+ expect(Number(match[1]) * 1024 * 1024).toBe(MAX_SCREENSHOT_BYTES);
+ });
});