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

fix: name and mark the Digital Twin scale buttons for screen readers (#3920)

[._.]/ Adam Eivyc6e1c04a7161
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index c8e451037e..60b72ac167 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -68,6 +68,7 @@
- `docs/SELF_UPDATE.md` now documents that `update.sh` / `update.ps1` check out `main` before pulling, stashing a dirty working tree first so the checkout can proceed. The doc described only the `git pull --rebase --autostash`, so anyone running an in-app or CLI update from a feature branch or a detached HEAD was surprised to find their checkout moved to `main` with their work parked in `git stash` — the scripts print the restore commands on completion, but nothing said so up front.
- The Vite dev server example in `docs/PM2.md` no longer tells you to point PM2 at `node_modules/.bin/vite`. PM2 resolves a relative `script` against its own working directory rather than the app's `cwd`, and the `.bin` entry itself varies by platform and package manager (symlink, `.cmd`/`.ps1` wrapper, generated shell script), none of which the Node interpreter launches uniformly — so a config copy-pasted from the doc crashed on startup. Both the standalone snippet and the complete monorepo example now use the absolute `path.join(__dirname, 'client', 'node_modules', 'vite', 'bin', 'vite.js')` form that PortOS's own `portos-ui` app has always used, with a note explaining why.
- A failed URL import in the SongBook importer no longer leaves the form looking untouched. The error had only a transient toast behind it, so once it faded the URL still sat in the input with no preview, no explanation, and a Save button that answered with the unrelated "Nothing to save — paste or fetch a tab first". The From URL tab now keeps an inline alert under the input naming the failure with a Retry button next to it, clears that alert as soon as the URL is edited, and drops any previously fetched draft (and the title/artist it auto-filled) so a failed fetch can't leave the earlier song previewed under a URL that never loaded. The disabled Save button now says why it's disabled instead of waiting for the click. A result that lands after the URL has been edited (or after the user has left the tab) is discarded rather than written under whatever is on screen now.
+- The Digital Twin rating scale is now legible to a screen reader. Its 1–5 buttons carried only a bare number as their accessible name and nothing marking the current selection, so navigating by rotor or keyboard announced "1, 2, 3, 4, 5" with no indication of which end meant Strongly Disagree or which option was already chosen. Each button now names itself as "1 - Strongly Disagree" and reports `aria-pressed`, the row is a labelled group carrying the question text so the rating is announced in context, and a caller-supplied `labels` array shorter than five positions falls back to the default wording per position instead of announcing "undefined".
- The Digital Twin confidence gauge is now announced to screen readers. The circular SVG ring and the per-dimension bars beneath it were plain `<div>`s with a decorative SVG inside, so assistive tech either skipped them or read the loose "72%" text node with nothing to say what it measured. The overall gauge now carries `role="meter"` with `aria-label="Digital Twin overall confidence"`, the min/max/now values, and an `aria-valuetext` pairing the percentage with its Strong/Moderate/Needs Work band; each dimension bar carries the same meter semantics under its own dimension label, and the ring SVG is marked `aria-hidden` so its geometry isn't read twice.
- Pushing a series or music video project to a peer running an older PortOS no longer fires the same rejected request every sync cycle forever. When the older peer's strict schema rejects a newer bundled key (`manuscriptReview`, `reverseOutline`, `linkedTrack`), the sender strips it and retries — and deliberately withholds `lastPushedHash` so the stripped doc is re-sent once that peer upgrades. With nothing else recorded, the next cycle had no way to tell a settled record from a new edit, so every 60-second tick re-ran the same 400-plus-retry pair for content that had not moved. A second water-mark (`lastPushedLegacyHash`) now records what was actually delivered in stripped form, so an unchanged record short-circuits; any real edit still moves the hash and re-attempts the full push, and the `peer:online` re-probe still pushes unconditionally, which is where the stripped key finally lands after an upgrade. A pending doc the *receiver* reported (its bundled merge threw) is left un-water-marked, since that one is transient and must genuinely retry.
- A failed first read on the Quota Burn page no longer strands you on a dead end. `load()` swallowed the error and left `config` null, and the unavailable branch returns before the header — so the only control that could re-read, "Refresh quota", was never rendered, and the one line on screen named neither the cause nor a way out short of reloading the browser tab. The read's failure is now kept in its own state (`null` = never failed, distinct from "the server answered and has no plan"), and the unavailable branch renders an error banner carrying that message with a Retry button that re-reads and clears it on success.
diff --git a/client/src/components/digital-twin/NextActionBanner.jsx b/client/src/components/digital-twin/NextActionBanner.jsx
index 5858a65440..bfac498007 100644
--- a/client/src/components/digital-twin/NextActionBanner.jsx
+++ b/client/src/components/digital-twin/NextActionBanner.jsx
@@ -336,6 +336,7 @@ export default function NextActionBanner({ gaps, status, traits, onRefresh }) {
{question.questionType === 'scale' ? (
<div className="mb-2">
<ScaleInput
+ groupLabel={question.question}
labels={question.labels}
value={scaleValue}
onChange={setScaleValue}
diff --git a/client/src/components/digital-twin/ScaleInput.jsx b/client/src/components/digital-twin/ScaleInput.jsx
index 1eba7ca622..ab3c4b99b1 100644
--- a/client/src/components/digital-twin/ScaleInput.jsx
+++ b/client/src/components/digital-twin/ScaleInput.jsx
@@ -1,17 +1,23 @@
-export default function ScaleInput({ labels, value, onChange, disabled }) {
- const defaultLabels = ['Strongly Disagree', 'Disagree', 'Neutral', 'Agree', 'Strongly Agree'];
- const shortLabels = ['SD', 'D', 'N', 'A', 'SA'];
- const displayLabels = labels || defaultLabels;
+const DEFAULT_LABELS = ['Strongly Disagree', 'Disagree', 'Neutral', 'Agree', 'Strongly Agree'];
+const SHORT_LABELS = ['SD', 'D', 'N', 'A', 'SA'];
+const VALUES = [1, 2, 3, 4, 5];
+
+export default function ScaleInput({ labels, value, onChange, disabled, groupLabel }) {
+ // A caller-supplied `labels` array may be short or sparse — fall back per position
+ // so the accessible name never announces "undefined".
+ const labelFor = (val) => labels?.[val - 1] || DEFAULT_LABELS[val - 1];
return (
- <div className="flex gap-2 justify-center">
- {[1, 2, 3, 4, 5].map((val) => {
+ <div className="flex gap-2 justify-center" role="group" aria-label={groupLabel || 'Rating scale'}>
+ {VALUES.map((val) => {
const selected = value === val;
return (
<button
key={val}
type="button"
disabled={disabled}
+ aria-pressed={selected}
+ aria-label={`${val} - ${labelFor(val)}`}
onClick={() => onChange(val)}
className={`flex-1 min-w-[48px] min-h-[48px] flex flex-col items-center justify-center rounded-lg border transition-all ${
selected
@@ -20,8 +26,8 @@ export default function ScaleInput({ labels, value, onChange, disabled }) {
} ${disabled ? 'opacity-50 cursor-not-allowed' : 'cursor-pointer'}`}
>
<span className="text-lg font-bold">{val}</span>
- <span className="text-[10px] leading-tight mt-0.5 hidden sm:block">{displayLabels[val - 1]}</span>
- <span className="text-[10px] leading-tight mt-0.5 sm:hidden">{shortLabels[val - 1]}</span>
+ <span className="text-[10px] leading-tight mt-0.5 hidden sm:block">{labelFor(val)}</span>
+ <span className="text-[10px] leading-tight mt-0.5 sm:hidden">{SHORT_LABELS[val - 1]}</span>
</button>
);
})}
diff --git a/client/src/components/digital-twin/ScaleInput.test.jsx b/client/src/components/digital-twin/ScaleInput.test.jsx
new file mode 100644
index 0000000000..02bd58b93a
--- /dev/null
+++ b/client/src/components/digital-twin/ScaleInput.test.jsx
@@ -0,0 +1,69 @@
+import { describe, it, expect, vi } from 'vitest';
+import { render, screen, fireEvent } from '@testing-library/react';
+
+import ScaleInput from './ScaleInput';
+
+describe('ScaleInput accessibility', () => {
+ it('names every button with its value and descriptive label', () => {
+ render(<ScaleInput value={null} onChange={() => {}} />);
+ expect(screen.getByRole('button', { name: '1 - Strongly Disagree' })).toBeTruthy();
+ expect(screen.getByRole('button', { name: '3 - Neutral' })).toBeTruthy();
+ expect(screen.getByRole('button', { name: '5 - Strongly Agree' })).toBeTruthy();
+ });
+
+ it('uses caller-supplied labels in the accessible name', () => {
+ render(<ScaleInput labels={['Never', 'Rarely', 'Sometimes', 'Often', 'Always']} value={2} onChange={() => {}} />);
+ expect(screen.getByRole('button', { name: '2 - Rarely' })).toBeTruthy();
+ });
+
+ it('falls back to the default label when a supplied label is missing', () => {
+ render(<ScaleInput labels={['Never']} value={null} onChange={() => {}} />);
+ // A short labels array must not announce "undefined".
+ expect(screen.getByRole('button', { name: '1 - Never' })).toBeTruthy();
+ expect(screen.getByRole('button', { name: '4 - Agree' })).toBeTruthy();
+ });
+
+ it('marks only the selected rating as pressed', () => {
+ render(<ScaleInput value={4} onChange={() => {}} />);
+ const pressed = screen.getAllByRole('button').filter((b) => b.getAttribute('aria-pressed') === 'true');
+ expect(pressed).toHaveLength(1);
+ expect(pressed[0].getAttribute('aria-label')).toBe('4 - Agree');
+ });
+
+ it('marks nothing pressed before a selection is made', () => {
+ render(<ScaleInput value={null} onChange={() => {}} />);
+ for (const b of screen.getAllByRole('button')) expect(b.getAttribute('aria-pressed')).toBe('false');
+ });
+
+ it('groups the buttons under the question text', () => {
+ render(<ScaleInput groupLabel="I enjoy long walks" value={null} onChange={() => {}} />);
+ expect(screen.getByRole('group', { name: 'I enjoy long walks' })).toBeTruthy();
+ });
+
+ it('falls back to a generic group label', () => {
+ render(<ScaleInput value={null} onChange={() => {}} />);
+ expect(screen.getByRole('group', { name: 'Rating scale' })).toBeTruthy();
+ });
+
+ it('reports the chosen value on click and on keyboard activation', () => {
+ const onChange = vi.fn();
+ render(<ScaleInput value={null} onChange={onChange} />);
+ const btn = screen.getByRole('button', { name: '5 - Strongly Agree' });
+ fireEvent.click(btn);
+ expect(onChange).toHaveBeenCalledWith(5);
+ // Native <button> maps Enter/Space to a click, so focus + keyboard activation
+ // reaches the same handler.
+ btn.focus();
+ expect(document.activeElement).toBe(btn);
+ fireEvent.keyDown(btn, { key: 'Enter' });
+ fireEvent.click(btn);
+ expect(onChange).toHaveBeenCalledTimes(2);
+ });
+
+ it('does not fire onChange while disabled', () => {
+ const onChange = vi.fn();
+ render(<ScaleInput value={null} onChange={onChange} disabled />);
+ fireEvent.click(screen.getByRole('button', { name: '1 - Strongly Disagree' }));
+ expect(onChange).not.toHaveBeenCalled();
+ });
+});
diff --git a/client/src/components/digital-twin/tabs/EnrichTab.jsx b/client/src/components/digital-twin/tabs/EnrichTab.jsx
index d69ac1e09e..0c2c98aae6 100644
--- a/client/src/components/digital-twin/tabs/EnrichTab.jsx
+++ b/client/src/components/digital-twin/tabs/EnrichTab.jsx
@@ -363,6 +363,7 @@ export default function EnrichTab({ onRefresh }) {
<div className="mb-6">
{currentQuestion.questionType === 'scale' ? (
<ScaleInput
+ groupLabel={currentQuestion.question}
labels={currentQuestion.labels}
value={scaleValue}
onChange={setScaleValue}