pinokiod 8.3.30 → 8.3.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pinokiod",
3
- "version": "8.3.30",
3
+ "version": "8.3.32",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -180,6 +180,16 @@ header.navheader.agent-bar-raised {
180
180
  background: var(--agent-bar-chip);
181
181
  color: var(--agent-bar-text);
182
182
  }
183
+ /* it opens a list: the same caret as the agent picker beside it */
184
+ .agent-bar__running::after {
185
+ content: "\f078";
186
+ font-family: "Font Awesome 7 Free";
187
+ font-weight: 900;
188
+ font-size: 8px;
189
+ line-height: 1;
190
+ margin-left: -2px;
191
+ opacity: 0.6;
192
+ }
183
193
  .agent-bar__dot {
184
194
  width: 7px;
185
195
  height: 7px;
@@ -8,7 +8,8 @@
8
8
  lastSize: null,
9
9
  initialSent: false,
10
10
  suppressNext: false,
11
- allowLocalFit: true
11
+ allowLocalFit: true,
12
+ lastShellSeen: null
12
13
  }
13
14
 
14
15
  function sameSize(cols, rows) {
@@ -76,6 +77,17 @@
76
77
  sendResize(state.term.cols, state.term.rows, true)
77
78
  state.initialSent = true
78
79
  },
