diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml
index 071e1aa..be44ef6 100644
--- a/.github/workflows/web.yml
+++ b/.github/workflows/web.yml
@@ -32,6 +32,7 @@ jobs:
# Safari on iPhone runs WebKit; the Chrome acceptance above does not see its layout.
# Uses the build from test:browser.
- run: npx playwright install --with-deps webkit
+ - run: node scripts/quality.acceptance.mjs
- run: node scripts/webkit-layout.mjs
# The reference views (web/DESIGN.md, "Rebuild") for review on every PR.
- uses: actions/upload-artifact@v7.0.2
@@ -89,3 +90,6 @@ jobs:
env:
BASE_URL: https://proofofwork.fyi
EXPECT_POSTHOG: '1'
+ - run: node scripts/quality.acceptance.mjs
+ env:
+ BASE_URL: https://proofofwork.fyi
diff --git a/web/DESIGN.md b/web/DESIGN.md
index 41c3f4f..b1d39dc 100644
--- a/web/DESIGN.md
+++ b/web/DESIGN.md
@@ -377,6 +377,9 @@ decision, 2026-10-27):
"Mining" between races, "Re-mine block #K" during a repair. Nothing else: not "Start demo",
not during a race or a repeating run, not while typing, with Cmd/Ctrl/Alt, on key repeat or
under an open dialog.
+ Settings lets the learner disable this single-letter shortcut, including its
+ announcement, for speech input or assistive technology. The choice stays in this
+ browser; the mining button remains available.
- **Miner details** (Mirko, 2026-11-03, replaces the miner editor): a click on a miner's name
opens a **popover** under its lane, between races and during one: its **share** of the racing
miners' hashpower as a slider from 5 to 90 %, which is its chance to find the next block; the
@@ -597,6 +600,16 @@ Rules for every workbench component (`src/components/workbench/`):
## Guards
+- Labs and the leaderboard view load on demand; the workbench starts without their
+ code or styles. `check:bundle` follows the build manifest's static imports and caps
+ initial gzip transfer at 255 KiB JavaScript and 25 KiB CSS.
+- `test:quality` checks WCAG A/AA axe rules in both themes at 360 px and desktop,
+ plus the skip link, dialog focus return and shortcut preference. The skip link
+ focuses the current view without changing experiments. Explaining bubbles remain
+ hoverable; Escape dismisses chain explanations while preserving keyboard position.
+- Accent labels use dark ink on the brighter dark-theme blue; muted text remains
+ readable on all panel surfaces. The light theme uses white labels on darker blue.
+
- `src/__tests__/designTokens.test.js` fails on any color literal (hex,
`rgb()`, `hsl()`) outside `src/styles/tokens.css`.
- The browser acceptance (`npm run test:browser`) writes the reference views
diff --git a/web/package-lock.json b/web/package-lock.json
index 35aec50..2f4ca30 100644
--- a/web/package-lock.json
+++ b/web/package-lock.json
@@ -22,6 +22,7 @@
"@types/react": "^19.2.5",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^5.1.1",
+ "axe-core": "4.14.0",
"eslint": "^9.39.1",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.4.24",
@@ -2942,6 +2943,16 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/axe-core": {
+ "version": "4.14.0",
+ "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.14.0.tgz",
+ "integrity": "sha512-9WTZxEjsZ7b13TH8JPmbV2z8CHbl80/2hm3XPEG4JgNdQLK81IBRXmSxHfMAOkSqQeRxT/0dwNDz2GOm3zzpcQ==",
+ "dev": true,
+ "license": "MPL-2.0",
+ "engines": {
+ "node": ">=4"
+ }
+ },
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
diff --git a/web/package.json b/web/package.json
index 3d5ca2f..f096c04 100644
--- a/web/package.json
+++ b/web/package.json
@@ -9,7 +9,9 @@
"lint": "eslint .",
"preview": "vite preview",
"test": "vitest run",
- "check": "npm run lint && npm test && npm run build",
+ "check": "npm run lint && npm test && npm run build && npm run check:bundle",
+ "check:bundle": "node scripts/check-bundle.mjs",
+ "test:quality": "npm run build && node scripts/quality.acceptance.mjs",
"deploy:check": "npm run build && wrangler deploy --env production --dry-run",
"deploy": "npm run build && wrangler deploy --env \"\"",
"deploy:production": "npm run build && wrangler deploy --env production",
@@ -31,6 +33,7 @@
"@types/react": "^19.2.5",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^5.1.1",
+ "axe-core": "4.14.0",
"eslint": "^9.39.1",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.4.24",
diff --git a/web/scripts/check-bundle.mjs b/web/scripts/check-bundle.mjs
new file mode 100644
index 0000000..402addc
--- /dev/null
+++ b/web/scripts/check-bundle.mjs
@@ -0,0 +1,32 @@
+import assert from 'node:assert/strict';
+import { readFile } from 'node:fs/promises';
+import { gzipSync } from 'node:zlib';
+import { resolve } from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const dist = resolve(process.argv[2] || fileURLToPath(new URL('../dist', import.meta.url)));
+const manifest = JSON.parse(await readFile(`${dist}/.vite/manifest.json`, 'utf8'));
+const entries = Object.keys(manifest).filter(key => manifest[key].isEntry);
+assert.ok(entries.length, 'Build manifest has no entry');
+const files = new Set();
+const visited = new Set();
+function collect(key) {
+ if (visited.has(key)) return;
+ visited.add(key);
+ const chunk = manifest[key];
+ assert.ok(chunk, `Missing static dependency ${key}`);
+ files.add(chunk.file);
+ for (const css of chunk.css || []) files.add(css);
+ for (const dependency of chunk.imports || []) collect(dependency);
+}
+entries.forEach(collect);
+const sizes = { js: 0, css: 0 };
+for (const file of files) {
+ const kind = file.endsWith('.js') ? 'js' : file.endsWith('.css') ? 'css' : null;
+ if (kind) sizes[kind] += gzipSync(await readFile(resolve(dist, file))).length;
+}
+// e009022 eagerly shipped 265,995 bytes JS and 26,504 bytes CSS (gzip).
+// Keep room above the split build while preventing a return to that payload.
+assert.ok(sizes.js <= 255 * 1024, `Initial JavaScript ${sizes.js} exceeds 255 KiB gzip`);
+assert.ok(sizes.css <= 25 * 1024, `Initial CSS ${sizes.css} exceeds 25 KiB gzip`);
+console.log(JSON.stringify({ initialGzipBytes: sizes, files: [...files] }));
diff --git a/web/scripts/quality.acceptance.mjs b/web/scripts/quality.acceptance.mjs
new file mode 100644
index 0000000..79cd2b9
--- /dev/null
+++ b/web/scripts/quality.acceptance.mjs
@@ -0,0 +1,96 @@
+import assert from 'node:assert/strict';
+import { chromium } from 'playwright';
+import { createRequire } from 'node:module';
+import { spawn } from 'node:child_process';
+import { stripVTControlCharacters } from 'node:util';
+import { fileURLToPath } from 'node:url';
+
+const require = createRequire(import.meta.url);
+const base = process.env.BASE_URL || 'http://127.0.0.1:4187';
+const root = fileURLToPath(new URL('..', import.meta.url));
+let server, browser;
+try {
+ if (!process.env.BASE_URL) {
+ server = spawn(process.execPath, [fileURLToPath(new URL('../node_modules/vite/bin/vite.js', import.meta.url)), 'preview', '--host', '127.0.0.1', '--port', '4187', '--strictPort'], { cwd: root, stdio: ['ignore', 'pipe', 'pipe'] });
+ let log = '';
+ server.stdout.on('data', data => { log += data; });
+ server.stderr.on('data', data => { log += data; });
+ let ready = false;
+ for (let i = 0; i < 100; i++) {
+ if (server.exitCode !== null) throw new Error(`Preview exited: ${log}`);
+ try { if (stripVTControlCharacters(log).includes(base) && (await fetch(base)).ok) { ready = true; break; } } catch { /* Startup only. */ }
+ await new Promise(resolve => setTimeout(resolve, 100));
+ }
+ assert.ok(ready, `Preview did not start: ${log}`);
+ }
+ browser = await chromium.launch({ channel: 'chrome', headless: true });
+ for (const width of [360, 1512]) {
+ const context = await browser.newContext({ viewport: { width, height: 860 }, reducedMotion: 'reduce' });
+ await context.route(/^https:\/\/(eu\.i\.posthog\.com|api\.proofofwork\.fyi)\//, route => route.abort('connectionrefused'));
+ const page = await context.newPage();
+ const errors = [];
+ page.on('pageerror', error => errors.push(error.message));
+ const audit = async label => {
+ await page.addScriptTag({ path: require.resolve('axe-core/axe.min.js') });
+ const violations = await page.evaluate(async () => (await globalThis.axe.run(document, {
+ runOnly: { type: 'tag', values: ['wcag2a', 'wcag2aa', 'wcag21aa', 'wcag22aa'] }
+ })).violations.map(v => ({ id: v.id, targets: v.nodes.map(node => node.target) })));
+ assert.deepEqual(violations, [], `${label} ${width}px`);
+ assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), `${label}: horizontal overflow`);
+ };
+ for (const route of ['', '#/hash-lab', '#/chain-lab']) {
+ await page.goto(`${base}/${route}`);
+ await page.getByRole('main').waitFor();
+ if (route) await page.getByRole('button', { name: 'Back to simulator', exact: true }).waitFor();
+ const view = await page.getByRole('main').getAttribute('aria-label');
+ await page.getByRole('link', { name: 'Skip to content', exact: true }).focus();
+ await page.keyboard.press('Enter');
+ assert.equal(await page.evaluate(() => document.activeElement.id), 'workbench');
+ assert.equal(await page.getByRole('main').getAttribute('aria-label'), view);
+ for (const theme of ['dark', 'light']) {
+ await page.evaluate(theme => document.documentElement.setAttribute('data-theme', theme), theme);
+ await audit(`${route || 'workbench'} ${theme}`);
+ }
+ if (!route) {
+ const newTransaction = page.getByRole('button', { name: 'New transaction', exact: true });
+ await newTransaction.click();
+ await page.getByRole('button', { name: 'Cancel', exact: true }).focus();
+ await page.keyboard.press('Enter');
+ assert.equal(await newTransaction.evaluate(element => element === document.activeElement), true);
+ const miner = page.getByRole('button', { name: 'Hal: hashpower, attempts and name', exact: true });
+ await miner.click();
+ await page.getByRole('group', { name: 'Miner Hal', exact: true }).getByRole('button', { name: 'Done', exact: true }).click();
+ assert.equal(await miner.evaluate(element => element === document.activeElement), true);
+ if (width >= 1024) {
+ const face = page.locator('.chain-band-tile-face').first();
+ await page.keyboard.press('Tab');
+ await face.focus();
+ const explanation = page.getByRole('group', { name: 'Full hash of block 0', exact: true });
+ assert.equal(await explanation.isVisible(), true);
+ await page.keyboard.press('Escape');
+ assert.equal(await explanation.isVisible(), false);
+ assert.equal(await face.evaluate(element => element === document.activeElement), true);
+ }
+ }
+ }
+ await page.goto(`${base}/`);
+ await page.getByRole('button', { name: width < 768 ? 'Menu' : 'More', exact: true }).click();
+ await page.getByRole('button', { name: 'Reset', exact: true }).hover();
+ await page.getByRole('tooltip').waitFor();
+ await page.getByRole('button', { name: 'Settings', exact: true }).click();
+ await page.getByRole('dialog', { name: 'Settings', exact: true }).waitFor();
+ for (const theme of ['dark', 'light']) {
+ await page.evaluate(theme => document.documentElement.setAttribute('data-theme', theme), theme);
+ await audit(`Settings ${theme}`);
+ }
+ const shortcut = page.getByRole('checkbox', { name: 'Enable M to mine or re-mine a block', exact: true });
+ await shortcut.uncheck();
+ await page.keyboard.press('Escape');
+ assert.equal(await page.evaluate(() => document.activeElement.getAttribute('aria-label')), width < 768 ? 'Menu' : 'More');
+ await page.reload();
+ assert.equal(await page.evaluate(() => localStorage.getItem('proofofwork-mining-shortcut')), '0');
+ assert.deepEqual(errors, []);
+ await context.close();
+ }
+ console.log('Quality: WCAG A/AA axe checks in both themes, 360px/desktop, skip link, dialog focus return and shortcut preference passed');
+} finally { await browser?.close(); server?.kill(); }
diff --git a/web/src/App.jsx b/web/src/App.jsx
index 9e3607b..c0c76fc 100644
--- a/web/src/App.jsx
+++ b/web/src/App.jsx
@@ -1,4 +1,4 @@
-import { useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react';
+import { lazy, Suspense, useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react';
import { useBlockchain } from './hooks/useBlockchain';
import { useMinerIdentity } from './hooks/useMinerIdentity';
import { playMiningSuccessSound, playRecordSound, unlockMiningAudio } from './lib/sound';
@@ -15,9 +15,6 @@ import { LowerDifficultyDialog } from './components/workbench/LowerDifficultyDia
import { Workbench } from './components/workbench/Workbench';
import { MissionRail } from './components/workbench/MissionRail';
import { MissionIntro } from './components/workbench/MissionIntro';
-import { HashLab } from './components/HashLab';
-import { ChainLab } from './components/ChainLab';
-import { PoolPanel } from './components/PoolPanel';
import { minerProfileHash, POOL_HASH } from './lib/poolApi';
import { BlockDetailsModal } from './components/BlockDetailsModal';
import { ParticipantDetailsModal } from './components/ParticipantDetailsModal';
@@ -29,6 +26,11 @@ import './index.css';
import { adjustedDifficulty, averagePace, checkWindowStart, isCheckHeight } from './lib/difficulty';
import { DEFAULT_FEE_RATE } from './lib/blockchain';
+// Free play starts on the workbench; other experiments load when opened.
+const HashLab = lazy(() => import('./components/HashLab').then(module => ({ default: module.HashLab })));
+const ChainLab = lazy(() => import('./components/ChainLab').then(module => ({ default: module.ChainLab })));
+const PoolPanel = lazy(() => import('./components/PoolPanel').then(module => ({ default: module.PoolPanel })));
+
const INITIAL_CONFIG = {
name: 'powfyicoin', miningDifficulty: 4, blockReward: 3.125, halvingEvent: 21,
participants: ['Alice', 'Bob', 'Chris', 'Hal', 'Dorian', 'Laszlo'], miners: ['Hal', 'Dorian', 'Laszlo']
@@ -447,7 +449,7 @@ function App() {
return (
-
Skip to workbench
+
{ event.preventDefault(); document.getElementById('workbench')?.focus(); }}>Skip to content
setShowSettings(true)} compact={compact} saveState={sim.saveState} />
@@ -457,7 +459,7 @@ function App() {
-
+
{showIntro && }
@@ -471,6 +473,7 @@ function App() {
onDifficulty={onDifficulty} onBack={onBack} onCreateTransaction={onCreateTransaction} onCreateWallet={createWallet} onCreateMiner={createMiner}
onRenameMiner={onRenameMiner} onShare={setMinerShare} onOpenMiner={openMiner} onSlowMotion={setSlowMotion}
onOpenWallet={setWalletDetails} onOpenDetails={setDetails} onOpenTransaction={setPendingTx} onOpenBlockTx={(transaction, blockIndex) => setBlockTx({ transaction, blockIndex })} onOpenChainLab={() => navigate('chain-lab')} error={error} />}
+ Loading {VIEW_LABELS[view]}…}>
{view === 'hash-lab' &&
navigate('workbench')}
@@ -483,6 +486,7 @@ function App() {
{view === 'pool' && navigate('workbench')}
profile={profile} onOpenProfile={openProfile} onCloseProfile={closeProfile} /> }
+
{winner && {winner.name} mined a block
}
diff --git a/web/src/__tests__/AppMissions.test.jsx b/web/src/__tests__/AppMissions.test.jsx
index 04166ac..e9eb361 100644
--- a/web/src/__tests__/AppMissions.test.jsx
+++ b/web/src/__tests__/AppMissions.test.jsx
@@ -55,12 +55,12 @@ describe('optional missions in App', () => {
expect(collapsed()).toBe(true);
});
- it('remembers dismissal, while the page and free labs stay usable', () => {
+ it('remembers dismissal, while the page and free labs stay usable', async () => {
render( );
fireEvent.click(screen.getByRole('button', { name: "Don't show again" }));
expect(intro()).toBeNull();
fireEvent.click(screen.getByRole('button', { name: 'Hash lab', exact: true }));
- expect(screen.getByText('Free hash lab')).toBeTruthy();
+ expect(await screen.findByText('Free hash lab')).toBeTruthy();
expect(screen.getByText('No coach')).toBeTruthy();
fireEvent.click(screen.getByRole('button', { name: 'Complete manual proof' }));
expect(JSON.parse(localStorage.getItem(STORAGE_KEY)).completed).toEqual([]);
diff --git a/web/src/__tests__/ChainBand.test.jsx b/web/src/__tests__/ChainBand.test.jsx
index 5aa0527..f41b9ee 100644
--- a/web/src/__tests__/ChainBand.test.jsx
+++ b/web/src/__tests__/ChainBand.test.jsx
@@ -256,13 +256,26 @@ describe('ChainBand health line', () => {
});
describe('ChainBand full-hash tooltip', () => {
+ it('dismisses a full-hash group and a link explanation with Escape without losing position', () => {
+ renderBand();
+ const face = tile(2);
+ act(() => face.focus());
+ fireEvent.keyDown(face, { key: 'Escape' });
+ expect(face.closest('.chain-band-tile').classList.contains('is-tip-dismissed')).toBe(true);
+ expect(document.activeElement).toBe(face);
+ const link = document.querySelector('.chain-band-link');
+ act(() => link.focus());
+ fireEvent.keyDown(link, { key: 'Escape' });
+ expect(link.classList.contains('is-tip-dismissed')).toBe(true);
+ expect(link.getAttribute('role')).toBe('group');
+ });
it('copies the full hash without selecting the block', async () => {
const writeText = vi.fn(() => Promise.resolve());
vi.stubGlobal('navigator', { ...navigator, clipboard: { writeText } });
const { onSelect } = renderBand();
const copy = screen.getByRole('button', { name: 'Copy full hash of block 2' });
- expect(copy.closest('[role="tooltip"]').textContent).toContain('Starts with 00 · prev = hash of #1');
- expect(tile(2).getAttribute('aria-describedby')).toBe(copy.closest('[role="tooltip"]').id);
+ expect(copy.closest('[role="group"]').textContent).toContain('Starts with 00 · prev = hash of #1');
+ expect(tile(2).getAttribute('aria-describedby')).toBe(copy.closest('[role="group"]').id);
await act(async () => { fireEvent.click(copy); });
expect(writeText).toHaveBeenCalledWith(hashOf(2));
expect(copy.textContent).toBe('Copied');
@@ -274,7 +287,7 @@ describe('ChainBand full-hash tooltip', () => {
vi.stubGlobal('navigator', { ...navigator, clipboard: { writeText } });
renderBand({ views: makeViews(5, TAMPERED) });
const copy = screen.getByRole('button', { name: 'Copy full hash of block 2' });
- const tip = copy.closest('[role="tooltip"]');
+ const tip = copy.closest('[role="group"]');
expect(tip.textContent).toContain('Now');
expect(tip.textContent).toContain('As mined');
expect(tip.textContent).toContain('Your edit: tx 1: 1.5 → 2');
@@ -318,13 +331,23 @@ describe('ChainBand scrolling row', () => {
expect(items).toHaveLength(13);
expect(items.slice(0, 12).map(item => item.querySelector('.chain-band-tile > .chain-band-num').textContent))
.toEqual(Array.from({ length: 12 }, (_, i) => `#${i}`));
- expect(items.at(-1).querySelector('[role="group"]').getAttribute('aria-label')).toMatch(/^Candidate block 12/);
+ expect(items.at(-1).querySelector('.chain-band-cand[role="group"]').getAttribute('aria-label')).toMatch(/^Candidate block 12/);
expect(items.every(item => ![...item.classList].some(cls => cls.startsWith('is-hidden')))).toBe(true);
expect(container.querySelector('.chain-band').className).not.toMatch(/has-earlier/);
expect(container.querySelectorAll('.chain-band-scroll')).toHaveLength(1);
});
describe('following the newest block', () => {
+ it('scrolls instantly when reduced motion is requested', () => {
+ const original = globalThis.matchMedia;
+ globalThis.matchMedia = () => ({ matches: true, addEventListener() {}, removeEventListener() {} });
+ try {
+ const { rerender } = render( );
+ scrollTo.mockClear();
+ rerender( );
+ expect(scrollTo).toHaveBeenCalledWith({ left: expect.any(Number), behavior: 'auto' });
+ } finally { globalThis.matchMedia = original; }
+ });
let scrollTo;
beforeEach(() => {
scrollTo = vi.fn();
diff --git a/web/src/__tests__/HashLabComparison.test.jsx b/web/src/__tests__/HashLabComparison.test.jsx
index 58bb3e2..6833897 100644
--- a/web/src/__tests__/HashLabComparison.test.jsx
+++ b/web/src/__tests__/HashLabComparison.test.jsx
@@ -73,6 +73,7 @@ describe('measured work-lesson comparison', () => {
localStorage.setItem('proofofwork-rail-collapsed', '0');
history.replaceState(null, '', '/#/hash-lab');
render( );
+ await act(async () => { await vi.dynamicImportSettled(); await vi.advanceTimersByTimeAsync(0); });
expect(screen.getByRole('heading', { name: 'Same message. A stricter target.' })).toBeTruthy();
await find(1);
const first = row('One zero').textContent;
diff --git a/web/src/__tests__/HintLayer.test.jsx b/web/src/__tests__/HintLayer.test.jsx
index 2daa5d3..82804eb 100644
--- a/web/src/__tests__/HintLayer.test.jsx
+++ b/web/src/__tests__/HintLayer.test.jsx
@@ -76,6 +76,29 @@ describe('HintLayer', () => {
});
describe('hints catalog', () => {
+ it('keeps a menu hint when the pointer returns to its control during the crossing delay', () => {
+ render();
+ fireEvent.pointerOver(backHal(), { pointerType: 'mouse' });
+ act(() => vi.advanceTimersByTime(400));
+ const bubble = screen.getByRole('tooltip');
+ fireEvent.pointerOut(backHal(), { pointerType: 'mouse', relatedTarget: document.body });
+ act(() => vi.advanceTimersByTime(100));
+ fireEvent.pointerOver(backHal(), { pointerType: 'mouse', relatedTarget: document.body });
+ act(() => vi.advanceTimersByTime(250));
+ expect(screen.getByRole('tooltip')).toBe(bubble);
+ });
+ it('lets the pointer cross into the explaining bubble and dismisses it with Escape', () => {
+ render( );
+ fireEvent.pointerOver(backHal(), { pointerType: 'mouse' });
+ act(() => vi.advanceTimersByTime(400));
+ const bubble = screen.getByRole('tooltip');
+ fireEvent.pointerOut(backHal(), { pointerType: 'mouse', relatedTarget: bubble });
+ fireEvent.pointerOver(bubble, { pointerType: 'mouse', relatedTarget: backHal() });
+ act(() => vi.advanceTimersByTime(500));
+ expect(screen.getByRole('tooltip')).toBe(bubble);
+ fireEvent.keyDown(document, { key: 'Escape' });
+ expect(screen.queryByRole('tooltip')).toBeNull();
+ });
it('throws on an unknown key, so a typo fails its component test', () => {
expect(() => hint('no.such-hint')).toThrow(/Unknown hint/);
});
diff --git a/web/src/__tests__/MempoolCard.test.jsx b/web/src/__tests__/MempoolCard.test.jsx
index 3293095..394b423 100644
--- a/web/src/__tests__/MempoolCard.test.jsx
+++ b/web/src/__tests__/MempoolCard.test.jsx
@@ -11,6 +11,15 @@ const card = () => screen.getByRole('region', { name: 'Mempool' });
const newTx = () => screen.getByRole('button', { name: 'New transaction' });
describe('MempoolCard', () => {
+ it('returns keyboard focus to New transaction after cancelling its inline form', () => {
+ render( );
+ newTx().focus();
+ fireEvent.click(newTx());
+ const cancel = screen.getByRole('button', { name: 'Cancel' });
+ cancel.focus();
+ fireEvent.click(cancel);
+ expect(document.activeElement).toBe(newTx());
+ });
it('idle: pending pill, rows, coinbase line and a glowing New transaction', () => {
render( );
const text = card().textContent;
diff --git a/web/src/__tests__/NextBlockCard.test.jsx b/web/src/__tests__/NextBlockCard.test.jsx
index b6d9a6f..5dccead 100644
--- a/web/src/__tests__/NextBlockCard.test.jsx
+++ b/web/src/__tests__/NextBlockCard.test.jsx
@@ -423,6 +423,19 @@ describe('NextBlockCard miner popover', () => {
});
describe('NextBlockCard M key', () => {
+ it('can disable single-letter mining shortcuts while retaining the button', () => {
+ localStorage.setItem('proofofwork-mining-shortcut', '0');
+ try {
+ const onMine = vi.fn();
+ render( );
+ const button = screen.getByRole('button', { name: 'Mining' });
+ expect(button.hasAttribute('aria-keyshortcuts')).toBe(false);
+ fireEvent.keyDown(document.body, { key: 'm' });
+ expect(onMine).not.toHaveBeenCalled();
+ fireEvent.click(button);
+ expect(onMine).toHaveBeenCalledTimes(1);
+ } finally { localStorage.removeItem('proofofwork-mining-shortcut'); }
+ });
const pressM = (target = document.body, options = {}) => fireEvent.keyDown(target, { key: 'm', ...options });
it('mines between races, like the button that announces it', () => {
const onMine = vi.fn();
diff --git a/web/src/__tests__/RecordCelebration.test.jsx b/web/src/__tests__/RecordCelebration.test.jsx
index def5f9a..fabd8a2 100644
--- a/web/src/__tests__/RecordCelebration.test.jsx
+++ b/web/src/__tests__/RecordCelebration.test.jsx
@@ -9,6 +9,24 @@ beforeEach(() => { vi.useFakeTimers(); });
afterEach(() => { cleanup(); vi.useRealTimers(); });
describe('RecordCelebration', () => {
+ it('keeps the focused action while the pointer leaves, and keeps hover when focus leaves', () => {
+ const onClose = vi.fn();
+ render( );
+ const card = screen.getByRole('status');
+ const action = screen.getByRole('button', { name: 'Leaderboard' });
+ fireEvent.pointerEnter(card);
+ act(() => action.focus());
+ fireEvent.pointerLeave(card);
+ act(() => vi.advanceTimersByTime(2000));
+ expect(onClose).not.toHaveBeenCalled();
+ fireEvent.pointerEnter(card);
+ act(() => action.blur());
+ act(() => vi.advanceTimersByTime(2000));
+ expect(onClose).not.toHaveBeenCalled();
+ fireEvent.pointerLeave(card);
+ act(() => vi.advanceTimersByTime(1000));
+ expect(onClose).toHaveBeenCalledTimes(1);
+ });
it('renders nothing without a record', () => {
const { container } = render( {}} />);
expect(container.innerHTML).toBe('');
diff --git a/web/src/__tests__/WorkbenchFeeMarket.test.jsx b/web/src/__tests__/WorkbenchFeeMarket.test.jsx
index 4b98717..f1e64e9 100644
--- a/web/src/__tests__/WorkbenchFeeMarket.test.jsx
+++ b/web/src/__tests__/WorkbenchFeeMarket.test.jsx
@@ -42,6 +42,19 @@ function view(chain, isMining = false) {
const props = { coinName: 'FixtureCoin', targetSeconds: 10, selectedIndex: null, remining: null };
describe('workbench fee-market counts', () => {
+ it('describes only the visible activity tail, and reuses it during mining progress', () => {
+ const chain = createBlockchain({ participants: ['Miner Fixture'], miners: ['Miner Fixture'], miningDifficulty: 1 });
+ for (let i = 0; i < 40; i++) mine(chain);
+ const sim = view(chain);
+ const original = sim.describeTx;
+ sim.describeTx = vi.fn(original);
+ const { rerender } = render( );
+ // The selected genesis is separate; Activity needs at most its 12 visible payments.
+ expect(sim.describeTx.mock.calls.filter(([tx]) => tx !== chain.blockArray[0].transactions[0]).length).toBeLessThanOrEqual(12);
+ sim.describeTx.mockClear();
+ rerender( );
+ expect(sim.describeTx.mock.calls.filter(([tx]) => tx !== chain.blockArray[0].transactions[0])).toHaveLength(0);
+ });
it('shows five candidate payments before and during mining, with eight still pending', () => {
const chain = fundedBatch();
const { rerender } = render( );
diff --git a/web/src/components/HintLayer.css b/web/src/components/HintLayer.css
index c1d2b93..e4e3c00 100644
--- a/web/src/components/HintLayer.css
+++ b/web/src/components/HintLayer.css
@@ -6,17 +6,23 @@
border-radius: var(--r-md); border: 1px solid var(--line-3); background: var(--overlay); color: var(--text-2);
box-shadow: 0 18px 40px -10px var(--shadow);
font: 13px/19px var(--ui); text-align: left; white-space: normal; overflow: visible;
- pointer-events: none;
+ pointer-events: auto;
animation: hint-layer-in 120ms ease-out;
}
.hint-layer-title { display: block; margin-bottom: 2px; color: var(--text); font-weight: 600; }
.hint-layer-text { display: block; }
+/* Keep the 10px crossing between the control and its bubble hoverable. */
+.hint-layer::after { content: ""; position: absolute; left: 0; right: 0; height: 10px; }
+.hint-layer[data-side="below"]::after { top: -10px; }
+.hint-layer[data-side="above"]::after { bottom: -10px; }
+.hint-layer[data-side="left"]::after { top: 0; left: auto; right: -10px; width: 10px; height: 100%; }
.hint-layer::before {
content: ""; position: absolute; left: calc(var(--hint-arrow, 50%) - 5px); width: 10px; height: 10px;
transform: rotate(45deg); background: var(--overlay);
}
.hint-layer[data-side="below"]::before { top: -6px; border-left: 1px solid var(--line-3); border-top: 1px solid var(--line-3); }
.hint-layer[data-side="above"]::before { bottom: -6px; border-right: 1px solid var(--line-3); border-bottom: 1px solid var(--line-3); }
+.hint-layer[data-side="left"]::before { left: auto; right: -6px; top: 12px; border-right: 1px solid var(--line-3); border-top: 1px solid var(--line-3); }
@keyframes hint-layer-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .hint-layer { animation: none; } }
diff --git a/web/src/components/HintLayer.jsx b/web/src/components/HintLayer.jsx
index f9eeb55..d5f4803 100644
--- a/web/src/components/HintLayer.jsx
+++ b/web/src/components/HintLayer.jsx
@@ -90,16 +90,27 @@ export function HintLayer() {
};
const onPointerOver = event => {
if (event.pointerType === 'touch') return;
+ if (bubbleRef.current?.contains(event.target)) { clearTimeout(s.timer); s.timer = null; return; }
const target = targetOf(event.target);
- if (!target || target === s.target || target === s.suppressed) return;
+ if (target && target === s.target) { clearTimeout(s.timer); s.timer = null; return; }
+ if (!target || target === s.suppressed) return;
schedule(target);
};
const onPointerOut = event => {
if (event.pointerType === 'touch') return;
+ const bubble = bubbleRef.current;
+ if (bubble?.contains(event.relatedTarget)) return;
+ if (bubble?.contains(event.target)) {
+ if (!s.target?.contains(event.relatedTarget)) hide();
+ return;
+ }
const from = targetOf(event.target);
if (!from || from.contains(event.relatedTarget)) return;
if (from === s.suppressed) s.suppressed = null;
- if (from === s.target || !s.target) hide();
+ if (from === s.target || !s.target) {
+ if (from.closest('.top-bar-menu')) { clearTimeout(s.timer); s.timer = setTimeout(hide, 200); }
+ else hide();
+ }
};
const onFocusIn = event => {
const target = targetOf(event.target);
@@ -171,13 +182,28 @@ export function HintLayer() {
const viewW = document.documentElement.clientWidth || window.innerWidth;
const viewH = window.innerHeight;
const below = rect.bottom + GAP + height <= viewH - EDGE || rect.top - GAP - height < EDGE;
- const top = below ? rect.bottom + GAP : rect.top - GAP - height;
+ let top = below ? rect.bottom + GAP : rect.top - GAP - height;
const center = rect.left + rect.width / 2;
- const left = Math.max(EDGE, Math.min(center - width / 2, viewW - EDGE - width));
+ let left = Math.max(EDGE, Math.min(center - width / 2, viewW - EDGE - width));
+ let side = below ? 'below' : 'above';
+ // A menu explanation must leave the other actions clickable. On narrow
+ // screens it sits below the menu; on a desktop it sits beside it.
+ const menu = shown.target.closest('.top-bar-menu')?.getBoundingClientRect();
+ if (menu) {
+ if (menu.left - GAP - width >= EDGE) {
+ left = menu.left - GAP - width;
+ top = Math.max(EDGE, Math.min(rect.top, viewH - EDGE - height));
+ side = 'left';
+ } else {
+ const underMenu = menu.bottom + GAP + height <= viewH - EDGE;
+ top = underMenu ? menu.bottom + GAP : Math.max(EDGE, menu.top - GAP - height);
+ side = underMenu ? 'below' : 'above';
+ }
+ }
bubble.style.top = `${Math.round(top)}px`;
bubble.style.left = `${Math.round(left)}px`;
bubble.style.setProperty('--hint-arrow', `${Math.round(Math.max(12, Math.min(center - left, width - 12)))}px`);
- bubble.dataset.side = below ? 'below' : 'above';
+ bubble.dataset.side = side;
}, [shown]);
// Every way out of explain mode starts with a tap (which closes the bubble) or Escape.
diff --git a/web/src/components/workbench/ChainBand.css b/web/src/components/workbench/ChainBand.css
index 936ad6a..d1e819e 100644
--- a/web/src/components/workbench/ChainBand.css
+++ b/web/src/components/workbench/ChainBand.css
@@ -286,6 +286,7 @@
.chain-band-tip.is-end { left: auto; right: -12px; }
.chain-band-tip.is-end::before { left: auto; right: 40px; }
.chain-band-tile:hover .chain-band-tip, .chain-band-tile-face:focus-visible ~ .chain-band-tip, .chain-band-tip:focus-within { display: block; }
+.chain-band-tile.is-tip-dismissed .chain-band-tip, .chain-band-link.is-tip-dismissed .chain-band-ltip { display: none; }
.chain-band-tile:hover, .chain-band-tile:has(.chain-band-tile-face:focus-visible), .chain-band-tile:has(.chain-band-tip:focus-within) { z-index: 31; }
.chain-band-tip-head {
display: flex; align-items: center; gap: var(--s-3); margin-bottom: 6px;
diff --git a/web/src/components/workbench/ChainBand.jsx b/web/src/components/workbench/ChainBand.jsx
index 0504fa8..73f84ec 100644
--- a/web/src/components/workbench/ChainBand.jsx
+++ b/web/src/components/workbench/ChainBand.jsx
@@ -187,6 +187,8 @@ function FullHash({ hash, miss = 0 }) {
function Tile({ view, views, newest, selected, pinned, repairPosition, shade, onSelect, tipEnd, events, pace }) {
const tipId = useId();
+ const [dismissed, setDismissed] = useState(false);
+ const face = useRef(null);
const state = stateOf(view);
const mismatch = view.status === 'hash-mismatch';
const classes = ['chain-band-tile', newest && 'is-newest', selected && (pinned ? 'is-selected' : 'is-current'),
@@ -196,12 +198,14 @@ function Tile({ view, views, newest, selected, pinned, repairPosition, shade, on
const shownHash = mismatch ? view.computedHash : view.storedHash;
const miss = mismatch ? view.difficulty : 0;
return (
-
+
setDismissed(false)} onFocusCapture={() => setDismissed(false)}
+ onKeyDown={event => { if (event.key === 'Escape') { event.stopPropagation(); face.current?.focus(); setDismissed(true); } }}>
{repairPosition ? (
{repairPosition}
) : null}
#{view.index}
-
onSelect?.(view.index)}>
{tag && {tag} }
@@ -235,7 +239,7 @@ function Tile({ view, views, newest, selected, pinned, repairPosition, shade, on
{state !== 'broken' &&
}
-
+
Block #{view.index} · full hash
{mismatch ? (
<>
@@ -304,8 +308,11 @@ function MiniCandidate({ candidate }) {
}
function Link({ link, epoch = false }) {
+ const [dismissed, setDismissed] = useState(false);
return (
-
+ setDismissed(false)} onFocus={() => setDismissed(false)}
+ onKeyDown={event => { if (event.key === 'Escape') { event.stopPropagation(); setDismissed(true); } }}>
{link.title} · {link.text}
@@ -479,7 +486,7 @@ export function ChainBand({
if (!el || typeof el.scrollTo !== 'function') return;
atEnd.current = true;
following.current = true;
- el.scrollTo({ left: el.scrollWidth, behavior: smooth ? 'smooth' : 'auto' });
+ el.scrollTo({ left: el.scrollWidth, behavior: smooth && !globalThis.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches ? 'smooth' : 'auto' });
};
const mounted = useRef(false);
// A new block, or letting go of a held one, brings the newest end into view.
@@ -504,8 +511,9 @@ export function ChainBand({
if (!el || !tile || typeof el.scrollTo !== 'function') return;
const left = tile.offsetLeft;
const right = left + tile.offsetWidth;
- if (left < el.scrollLeft) el.scrollTo({ left: left - END_SLACK, behavior: 'smooth' });
- else if (right > el.scrollLeft + el.clientWidth) el.scrollTo({ left: right - el.clientWidth + END_SLACK, behavior: 'smooth' });
+ const behavior = globalThis.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches ? 'auto' : 'smooth';
+ if (left < el.scrollLeft) el.scrollTo({ left: left - END_SLACK, behavior });
+ else if (right > el.scrollLeft + el.clientWidth) el.scrollTo({ left: right - el.clientWidth + END_SLACK, behavior });
}, [selectedIndex, pinned, repairOrder.length]);
const shadeOf = view => {
diff --git a/web/src/components/workbench/MempoolCard.jsx b/web/src/components/workbench/MempoolCard.jsx
index 161e48a..825e7b2 100644
--- a/web/src/components/workbench/MempoolCard.jsx
+++ b/web/src/components/workbench/MempoolCard.jsx
@@ -1,4 +1,4 @@
-import { useState } from 'react';
+import { useRef, useState } from 'react';
import { DEFAULT_FEE_RATE, FEE_RATES } from '../../lib/blockchain';
import { CoachMark } from './CoachMark';
import { RepeatToggle } from './RepeatToggle';
@@ -147,6 +147,8 @@ export function MempoolCard({
onCreateTransaction, onPreviewTransaction, onOpenTransaction, autoTransact = false, onAutoTransact, newTxGlow = false, coach = null
}) {
const [open, setOpen] = useState(false);
+ const trigger = useRef(null);
+ const closeForm = () => { setOpen(false); trigger.current?.focus(); };
const names = participants.map(p => (typeof p === 'string' ? p : p.name)).filter(Boolean);
const pending = transactions.length;
const selecting = mining && remining === null;
@@ -163,7 +165,7 @@ export function MempoolCard({
: space && space.included < space.total ? `${space.included} of ${space.total} fit into #${nextIndex}` : `goes into #${nextIndex}`}
- setOpen(value => !value)}>
New transaction
@@ -172,7 +174,7 @@ export function MempoolCard({
- {open &&
setOpen(false)} />}
+ {open && }
{space && pending > 0 && }
{pending === 0 && (
diff --git a/web/src/components/workbench/MinerDetails.jsx b/web/src/components/workbench/MinerDetails.jsx
index 66099e2..f50c0d3 100644
--- a/web/src/components/workbench/MinerDetails.jsx
+++ b/web/src/components/workbench/MinerDetails.jsx
@@ -1,4 +1,4 @@
-import { useEffect, useId, useRef, useState } from 'react';
+import { useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
import { headerFields, le } from '../../../../shared/bitcoin-block.mjs';
import { MAX_SHARE, MIN_SHARE } from '../../lib/blockchain';
import { COUNT_ZEROS, SLOW_MS } from '../../lib/powSearch';
@@ -249,10 +249,17 @@ export function MinerDrawer({ miner, miners, progress, difficulty, isMining, win
// The popover under a race lane: share, a few attempts, the way to the drawer. `children`
// carries what only the card knows (the name field between races).
export function MinerPopover({ miner, miners, progress, difficulty, onShare, onOpenDetails, onClose, children }) {
+ const root = useRef(null);
+ useLayoutEffect(() => {
+ const opener = document.activeElement;
+ const element = root.current;
+ element.querySelector('input, button')?.focus();
+ return () => { if (element.contains(document.activeElement) && opener?.isConnected) opener.focus(); };
+ }, []);
const rate = rateOf(progress);
const racing = miners.some(m => m.name === miner.name);
return (
- { if (event.key === 'Escape') { event.stopPropagation(); onClose(); } }}>
{children}
{racing &&
}
diff --git a/web/src/components/workbench/NextBlockCard.jsx b/web/src/components/workbench/NextBlockCard.jsx
index 711f3c2..6dad1a7 100644
--- a/web/src/components/workbench/NextBlockCard.jsx
+++ b/web/src/components/workbench/NextBlockCard.jsx
@@ -10,6 +10,7 @@ import { issueText } from './blockView';
import { colorOf } from './minerColors';
import { MinerPopover, StreamWall } from './MinerDetails';
import { SLOW_MS } from '../../lib/powSearch';
+import { useMiningShortcut } from '../../lib/miningShortcut';
import { hint, term } from '../../lib/hints';
// Next block card (web/DESIGN.md, "Card grid" and "Interaction patterns").
@@ -43,8 +44,9 @@ function isTyping(target) {
return Boolean(target?.closest?.('input, textarea, select, [contenteditable=""], [contenteditable="true"]'));
}
function useMineKey(action) {
+ const enabled = useMiningShortcut();
const latest = useRef(action);
- useEffect(() => { latest.current = action; });
+ useEffect(() => { latest.current = enabled ? action : null; });
useEffect(() => {
const onKeyDown = event => {
if (event.key !== 'm' && event.key !== 'M') return;
@@ -57,6 +59,7 @@ function useMineKey(action) {
document.addEventListener('keydown', onKeyDown);
return () => document.removeEventListener('keydown', onKeyDown);
}, []);
+ return enabled;
}
function formatAmount(value) {
@@ -179,15 +182,15 @@ export function NextBlockCard({
const running = isMining || (repeating && !isRepair);
const startsDemo = isFresh;
const repairNext = repair?.next ?? repair?.order?.[0];
- useMineKey(isRepair
+ const shortcut = useMineKey(isRepair
? (repair && !repair.undoOnly && repairNext !== undefined ? () => onRemine?.(repairNext) : null)
: (!running && !startsDemo ? () => onMine?.() : null));
// Keep the same button mounted so keyboard focus follows Play → Pause → Play.
const action = (
running ? onPause?.() : startsDemo ? onStartDemo?.() : onMine?.()}>
{running ? : }
{running ? 'Pause' : startsDemo ? 'Start demo' : 'Mining'}
@@ -388,6 +391,7 @@ function LiveRace({ miners, race, index, difficulty, target, backedMiner, coach,
}
function RepairBody({ repair, difficulty, target, onRemine, coach }) {
+ const shortcut = useMiningShortcut();
const order = repair?.order ?? [];
const next = repair?.next ?? order[0];
const done = Math.max(0, order.indexOf(next));
@@ -421,7 +425,7 @@ function RepairBody({ repair, difficulty, target, onRemine, coach }) {
:
- onRemine?.(next)}> Re-mine block #{next}
+ onRemine?.(next)}> Re-mine block #{next}
Finds a new nonce so #{next} starts with {target} again.{then}
}
diff --git a/web/src/components/workbench/RecordCelebration.jsx b/web/src/components/workbench/RecordCelebration.jsx
index 4ee5f59..6ae95b3 100644
--- a/web/src/components/workbench/RecordCelebration.jsx
+++ b/web/src/components/workbench/RecordCelebration.jsx
@@ -37,7 +37,7 @@ function TrophyIcon() {
}
export function RecordCelebration({ record, name, onClose, onOpenLeaderboard, durationMs = CELEBRATION_MS }) {
- const held = useRef(false);
+ const held = useRef({ pointer: false, focus: false });
const timer = useRef(null);
const closeRef = useRef(onClose);
useEffect(() => { closeRef.current = onClose; }, [onClose]);
@@ -46,7 +46,7 @@ export function RecordCelebration({ record, name, onClose, onOpenLeaderboard, du
if (!record) return undefined;
const arm = () => {
clearTimeout(timer.current);
- timer.current = setTimeout(() => { if (!held.current) closeRef.current?.(); else arm(); }, durationMs);
+ timer.current = setTimeout(() => { if (!held.current.pointer && !held.current.focus) closeRef.current?.(); else arm(); }, durationMs);
};
arm();
const onKey = event => { if (event.key === 'Escape') closeRef.current?.(); };
@@ -56,11 +56,12 @@ export function RecordCelebration({ record, name, onClose, onOpenLeaderboard, du
if (!record) return null;
const copy = recordCopy(record);
- const hold = value => () => { held.current = value; };
return (
+ onPointerEnter={() => { held.current.pointer = true; }} onPointerLeave={() => { held.current.pointer = false; }}
+ onFocus={() => { held.current.focus = true; }}
+ onBlur={event => { if (!event.currentTarget.contains(event.relatedTarget)) held.current.focus = false; }}>
{confetti.map((piece, i) => (
Math.min(60, Math.max(1, Number(raw) || 10));
function Dialog({ onClose, coinName, onCoinName, difficulty, onDifficulty, halvingInterval, onHalvingInterval,
targetBlockTime, onTargetBlockTime, busy }) {
const ref = useRef(null);
+ const shortcut = useMiningShortcut();
const titleId = useId();
const helpId = useId();
const busyId = useId();
@@ -74,6 +76,11 @@ function Dialog({ onClose, coinName, onCoinName, difficulty, onDifficulty, halvi
+
+ setMiningShortcut(event.target.checked)} />
+ Enable M to mine or re-mine a block
+
+
Turn this off if single-letter shortcuts interfere with speech input or assistive technology.
{busy &&
Mining is running. Difficulty, halving interval and target block time unlock when it stops.
}
Each extra leading zero takes about 16× more attempts on average. High settings may take longer than you can wait; Pause stops mining. Lowering the difficulty by hand starts a new chain, so a longer chain always took more work. Difficulty adapts every 10 mined blocks. Halving reduces the reward for future blocks; it does not rewrite earlier rewards.
diff --git a/web/src/components/workbench/Workbench.jsx b/web/src/components/workbench/Workbench.jsx
index c34f348..1f1d6b0 100644
--- a/web/src/components/workbench/Workbench.jsx
+++ b/web/src/components/workbench/Workbench.jsx
@@ -127,14 +127,25 @@ export function Workbench({
});
const space = { bytes: template.bytes, capacity: template.space, included: template.included.length, total: memPool.length };
const pendingFees = template.fees / 1e8;
- const confirmed = blocks.slice(1).reverse().flatMap((b, i) => {
- const index = height - i;
- return b.transactions.map(tx => {
- const view = describeTx(tx);
- return { blockIndex: index, label: `${view.coinbase ? 'Coinbase' : view.from} → ${view.to}`, amount: view.amount };
- });
- }).slice(0, 12);
- const blockTimes = views.slice(1).reverse().filter(v => v.seconds !== null).map(v => ({ index: v.index, seconds: v.seconds })).slice(0, 8);
+ const confirmed = useMemo(() => {
+ const recent = [];
+ for (let index = blocks.length - 1; index > 0 && recent.length < 12; index--) {
+ for (const tx of blocks[index].transactions) {
+ const view = describeTx(tx);
+ recent.push({ blockIndex: index, label: `${view.coinbase ? 'Coinbase' : view.from} → ${view.to}`, amount: view.amount });
+ if (recent.length === 12) break;
+ }
+ }
+ return recent;
+ }, [blocks, describeTx]);
+ const blockTimes = useMemo(() => {
+ const recent = [];
+ for (let index = views.length - 1; index > 0 && recent.length < 8; index--) {
+ const view = views[index];
+ if (view.seconds !== null) recent.push({ index: view.index, seconds: view.seconds });
+ }
+ return recent;
+ }, [views]);
const workbenchCoach = coach?.view === 'workbench' ? coach : null;
const selectedTransactions = selectedBlock ? (blocks[selected]?.transactions ?? []).map(describeTx) : [];
const repairOrder = repair && !repair.undoOnly ? repair.order : [];
diff --git a/web/src/lib/hints/workbench.js b/web/src/lib/hints/workbench.js
index a32fb54..3fda425 100644
--- a/web/src/lib/hints/workbench.js
+++ b/web/src/lib/hints/workbench.js
@@ -98,7 +98,7 @@ export const WORKBENCH_HINTS = {
: 'One zero fewer: blocks are found about 16 times faster.' }),
'next.raise': { title: 'Raise difficulty', text: 'One zero more: blocks take about 16 times longer. High settings can take longer than you want to wait; Pause stops the search.' },
'next.start-demo': { title: 'Start demo', text: 'Mines the first block and shares its reward with the other wallets, so everyone has coins to send. A good first click.' },
- 'next.mine': { title: 'Mining', text: 'Start the race: every miner tries nonce after nonce until one finds a hash with enough leading zeros. The winner adds the block and earns the reward. Shortcut: M.' },
+ 'next.mine': (shortcut = true) => ({ title: 'Mining', text: `Start the race: every miner tries nonce after nonce until one finds a hash with enough leading zeros. The winner adds the block and earns the reward.${shortcut ? ' Shortcut: M.' : ''}` }),
'next.pause': { title: 'Pause', text: 'Stop the search. The unfinished block is dropped; nothing is added to the chain. You can change the difficulty and start again.' },
'next.auto-mine': on => (on
? { title: 'Auto-mine is on', text: 'After each found block the next race starts by itself. Click to stop after the current block.' }
@@ -118,7 +118,7 @@ export const WORKBENCH_HINTS = {
'next.all-streams': on => (on
? { title: 'Hide streams', text: 'Fold the miners’ attempt lists away again.' }
: { title: 'All streams', text: 'Every miner’s newest guesses side by side. More hashpower makes a list run faster.' }),
- 'next.remine': (index, target) => ({ title: `Re-mine block #${index}`, text: `Search a new nonce so the edited block’s hash starts with ${target} again. That gives it a new hash, so the block after it must be re-mined too. This is why rewriting history costs so much work. Shortcut: M.` }),
+ 'next.remine': (index, target, shortcut = true) => ({ title: `Re-mine block #${index}`, text: `Search a new nonce so the edited block’s hash starts with ${target} again. That gives it a new hash, so the block after it must be re-mined too. This is why rewriting history costs so much work.${shortcut ? ' Shortcut: M.' : ''}` }),
'next.undo-edit': { title: 'Undo edit', text: 'Put the original payment back. A broken signature or rule cannot be repaired by re-mining, only by undoing the change.' },
'next.repair-order': { title: 'Re-mine order', text: 'The blocks that need a new nonce, in order. Each re-mine changes a hash that the next block stores, so the repair walks forward one block at a time.' },
@@ -156,5 +156,6 @@ export const WORKBENCH_HINTS = {
'settings.coin': { title: 'Coin name', text: 'Just a label for the virtual coin. It changes nothing in the rules.' },
'settings.difficulty': { title: 'Mining difficulty', text: 'How many zeros a block hash must start with. Each step makes mining about 16 times slower on average. Raising keeps the chain; lowering by hand starts a new one.' },
'settings.halving': { title: 'Halving interval', text: 'After this many blocks the block reward is cut in half. Bitcoin halves every 210,000 blocks.' },
- 'settings.block-time': { title: 'Target block time', text: 'How long a block should take on average. Every 10 blocks the difficulty adjusts toward it. Bitcoin aims at 10 minutes.' }
+ 'settings.block-time': { title: 'Target block time', text: 'How long a block should take on average. Every 10 blocks the difficulty adjusts toward it. Bitcoin aims at 10 minutes.' },
+ 'settings.shortcut': { title: 'Mining shortcut', text: 'M starts mining or re-mining between races. Turn this off if single-letter shortcuts interfere with speech input or assistive technology. The mining button always works.' }
};
diff --git a/web/src/lib/miningShortcut.js b/web/src/lib/miningShortcut.js
new file mode 100644
index 0000000..7343385
--- /dev/null
+++ b/web/src/lib/miningShortcut.js
@@ -0,0 +1,23 @@
+import { useSyncExternalStore } from 'react';
+
+const KEY = 'proofofwork-mining-shortcut';
+const listeners = new Set();
+let fallback = true;
+let volatile = null;
+const read = () => {
+ if (volatile !== null) return volatile;
+ try { return globalThis.localStorage ? localStorage.getItem(KEY) !== '0' : fallback; }
+ catch { return fallback; }
+};
+const subscribe = notify => {
+ listeners.add(notify);
+ globalThis.addEventListener?.('storage', notify);
+ return () => { listeners.delete(notify); globalThis.removeEventListener?.('storage', notify); };
+};
+export function setMiningShortcut(enabled) {
+ fallback = Boolean(enabled);
+ try { globalThis.localStorage?.setItem(KEY, enabled ? '1' : '0'); volatile = null; }
+ catch { volatile = fallback; }
+ for (const notify of listeners) notify();
+}
+export const useMiningShortcut = () => useSyncExternalStore(subscribe, read, () => true);
diff --git a/web/src/styles/tokens.css b/web/src/styles/tokens.css
index f88cb7b..8dcd03c 100644
--- a/web/src/styles/tokens.css
+++ b/web/src/styles/tokens.css
@@ -27,8 +27,8 @@
/* text */
--text: #e7edf8;
--text-2: #a3b2cf;
- --text-3: #6c7d9e;
- --on-accent: #ffffff;
+ --text-3: #8293b3;
+ --on-accent: #0b1220;
--on-light: #0b1220;
/* action */
@@ -153,7 +153,7 @@ html[data-theme="light"] {
--focus: #2459e0;
/* status */
- --green: #047857;
+ --green: #046c50;
--green-bg: rgba(4, 120, 87, 0.10);
--green-line: rgba(4, 120, 87, 0.35);
--amber: #9a5800;
diff --git a/web/vite.config.js b/web/vite.config.js
index bcd57eb..c616325 100644
--- a/web/vite.config.js
+++ b/web/vite.config.js
@@ -10,6 +10,7 @@ export default defineConfig(({ mode }) => {
throw new Error('VITE_POSTHOG_PROJECT_TOKEN must be a public phc_ ingestion token, never a personal or project secret key')
}
return {
+ build: { manifest: true },
plugins: [
react(),
nodePolyfills({