pinokiod 8.3.15 → 8.3.17

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.
Files changed (36) hide show
  1. package/package.json +1 -1
  2. package/server/index.js +8 -3
  3. package/server/lib/create_page_url.js +21 -0
  4. package/server/lib/session_files.js +248 -0
  5. package/server/public/agent-bar-app.js +28 -6
  6. package/server/public/agent-bar-compose.js +18 -9
  7. package/server/public/agent-bar-files.css +391 -0
  8. package/server/public/agent-bar-files.js +394 -0
  9. package/server/public/agent-bar-panel.js +104 -14
  10. package/server/public/explore-create-handoff.js +49 -0
  11. package/server/public/sidebar-create.css +23 -0
  12. package/server/public/style.css +114 -0
  13. package/server/public/terminal-settings-sheet.js +66 -0
  14. package/server/public/terminal-settings.js +6 -1
  15. package/server/views/app.ejs +2 -0
  16. package/server/views/bootstrap.ejs +1 -0
  17. package/server/views/editor.ejs +1 -0
  18. package/server/views/explore.ejs +2 -1
  19. package/server/views/init/index.ejs +1 -0
  20. package/server/views/install.ejs +1 -0
  21. package/server/views/layout.ejs +13 -0
  22. package/server/views/partials/main_sidebar.ejs +4 -0
  23. package/server/views/pro.ejs +1 -0
  24. package/server/views/prototype/index.ejs +1 -0
  25. package/server/views/shell.ejs +1 -0
  26. package/server/views/terminal.ejs +1 -0
  27. package/test/agent-bar-compose.test.js +45 -0
  28. package/test/agent-bar-files.test.js +276 -0
  29. package/test/agent-bar-keyboard.test.js +84 -0
  30. package/test/agent-bar-running.test.js +148 -0
  31. package/test/agent-bar-step-aside.test.js +72 -0
  32. package/test/create-page.test.js +207 -0
  33. package/test/layout-soft-keyboard.test.js +12 -0
  34. package/test/session-files.test.js +214 -0
  35. package/test/terminal-settings-font-size.test.js +47 -0
  36. package/test/terminal-settings-sheet.test.js +58 -0
