pinokiod 8.3.26 → 8.3.29
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/kernel/shell.js +3 -0
- package/kernel/shell_size.js +99 -0
- package/kernel/shells.js +2 -0
- package/package.json +1 -1
- package/server/index.js +7 -3
- package/server/lib/app_run_tabs.js +29 -17
- package/server/public/agent-bar-about.css +67 -0
- package/server/public/agent-bar-about.js +205 -0
- package/server/public/agent-bar-compose.js +4 -1
- package/server/public/agent-bar-modes.css +78 -0
- package/server/public/agent-bar-modes.js +97 -0
- package/server/public/agent-bar-panel.js +41 -13
- package/server/public/agent-bar.css +7 -5
- package/server/public/agent-bar.js +37 -9
- package/server/public/app-run-tabs.js +0 -10
- package/server/public/files-app/open-folder.js +58 -41
- package/server/public/files-app/toolbar.css +27 -5
- package/server/public/git-page.css +0 -1
- package/server/public/git-page.js +269 -149
- package/server/public/home-actions-menu.css +188 -0
- package/server/public/home-actions-menu.js +135 -0
- package/server/public/home-shell.css +121 -0
- package/server/public/home-shell.js +290 -0
- package/server/routes/git_page.js +4 -6
- package/server/views/app.ejs +19 -5
- package/server/views/file_browser.ejs +3 -4
- package/server/views/index.ejs +42 -3
- package/server/views/partials/home_action_modal.ejs +1 -1
- package/server/views/partials/home_ask_button.ejs +15 -0
- package/server/views/partials/home_shell_button.ejs +21 -0
- package/server/views/partials/main_sidebar.ejs +5 -1
- package/server/views/pre.ejs +1 -1
- package/test/agent-bar-about.test.js +238 -0
- package/test/agent-bar-modes.test.js +191 -0
- package/test/agent-bar-new-tab.test.js +60 -0
- package/test/app-git-files-tabs.test.js +84 -0
- package/test/home-actions-menu.test.js +187 -0
- package/test/home-shell.test.js +358 -0
- package/test/shell-size.test.js +166 -0
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// The size a new shell starts at (kernel/shell_size.js): a script run's record
|
|
2
|
+
// of the page size is kept current by resizes, and each step's shell takes its
|
|
3
|
+
// size from it right before its console is created. The shells here are real
|
|
4
|
+
// Shell objects with a real terminal state, but no console process is started.
|
|
5
|
+
const assert = require('node:assert/strict')
|
|
6
|
+
const test = require('node:test')
|
|
7
|
+
const { Terminal } = require('@xterm/headless')
|
|
8
|
+
|
|
9
|
+
const ShellSize = require('../kernel/shell_size')
|
|
10
|
+
const Shell = require('../kernel/shell')
|
|
11
|
+
const Shells = require('../kernel/shells')
|
|
12
|
+
|
|
13
|
+
// the temporary log lines are not what is being tested
|
|
14
|
+
const quiet = (t) => t.mock.method(console, 'log', () => {})
|
|
15
|
+
|
|
16
|
+
// A shell as it is partway through starting: it has taken the size its step
|
|
17
|
+
// was given and has its id, and its console does not exist yet.
|
|
18
|
+
const startingShell = (id, params) => {
|
|
19
|
+
const shell = new Shell({ bracketedPasteSupport: {} })
|
|
20
|
+
shell.id = id
|
|
21
|
+
shell.params = params
|
|
22
|
+
shell.cols = params.cols
|
|
23
|
+
shell.rows = params.rows
|
|
24
|
+
shell.vt = new Terminal({ allowProposedApi: true, cols: shell.cols, rows: shell.rows })
|
|
25
|
+
ShellSize.track(shell, params)
|
|
26
|
+
return shell
|
|
27
|
+
}
|
|
28
|
+
// what a step hands its shell: the size copied when the step began, and its run
|
|
29
|
+
const step = (record, extra = {}) => Object.assign({ cols: record.cols, rows: record.rows, $parent: { client: record } }, extra)
|
|
30
|
+
const sizeOf = (shell) => ({ cols: shell.cols, rows: shell.rows })
|
|
31
|
+
|
|
32
|
+
test('a later step starts at the size of the last resize, not the launch size', (t) => {
|
|
33
|
+
quiet(t)
|
|
34
|
+
const record = { cols: 244, rows: 60 }
|
|
35
|
+
const first = startingShell('run-1', step(record))
|
|
36
|
+
ShellSize.beforeSpawn(first)
|
|
37
|
+
assert.deepEqual(sizeOf(first), { cols: 244, rows: 60 })
|
|
38
|
+
|
|
39
|
+
ShellSize.resized('run-1', { cols: 245, rows: 61 }, first)
|
|
40
|
+
assert.deepEqual(record, { cols: 245, rows: 61 })
|
|
41
|
+
|
|
42
|
+
// the step's other commands reuse the step's parameters, copied before the resize
|
|
43
|
+
const second = startingShell('run-1', { cols: 244, rows: 60, $parent: { client: record } })
|
|
44
|
+
ShellSize.beforeSpawn(second)
|
|
45
|
+
assert.deepEqual(sizeOf(second), { cols: 245, rows: 61 })
|
|
46
|
+
// the terminal state the server keeps for the shell follows too
|
|
47
|
+
assert.deepEqual({ cols: second.vt.cols, rows: second.vt.rows }, { cols: 245, rows: 61 })
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
test('a resize with no shell running reaches the next step', (t) => {
|
|
51
|
+
quiet(t)
|
|
52
|
+
const record = { cols: 120, rows: 30 }
|
|
53
|
+
ShellSize.beforeSpawn(startingShell('run-2', step(record)))
|
|
54
|
+
|
|
55
|
+
// between two steps: the shell is gone, only its id is known
|
|
56
|
+
ShellSize.resized('run-2', { cols: 90, rows: 25 }, null)
|
|
57
|
+
|
|
58
|
+
const next = startingShell('run-2', { cols: 120, rows: 30, $parent: { client: record } })
|
|
59
|
+
ShellSize.beforeSpawn(next)
|
|
60
|
+
assert.deepEqual(sizeOf(next), { cols: 90, rows: 25 })
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
test('a resize that arrives while a shell is still setting up is not lost', (t) => {
|
|
64
|
+
quiet(t)
|
|
65
|
+
const record = { cols: 100, rows: 30 }
|
|
66
|
+
// the shell has taken its size and its id, and is not findable yet
|
|
67
|
+
const shell = startingShell('run-3', step(record))
|
|
68
|
+
|
|
69
|
+
ShellSize.resized('run-3', { cols: 80, rows: 24 }, null)
|
|
70
|
+
|
|
71
|
+
ShellSize.beforeSpawn(shell)
|
|
72
|
+
assert.deepEqual(sizeOf(shell), { cols: 80, rows: 24 })
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
test('a step that sets its own size keeps it', (t) => {
|
|
76
|
+
quiet(t)
|
|
77
|
+
const record = { cols: 200, rows: 50 }
|
|
78
|
+
const params = step(record, { client: { cols: 80, rows: 24 } })
|
|
79
|
+
// the size the shell works out for itself when the step names one
|
|
80
|
+
const shell = startingShell('run-4', Object.assign({}, params, { cols: 80, rows: 24 }))
|
|
81
|
+
|
|
82
|
+
ShellSize.beforeSpawn(shell)
|
|
83
|
+
assert.deepEqual(sizeOf(shell), { cols: 80, rows: 24 })
|
|
84
|
+
|
|
85
|
+
// it still belongs to the run: a resize of it is what later steps start at
|
|
86
|
+
ShellSize.resized('run-4', { cols: 150, rows: 40 }, shell)
|
|
87
|
+
assert.deepEqual(record, { cols: 150, rows: 40 })
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
test('a resize updates the run of the shell it reached, also when two runs share an id', (t) => {
|
|
91
|
+
quiet(t)
|
|
92
|
+
const older = { cols: 100, rows: 30 }
|
|
93
|
+
const newer = { cols: 100, rows: 30 }
|
|
94
|
+
const live = startingShell('shared', step(older))
|
|
95
|
+
// a second run starts a shell under the same id
|
|
96
|
+
startingShell('shared', step(newer))
|
|
97
|
+
|
|
98
|
+
ShellSize.resized('shared', { cols: 70, rows: 20 }, live)
|
|
99
|
+
|
|
100
|
+
assert.deepEqual(older, { cols: 70, rows: 20 })
|
|
101
|
+
assert.deepEqual(newer, { cols: 100, rows: 30 })
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
test('a long-lived shell still updates its run after many other shells have started', (t) => {
|
|
105
|
+
quiet(t)
|
|
106
|
+
const record = { cols: 100, rows: 30 }
|
|
107
|
+
const live = startingShell('server', step(record))
|
|
108
|
+
const other = { cols: 100, rows: 30 }
|
|
109
|
+
for (let i = 0; i < 600; i++) {
|
|
110
|
+
ShellSize.track({ id: `bulk-${i}` }, step(other))
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
ShellSize.resized('server', { cols: 133, rows: 33 }, live)
|
|
114
|
+
assert.deepEqual(record, { cols: 133, rows: 33 })
|
|
115
|
+
|
|
116
|
+
// ids with no shell running are remembered up to a limit, newest kept
|
|
117
|
+
ShellSize.resized('bulk-0', { cols: 50, rows: 10 }, null)
|
|
118
|
+
assert.deepEqual(other, { cols: 100, rows: 30 })
|
|
119
|
+
ShellSize.resized('bulk-599', { cols: 50, rows: 10 }, null)
|
|
120
|
+
assert.deepEqual(other, { cols: 50, rows: 10 })
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
test('a shell outside a script run is left alone', (t) => {
|
|
124
|
+
quiet(t)
|
|
125
|
+
for (const params of [{ cols: 132, rows: 43 }, { cols: 132, rows: 43, $parent: { path: '/x' } }]) {
|
|
126
|
+
const shell = startingShell('plain', params)
|
|
127
|
+
ShellSize.resized('plain', { cols: 10, rows: 10 }, null)
|
|
128
|
+
ShellSize.beforeSpawn(shell)
|
|
129
|
+
assert.deepEqual(sizeOf(shell), { cols: 132, rows: 43 })
|
|
130
|
+
// and a resize of it while running has no record to touch
|
|
131
|
+
ShellSize.resized('plain', { cols: 20, rows: 20 }, shell)
|
|
132
|
+
}
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
test('a record without a usable size is not applied, and a bad resize is not stored', (t) => {
|
|
136
|
+
quiet(t)
|
|
137
|
+
const empty = { source: 'desktop' }
|
|
138
|
+
const shell = startingShell('run-5', { cols: 100, rows: 30, $parent: { client: empty } })
|
|
139
|
+
ShellSize.beforeSpawn(shell)
|
|
140
|
+
assert.deepEqual(sizeOf(shell), { cols: 100, rows: 30 })
|
|
141
|
+
|
|
142
|
+
const record = { cols: 100, rows: 30 }
|
|
143
|
+
const live = startingShell('run-6', step(record))
|
|
144
|
+
for (const bad of [undefined, {}, { cols: 0, rows: 30 }, { cols: '80', rows: 24 }, { cols: 80.5, rows: 24 }, { cols: 80 }]) {
|
|
145
|
+
ShellSize.resized('run-6', bad, live)
|
|
146
|
+
ShellSize.resized('run-6', bad, null)
|
|
147
|
+
}
|
|
148
|
+
assert.deepEqual(record, { cols: 100, rows: 30 })
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
test('a resize sent to the shells reaches the running shell and its run', (t) => {
|
|
152
|
+
quiet(t)
|
|
153
|
+
const shells = new Shells({})
|
|
154
|
+
const record = { cols: 100, rows: 30 }
|
|
155
|
+
const live = startingShell('live', step(record))
|
|
156
|
+
shells.shells.push(live)
|
|
157
|
+
|
|
158
|
+
shells.resize({ id: 'live', resize: { cols: 111, rows: 31 } })
|
|
159
|
+
assert.deepEqual(sizeOf(live), { cols: 111, rows: 31 })
|
|
160
|
+
assert.deepEqual(record, { cols: 111, rows: 31 })
|
|
161
|
+
|
|
162
|
+
// between two steps no shell is running: the record still follows
|
|
163
|
+
shells.shells.length = 0
|
|
164
|
+
shells.resize({ id: 'live', resize: { cols: 99, rows: 29 } })
|
|
165
|
+
assert.deepEqual(record, { cols: 99, rows: 29 })
|
|
166
|
+
})
|