@stellarshenson/jupyterlab-audio-extension 1.0.2 → 1.0.5

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/lib/index.js CHANGED
@@ -64,7 +64,8 @@ const plugin = {
64
64
  execute: async (args) => {
65
65
  const settings = app.serviceManager.serverSettings;
66
66
  const response = await ServerConnection.makeRequest(URLExt.join(settings.baseUrl, 'jupyterlab-audio-extension', 'player'), { method: 'POST', body: JSON.stringify(args) }, settings);
67
- const state = await response.json();
67
+ // An error from outside the route (extension disabled, a proxy) has no JSON body.
68
+ const state = await response.json().catch(() => ({}));
68
69
  if (!response.ok) {
69
70
  throw new Error(state.message || `audio:player failed: HTTP ${response.status}`);
70
71
  }
package/lib/status.js CHANGED
@@ -237,7 +237,9 @@ export class VoiceStatus extends Widget {
237
237
  }
238
238
  async _request(action) {
239
239
  try {
240
- const response = await ServerConnection.makeRequest(URLExt.join(this._settings.baseUrl, 'jupyterlab-audio-extension', 'player'), { method: 'POST', body: JSON.stringify({ action }) }, this._settings);
240
+ const response = await ServerConnection.makeRequest(URLExt.join(this._settings.baseUrl, 'jupyterlab-audio-extension', 'player'
241
+ // A poll is not user activity: it must not hold off the server's idle shutdown.
242
+ ) + (action === 'status' ? '?no_track_activity=1' : ''), { method: 'POST', body: JSON.stringify({ action }) }, this._settings);
241
243
  if (!response.ok) {
242
244
  return; // a failed poll keeps the last state; the next poll retries
243
245
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stellarshenson/jupyterlab-audio-extension",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
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",
@@ -117,6 +117,19 @@ describe('audio:player', () => {
117
117
  commands.get(PLAYER).execute({ action: 'play', path: 'missing.wav' })
118
118
  ).rejects.toThrow('Cannot play missing.wav');
119
119
  });
120
+
121
+ it('DEF-PLAYER-20: an error with no JSON body rejects with the HTTP status', async () => {
122
+ jest
123
+ .spyOn(ServerConnection, 'makeRequest')
124
+ .mockResolvedValue(
125
+ new Response('<html>Not Found</html>', { status: 404 })
126
+ );
127
+ const { commands } = activate();
128
+
129
+ await expect(
130
+ commands.get(PLAYER).execute({ action: 'status' })
131
+ ).rejects.toThrow('audio:player failed: HTTP 404');
132
+ });
120
133
  });
121
134
 
122
135
  describe('Stop All Audio', () => {
@@ -562,6 +562,10 @@ describe('VoiceStatus polling', () => {
562
562
 
563
563
  jest.advanceTimersByTime(2000);
564
564
  expect(request).toHaveBeenCalledTimes(2);
565
+ // DEF-LIFE-19: a poll must not count as activity for the server's idle shutdown.
566
+ for (const [url] of request.mock.calls) {
567
+ expect(url).toBe(`${ROUTE}?no_track_activity=1`);
568
+ }
565
569
 
566
570
  widget.dispose();
567
571
  jest.advanceTimersByTime(4000);
package/src/index.ts CHANGED
@@ -98,7 +98,8 @@ const plugin: JupyterFrontEndPlugin<void> = {
98
98
  { method: 'POST', body: JSON.stringify(args) },
99
99
  settings
100
100
  );
101
- const state = await response.json();
101
+ // An error from outside the route (extension disabled, a proxy) has no JSON body.
102
+ const state = await response.json().catch(() => ({}));
102
103
  if (!response.ok) {
103
104
  throw new Error(
104
105
  state.message || `audio:player failed: HTTP ${response.status}`
package/src/status.ts CHANGED
@@ -283,7 +283,8 @@ export class VoiceStatus extends Widget {
283
283
  this._settings.baseUrl,
284
284
  'jupyterlab-audio-extension',
285
285
  'player'
286
- ),
286
+ // A poll is not user activity: it must not hold off the server's idle shutdown.
287
+ ) + (action === 'status' ? '?no_track_activity=1' : ''),
287
288
  { method: 'POST', body: JSON.stringify({ action }) },
288
289
  this._settings
289
290
  );