@stellarshenson/jupyterlab-audio-extension 1.0.49 → 1.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -78,7 +78,7 @@ See [docs/jupyterlab-enable-claude-voice.md](docs/jupyterlab-enable-claude-voice
78
78
  - Every open JupyterLab browser tab plays the sound; opening another tab stops none of them
79
79
  - The status bar pill leads with a small audio lamp, then the microphone toggle, a play/stop control and a pause control: the lamp is a filled grey disc when the audio output is ready, green while the microphone streams or a file plays, and a hollow grey ring when the audio output is deliberately shut down; a paused file leaves the lamp grey; hovering the lamp states whether the audio system is ready, in use, shut down or unavailable; while a file plays both controls are enabled and the first shows stop; while paused the first shows play and resumes; with nothing playing both are disabled and greyed
80
80
  - When the audio output is unavailable, the lamp blinks amber for 30 seconds and the player tooltip says audio output is unavailable; the controls follow the player mode during the blink, and after 30 seconds the lamp settles to the hollow grey ring and both player controls read as disabled with the same message left in the tooltip; a deliberate shutdown shows the hollow grey ring at once, disables both player controls and leaves the tooltip saying audio output is shut down; the microphone toggle stays enabled whatever the lamp shows
81
- - The gear at the right end of the pill opens the **Audio Settings** tab in the main area; a second click focuses the same tab, and closing the tab ends it. The tab lays its cards out as a board: **Audio system** states whether the microphone captures, whether playback runs, the audio system's own state and the FIFO that receives captured audio; **Capture** holds the **Auto-connect on startup** switch, which saves the setting at once; **Status bar** lists the pill's toolbar items and where to edit them; **Panel cards** is the empty state shown while no other extension adds a card
81
+ - The gear at the right end of the pill opens the **Audio Settings** tab in the main area; a second click focuses the same tab, and closing the tab ends it. The tab lays its cards out as a board: **Audio system** states whether the microphone captures, whether playback runs, the audio system's own state and the FIFO that receives captured audio; **Capture** holds the **Auto-connect on startup** switch, which saves the setting at once; **Status bar** lists the pill's toolbar items and where to edit them; **Panel cards** is the empty state shown while no other extension adds a card; the page has a header strip at its top edge holding the title and subtitle above a scrolling body with the board and footer; the Audio system state words are green when healthy and red on a problem; the Auto-connect on startup control is JupyterLab's standard switch
82
82
  - Another extension adds its own card to the board after the Audio system, Capture and Status bar cards: an entry `{"name": "<card>", "rank": <number>}` under `"jupyter.lab.toolbars"` → `"AudioSettings"` in its settings schema, and `IToolbarWidgetRegistry.addFactory('AudioSettings', '<card>', factory)`, where `factory` returns the card widget. Cards show as tiles in rank order, and the card of a disabled or uninstalled extension is absent
83
83
  - The command `audio:player` drives the container player and returns its state: `play` with a `path` relative to the Jupyter root queues an mp3 or wav file and starts it when nothing plays, `mode: "now"` starts it at once, mixed with every file already playing, `pause` and `resume` stop and continue every playing file at its position, `stop` ends every playing file and keeps the queue, `clear` removes the queue, and `status` reports `paused`, `stopped`, `playing` with ids and positions, and `queue`. A missing or undecodable file, a path outside the root or an unknown action is refused with the reason and changes nothing. The palette entry **Stop All Audio** in category **Audio** runs the command with `{"action": "stop"}`. From a terminal: `jupyterlab_audio player play <file>` queues the file, `jupyterlab_audio player play <file> --now` plays it mixed with every playing file, `jupyterlab_audio player status` reports the state, and `jupyterlab_audio player pause`, `resume`, `stop` and `clear` control it. Every player command works without a tab, but sound is heard only while a JupyterLab tab is open. `jupyterlab_audio player stop` ends playback and leaves the PulseAudio daemon; the top-level `jupyterlab_audio stop` kills the daemon
84
84
  - The commands `audio:enable` (label **Enable Audio Capture**) and `audio:disable` (label **Disable Audio Capture**) start capture in the tab that runs `audio:enable` and stop capture in every open tab, for terminal programs such as Claude Code `/voice`. `audio:enable` returns once capture streams, fails with the error message (for example `Microphone permission denied.`) when capture turns to Error, and does nothing when capture already streams; `audio:disable` does nothing when capture is already off. From a terminal: `jupyterlab-commands execute audio:enable`, which runs only after the command is added to the `allowedCommands` setting
package/lib/settings.d.ts CHANGED
@@ -8,8 +8,11 @@ declare const ROWS: {
8
8
  readonly playback: "Playback";
9
9
  readonly delivery: "Captured audio goes to";
10
10
  };
11
- /** The audio extension's state, one plain phrase per row of the Audio system card. */
12
- export type AudioSummary = Record<keyof typeof ROWS, string>;
11
+ /** The audio extension's state: one row per card row, with its phrase and health colour. */
12
+ export type AudioSummary = Record<keyof typeof ROWS, {
13
+ text: string;
14
+ health: 'ok' | 'bad' | '';
15
+ }>;
13
16
  /**
14
17
  * The Audio Settings tab (ACC-CTRL-99): a page on the main-area background with the
15
18
  * extension's settings laid out as a board of cards. The Audio system card follows the
@@ -28,7 +31,7 @@ export declare class AudioSettings extends Widget {
28
31
  /** Binds the Capture switch and the Status bar list to the plugin setting. */
29
32
  private _bindSettings;
30
33
  private _onSettingsChanged;
31
- /** Toggling saves the setting; it starts no capture. */
34
+ /** Clicking saves the next value; it starts no capture. */
32
35
  private _onToggle;
33
36
  /** One read-only row per pill item, or the empty state. */
34
37
  private _renderToolbar;
package/lib/settings.js CHANGED
@@ -20,18 +20,17 @@ const ROWS = {
20
20
  export class AudioSettings extends Widget {
21
21
  constructor(status, settingRegistry, cards) {
22
22
  super();
23
- /** Toggling saves the setting; it starts no capture. */
23
+ /** Clicking saves the next value; it starts no capture. */
24
24
  this._onToggle = () => {
25
+ const next = this._switch.getAttribute('aria-checked') !== 'true';
26
+ this._switch.setAttribute('aria-checked', String(next));
25
27
  if (!this._settings) {
26
28
  return;
27
29
  }
28
- void this._settings
29
- .set('autoConnect', this._switch.checked)
30
- .catch(reason => {
30
+ void this._settings.set('autoConnect', next).catch(reason => {
31
31
  console.error('Failed to save jupyterlab_audio_extension settings.', reason);
32
32
  if (this._settings) {
33
- this._switch.checked =
34
- this._settings.get('autoConnect').composite === true;
33
+ this._switch.setAttribute('aria-checked', String(this._settings.get('autoConnect').composite === true));
35
34
  }
36
35
  });
37
36
  };
@@ -63,13 +62,17 @@ export class AudioSettings extends Widget {
63
62
  subtitle.textContent =
64
63
  'Microphone capture and playback. Changes save immediately.';
65
64
  head.append(title, subtitle);
65
+ const body = document.createElement('div');
66
+ body.className = 'jp-AudioSettings-body';
66
67
  // The board is a widget so the cards another extension adds are attached with the tab.
67
68
  const board = new Panel();
68
69
  board.addClass('jp-AudioSettings-board');
69
70
  const layout = new PanelLayout();
70
71
  this.layout = layout;
71
72
  layout.addWidget(board);
72
- this.node.insertBefore(head, board.node);
73
+ // The page head and the body are the page's only children; the body scrolls under the head.
74
+ this.node.append(head, body);
75
+ body.appendChild(board.node);
73
76
  // The extension cards join the board before the plain DOM tiles, so the board layout's
74
77
  // single widget index stays correct; the core cards are then inserted before it.
75
78
  if (cards) {
@@ -111,23 +114,19 @@ export class AudioSettings extends Widget {
111
114
  this._settingDescription = document.createElement('p');
112
115
  this._settingDescription.className = 'jp-AudioSettings-settingDescription';
113
116
  settingText.append(this._settingTitle, this._settingDescription);
114
- const switchLabel = document.createElement('label');
115
- switchLabel.className = 'jp-AudioSettings-switch';
116
- this._switch = document.createElement('input');
117
- this._switch.type = 'checkbox';
118
- this._switch.className = 'jp-AudioSettings-switchInput';
117
+ // The standard JupyterLab switch (jp-switch); the shipped theme CSS draws the track.
118
+ this._switch = document.createElement('button');
119
+ this._switch.className = 'jp-switch';
120
+ this._switch.setAttribute('role', 'switch');
121
+ this._switch.setAttribute('aria-checked', 'false');
122
+ this._switch.setAttribute('aria-label', 'Auto-connect on startup');
119
123
  this._switch.disabled = true;
120
- this._switch.addEventListener('change', this._onToggle);
121
- const track = document.createElement('span');
122
- track.className = 'jp-AudioSettings-switchTrack';
123
- const thumb = document.createElement('span');
124
- thumb.className = 'jp-AudioSettings-switchThumb';
125
- track.appendChild(thumb);
126
- const switchText = document.createElement('span');
127
- switchText.className = 'jp-AudioSettings-switchLabel';
128
- switchText.textContent = 'Auto-connect on startup';
129
- switchLabel.append(this._switch, track, switchText);
130
- setting.append(settingText, switchLabel);
124
+ this._switch.addEventListener('click', this._onToggle);
125
+ const track = document.createElement('div');
126
+ track.className = 'jp-switch-track';
127
+ track.setAttribute('aria-hidden', 'true');
128
+ this._switch.appendChild(track);
129
+ setting.append(settingText, this._switch);
131
130
  captureBody.appendChild(setting);
132
131
  captureCard.appendChild(captureBody);
133
132
  board.node.insertBefore(captureCard, insert);
@@ -164,7 +163,7 @@ export class AudioSettings extends Widget {
164
163
  footer.className = 'jp-AudioSettings-footer';
165
164
  footer.textContent =
166
165
  'Raw values: Settings Editor > Audio Capture and Audio Settings Panel.';
167
- this.node.appendChild(footer);
166
+ body.appendChild(footer);
168
167
  this._status.summaryChanged.connect(this._onSummary);
169
168
  this._status.disposed.connect(this._onStatusDisposed);
170
169
  this._writeSummary(this._status.summary());
@@ -227,7 +226,7 @@ export class AudioSettings extends Widget {
227
226
  if (!this._settings) {
228
227
  return;
229
228
  }
230
- this._switch.checked = this._settings.get('autoConnect').composite === true;
229
+ this._switch.setAttribute('aria-checked', String(this._settings.get('autoConnect').composite === true));
231
230
  this._renderToolbar(this._settings);
232
231
  }
233
232
  /** One read-only row per pill item, or the empty state. */
@@ -256,10 +255,14 @@ export class AudioSettings extends Widget {
256
255
  }
257
256
  }
258
257
  _writeSummary(summary) {
259
- for (const [key, text] of Object.entries(summary)) {
258
+ for (const [key, entry] of Object.entries(summary)) {
260
259
  const value = this.node.querySelector(`[data-vc-summary="${key}"]`);
261
- if (value && value.textContent !== text) {
262
- value.textContent = text;
260
+ if (value) {
261
+ if (value.textContent !== entry.text) {
262
+ value.textContent = entry.text;
263
+ }
264
+ value.classList.toggle('jp-AudioSettings-value-ok', entry.health === 'ok');
265
+ value.classList.toggle('jp-AudioSettings-value-bad', entry.health === 'bad');
263
266
  }
264
267
  }
265
268
  }
package/lib/status.d.ts CHANGED
@@ -24,7 +24,7 @@ export declare const gearIcon: LabIcon;
24
24
  export declare class VoiceStatus extends Widget {
25
25
  constructor(model: AudioCapture, settings: ServerConnection.ISettings, openSettings: () => void, slot?: Widget);
26
26
  dispose(): void;
27
- /** The audio extension's state, one plain phrase per row of the Audio system card. */
27
+ /** The audio extension's state, one entry per row of the Audio system card. */
28
28
  summary(): AudioSummary;
29
29
  private _createMic;
30
30
  private _createControl;
package/lib/status.js CHANGED
@@ -148,26 +148,41 @@ export class VoiceStatus extends Widget {
148
148
  this._model.stateChanged.disconnect(this._refresh, this);
149
149
  super.dispose();
150
150
  }
151
- /** The audio extension's state, one plain phrase per row of the Audio system card. */
151
+ /** The audio extension's state, one entry per row of the Audio system card. */
152
152
  summary() {
153
153
  const state = this._model.state;
154
154
  return {
155
- audioSystem: this._sink === 'missing'
156
- ? 'Unavailable'
157
- : this._sink === 'off'
158
- ? 'Shut down'
159
- : state === 'streaming' || this._mode === 'playing'
160
- ? 'In use'
161
- : 'Ready',
162
- microphone: state === 'error'
163
- ? this._model.message || CAPTURE_WORDS.error
164
- : CAPTURE_WORDS[state],
165
- playback: this._sink === 'missing'
166
- ? SINK_UNAVAILABLE
167
- : this._sink === 'off'
168
- ? SINK_SHUT_DOWN
169
- : PLAYER_WORDS[this._mode],
170
- delivery: this._capture || 'Unknown'
155
+ audioSystem: {
156
+ text: this._sink === 'missing'
157
+ ? 'Unavailable'
158
+ : this._sink === 'off'
159
+ ? 'Shut down'
160
+ : state === 'streaming' || this._mode === 'playing'
161
+ ? 'In use'
162
+ : 'Ready',
163
+ health: this._sink === 'missing' ? 'bad' : this._sink === 'off' ? '' : 'ok'
164
+ },
165
+ microphone: {
166
+ text: state === 'error'
167
+ ? this._model.message || CAPTURE_WORDS.error
168
+ : CAPTURE_WORDS[state],
169
+ health: state === 'error' ? 'bad' : state === 'streaming' ? 'ok' : ''
170
+ },
171
+ playback: {
172
+ text: this._sink === 'missing'
173
+ ? SINK_UNAVAILABLE
174
+ : this._sink === 'off'
175
+ ? SINK_SHUT_DOWN
176
+ : PLAYER_WORDS[this._mode],
177
+ health: this._sink === 'missing'
178
+ ? 'bad'
179
+ : this._sink === 'off'
180
+ ? ''
181
+ : this._mode === 'playing'
182
+ ? 'ok'
183
+ : ''
184
+ },
185
+ delivery: { text: this._capture || 'Unknown', health: '' }
171
186
  };
172
187
  }
173
188
  _createMic() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stellarshenson/jupyterlab-audio-extension",
3
- "version": "1.0.49",
3
+ "version": "1.0.53",
4
4
  "description": "JupyterLab extension that captures microphone audio in the browser and streams it to a server-side bridge, exposing it as a virtual audio source so terminal applications running in the container (such as Claude Code voice mode) can record from the user's microphone",
5
5
  "keywords": [
6
6
  "jupyter",
@@ -5,7 +5,7 @@ import {
5
5
 
6
6
  import { ServerConnection } from '@jupyterlab/services';
7
7
 
8
- import { SettingRegistry } from '@jupyterlab/settingregistry';
8
+ import { ISettingRegistry, SettingRegistry } from '@jupyterlab/settingregistry';
9
9
 
10
10
  import { CommandRegistry } from '@lumino/commands';
11
11
 
@@ -145,8 +145,19 @@ function row(name: string): string | null {
145
145
  );
146
146
  }
147
147
 
148
- function switchInput(): HTMLInputElement {
149
- return root().querySelector('.jp-AudioSettings-switchInput')!;
148
+ const OK = 'jp-AudioSettings-value-ok';
149
+ const BAD = 'jp-AudioSettings-value-bad';
150
+
151
+ /** The health classes one row of the Audio system card carries, or the empty string. */
152
+ function health(name: string): string {
153
+ const value = root().querySelector(`[data-vc-summary="${name}"]`)!;
154
+ return [OK, BAD]
155
+ .filter(className => value.classList.contains(className))
156
+ .join(' ');
157
+ }
158
+
159
+ function switchInput(): HTMLButtonElement {
160
+ return root().querySelector('.jp-switch')!;
150
161
  }
151
162
 
152
163
  function settingDescription(): HTMLElement {
@@ -224,6 +235,25 @@ describe('AudioSettings tab board', () => {
224
235
  );
225
236
  });
226
237
 
238
+ it('ACC-CTRL-110-PAGE-CHROME: the page holds the head and the body, which holds the board and the footer', async () => {
239
+ await create();
240
+ const children = Array.from(root().children);
241
+
242
+ expect(children).toHaveLength(2);
243
+ expect(children[0].classList.contains('jp-AudioSettings-pageHead')).toBe(
244
+ true
245
+ );
246
+ expect(children[1].classList.contains('jp-AudioSettings-body')).toBe(true);
247
+ expect(children[0].querySelector('h1')!.textContent).toBe('Audio Settings');
248
+ expect(
249
+ children[0].querySelector('.jp-AudioSettings-subtitle')!.textContent
250
+ ).toBe('Microphone capture and playback. Changes save immediately.');
251
+ expect(children[1].querySelector('.jp-AudioSettings-board')).toBe(board());
252
+ expect(
253
+ children[1].querySelector('.jp-AudioSettings-footer')
254
+ ).not.toBeNull();
255
+ });
256
+
227
257
  it('ACC-CTRL-99-TAB: the tab disposes with the status widget and stops following it', async () => {
228
258
  await create();
229
259
  const microphone = root().querySelector('[data-vc-summary="microphone"]')!;
@@ -343,6 +373,65 @@ describe('AudioSettings Audio system card', () => {
343
373
  expect(capture).toBe(FIFO);
344
374
  expect(row('delivery')).toBe('Unknown');
345
375
  });
376
+
377
+ it.each([
378
+ [
379
+ 'a ready system',
380
+ IDLE,
381
+ { audioSystem: OK, microphone: '', playback: '', delivery: '' }
382
+ ],
383
+ [
384
+ 'a playing file',
385
+ PLAYING,
386
+ { audioSystem: OK, microphone: '', playback: OK, delivery: '' }
387
+ ],
388
+ [
389
+ 'a paused file',
390
+ { ...PLAYING, paused: true },
391
+ { audioSystem: OK, microphone: '', playback: '', delivery: '' }
392
+ ],
393
+ [
394
+ 'a missing speaker sink',
395
+ { ...IDLE, sink: { state: 'missing' } },
396
+ { audioSystem: BAD, microphone: '', playback: BAD, delivery: '' }
397
+ ],
398
+ [
399
+ 'a shut-down speaker sink',
400
+ { ...PLAYING, sink: { state: 'off' } },
401
+ { audioSystem: '', microphone: '', playback: '', delivery: '' }
402
+ ]
403
+ ])(
404
+ 'ACC-CTRL-108-STATUS-COLOR: the card colours the rows for %s',
405
+ async (_, state, expected) => {
406
+ await create(state);
407
+
408
+ for (const [name, className] of Object.entries(expected)) {
409
+ expect(health(name)).toBe(className);
410
+ }
411
+ }
412
+ );
413
+
414
+ it('ACC-CTRL-108-STATUS-COLOR: the microphone row is plain idle and connecting, green streaming and red on error', async () => {
415
+ await create();
416
+ const turn = (state: AudioCaptureState, message = ''): void => {
417
+ model.state = state;
418
+ model.message = message;
419
+ model.stateChanged.emit(state);
420
+ };
421
+
422
+ turn('connecting');
423
+ expect(health('microphone')).toBe('');
424
+ turn('streaming');
425
+ expect(health('microphone')).toBe(OK);
426
+ turn('error', 'Microphone permission denied.');
427
+ expect(health('microphone')).toBe(BAD);
428
+ expect(row('microphone')).toBe('Microphone permission denied.');
429
+ turn('error');
430
+ expect(health('microphone')).toBe(BAD);
431
+ expect(row('microphone')).toBe('Error');
432
+ turn('idle');
433
+ expect(health('microphone')).toBe('');
434
+ });
346
435
  });
347
436
 
348
437
  describe('AudioSettings Capture card', () => {
@@ -412,33 +501,75 @@ describe('AudioSettings Capture card', () => {
412
501
 
413
502
  let releaseCards: () => void = () => undefined;
414
503
 
415
- it('ACC-CTRL-107-AUTOCONNECT: the switch reads the setting, saves it and follows a later change', async () => {
504
+ it('ACC-CTRL-107-AUTOCONNECT: the standard switch starts disabled, reads the setting, saves a click and follows a later change', async () => {
416
505
  registries([]);
506
+ const load = settingRegistry.load.bind(settingRegistry);
507
+ let release: () => void = () => undefined;
508
+ jest.spyOn(settingRegistry, 'load').mockReturnValueOnce(
509
+ new Promise<ISettingRegistry.ISettings>(resolve => {
510
+ release = () => resolve(load(PLUGIN_ID));
511
+ })
512
+ );
417
513
  await create(IDLE, { registry: settingRegistry });
418
- const settings = await settingRegistry.load(PLUGIN_ID);
514
+
515
+ // The switch is the standard JupyterLab one and waits, disabled, for the bind.
516
+ const button = switchInput();
517
+ expect(button.className).toBe('jp-switch');
518
+ expect(button.getAttribute('role')).toBe('switch');
519
+ expect(button.getAttribute('aria-checked')).toBe('false');
520
+ expect(button.getAttribute('aria-label')).toBe('Auto-connect on startup');
521
+ expect(button.disabled).toBe(true);
522
+ expect(
523
+ button.querySelector('.jp-switch-track')!.getAttribute('aria-hidden')
524
+ ).toBe('true');
525
+ expect(root().querySelector('.jp-switch-label')).toBeNull();
526
+
527
+ release();
528
+ await until(() => switchInput().disabled === false);
529
+ const settings = await load(PLUGIN_ID);
419
530
  await until(() =>
420
531
  settingDescription().textContent!.includes(
421
532
  'Start microphone capture automatically'
422
533
  )
423
534
  );
535
+ expect(switchInput().getAttribute('aria-label')).toBe(
536
+ 'Auto-connect on startup'
537
+ );
538
+ expect(switchInput().getAttribute('aria-checked')).toBe('false');
424
539
 
425
- expect(switchInput().disabled).toBe(false);
426
- expect(switchInput().checked).toBe(false);
427
- switchInput().checked = true;
428
- switchInput().dispatchEvent(new Event('change'));
540
+ // A click paints the next value and saves it.
541
+ switchInput().click();
542
+ expect(switchInput().getAttribute('aria-checked')).toBe('true');
429
543
  await until(() => settings.get('autoConnect').composite === true);
430
544
  expect(settings.get('autoConnect').composite).toBe(true);
431
545
 
432
- // A later change, as the Settings Editor makes it, updates the switch.
546
+ // A later change, as the Settings Editor makes it, repaints the switch.
433
547
  await settings.set('autoConnect', false);
434
- await until(() => switchInput().checked === false);
435
- expect(switchInput().checked).toBe(false);
548
+ await until(() => switchInput().getAttribute('aria-checked') === 'false');
549
+ expect(switchInput().getAttribute('aria-checked')).toBe('false');
436
550
 
437
551
  // The switch starts no capture now.
438
552
  expect(model.enable).not.toHaveBeenCalled();
439
553
  expect(model.toggle).not.toHaveBeenCalled();
440
554
  });
441
555
 
556
+ it('ACC-CTRL-107-AUTOCONNECT: a refused save repaints the switch from the setting', async () => {
557
+ registries([]);
558
+ await create(IDLE, { registry: settingRegistry });
559
+ const settings = await settingRegistry.load(PLUGIN_ID);
560
+ await until(() => switchInput().disabled === false);
561
+
562
+ jest
563
+ .spyOn(settingRegistry, 'set')
564
+ .mockRejectedValueOnce(new Error('refused'));
565
+ switchInput().click();
566
+ expect(switchInput().getAttribute('aria-checked')).toBe('true');
567
+
568
+ await until(() => switchInput().getAttribute('aria-checked') === 'false');
569
+ expect(switchInput().getAttribute('aria-checked')).toBe('false');
570
+ expect(settings.get('autoConnect').composite).toBe(false);
571
+ });
572
+
442
573
  it('ACC-CTRL-106-BOARD: the Status bar card lists each pill item or No items', async () => {
443
574
  registries([]);
444
575
  await create(IDLE, { registry: settingRegistry });
package/src/settings.ts CHANGED
@@ -17,8 +17,11 @@ const ROWS = {
17
17
  delivery: 'Captured audio goes to'
18
18
  } as const;
19
19
 
20
- /** The audio extension's state, one plain phrase per row of the Audio system card. */
21
- export type AudioSummary = Record<keyof typeof ROWS, string>;
20
+ /** The audio extension's state: one row per card row, with its phrase and health colour. */
21
+ export type AudioSummary = Record<
22
+ keyof typeof ROWS,
23
+ { text: string; health: 'ok' | 'bad' | '' }
24
+ >;
22
25
 
23
26
  /**
24
27
  * The Audio Settings tab (ACC-CTRL-99): a page on the main-area background with the
@@ -49,13 +52,18 @@ export class AudioSettings extends Widget {
49
52
  'Microphone capture and playback. Changes save immediately.';
50
53
  head.append(title, subtitle);
51
54
 
55
+ const body = document.createElement('div');
56
+ body.className = 'jp-AudioSettings-body';
57
+
52
58
  // The board is a widget so the cards another extension adds are attached with the tab.
53
59
  const board = new Panel();
54
60
  board.addClass('jp-AudioSettings-board');
55
61
  const layout = new PanelLayout();
56
62
  this.layout = layout;
57
63
  layout.addWidget(board);
58
- this.node.insertBefore(head, board.node);
64
+ // The page head and the body are the page's only children; the body scrolls under the head.
65
+ this.node.append(head, body);
66
+ body.appendChild(board.node);
59
67
 
60
68
  // The extension cards join the board before the plain DOM tiles, so the board layout's
61
69
  // single widget index stays correct; the core cards are then inserted before it.
@@ -100,23 +108,19 @@ export class AudioSettings extends Widget {
100
108
  this._settingDescription = document.createElement('p');
101
109
  this._settingDescription.className = 'jp-AudioSettings-settingDescription';
102
110
  settingText.append(this._settingTitle, this._settingDescription);
103
- const switchLabel = document.createElement('label');
104
- switchLabel.className = 'jp-AudioSettings-switch';
105
- this._switch = document.createElement('input');
106
- this._switch.type = 'checkbox';
107
- this._switch.className = 'jp-AudioSettings-switchInput';
111
+ // The standard JupyterLab switch (jp-switch); the shipped theme CSS draws the track.
112
+ this._switch = document.createElement('button');
113
+ this._switch.className = 'jp-switch';
114
+ this._switch.setAttribute('role', 'switch');
115
+ this._switch.setAttribute('aria-checked', 'false');
116
+ this._switch.setAttribute('aria-label', 'Auto-connect on startup');
108
117
  this._switch.disabled = true;
109
- this._switch.addEventListener('change', this._onToggle);
110
- const track = document.createElement('span');
111
- track.className = 'jp-AudioSettings-switchTrack';
112
- const thumb = document.createElement('span');
113
- thumb.className = 'jp-AudioSettings-switchThumb';
114
- track.appendChild(thumb);
115
- const switchText = document.createElement('span');
116
- switchText.className = 'jp-AudioSettings-switchLabel';
117
- switchText.textContent = 'Auto-connect on startup';
118
- switchLabel.append(this._switch, track, switchText);
119
- setting.append(settingText, switchLabel);
118
+ this._switch.addEventListener('click', this._onToggle);
119
+ const track = document.createElement('div');
120
+ track.className = 'jp-switch-track';
121
+ track.setAttribute('aria-hidden', 'true');
122
+ this._switch.appendChild(track);
123
+ setting.append(settingText, this._switch);
120
124
  captureBody.appendChild(setting);
121
125
  captureCard.appendChild(captureBody);
122
126
  board.node.insertBefore(captureCard, insert);
@@ -156,7 +160,7 @@ export class AudioSettings extends Widget {
156
160
  footer.className = 'jp-AudioSettings-footer';
157
161
  footer.textContent =
158
162
  'Raw values: Settings Editor > Audio Capture and Audio Settings Panel.';
159
- this.node.appendChild(footer);
163
+ body.appendChild(footer);
160
164
 
161
165
  this._status.summaryChanged.connect(this._onSummary);
162
166
  this._status.disposed.connect(this._onStatusDisposed);
@@ -227,27 +231,32 @@ export class AudioSettings extends Widget {
227
231
  if (!this._settings) {
228
232
  return;
229
233
  }
230
- this._switch.checked = this._settings.get('autoConnect').composite === true;
234
+ this._switch.setAttribute(
235
+ 'aria-checked',
236
+ String(this._settings.get('autoConnect').composite === true)
237
+ );
231
238
  this._renderToolbar(this._settings);
232
239
  }
233
240
 
234
- /** Toggling saves the setting; it starts no capture. */
241
+ /** Clicking saves the next value; it starts no capture. */
235
242
  private _onToggle = (): void => {
243
+ const next = this._switch.getAttribute('aria-checked') !== 'true';
244
+ this._switch.setAttribute('aria-checked', String(next));
236
245
  if (!this._settings) {
237
246
  return;
238
247
  }
239
- void this._settings
240
- .set('autoConnect', this._switch.checked)
241
- .catch(reason => {
242
- console.error(
243
- 'Failed to save jupyterlab_audio_extension settings.',
244
- reason
248
+ void this._settings.set('autoConnect', next).catch(reason => {
249
+ console.error(
250
+ 'Failed to save jupyterlab_audio_extension settings.',
251
+ reason
252
+ );
253
+ if (this._settings) {
254
+ this._switch.setAttribute(
255
+ 'aria-checked',
256
+ String(this._settings.get('autoConnect').composite === true)
245
257
  );
246
- if (this._settings) {
247
- this._switch.checked =
248
- this._settings.get('autoConnect').composite === true;
249
- }
250
- });
258
+ }
259
+ });
251
260
  };
252
261
 
253
262
  /** One read-only row per pill item, or the empty state. */
@@ -289,10 +298,20 @@ export class AudioSettings extends Widget {
289
298
  };
290
299
 
291
300
  private _writeSummary(summary: AudioSummary): void {
292
- for (const [key, text] of Object.entries(summary)) {
301
+ for (const [key, entry] of Object.entries(summary)) {
293
302
  const value = this.node.querySelector(`[data-vc-summary="${key}"]`);
294
- if (value && value.textContent !== text) {
295
- value.textContent = text;
303
+ if (value) {
304
+ if (value.textContent !== entry.text) {
305
+ value.textContent = entry.text;
306
+ }
307
+ value.classList.toggle(
308
+ 'jp-AudioSettings-value-ok',
309
+ entry.health === 'ok'
310
+ );
311
+ value.classList.toggle(
312
+ 'jp-AudioSettings-value-bad',
313
+ entry.health === 'bad'
314
+ );
296
315
  }
297
316
  }
298
317
  }
@@ -307,7 +326,7 @@ export class AudioSettings extends Widget {
307
326
 
308
327
  private _status: VoiceStatus;
309
328
  private _settings: ISettingRegistry.ISettings | null = null;
310
- private _switch: HTMLInputElement;
329
+ private _switch: HTMLButtonElement;
311
330
  private _settingTitle: HTMLDivElement;
312
331
  private _settingDescription: HTMLParagraphElement;
313
332
  private _toolbarList: HTMLDivElement;
package/src/status.ts CHANGED
@@ -179,29 +179,46 @@ export class VoiceStatus extends Widget {
179
179
  super.dispose();
180
180
  }
181
181
 
182
- /** The audio extension's state, one plain phrase per row of the Audio system card. */
182
+ /** The audio extension's state, one entry per row of the Audio system card. */
183
183
  summary(): AudioSummary {
184
184
  const state = this._model.state;
185
185
  return {
186
- audioSystem:
187
- this._sink === 'missing'
188
- ? 'Unavailable'
189
- : this._sink === 'off'
190
- ? 'Shut down'
191
- : state === 'streaming' || this._mode === 'playing'
192
- ? 'In use'
193
- : 'Ready',
194
- microphone:
195
- state === 'error'
196
- ? this._model.message || CAPTURE_WORDS.error
197
- : CAPTURE_WORDS[state],
198
- playback:
199
- this._sink === 'missing'
200
- ? SINK_UNAVAILABLE
201
- : this._sink === 'off'
202
- ? SINK_SHUT_DOWN
203
- : PLAYER_WORDS[this._mode],
204
- delivery: this._capture || 'Unknown'
186
+ audioSystem: {
187
+ text:
188
+ this._sink === 'missing'
189
+ ? 'Unavailable'
190
+ : this._sink === 'off'
191
+ ? 'Shut down'
192
+ : state === 'streaming' || this._mode === 'playing'
193
+ ? 'In use'
194
+ : 'Ready',
195
+ health:
196
+ this._sink === 'missing' ? 'bad' : this._sink === 'off' ? '' : 'ok'
197
+ },
198
+ microphone: {
199
+ text:
200
+ state === 'error'
201
+ ? this._model.message || CAPTURE_WORDS.error
202
+ : CAPTURE_WORDS[state],
203
+ health: state === 'error' ? 'bad' : state === 'streaming' ? 'ok' : ''
204
+ },
205
+ playback: {
206
+ text:
207
+ this._sink === 'missing'
208
+ ? SINK_UNAVAILABLE
209
+ : this._sink === 'off'
210
+ ? SINK_SHUT_DOWN
211
+ : PLAYER_WORDS[this._mode],
212
+ health:
213
+ this._sink === 'missing'
214
+ ? 'bad'
215
+ : this._sink === 'off'
216
+ ? ''
217
+ : this._mode === 'playing'
218
+ ? 'ok'
219
+ : ''
220
+ },
221
+ delivery: { text: this._capture || 'Unknown', health: '' }
205
222
  };
206
223
  }
207
224
 
package/style/base.css CHANGED
@@ -145,32 +145,51 @@
145
145
  /* The Audio Settings tab the gear opens (ACC-CTRL-99): a page on the main-area background. */
146
146
  .jp-AudioSettings {
147
147
  box-sizing: border-box;
148
+ display: flex;
149
+ flex-direction: column;
148
150
  height: 100%;
149
- padding: 20px 28px;
150
- overflow: auto;
151
+ overflow: hidden;
151
152
  background: var(--jp-layout-color0);
152
153
  color: var(--jp-ui-font-color1);
153
154
  font-family: var(--jp-ui-font-family);
154
155
  font-size: var(--jp-ui-font-size1);
155
156
  }
156
157
 
157
- .jp-AudioSettings-pageHead,
158
+ .jp-AudioSettings-pageHead {
159
+ flex: none;
160
+ display: flex;
161
+ align-items: baseline;
162
+ flex-wrap: wrap;
163
+ gap: 2px 10px;
164
+ padding: 8px 16px;
165
+ background: var(--jp-layout-color1);
166
+ border-bottom: 1px solid var(--jp-border-color1);
167
+ }
168
+
158
169
  .jp-AudioSettings-footer {
159
170
  max-width: 900px;
160
- margin-left: auto;
161
- margin-right: auto;
171
+ margin: 16px auto 0;
162
172
  }
163
173
 
164
174
  .jp-AudioSettings-title {
165
- margin: 0 0 2px;
175
+ margin: 0;
166
176
  color: var(--jp-ui-font-color0);
167
- font-size: 20px;
177
+ font-size: 16px;
168
178
  font-weight: 600;
169
179
  }
170
180
 
171
181
  .jp-AudioSettings-subtitle {
172
- margin: 0 0 14px;
182
+ margin: 0;
173
183
  color: var(--jp-ui-font-color2);
184
+ font-size: var(--jp-ui-font-size1);
185
+ }
186
+
187
+ /* The body scrolls under the fixed page head. */
188
+ .jp-AudioSettings-body {
189
+ flex: 1 1 auto;
190
+ min-height: 0;
191
+ overflow: auto;
192
+ padding: 16px 16px 20px;
174
193
  }
175
194
 
176
195
  /* The board: two columns on a wide tab, one on a narrow one (ACC-CTRL-106-BOARD). */
@@ -224,6 +243,14 @@
224
243
  overflow-wrap: anywhere;
225
244
  }
226
245
 
246
+ .jp-AudioSettings-value-ok {
247
+ color: var(--jp-Audio-value-ok);
248
+ }
249
+
250
+ .jp-AudioSettings-value-bad {
251
+ color: var(--jp-Audio-value-bad);
252
+ }
253
+
227
254
  .jp-AudioSettings-value[data-vc-summary='delivery'] {
228
255
  font-family: var(--jp-code-font-family);
229
256
  }
@@ -248,10 +275,6 @@
248
275
  margin: 8px 0 0;
249
276
  }
250
277
 
251
- .jp-AudioSettings-footer {
252
- margin: 16px auto 0;
253
- }
254
-
255
278
  .jp-AudioSettings-empty {
256
279
  padding: 8px 10px;
257
280
  border: 1px dashed var(--jp-border-color1);
@@ -278,86 +301,33 @@
278
301
  max-width: 62ch;
279
302
  }
280
303
 
281
- /* The auto-connect switch: a real checkbox, visually hidden, with a track and a thumb. */
282
- .jp-AudioSettings-switch {
283
- position: relative;
284
- flex: none;
285
- display: block;
286
- width: 34px;
287
- height: 18px;
288
- margin-top: 2px;
289
- cursor: pointer;
290
- }
291
-
292
- .jp-AudioSettings-switchInput {
293
- position: absolute;
294
- width: 1px;
295
- height: 1px;
296
- overflow: hidden;
297
- clip-path: inset(50%);
298
- white-space: nowrap;
299
- }
300
-
301
- .jp-AudioSettings-switchTrack {
302
- display: block;
303
- box-sizing: border-box;
304
- width: 34px;
305
- height: 18px;
306
- border-radius: 2px;
307
- background: var(--jp-border-color1);
308
- }
309
-
310
- .jp-AudioSettings-switchThumb {
311
- display: block;
312
- width: 14px;
313
- height: 14px;
314
- margin: 2px;
315
- border-radius: 2px;
316
- background: var(--jp-ui-font-color0);
317
- }
318
-
319
- .jp-AudioSettings-switchInput:checked + .jp-AudioSettings-switchTrack {
320
- background: var(--jp-brand-color1);
321
- }
322
-
323
- .jp-AudioSettings-switchInput:checked
324
- + .jp-AudioSettings-switchTrack
325
- .jp-AudioSettings-switchThumb {
326
- transform: translateX(16px);
327
- }
328
-
329
- .jp-AudioSettings-switchInput:focus-visible + .jp-AudioSettings-switchTrack {
330
- outline: 2px solid var(--jp-brand-color1);
331
- outline-offset: 2px;
332
- }
333
-
334
- .jp-AudioSettings-switchInput:disabled + .jp-AudioSettings-switchTrack {
304
+ /* The standard switch dims until the setting loads and binds it. */
305
+ .jp-AudioSettings .jp-switch:disabled {
335
306
  opacity: 0.5;
336
- }
337
-
338
- .jp-AudioSettings-switch:has(.jp-AudioSettings-switchInput:disabled) {
339
307
  cursor: default;
340
308
  }
341
309
 
342
- .jp-AudioSettings-switchLabel {
343
- position: absolute;
344
- width: 1px;
345
- height: 1px;
346
- overflow: hidden;
347
- clip-path: inset(50%);
348
- white-space: nowrap;
310
+ /* The standard switch has no hover fill: the track alone shows the control. */
311
+ .jp-AudioSettings .jp-switch:hover {
312
+ background-color: transparent;
349
313
  }
350
314
 
351
315
  /*
352
316
  The live microphone green of the active lamp and the streaming microphone, one per theme
353
317
  (ACC-CTRL-102-LIVECOLOR); another extension reads it without importing this package.
318
+
319
+ The Audio system state words, one pair per theme, so both clear WCAG AA on the card.
354
320
  */
355
321
  :root {
356
322
  --jp-Audio-live-color: #6dbd81;
323
+ --jp-Audio-value-ok: var(--jp-success-color2);
324
+ --jp-Audio-value-bad: var(--md-red-200);
357
325
  }
358
326
 
359
327
  :root:has(> body[data-jp-theme-light='true']) {
360
328
  --jp-Audio-live-color: #347443;
329
+ --jp-Audio-value-ok: var(--jp-success-color0);
330
+ --jp-Audio-value-bad: var(--jp-error-color0);
361
331
  }
362
332
 
363
333
  /* The audio-system lamp leads the pill: a 6 px disc, filled passive grey when ready. */