80
+ // Called with the id of the shell whose output just arrived. A shell the
81
+ // page has not had output from before is sent the page's size: it was
82
+ // started at the size its run was launched with, which need not be the
83
+ // page's size now. Every step of a script run is a new shell. The id a
84
+ // page is handed when it connects is not counted: it can be the finished
85
+ // shell of an earlier run, and a size sent there reaches no one.
86
+ shellSeen: function(id) {
87
+ if (!id || id === state.lastShellSeen || !state.term) return
88
+ state.lastShellSeen = id
89
+ sendResize(state.term.cols, state.term.rows, true)
90
+ },
79
91
  handleResizePacket: function(packet) {
80
92
  if (!state.term || !packet || !packet.data) return
81
93
  const cols = packet.data.cols
@@ -578,10 +578,6 @@ document.addEventListener("click", async (e) => {
578
578
  socket.close()
579
579
  target.querySelector("i.fa-stop").className = "fa-solid fa-check"
580
580
  target.querySelector("i.fa-spin").classList.add("hidden")
581
- n.Noty({
582
- text: `stopped ${src}`,
583
- silent: true
584
- })
585
581
  setTimeout(() => {
586
582
  location.href = location.href
587
583
  }, 1000)
@@ -3803,10 +3803,6 @@ document.addEventListener("click", async (e) => {
3803
3803
  if (resultSpinIcon) {
3804
3804
  resultSpinIcon.classList.add("hidden")
3805
3805
  }
3806
- n.Noty({
3807
- text: `stopped`,
3808
- silent: true
3809
- })
3810
3806
  setTimeout(() => {
3811
3807
  location.href = location.href
3812
3808
  }, 500)
@@ -3825,10 +3821,6 @@ document.addEventListener("click", async (e) => {
3825
3821
  if (resultSpinIcon) {
3826
3822
  resultSpinIcon.classList.add("hidden")
3827
3823
  }
3828
- n.Noty({
3829
- text: `stopped ${src}`,
3830
- silent: true
3831
- })
3832
3824
  setTimeout(() => {
3833
3825
  if (typeof refreshHomeStatusOnce === "function") {
3834
3826
  const stoppedLine = target.closest(".home-app-line")
@@ -2174,10 +2174,6 @@ document.addEventListener("click", async (e) => {
2174
2174
  socket.close()
2175
2175
  target.querySelector("i.fa-stop").className = "fa-solid fa-check"
2176
2176
  target.querySelector("i.fa-spin").classList.add("hidden")
2177
- n.Noty({
2178
- text: `stopped`,
2179
- silent: true
2180
- })
2181
2177
  setTimeout(() => {
2182
2178
  location.href = location.href
2183
2179
  }, 500)
@@ -2193,10 +2189,6 @@ document.addEventListener("click", async (e) => {
2193
2189
  socket.close()
2194
2190
  target.querySelector("i.fa-stop").className = "fa-solid fa-check"
2195
2191
  target.querySelector("i.fa-spin").classList.add("hidden")
2196
- n.Noty({
2197
- text: `stopped ${src}`,
2198
- silent: true
2199
- })
2200
2192
  setTimeout(() => {
2201
2193
  location.href = location.href
2202
2194
  }, 500)
@@ -339,13 +339,10 @@ async function displayResults(config) {
339
339
  }
340
340
  } else if (packet.type === "stream") {
341
341
  // set the current shell id
342
- const previousShellId = shell_id
343
342
  if (packet.data.id) {
344
343
  shell_id = packet.data.id
345
344
  }
346
- if (!previousShellId && shell_id) {
347
- resizeSync.sendInitial()
348
- }
345
+ resizeSync.shellSeen(shell_id)
349
346
  if (packet.data.raw) {
350
347
  write(packet.data.raw)
351
348
  } else if (packet.data.json) {
@@ -689,9 +689,7 @@ document.addEventListener("DOMContentLoaded", async () => {
689
689
  if (!previousShellId) {
690
690
  this.flushPendingInput()
691
691
  }
692
- if (!previousShellId) {
693
- this.resizeSync.sendInitial()
694
- }
692
+ this.resizeSync.shellSeen(shell_id)
695
693
  notifyShellSession(shell_id)
696
694
  }
697
695
  if (packet.data.raw) {
@@ -1944,14 +1944,11 @@ document.addEventListener("DOMContentLoaded", async () => {
1944
1944
  refreshParent(packet)
1945
1945
  pluginTerminalDiscoveryRefresher.markActivity()
1946
1946
  // set the current shell id
1947
- const previousShellId = shell_id
1948
1947
  if (packet.data.id) {
1949
1948
  shell_id = packet.data.id
1950
1949
  this.flushPendingInput()
1951
1950
  }
1952
- if (!previousShellId && shell_id) {
1953
- this.resizeSync.sendInitial()
1954
- }
1951
+ this.resizeSync.shellSeen(shell_id)
1955
1952
  if (packet.data.raw) {
1956
1953
  this.writeBatched(packet.data.raw)
1957
1954
  } else if (packet.data.json) {
@@ -0,0 +1,100 @@
1
+ // The size a terminal page sends to its shell (server/public/resizeSync.js),
2
+ // driven with the packets a script's page gets, in the order it gets them.
3
+ const assert = require('node:assert/strict')
4
+ const fs = require('node:fs')
5
+ const path = require('node:path')
6
+ const test = require('node:test')
7
+ const vm = require('node:vm')
8
+
9
+ const source = fs.readFileSync(path.resolve(__dirname, '../server/public/resizeSync.js'), 'utf8')
10
+
11
+ // A page: its terminal, the id of the shell it believes it is on, and what it
12
+ // has sent. `connect` and `stream` do what the page does on those packets.
13
+ const page = (cols, rows) => {
14
+ const window = {}
15
+ vm.runInNewContext(source, { window })
16
+ const sent = []
17
+ const term = { cols, rows }
18
+ let shellId = null
19
+ const sync = window.PinokioResizeSync.create({
20
+ term,
21
+ socket: { run: (message) => sent.push({ id: message.id, cols: message.resize.cols, rows: message.resize.rows }) },
22
+ getShellId: () => shellId,
23
+ })
24
+ return {
25
+ term, sent, sync,
26
+ launch() { sync.reset() },
27
+ connect(shell) {
28
+ if (shell) shellId = shell
29
+ if (shellId) sync.sendInitial()
30
+ },
31
+ stream(id) {
32
+ if (id) shellId = id
33
+ sync.shellSeen(shellId)
34
+ },
35
+ }
36
+ }
37
+
38
+ test('the first shell of a first run is sent the page size', () => {
39
+ const p = page(120, 40)
40
+ p.launch()
41
+ p.connect(null) // nothing has run under this script before
42
+ p.stream('shell-1')
43
+ assert.deepEqual(p.sent, [{ id: 'shell-1', cols: 120, rows: 40 }])
44
+ })
45
+
46
+ test('a run started again sends its size to the new shell, not only to the finished one it was handed', () => {
47
+ const p = page(260, 61)
48
+ p.launch()
49
+ // the page is one column wider by the time the server answers
50
+ p.term.cols = 261
51
+ // the server hands over the last shell of the earlier run, which is finished
52
+ p.connect('old-run-last-shell')
53
+ assert.deepEqual(p.sent, [{ id: 'old-run-last-shell', cols: 261, rows: 61 }])
54
+ // output arrives from the new run's first shell, started at the launch size
55
+ p.stream('new-run-shell-1')
56
+ assert.deepEqual(p.sent[1], { id: 'new-run-shell-1', cols: 261, rows: 61 })
57
+ assert.equal(p.sent.length, 2)
58
+ })
59
+
60
+ test('every step of a run is a new shell and each is sent the size once', () => {
61
+ const p = page(100, 30)
62
+ p.launch()
63
+ p.connect(null)
64
+ p.stream('step-1')
65
+ p.stream('step-1')
66
+ p.stream('step-1')
67
+ // resized while step 1 runs: goes to step 1 as before
68
+ p.term.cols = 140
69
+ p.sync.sendResize(p.term.cols, p.term.rows)
70
+ p.stream('step-2')
71
+ p.stream('step-2')
72
+ p.stream('step-3')
73
+ assert.deepEqual(p.sent, [
74
+ { id: 'step-1', cols: 100, rows: 30 },
75
+ { id: 'step-1', cols: 140, rows: 30 },
76
+ { id: 'step-2', cols: 140, rows: 30 },
77
+ { id: 'step-3', cols: 140, rows: 30 },
78
+ ])
79
+ })
80
+
81
+ test('output with no shell id sends nothing', () => {
82
+ const p = page(100, 30)
83
+ p.launch()
84
+ p.stream(null)
85
+ assert.deepEqual(p.sent, [])
86
+ })
87
+
88
+ test('every page that shows a shell reports each shell it gets output from', () => {
89
+ // Each page's own handling of a stream packet is inline in its view. If the
90
+ // call goes from one, a shell started again under that page is back to
91
+ // having its size sent only to a finished shell.
92
+ for (const name of ['terminal.ejs', 'shell.ejs', 'pro.ejs']) {
93
+ const view = fs.readFileSync(path.resolve(__dirname, '../server/views', name), 'utf8')
94
+ const stream = view.slice(view.indexOf('packet.type === "stream"'))
95
+ const handler = stream.slice(0, stream.indexOf("packet.type === 'disconnect'"))
96
+ assert.ok(handler.length > 0, name)
97
+ assert.match(handler, /shell_id = packet\.data\.id[\s\S]*resizeSync\.shellSeen\(shell_id\)/, name)
98
+ assert.doesNotMatch(handler, /sendInitial/, name)
99
+ }
100
+ })