pinokiod 8.3.23 → 8.3.28

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.
@@ -4598,7 +4598,7 @@
4598
4598
  if (ui.intent === 'create_app') {
4599
4599
  setSubmissionState(ui, {
4600
4600
  title: 'Creating app...',
4601
- description: 'Setting up the new app and preparing the dev page.',
4601
+ description: 'Setting up the new app and preparing its page.',
4602
4602
  label: files.length ? 'Uploading files' : 'Preparing app workspace',
4603
4603
  detail: files.length
4604
4604
  ? 'Uploading your files, then creating the app folder and first git commit.'
@@ -4612,7 +4612,7 @@
4612
4612
  if (ui.intent === 'create_app') {
4613
4613
  setSubmissionState(ui, {
4614
4614
  title: 'Creating app...',
4615
- description: 'Setting up the new app and preparing the dev page.',
4615
+ description: 'Setting up the new app and preparing its page.',
4616
4616
  label: 'Preparing app workspace',
4617
4617
  detail: 'Creating the app folder, starter files, and first git commit. This usually takes a few seconds.',
4618
4618
  confirmLabel: 'Working...'
@@ -4635,8 +4635,8 @@
4635
4635
  }
4636
4636
  setSubmissionState(ui, {
4637
4637
  title: 'Opening app...',
4638
- description: 'The app is ready. Opening the dev page now.',
4639
- label: 'Opening dev page',
4638
+ description: 'The app is ready. Opening it now.',
4639
+ label: 'Opening the app',
4640
4640
  detail: 'Redirecting to the new app.',
4641
4641
  confirmLabel: 'Opening...'
4642
4642
  });
@@ -195,7 +195,6 @@ function initUrlDropdown(config = {}) {
195
195
  if (!projectCtx) return '';
196
196
  const modes = [
197
197
  { key: 'run', label: 'Run', icon: 'fa-solid fa-circle-play', suffix: '' },
198
- { key: 'dev', label: 'Dev', icon: 'fa-solid fa-code', suffix: '/dev' },
199
198
  { key: 'files', label: 'Files', icon: 'fa-solid fa-file-lines', suffix: '/files' },
200
199
  ].filter((mode) => includeFiles || mode.key !== 'files');
201
200
 
@@ -0,0 +1,28 @@
1
+ // The app's Git page: every repository in the app's folder, with its changes,
2
+ // history, fork and publish, all on one page. Opened as a tab on the app page.
3
+ //
4
+ // GET /pinokio/git/:name ?publish=1 opens on the Publish section
5
+ const fs = require("fs")
6
+
7
+ module.exports = function registerGitPageRoutes(app, options = {}) {
8
+ const kernel = options.kernel
9
+ const getPageContext = options.getPageContext || (() => ({}))
10
+
11
+ app.get("/pinokio/git/:name", async (req, res) => {
12
+ const name = req.params.name
13
+ const cwd = kernel.path("api", name)
14
+ // an app is one folder directly inside the apps folder, nothing else
15
+ const valid = name && name !== "." && name !== ".." && !/[\\/\0]/.test(name)
16
+ const stat = valid ? await fs.promises.stat(cwd).catch(() => null) : null
17
+ if (!stat || !stat.isDirectory()) {
18
+ res.status(404).send("App not found")
19
+ return
20
+ }
21
+ res.render("git_page", {
22
+ ...getPageContext(req),
23
+ name,
24
+ cwd,
25
+ publish: req.query && req.query.publish === "1",
26
+ })
27
+ })
28
+ }
@@ -8441,6 +8441,9 @@ body.dark .pinokio-custom-terminal-header {
8441
8441
  <div class="app-header-info-popover-title"><%=config.title || name%></div>
8442
8442
  <div class="app-header-info-popover-description"><%=config.description || 'No description provided.'%></div>
8443
8443
  </div>
8444
+ <button type="button" id="edit" class="app-header-info-popover-row-action" style="flex: 0 0 auto" title="Edit metadata" aria-label="Edit metadata" data-app-info-reveal-path>
8445
+ <i class="fa-solid fa-pen-to-square" aria-hidden="true"></i>
8446
+ </button>
8444
8447
  </div>
8445
8448
  <div class="app-header-info-popover-meta">
8446
8449
  <% if (appInfoFolderPath) { %>
@@ -8567,16 +8570,6 @@ body.dark .pinokio-custom-terminal-header {
8567
8570
  <aside id='app-sidebar' class='active'>
8568
8571
  <div class='menu-container'>
8569
8572
  <div class='menu-scroller'>
8570
- <div class='workspace-mode-switch' role="tablist" aria-label="Workspace mode">
8571
- <a class="workspace-mode-link <%=type === 'run' ? 'selected' : ''%>" href="<%=run_tab%>" role="tab" aria-selected="<%=type === 'run' ? 'true' : 'false'%>">
8572
- <i class="fa-solid fa-circle-play"></i>
8573
- <span>Run</span>
8574
- </a>
8575
- <a class="workspace-mode-link <%=type === 'browse' || type === 'files' ? 'selected' : ''%>" href="<%=dev_tab%>" role="tab" aria-selected="<%=type === 'browse' || type === 'files' ? 'true' : 'false'%>">
8576
- <i class="fa-solid fa-terminal"></i>
8577
- <span>Dev</span>
8578
- </a>
8579
- </div>
8580
8573
  <%if (type==='browse') { %>
8581
8574
  <div class='m n system' data-type="n">
8582
8575
  <a id='devtab' data-mode="refresh" target="<%=dev_link%>" href="<%=dev_link%>" class="btn frame-link <%=dev_initial_tab === 'files' ? '' : 'selected'%>" data-index="10">
@@ -8643,6 +8636,20 @@ body.dark .pinokio-custom-terminal-header {
8643
8636
  <div class='flexible'></div>
8644
8637
  </div>
8645
8638
  </button>
8639
+ <button type='button' class='btn header-item' data-mobile-proxy="#files-tab" data-mobile-close-menu="true" aria-label="Files">
8640
+ <div class='tab'>
8641
+ <i class="fa-solid fa-file-lines menu-action-leading-icon"></i>
8642
+ <div class='display'>Files</div>
8643
+ <div class='flexible'></div>
8644
+ </div>
8645
+ </button>
8646
+ <button type='button' class='btn header-item' data-mobile-proxy="#git-tab" data-mobile-close-menu="true" aria-label="Git">
8647
+ <div class='tab'>
8648
+ <i class="fa-brands fa-git-alt menu-action-leading-icon"></i>
8649
+ <div class='display'>Git</div>
8650
+ <div class='flexible'></div>
8651
+ </div>
8652
+ </button>
8646
8653
  <% } %>
8647
8654
  <% if (registryEnabled) { %>
8648
8655
  <button type='button' class='btn header-item mobile-nav-community' data-mobile-proxy="#community-mode-toggle" data-mobile-panel="feed" data-mobile-close-menu="true" aria-pressed="false" aria-label="Project feed">
@@ -8696,13 +8703,22 @@ body.dark .pinokio-custom-terminal-header {
8696
8703
  <span class='logs-new-badge hidden' id='logs-new-badge'>New</span>
8697
8704
  </div>
8698
8705
  </button>
8699
- <button type='button' id='sidebar-open-explorer' class="btn header-item" data-filepath="<%=path%>" data-tippy-content="Open in File Explorer">
8706
+ <% if (type === 'run') { %>
8707
+ <a id='files-tab' target="pinokio-files" href="<%=editor_tab%>" class="btn header-item frame-link" data-index="files" data-static="retain">
8700
8708
  <div class='tab'>
8701
- <i class="fa-solid fa-folder-open menu-action-leading-icon"></i>
8702
- <div class='display'>File Explorer</div>
8709
+ <i class="fa-solid fa-file-lines menu-action-leading-icon"></i>
8710
+ <div class='display'>Files</div>
8703
8711
  <div class='flexible'></div>
8704
8712
  </div>
8705
- </button>
8713
+ </a>
8714
+ <a id='git-tab' target="app-git" href="/pinokio/git/<%=encodeURIComponent(name)%><%=typeof git_initial_publish !== 'undefined' && git_initial_publish ? '?publish=1' : ''%>" class="btn header-item frame-link" data-index="git" data-static="retain">
8715
+ <div class='tab'>
8716
+ <i class="fa-brands fa-git-alt menu-action-leading-icon"></i>
8717
+ <div class='display'>Git</div>
8718
+ <div class='flexible'></div>
8719
+ </div>
8720
+ </a>
8721
+ <% } %>
8706
8722
  <% if (typeof vault_enabled !== 'undefined' && vault_enabled) { %>
8707
8723
  <% const vaultAutomaticMode = typeof vault_automatic_mode === 'string' && vault_automatic_mode === 'manual' ? 'manual' : 'automatic' %>
8708
8724
  <% const vaultGlobalScanReady = typeof vault_global_scan_ready !== 'undefined' && vault_global_scan_ready === true %>
@@ -9057,6 +9073,9 @@ body.dark .pinokio-custom-terminal-header {
9057
9073
  <div class="app-header-info-popover-title"><%=config.title || name%></div>
9058
9074
  <div class="app-header-info-popover-description"><%=config.description || 'No description provided.'%></div>
9059
9075
  </div>
9076
+ <button type="button" class="app-header-info-popover-row-action" style="flex: 0 0 auto" title="Edit metadata" aria-label="Edit metadata" data-app-info-reveal-path onclick="document.getElementById('edit').click()">
9077
+ <i class="fa-solid fa-pen-to-square" aria-hidden="true"></i>
9078
+ </button>
9060
9079
  </div>
9061
9080
  <div class="app-header-info-popover-meta">
9062
9081
  <% if (appInfoFolderPath) { %>
@@ -9136,16 +9155,6 @@ body.dark .pinokio-custom-terminal-header {
9136
9155
  <div>Pinokio</div>
9137
9156
  </div>
9138
9157
  <div class='mobile-menu-fallback__body'>
9139
- <div class='workspace-mode-switch' role="tablist" aria-label="Workspace mode">
9140
- <a class="workspace-mode-link <%=type === 'run' ? 'selected' : ''%>" href="<%=run_tab%>" role="tab" aria-selected="<%=type === 'run' ? 'true' : 'false'%>">
9141
- <i class="fa-solid fa-circle-play"></i>
9142
- <span>Run</span>
9143
- </a>
9144
- <a class="workspace-mode-link <%=type === 'browse' || type === 'files' ? 'selected' : ''%>" href="<%=dev_tab%>" role="tab" aria-selected="<%=type === 'browse' || type === 'files' ? 'true' : 'false'%>">
9145
- <i class="fa-solid fa-terminal"></i>
9146
- <span>Dev</span>
9147
- </a>
9148
- </div>
9149
9158
  <div class='mobile-drawer-actions' aria-label="App actions">
9150
9159
  <button type='button' class='btn header-item mobile-nav-logs' data-mobile-proxy="#fs-status .fs-logs .fs-status-btn" data-mobile-panel="logs" data-mobile-close-menu="true" aria-pressed="false" aria-label="Logs">
9151
9160
  <div class='tab'>
@@ -12179,10 +12188,10 @@ const rerenderMenuSection = (container, html) => {
12179
12188
  e.preventDefault()
12180
12189
  e.stopPropagation()
12181
12190
  await FSEditor({
12182
- title: `<%=config.title%>`,
12183
- description: `<%=config.description%>`,
12184
- old_path: `<%=name%>`,
12185
- icon: `<%=config.icon%>`,
12191
+ title: <%-JSON.stringify(config.title || '').replace(/</g, '\\u003c')%>,
12192
+ description: <%-JSON.stringify(config.description || '').replace(/</g, '\\u003c')%>,
12193
+ old_path: <%-JSON.stringify(name)%>,
12194
+ icon: <%-JSON.stringify(config.icon || '').replace(/</g, '\\u003c')%>,
12186
12195
  <% if (config.iconpath) { %>
12187
12196
  iconpath: `<%-JSON.stringify(config.iconpath).slice(1, -1)%>`,
12188
12197
  <% } %>
@@ -17313,11 +17322,8 @@ document.addEventListener("DOMContentLoaded", () => {
17313
17322
  focusConfirm: false,
17314
17323
  }).then((result) => {
17315
17324
  if (result && result.isConfirmed) {
17316
- const params = new URLSearchParams(window.location.search || "")
17317
- params.set("pinokio.publish", "1")
17318
- const qs = params.toString()
17319
- const url = `/p/${encodeURIComponent(workspace)}/dev${qs ? `?${qs}` : ""}`
17320
- window.location.href = url
17325
+ // the app page, not launching the app, on its Git tab's Publish section
17326
+ window.location.href = `/v/${encodeURIComponent(workspace)}?git_publish=1`
17321
17327
  }
17322
17328
  })
17323
17329
  return
@@ -20039,5 +20045,8 @@ document.addEventListener("DOMContentLoaded", () => {
20039
20045
  }
20040
20046
  })()
20041
20047
  </script>
20048
+ <% if (type === 'run') { %>
20049
+ <script src="/app-run-tabs.js" data-tab="<%=typeof run_initial_tab === 'string' ? run_initial_tab : ''%>"></script>
20050
+ <% } %>
20042
20051
  </body>
20043
20052
  </html>
@@ -10,6 +10,7 @@
10
10
  <link href="/css/brands.min.css" rel="stylesheet">
11
11
  <link href="/style.css" rel="stylesheet">
12
12
  <link href="/files-app/app.css" rel="stylesheet">
13
+ <link href="/files-app/toolbar.css" rel="stylesheet">
13
14
  <link href="/filepond.min.css" rel="stylesheet" />
14
15
  <link href="/filepond-plugin-image-preview.min.css" rel="stylesheet" />
15
16
  <link href="/filepond-plugin-image-edit.min.css" rel="stylesheet" />
@@ -20,47 +21,30 @@
20
21
  </head>
21
22
  <body class="<%=theme%>" data-agent="<%=agent%>">
22
23
  <div class="files-app" data-theme="<%=theme%>">
23
- <header class="files-app__header">
24
- <button class="files-app__mobile-back" id="files-app-mobile-back" type="button" aria-label="Back to files">
25
- <i class="fa-solid fa-chevron-left" aria-hidden="true"></i>
26
- <span>Files</span>
27
- </button>
28
- <div class="files-app__header-title">
29
- <% if (workspaceMeta && workspaceMeta.icon) { %>
30
- <img class="files-app__header-icon" src="<%= workspaceMeta.icon %>" onerror="this.onerror=null; this.src='/pinokio-black.png'" alt="Project icon" />
31
- <% } else { %>
32
- <i class="fa-regular fa-folder-open"></i>
33
- <% } %>
34
- <div class="files-app__header-text">
35
- <div class="files-app__header-primary"><%= (workspaceMeta && workspaceMeta.title) ? workspaceMeta.title : workspaceLabel %></div>
36
- <% if (workspaceMeta && workspaceMeta.description) { %>
37
- <div class="files-app__header-desc"><%= workspaceMeta.description %></div>
38
- <% } %>
39
- <div class="files-app__header-sub"><%=workspaceRoot%></div>
40
- </div>
41
- </div>
42
- <div class="files-app__header-actions">
43
- <button class="files-app__meta" type="button" id="files-app-edit-metadata">
44
- <i class="fa-solid fa-pen-to-square"></i>
45
- <span>Edit metadata</span>
46
- </button>
47
- <button class="files-app__save" id="files-app-save" disabled>
48
- <i class="fa-solid fa-floppy-disk"></i>
49
- <span>Save</span>
50
- </button>
51
- </div>
52
- </header>
53
24
  <section class="files-app__body">
54
25
  <aside class="files-app__sidebar" aria-label="Project files">
55
26
  <div class="files-app__sidebar-scroll" id="files-app-tree">
56
27
  </div>
57
28
  </aside>
58
29
  <main class="files-app__main">
59
- <button class="files-app__sidebar-toggle" id="files-app-toggle-sidebar" type="button" aria-controls="files-app-tree" aria-expanded="true">
60
- <span class="sr-only">Hide files</span>
61
- <i class="fa-solid fa-chevron-left" aria-hidden="true"></i>
62
- </button>
63
- <div class="files-app__tabs" id="files-app-tabs" role="tablist" aria-label="Open files"></div>
30
+ <div class="files-app__tabbar">
31
+ <button class="files-app__sidebar-toggle" id="files-app-toggle-sidebar" type="button" aria-controls="files-app-tree" aria-expanded="true" title="Hide files" aria-label="Hide files">
32
+ <i class="fa-solid fa-chevron-left" aria-hidden="true"></i>
33
+ </button>
34
+ <button class="files-app__mobile-back" id="files-app-mobile-back" type="button" aria-label="Back to files">
35
+ <i class="fa-solid fa-chevron-left" aria-hidden="true"></i>
36
+ <span>Files</span>
37
+ </button>
38
+ <div class="files-app__tabs" id="files-app-tabs" role="tablist" aria-label="Open files"></div>
39
+ <button class="files-app__meta" type="button" id="files-app-open-explorer" data-root="<%=workspaceRoot%>">
40
+ <i class="fa-solid fa-folder-open"></i>
41
+ <span>File Explorer</span>
42
+ </button>
43
+ <button class="files-app__save" id="files-app-save" title="Save" aria-label="Save" disabled>
44
+ <i class="fa-solid fa-floppy-disk"></i>
45
+ <span>Save</span>
46
+ </button>
47
+ </div>
64
48
  <div class="files-app__editor" id="files-app-editor" role="presentation"></div>
65
49
  <div class="files-app__status" id="files-app-status" role="status" aria-live="polite"></div>
66
50
  </main>
@@ -79,6 +63,7 @@
79
63
  <script src="/ace/ace.js"></script>
80
64
  <script src="/ace/ext-modelist.js"></script>
81
65
  <script src="/files-app/app.js"></script>
66
+ <script src="/files-app/open-folder.js"></script>
82
67
  <script>
83
68
  window.FilesApp.init({
84
69
  workspace: <%- JSON.stringify(workspaceSlug) %>,
@@ -0,0 +1,21 @@
1
+ <html>
2
+ <head>
3
+ <title>Git</title>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
6
+ <link href="/css/fontawesome.min.css" rel="stylesheet">
7
+ <link href="/css/solid.min.css" rel="stylesheet">
8
+ <link href="/css/regular.min.css" rel="stylesheet">
9
+ <link href="/css/brands.min.css" rel="stylesheet">
10
+ <link href="/style.css" rel="stylesheet"/>
11
+ <% if (agent === "electron") { %>
12
+ <link href="/electron.css" rel="stylesheet"/>
13
+ <% } %>
14
+ <link href="/git-page.css" rel="stylesheet"/>
15
+ <script src="/timeago.min.js"></script>
16
+ </head>
17
+ <body class='<%=theme%> git-page' data-agent="<%=agent%>">
18
+ <div class='git-page-root' id='git-page' data-name="<%=name%>" data-cwd="<%=cwd%>" data-publish="<%= publish ? '1' : '' %>"></div>
19
+ <script src="/git-page.js"></script>
20
+ </body>
21
+ </html>
@@ -76,13 +76,6 @@ const homeActionsShareExternalReadyUrls = item && Array.isArray(item.external_re
76
76
  <i class='fa-regular fa-eye' aria-hidden='true'></i>
77
77
  <span>Open without launching</span>
78
78
  </button>
79
- <button type='button' class='home-mode-command home-browse' data-src='<%= item.dev_url %>'>
80
- <i class='fa-solid fa-code' aria-hidden='true'></i>
81
- <span>Open dev mode</span>
82
- <% if (item.terminal_online_count > 0) { %>
83
- <span class='home-actions-count'><%= item.terminal_online_count %> online</span>
84
- <% } %>
85
- </button>
86
79
  <% if (homeActionsSettingsHref) { %>
87
80
  <a class='home-mode-command' href='<%= homeActionsSettingsHref %>'>
88
81
  <i class='fa-solid fa-gear' aria-hidden='true'></i>
@@ -0,0 +1,60 @@
1
+ // "Open in a new tab" in a session window's menu opens a top-level Pinokio
2
+ // window that shows the session's own page. In the desktop app only that
3
+ // top-level page has the strip a window is dragged by.
4
+ const assert = require('node:assert/strict')
5
+ const fs = require('node:fs')
6
+ const path = require('node:path')
7
+ const test = require('node:test')
8
+ const { JSDOM, ResourceLoader } = require('jsdom')
9
+
10
+ const script = (name) => fs.readFileSync(path.resolve(__dirname, '../server/public', name), 'utf8')
11
+
12
+ class TerminalPage extends ResourceLoader {
13
+ fetch() {
14
+ return Promise.resolve(Buffer.from('<!doctype html><div id="terminal"><textarea></textarea></div>'))
15
+ }
16
+ }
17
+
18
+ test('"Open in a new tab" opens the session\'s page inside a top-level window', { timeout: 3000 }, async (t) => {
19
+ const dom = new JSDOM('<!doctype html><body class="main-sidebar-page"><header class="navheader"><h1><div class="flexible"></div></h1></header></body>', {
20
+ url: 'http://127.0.0.1:42000/home',
21
+ resources: new TerminalPage(),
22
+ runScripts: 'outside-only',
23
+ pretendToBeVisual: true,
24
+ })
25
+ t.after(() => dom.window.close())
26
+ const { window } = dom
27
+ const { document } = window
28
+ window.innerWidth = 1760
29
+ window.matchMedia = () => ({ matches: false, addEventListener() {}, removeEventListener() {} })
30
+ window.Element.prototype.getBoundingClientRect = () => ({ left: 300, top: 8, right: 900, bottom: 40, width: 600, height: 32 })
31
+ window.sessionStorage.setItem('pinokio.agentBar.dock.tabs', JSON.stringify([
32
+ { key: '/plugin/codex/pinokio.js|/home/brain|s1', kind: 'agent', open: true, z: 1 },
33
+ ]))
34
+ window.fetch = async (url) => {
35
+ if (url === '/info/shells') {
36
+ return { ok: true, json: async () => [{ id: 'agent', group: '/home/plugin/codex/pinokio.js?cwd=/home/brain&session=s1' }] }
37
+ }
38
+ return { ok: true, json: async () => ({ menu: [{ href: '/pinokio/run/plugin/codex/pinokio.js', title: 'Codex', default: true }] }) }
39
+ }
40
+ const opened = new Promise((resolve) => { window.open = (...args) => resolve(args) })
41
+ for (const name of ['agent-bar.js', 'agent-bar-panel.js']) window.eval(script(name))
42
+ await window.PinokioAgentBar.ready
43
+ let row = null
44
+ for (let i = 0; i < 50 && !row; i += 1) {
45
+ await new Promise((resolve) => window.setTimeout(resolve, 10))
46
+ row = Array.from(document.querySelectorAll('.agent-dock__more-row')).find((item) => item.textContent === 'Open in a new tab')
47
+ }
48
+ assert.ok(row, 'the session window has the row')
49
+ row.click()
50
+
51
+ const [address, target] = await opened
52
+ assert.equal(target, '_blank')
53
+ const top = new URL(address, window.location.href)
54
+ assert.equal(top.pathname, '/', 'the new window is the top-level page')
55
+ const shown = new URL(top.searchParams.get('page'), window.location.href)
56
+ assert.equal(shown.pathname, '/pinokio/run/plugin/codex/pinokio.js')
57
+ assert.equal(shown.searchParams.get('cwd'), '/home/brain')
58
+ assert.equal(shown.searchParams.get('session'), 's1')
59
+ assert.equal(shown.searchParams.get('chrome'), 'full')
60
+ })
@@ -0,0 +1,84 @@
1
+ // The app page's Files and Git tabs: which tab a page opens on, where old Dev
2
+ // addresses go, and the Git page's address.
3
+ const assert = require('node:assert/strict')
4
+ const fs = require('node:fs')
5
+ const os = require('node:os')
6
+ const path = require('node:path')
7
+ const test = require('node:test')
8
+
9
+ const AppRunTabs = require('../server/lib/app_run_tabs')
10
+ const registerGitPageRoutes = require('../server/routes/git_page')
11
+
12
+ const tempDir = () => fs.mkdtempSync(path.join(os.tmpdir(), 'pinokio-tabs-'))
13
+ const launcherMenu = { menu: [{ default: true, text: 'Start', href: 'start.js' }] }
14
+ const htmlOnly = { menu: [{ default: true, text: 'index.html', href: '/asset/api/demo/index.html' }] }
15
+ const listingOnly = { menu: [{ default: true, text: 'Project Files', href: '/files/api/demo' }] }
16
+
17
+ const page = (query) => ({ params: { name: 'demo' }, query })
18
+
19
+ test('a link that asks for a tab is recognised, so the page opens without launching the app', () => {
20
+ assert.equal(AppRunTabs.chosen(page({ pinokio_tab: 'files' })), 'files')
21
+ assert.equal(AppRunTabs.chosen(page({ pinokio_tab: 'git' })), 'git')
22
+ assert.equal(AppRunTabs.chosen(page({ git_publish: '1' })), 'git')
23
+ assert.equal(AppRunTabs.chosen(page({ pinokio_tab: 'other' })), '')
24
+ assert.equal(AppRunTabs.chosen(page({})), '')
25
+ })
26
+
27
+ test('the page opens on the tab that was asked for', () => {
28
+ assert.deepEqual(AppRunTabs.locals(page({ pinokio_tab: 'git' }), 'run', launcherMenu), { run_initial_tab: 'git', git_initial_publish: false })
29
+ assert.deepEqual(AppRunTabs.locals(page({ git_publish: '1' }), 'run', launcherMenu), { run_initial_tab: 'git', git_initial_publish: true })
30
+ assert.deepEqual(AppRunTabs.locals(page({}), 'run', launcherMenu), { run_initial_tab: '', git_initial_publish: false })
31
+ })
32
+
33
+ test('a folder with only an index.html keeps opening on that page', () => {
34
+ assert.equal(AppRunTabs.locals(page({}), 'run', htmlOnly).run_initial_tab, '')
35
+ })
36
+
37
+ test('a folder with nothing of its own to show opens on Files', () => {
38
+ assert.equal(AppRunTabs.locals(page({}), 'run', listingOnly).run_initial_tab, 'files')
39
+ // unless the link came for something else: a plugin to start, Settings from Home, a file to reveal
40
+ for (const query of [{ plugin: '/plugin/x' }, { pinokio_home_select: '{}' }, { reveal: 'a.bin' }]) {
41
+ assert.equal(AppRunTabs.locals(page(query), 'run', listingOnly).run_initial_tab, '')
42
+ }
43
+ // or its launcher chose a page of its own, even one under the same address
44
+ const docs = { menu: [{ default: true, text: 'Docs', href: '/files/api/demo/docs' }] }
45
+ assert.equal(AppRunTabs.locals(page({}), 'run', docs).run_initial_tab, '')
46
+ })
47
+
48
+ test('old Dev addresses go to the app page without launching, on the matching tab', () => {
49
+ const redirect = (query, tab) => {
50
+ let target = ''
51
+ AppRunTabs.redirectDev({ params: { name: 'my app' }, query }, { redirect: (url) => { target = url } }, tab)
52
+ return target
53
+ }
54
+ assert.equal(redirect({}), '/v/my%20app')
55
+ assert.equal(redirect({}, 'files'), '/v/my%20app?pinokio_tab=files')
56
+ assert.equal(redirect({ pinokio_dev_tab: 'files' }), '/v/my%20app?pinokio_tab=files')
57
+ assert.equal(redirect({ 'pinokio.publish': '1' }), '/v/my%20app?git_publish=1')
58
+ assert.equal(redirect({ plugin: '/plugin/x', prompt: 'hi' }), '/v/my%20app?plugin=%2Fplugin%2Fx&prompt=hi')
59
+ assert.equal(redirect({ prompt: ['first', 'second'] }), '/v/my%20app?prompt=first&prompt=second')
60
+ })
61
+
62
+ test('the Git page only opens for a folder directly inside the apps folder', async () => {
63
+ const apiRoot = tempDir()
64
+ fs.mkdirSync(path.join(apiRoot, 'demo'))
65
+ let handler
66
+ registerGitPageRoutes({ get: (route, fn) => { handler = fn } }, {
67
+ kernel: { path: (first, ...rest) => path.join(apiRoot, ...rest) },
68
+ getPageContext: () => ({ theme: 'light' }),
69
+ })
70
+ const open = async (name) => {
71
+ const result = {}
72
+ await handler({ params: { name }, query: {} }, {
73
+ status: (code) => { result.status = code; return { send: () => {} } },
74
+ render: (view, locals) => { result.view = view; result.locals = locals },
75
+ })
76
+ return result
77
+ }
78
+ const ok = await open('demo')
79
+ assert.equal(ok.view, 'git_page')
80
+ assert.equal(ok.locals.cwd, path.join(apiRoot, 'demo'))
81
+ for (const name of ['..', '.', 'missing', 'a/b', 'a\\b']) {
82
+ assert.equal((await open(name)).status, 404, name)
83
+ }
84
+ })
@@ -372,7 +372,7 @@ test("static guard: open without launching is not wired to launch requirement st
372
372
 
373
373
  assert.match(homeActionModal, /Open without launching/)
374
374
  assert.match(homeActionModal, /class='home-mode-command home-browse' data-src='<%= item\.view_url %>'/)
375
- assert.match(homeActionModal, /Open dev mode/)
375
+ assert.doesNotMatch(homeActionModal, /Open dev mode/)
376
376
  assert.match(homeActionModal, /const homeActionsAppId = item && \(item\.uri \|\| item\.path \|\| item\.name\)/)
377
377
  assert.match(homeActionModal, /pinokio_home_select: JSON\.stringify/)
378
378
  assert.match(homeActionModal, /target: "env-settings"/)
@@ -94,7 +94,7 @@ test("split URL modal uses inline submit and omits Files actions", async () => {
94
94
  assert.equal(content.classList.contains("split-mode"), true)
95
95
  assert.equal(inlineSubmit.textContent, "Open in pane")
96
96
  assert.ok(actions)
97
- assert.deepEqual([...new Set(modeLabels)].sort(), ["Dev", "Run"])
97
+ assert.deepEqual([...new Set(modeLabels)].sort(), ["Run"])
98
98
  assert.doesNotMatch(content.textContent, /\bFiles\b/)
99
99
 
100
100
  const input = document.querySelector(".url-modal-input")