@@ -0,0 +1,23 @@
1
+ /* The sidebar's Create entry: the first row, drawn as a button. It has a
2
+ hairline border and no fill, its plus and label are centred, and it sits 4px
3
+ above My Apps (3px here plus the section's 1px row gap). Its icon and text
4
+ are the sidebar's own at full strength; no colour is added. Selected, it
5
+ gets the fill and bold text every selected row gets. */
6
+ body.main-sidebar-page aside.main-sidebar .tab.main-sidebar-create,
7
+ aside.main-sidebar .tab.main-sidebar-create {
8
+ display: flex !important;
9
+ justify-content: center;
10
+ margin-bottom: 3px;
11
+ border: 1px solid rgba(15, 23, 42, 0.11) !important;
12
+ padding-left: 4px !important;
13
+ padding-right: 4px !important;
14
+ color: var(--pinokio-sidebar-tab-active-color) !important;
15
+ }
16
+ body.dark.main-sidebar-page aside.main-sidebar .tab.main-sidebar-create,
17
+ body.dark aside.main-sidebar .tab.main-sidebar-create {
18
+ border-color: rgba(255, 255, 255, 0.13) !important;
19
+ }
20
+ body.main-sidebar-page aside.main-sidebar .tab.main-sidebar-create i,
21
+ aside.main-sidebar .tab.main-sidebar-create i {
22
+ color: var(--pinokio-sidebar-icon-active) !important;
23
+ }
@@ -2404,6 +2404,120 @@ body.dark .terminal-config-menu .terminal-config-input:focus {
2404
2404
  .terminal-config-open .terminal-config-menu {
2405
2405
  display: block;
2406
2406
  }
2407
+ /* The parts terminal-settings-sheet.js adds. They show on a phone only. */
2408
+ .terminal-config-sheet-head,
2409
+ .terminal-config-step,
2410
+ .terminal-config-fold {
2411
+ display: none;
2412
+ }
2413
+ .terminal-config-stepper {
2414
+ display: contents;
2415
+ }
2416
+ /* A phone: the menu is a sheet at the bottom of the screen. (The menu is placed
2417
+ by its own script and, in the agent panel, by the panel: the sheet's place
2418
+ has to win over both.) */
2419
+ @media (max-width: 768px) and (pointer: coarse) {
2420
+ html body > .terminal-config-menu.terminal-config-sheet {
2421
+ left: 0 !important;
2422
+ right: 0 !important;
2423
+ top: auto !important;
2424
+ bottom: 0 !important;
2425
+ max-height: 85%;
2426
+ padding: 0 16px calc(16px + env(safe-area-inset-bottom, 0px));
2427
+ border-radius: 16px 16px 0 0;
2428
+ border-width: 1px 0 0;
2429
+ box-sizing: border-box;
2430
+ overscroll-behavior: contain;
2431
+ }
2432
+ .terminal-config-sheet .terminal-config-title {
2433
+ display: none;
2434
+ }
2435
+ .terminal-config-sheet .terminal-config-sheet-head {
2436
+ display: flex;
2437
+ align-items: center;
2438
+ justify-content: space-between;
2439
+ position: sticky;
2440
+ top: 0;
2441
+ z-index: 1;
2442
+ padding: 14px 0 10px;
2443
+ background: inherit;
2444
+ }
2445
+ .terminal-config-sheet .terminal-config-sheet-title {
2446
+ font-size: 16px;
2447
+ font-weight: 600;
2448
+ }
2449
+ .terminal-config-sheet .terminal-config-sheet-done,
2450
+ .terminal-config-sheet .terminal-config-step,
2451
+ .terminal-config-sheet .terminal-config-fold {
2452
+ font: inherit;
2453
+ font-size: 16px;
2454
+ color: inherit;
2455
+ background: transparent;
2456
+ border: 1px solid rgba(128, 128, 128, 0.4);
2457
+ border-radius: 8px;
2458
+ min-height: 44px;
2459
+ cursor: pointer;
2460
+ touch-action: manipulation;
2461
+ }
2462
+ .terminal-config-sheet .terminal-config-sheet-done {
2463
+ padding: 0 16px;
2464
+ font-weight: 600;
2465
+ }
2466
+ .terminal-config-sheet .terminal-config-label,
2467
+ .terminal-config-sheet .terminal-config-note,
2468
+ .terminal-config-sheet .terminal-config-help {
2469
+ font-size: 13px;
2470
+ }
2471
+ /* 16px: smaller text in a field makes the phone zoom the page in on a tap */
2472
+ .terminal-config-sheet .terminal-config-select,
2473
+ .terminal-config-sheet .terminal-config-input {
2474
+ font-size: 16px;
2475
+ min-height: 44px;
2476
+ box-sizing: border-box;
2477
+ }
2478
+ .terminal-config-sheet .terminal-config-stepper {
2479
+ display: flex;
2480
+ gap: 8px;
2481
+ }
2482
+ .terminal-config-sheet .terminal-config-stepper .terminal-config-input {
2483
+ flex: 1;
2484
+ min-width: 0;
2485
+ text-align: center;
2486
+ }
2487
+ .terminal-config-sheet .terminal-config-step {
2488
+ display: block;
2489
+ flex: 0 0 56px;
2490
+ font-size: 22px;
2491
+ line-height: 1;
2492
+ }
2493
+ /* the theme colors are folded away until their row is pressed */
2494
+ .terminal-config-sheet .terminal-config-fold {
2495
+ display: flex;
2496
+ align-items: center;
2497
+ justify-content: space-between;
2498
+ padding: 0 12px;
2499
+ }
2500
+ .terminal-config-sheet .terminal-config-fold::after {
2501
+ content: '\203A';
2502
+ font-size: 20px;
2503
+ transform: rotate(90deg);
2504
+ }
2505
+ .terminal-config-sheet .terminal-config-fold[aria-expanded='true']::after {
2506
+ transform: rotate(-90deg);
2507
+ }
2508
+ .terminal-config-sheet .terminal-config-theme .terminal-config-subtitle,
2509
+ .terminal-config-sheet .terminal-config-theme:not(.terminal-config-theme--open) .terminal-config-help,
2510
+ .terminal-config-sheet .terminal-config-theme:not(.terminal-config-theme--open) .terminal-config-theme-grid {
2511
+ display: none;
2512
+ }
2513
+ .terminal-config-sheet .terminal-config-theme-row {
2514
+ grid-template-columns: minmax(0, 1fr) 36px minmax(0, 1fr) 44px;
2515
+ }
2516
+ .terminal-config-sheet .terminal-config-theme-clear,
2517
+ .terminal-config-sheet .terminal-config-reset {
2518
+ min-height: 44px;
2519
+ }
2520
+ }
2407
2521
  .terminal-keyboard-backdrop {
2408
2522
  position: fixed;
2409
2523
  inset: 0;
@@ -0,0 +1,66 @@
1
+ // The terminal appearance menu on a phone.
2
+ //
3
+ // terminal-settings.js builds the menu and decides everything it sets. This
4
+ // file adds three parts to it, which the stylesheet shows on a phone only (a
5
+ // narrow screen that is used with a finger) where the menu is a sheet at the
6
+ // bottom of the screen:
7
+ // - a head with a Done button,
8
+ // - a minus and a plus beside the font size,
9
+ // - a row that opens the theme colors, which start folded away.
10
+ // Everywhere else the parts are hidden and the menu is as it was.
11
+ (function (window, document) {
12
+ 'use strict';
13
+ const settings = window.PinokioTerminalSettings;
14
+ if (!settings) return;
15
+
16
+ function el(tag, className, text) {
17
+ const node = document.createElement(tag);
18
+ node.className = className;
19
+ if (tag === 'button') node.type = 'button';
20
+ if (text) node.textContent = text;
21
+ return node;
22
+ }
23
+
24
+ function dress(record) {
25
+ const { menu, sizeInput, themeSection } = record;
26
+ if (menu.classList.contains('terminal-config-sheet')) return;
27
+ menu.classList.add('terminal-config-sheet');
28
+
29
+ const head = el('div', 'terminal-config-sheet-head');
30
+ const done = el('button', 'terminal-config-sheet-done', 'Done');
31
+ done.addEventListener('click', () => record.close());
32
+ head.append(el('span', 'terminal-config-sheet-title', 'Terminal appearance'), done);
33
+ menu.insertBefore(head, menu.firstChild);
34
+
35
+ // one step from the size in use: the one set here, or else the terminal's own
36
+ const step = (by, label, sign) => {
37
+ const button = el('button', 'terminal-config-step', sign);
38
+ button.setAttribute('aria-label', label);
39
+ button.addEventListener('click', () => {
40
+ const size = Number(sizeInput.value || sizeInput.placeholder);
41
+ if (size) settings.updateFontSize(size + by);
42
+ });
43
+ return button;
44
+ };
45
+ const stepper = el('div', 'terminal-config-stepper');
46
+ sizeInput.parentNode.insertBefore(stepper, sizeInput);
47
+ stepper.append(step(-1, 'Smaller text', '\u2212'), sizeInput, step(1, 'Larger text', '+'));
48
+
49
+ const fold = el('button', 'terminal-config-fold', 'Theme colors');
50
+ fold.setAttribute('aria-expanded', 'false');
51
+ fold.addEventListener('click', () => {
52
+ fold.setAttribute('aria-expanded', String(themeSection.classList.toggle('terminal-config-theme--open')));
53
+ });
54
+ themeSection.insertBefore(fold, themeSection.firstChild);
55
+ }
56
+
57
+ // A menu is dressed as its button is pressed, before it opens: terminals, and
58
+ // their menus, can be made at any time.
59
+ document.addEventListener('click', (event) => {
60
+ const button = event.target.closest && event.target.closest('.terminal-config-button');
61
+ if (!button) return;
62
+ settings.menus.forEach((record) => {
63
+ if (record.button === button) dress(record);
64
+ });
65
+ }, true);
66
+ })(window, document);
@@ -1890,7 +1890,12 @@
1890
1890
  }
1891
1891
  });
1892
1892
 
1893
- const handleSizeChange = () => {
1893
+ const handleSizeChange = (event) => {
1894
+ // While typing, a number that is not a size yet ("1" on the way to "14")
1895
+ // is left as typed. Leaving the field settles it.
1896
+ if (event.type === 'input' && !sizeInput.validity.valid) {
1897
+ return;
1898
+ }
1894
1899
  const raw = sizeInput.value.trim();
1895
1900
  if (!raw) {
1896
1901
  settings.updateFontSize(null);
@@ -8378,6 +8378,8 @@ body.dark .pinokio-custom-terminal-header {
8378
8378
  <script src="/storage-sweep.js"></script>
8379
8379
  <script src="/agent-bar.js" data-agent-bar="true"></script>
8380
8380
  <script src="/agent-bar-app.js" data-agent-bar-app="true"></script>
8381
+ <link rel="stylesheet" href="/agent-bar-files.css">
8382
+ <script src="/agent-bar-files.js" data-agent-bar-files="true"></script>
8381
8383
  <link rel="stylesheet" href="/agent-bar-panel.css">
8382
8384
  <script src="/agent-bar-panel.js" data-agent-bar-panel="true"></script>
8383
8385
  <link rel="stylesheet" href="/agent-bar-attach.css">
@@ -89,6 +89,7 @@ body {
89
89
  <script src="/sweetalert2.js"></script>
90
90
  <script src="/Socket.js"></script>
91
91
  <script src="/terminal-settings.js"></script>
92
+ <script src="/terminal-settings-sheet.js"></script>
92
93
  <script>
93
94
  function isASCII(str) {
94
95
  for (let i = 0; i < str.length; i++) {
@@ -16,6 +16,7 @@
16
16
  <script src="/Socket.js"></script>
17
17
  <script src="/resizeSync.js"></script>
18
18
  <script src="/terminal-settings.js"></script>
19
+ <script src="/terminal-settings-sheet.js"></script>
19
20
  <script src="/pinokio-touch.js"></script>
20
21
  <script src="/common.js"></script>
21
22
  <script src="/he.js"></script>
@@ -181,7 +181,7 @@ body.dark .explore-url {
181
181
  <% } else { %>
182
182
  <iframe name="pinokio-explore" src="<%=discover_light%>" <%=agent === "electron" ? "no-referrer" : ""%> allow="fullscreen *;" allowfullscreen></iframe>
183
183
  <% } %>
184
- <%- include('partials/main_sidebar', { selected: 'explore' }) %>
184
+ <%- include('partials/main_sidebar', { selected: typeof sidebar_selected === 'string' ? sidebar_selected : 'explore' }) %>
185
185
  </main>
186
186
  <link href="/xterm.min.css" rel="stylesheet" />
187
187
  <link href="/css/fontawesome.min.css" rel="stylesheet">
@@ -192,6 +192,7 @@ body.dark .explore-url {
192
192
  <link href="/electron.css" rel="stylesheet"/>
193
193
  <% } %>
194
194
  <script src="/common.js"></script>
195
+ <script src="/explore-create-handoff.js"></script>
195
196
  <script>
196
197
  /*
197
198
  document.querySelector("form").addEventListener("submit", (e) => {
@@ -1500,6 +1500,7 @@ body.dark .ace-editor {
1500
1500
  <script src="/terminal-input.js"></script>
1501
1501
  <script src="/resizeSync.js"></script>
1502
1502
  <script src="/terminal-settings.js"></script>
1503
+ <script src="/terminal-settings-sheet.js"></script>
1503
1504
  <script src="/pinokio-touch.js"></script>
1504
1505
  <script src="/noty.js"></script>
1505
1506
  <script src="/notyq.js"></script>
@@ -502,6 +502,7 @@ body.install-page #terminal .xterm {
502
502
  <script src="/Socket.js"></script>
503
503
  <script src="/terminal-input.js"></script>
504
504
  <script src="/terminal-settings.js"></script>
505
+ <script src="/terminal-settings-sheet.js"></script>
505
506
  <script src="/pinokio-touch.js"></script>
506
507
  <!--
507
508
  <script src="/install.js"></script>
@@ -137,7 +137,9 @@
137
137
  const root = document.documentElement;
138
138
  let lastViewportHeight = null;
139
139
  let lastViewportTop = null;
140
+ const viewportHolds = new Set();
140
141
  const updateViewportHeight = () => {
142
+ if (viewportHolds.size) return;
141
143
  const viewport = window.visualViewport;
142
144
  // Pinch-zoomed in: the visible part is then a magnified piece of the page,
143
145
  // not what a keyboard leaves free. The panes fill the window, as they do
@@ -172,6 +174,17 @@
172
174
  }));
173
175
  };
174
176
 
177
+ // The Agent Bar in a pane protects its terminal tap from both levels of resize.
178
+ window.PinokioLayoutViewport = {
179
+ hold() {
180
+ const token = {};
181
+ viewportHolds.add(token);
182
+ return () => {
183
+ if (viewportHolds.delete(token) && !viewportHolds.size) updateViewportHeight();
184
+ };
185
+ },
186
+ };
187
+
175
188
  const resizeEvents = ['resize', 'orientationchange'];
176
189
  const boundUpdate = () => requestAnimationFrame(updateViewportHeight);
177
190
 
@@ -2,8 +2,11 @@
2
2
  const sidebarSelected = (typeof selected !== "undefined" && selected) ? String(selected) : "";
3
3
  %>
4
4
  <link rel="stylesheet" href="/agent-bar.css">
5
+ <link rel="stylesheet" href="/sidebar-create.css">
5
6
  <script src="/storage-sweep.js"></script>
6
7
  <script src="/agent-bar.js" data-agent-bar="true"></script>
8
+ <link rel="stylesheet" href="/agent-bar-files.css">
9
+ <script src="/agent-bar-files.js" data-agent-bar-files="true"></script>
7
10
  <link rel="stylesheet" href="/agent-bar-panel.css">
8
11
  <script src="/agent-bar-panel.js" data-agent-bar-panel="true"></script>
9
12
  <link rel="stylesheet" href="/agent-bar-attach.css">
@@ -18,6 +21,7 @@
18
21
  <aside class="main-sidebar" id="main-sidebar" aria-label="Primary navigation">
19
22
  <nav class="main-sidebar-nav" aria-label="Pinokio navigation">
20
23
  <div class='main-sidebar-section main-sidebar-section-actions' aria-label="Actions">
24
+ <a class='tab main-sidebar-create <%= sidebarSelected === 'create' ? 'selected' : '' %>' id='create' href="/home?mode=create"<% if (sidebarSelected === 'create') { %> aria-current="page"<% } %>><i class="fa-solid fa-plus main-sidebar-action-icon"></i><div class='caption'>Create</div></a>
21
25
  <a class='tab main-sidebar-action <%= sidebarSelected === 'home' ? 'selected' : '' %>' id='home' href="/home"<% if (sidebarSelected === 'home') { %> aria-current="page"<% } %>><i class="fa-solid fa-layer-group main-sidebar-action-icon"></i><div class='caption'>My Apps</div></a>
22
26
  <a class='tab main-sidebar-action <%= sidebarSelected === 'explore' ? 'selected' : '' %>' id='explore' href="/home?mode=explore"<% if (sidebarSelected === 'explore') { %> aria-current="page"<% } %>><i class="fa-solid fa-globe main-sidebar-action-icon"></i><div class='caption'>Explore</div></a>
23
27
  <details class="universal-create-menu">
@@ -17,6 +17,7 @@
17
17
  <script src="/terminal-input.js"></script>
18
18
  <script src="/resizeSync.js"></script>
19
19
  <script src="/terminal-settings.js"></script>
20
+ <script src="/terminal-settings-sheet.js"></script>
20
21
  <script src="/pinokio-touch.js"></script>
21
22
  <script src="/common.js"></script>
22
23
  <script src="/he.js"></script>
@@ -984,6 +984,7 @@ body.dark .appcanvas {
984
984
  <script src="/terminal-input.js"></script>
985
985
  <script src="/resizeSync.js"></script>
986
986
  <script src="/terminal-settings.js"></script>
987
+ <script src="/terminal-settings-sheet.js"></script>
987
988
  <script src="/pinokio-touch.js"></script>
988
989
  <script src="/noty.js"></script>
989
990
  <script src="/notyq.js"></script>
@@ -20,6 +20,7 @@
20
20
  <script src="/terminal_input_utils.js"></script>
21
21
  <script src="/terminal_key_caption.js"></script>
22
22
  <script src="/terminal-settings.js"></script>
23
+ <script src="/terminal-settings-sheet.js"></script>
23
24
  <script src="/pinokio-touch.js"></script>
24
25
  <script src="/common.js"></script>
25
26
  <script src="/run-task-save.js"></script>
@@ -20,6 +20,7 @@
20
20
  <script src="/terminal_input_utils.js"></script>
21
21
  <script src="/terminal_key_caption.js"></script>
22
22
  <script src="/terminal-settings.js"></script>
23
+ <script src="/terminal-settings-sheet.js"></script>
23
24
  <script src="/pinokio-touch.js"></script>
24
25
  <script src="/common.js"></script>
25
26
  <script src="/run-task-save.js"></script>
@@ -275,6 +275,47 @@ test('on a phone the cursor counts only with the keyboard up', async (t) => {
275
275
  assert.equal(p.input.placeholder, 'Type here…')
276
276
  })
277
277
 
278
+ test('in a layout pane the keyboard is measured on the layout\'s window', async (t) => {
279
+ const p = await page(t, { media: [PHONE, TOUCH] })
280
+ // the pane is cut to what the keyboard leaves: its own sizes show no keyboard
281
+ p.window.visualViewport = { height: 400, offsetTop: 0, addEventListener() {} }
282
+ p.window.innerHeight = 400
283
+ const layout = { innerHeight: 800, visualViewport: { height: 400 } }
284
+ Object.defineProperty(p.window, 'frameElement', { value: {}, configurable: true })
285
+ Object.defineProperty(p.window, 'parent', { value: layout, configurable: true })
286
+ await p.focus()
287
+ assert.equal(p.shape(), 'screen')
288
+ assert.equal(p.input.placeholder, '', 'the cursor is there')
289
+ layout.visualViewport.height = 800
290
+ p.window.dispatchEvent(new p.window.Event('resize'))
291
+ await settle(p.window)
292
+ assert.equal(p.input.placeholder, 'Ask Pinokio anything…')
293
+ })
294
+
295
+ test('on a phone the agent menu opens upward when the keyboard covers the room below', async (t) => {
296
+ // the window is 1000 tall; the agent button's lower edge is at 608
297
+ const hung = async (seen) => {
298
+ const p = await page(t, { media: [PHONE, TOUCH] })
299
+ p.window.visualViewport = { height: seen, offsetTop: 0, addEventListener() {} }
300
+ p.window.innerHeight = 1000
301
+ await p.focus()
302
+ assert.equal(p.shape(), 'screen')
303
+ p.root.querySelector('.agent-bar__agent').click()
304
+ await settle(p.window)
305
+ const menu = p.root.querySelector('.agent-bar__menu[data-menu="agent"]')
306
+ assert.equal(menu.hidden, false)
307
+ return menu.style
308
+ }
309
+ // no keyboard: there is room below the button
310
+ const down = await hung(1000)
311
+ assert.match(down.top, /px$/)
312
+ assert.equal(down.bottom, '')
313
+ // the keyboard covers everything under the button
314
+ const up = await hung(560)
315
+ assert.match(up.bottom, /px$/, 'it hangs above the button')
316
+ assert.equal(up.top, '', 'and not down under the keyboard')
317
+ })
318
+
278
319
  test('a press on the box, off its buttons, puts the cursor in the text', async (t) => {
279
320
  const p = await page(t, { search: '?universal&type=ask' })
280
321
  p.window.PinokioAgentBar.open({ type: 'ask' })
@@ -290,6 +331,10 @@ test('a press on the box, off its buttons, puts the cursor in the text', async (
290
331
  await settle(p.window)
291
332
  assert.equal(p.document.activeElement, p.input)
292
333
  assert.equal(p.shape(), 'centre')
334
+ // a message keeps its own press too: its words can be selected
335
+ const onNote = new p.window.Event('pointerdown', { bubbles: true, cancelable: true })
336
+ p.root.querySelector('.agent-bar__note').dispatchEvent(onNote)
337
+ assert.equal(onNote.defaultPrevented, false)
293
338
  // a button of the box keeps its own press
294
339
  p.input.blur()
295
340
  p.root.querySelector('.agent-bar__scope').click()