Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

fix(jev-sheets): Choose a file works in the desktop pane (#129)

Dee5ea5ba6a68fd
diff --git a/store/agents/jev-sheets/AGENTS.md b/store/agents/jev-sheets/AGENTS.md
index 74cdd571c..241008a41 100644
--- a/store/agents/jev-sheets/AGENTS.md
+++ b/store/agents/jev-sheets/AGENTS.md
@@ -17,8 +17,9 @@ second server.
## Your job, in this order
1. **Get the person's own data in.** Three ways in:
- - They **drop a file on the pane** or paste rows from a spreadsheet. The viewer saves the file in
- the workspace and points `sheet.json` at it by itself: `"source"` is already set when you look.
+ - They press **Choose a file** in the pane (its own chooser: recent spreadsheets, folders, or a
+ pasted path) or paste rows from a spreadsheet. The viewer saves the file in the workspace and
+ points `sheet.json` at it by itself: `"source"` is already set when you look.
- They give you a **path**. Copy the file into the workspace, then set `"source"`.
- They have a PDF, an old `.xls`, an export in an odd shape, or a folder of files. **Convert it for
them** into a `.csv` or `.jsonl` in the workspace, one row per item, and set `"source"`. Long
diff --git a/store/agents/jev-sheets/README.md b/store/agents/jev-sheets/README.md
index 9f2a7dc2a..fd989bba0 100644
--- a/store/agents/jev-sheets/README.md
+++ b/store/agents/jev-sheets/README.md
@@ -16,9 +16,13 @@ findings.
## Bring your file
-- **Drop it on the pane.** An Excel `.xlsx` file (its first sheet), or `.csv`, `.tsv`, `.json` or
- `.jsonl`, up to 32 MB and 10,000 rows.
-- **Paste rows** copied from Excel or Google Sheets, anywhere on the pane.
+- **Choose a file.** The pane has its own chooser, because the Harness desktop pane is a web view
+ that never opens the system file dialog. It lists your newest spreadsheets from Downloads, Desktop
+ and Documents, lets you browse your home folder, and takes a pasted path like
+ `~/Downloads/reviews.xlsx`. An Excel `.xlsx` file (its first sheet), or `.csv`, `.tsv`, `.json` or
+ `.jsonl`, up to 32 MB and 10,000 rows. macOS may ask once whether Harness may read those folders.
+- **Paste rows** copied from Excel or Google Sheets into the chooser's paste box.
+- In an ordinary browser you can also drop a file on the page.
- **Tell the agent where it is.** It copies the file in. It can also turn a PDF, a chat export or a
folder of notes into rows for you.
@@ -102,8 +106,9 @@ connect, every cell is asked again, for real.
question, not a finding. Reword it.
- Read the rows behind a number before you act on it. One click on the count shows them.
- It finds, counts and sorts. It is not legal, medical, financial or hiring advice.
-- The pane only accepts requests from itself: a web page on another site cannot upload a file, press
- a control or set a key.
+- The pane only accepts requests from itself: a web page on another site cannot upload a file, list
+ your folders, press a control or set a key. The chooser stays inside your home folder, never enters
+ a hidden folder such as `~/.ssh`, and reads nothing until you pick it.
## The sample, and the honest dial
@@ -130,13 +135,14 @@ jev-sheets/
viewer.sh setup.sh doctor.sh init-workspace.sh
viewer/
viewer.mjs the server: the sheet, uploads, the call pool, the cache, answers.csv, the verdict
+ picker.mjs the pane's own file chooser: recent files, folders, open by path, home folder only
source.mjs reads the person's file: Excel, CSV, TSV, JSON, JSONL
xlsx.mjs a small Excel reader: zip directory, shared strings, the first sheet
grammar.mjs the header parser, shared with the pane and check.mjs
mock.mjs the offline stand-in (reads only the row text and the question)
kit.mjs loopback server, same-origin guard, upload, download, key connect, SSE
index.html studio.css studio.js base.css jev-hud.js the pane
- test/viewer.test.mjs own-file.test.mjs xlsx.test.mjs count.test.mjs
+ test/viewer.test.mjs own-file.test.mjs picker.test.mjs xlsx.test.mjs count.test.mjs
```
## How it runs
diff --git a/store/agents/jev-sheets/skills/sheets/SKILL.md b/store/agents/jev-sheets/skills/sheets/SKILL.md
index 78e9337ab..a4c57b71d 100644
--- a/store/agents/jev-sheets/skills/sheets/SKILL.md
+++ b/store/agents/jev-sheets/skills/sheets/SKILL.md
@@ -37,8 +37,8 @@ In `sheet.json` a column is a header string or `{ "id": "team", "header": "Team:
## Working on the person's own file (the main job)
-1. **Get it in.** They drop it on the pane or paste rows, and `"source"` appears in `sheet.json` by
- itself. Or they give you a path: copy it into the workspace and set `"source"` (an Excel `.xlsx` works as it is: the first sheet is read). A PDF,
+1. **Get it in.** They press Choose a file in the pane or paste rows, and `"source"` appears in
+ `sheet.json` by itself. Or they give you a path: copy it into the workspace and set `"source"` (an Excel `.xlsx` works as it is: the first sheet is read). A PDF,
a chat export or a folder of notes: convert it to a `.csv` or `.jsonl` in the workspace, one row
per item, keeping a column that says where each row came from. Long documents: one row per
paragraph or clause.
diff --git a/store/agents/jev-sheets/test/picker.test.mjs b/store/agents/jev-sheets/test/picker.test.mjs
new file mode 100644
index 000000000..eabedeafb
--- /dev/null
+++ b/store/agents/jev-sheets/test/picker.test.mjs
@@ -0,0 +1,123 @@
+// The pane's own file chooser. The Harness desktop pane is a web view that never opens the system
+// file dialog, so the viewer lists the person's files itself, inside their home folder only.
+import { test } from 'node:test'
+import assert from 'node:assert/strict'
+import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, utimesSync, symlinkSync, realpathSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import { join, dirname } from 'node:path'
+import { fileURLToPath } from 'node:url'
+import { createPicker } from '../viewer/picker.mjs'
+import { startSheetsViewer } from '../viewer/viewer.mjs'
+
+const HERE = dirname(fileURLToPath(import.meta.url))
+const CSV = 'id,review\n1,It crashes on launch\n2,Best notes app\n'
+
+/** A made-up home folder: recent spreadsheets, other files, a hidden folder, and a secret outside it. */
+function home() {
+ const root = realpathSync(mkdtempSync(join(tmpdir(), 'jev-sheets-home-')))
+ const h = join(root, 'me')
+ for (const d of ['Downloads/exports', 'Desktop', 'Documents/deep/deeper', '.ssh', 'Library/Mail', 'Projects/data']) mkdirSync(join(h, d), { recursive: true })
+ const put = (rel, body, ageDays) => { const f = join(h, rel); writeFileSync(f, body); const t = Date.now() / 1000 - ageDays * 86400; utimesSync(f, t, t); return f }
+ put('Downloads/reviews q3.csv', CSV, 1)
+ put('Downloads/exports/survey.xlsx', 'PK-not-really', 3)
+ put('Desktop/tickets.jsonl', '"one"\n"two"\n', 2)
+ put('Documents/deep/deeper/too-deep.csv', CSV, 0)
+ put('Downloads/photo.png', 'x', 0)
+ put('Downloads/empty.csv', '', 0)
+ put('Downloads/notes.txt', 'a\nb\n', 0)
+ put('Projects/data/leads.tsv', 'name\tnote\nAna\tcall back\n', 9)
+ put('.ssh/keys.csv', CSV, 0)
+ put('Library/Mail/mail.csv', CSV, 0)
+ writeFileSync(join(root, 'outside.csv'), CSV)
+ symlinkSync(join(root, 'outside.csv'), join(h, 'Downloads', 'link-out.csv'))
+ return { root, h }
+}
+
+test('recent: the newest readable spreadsheets in Downloads, Desktop and Documents, one folder deep', () => {
+ const { h } = home()
+ const got = createPicker({ home: h }).recent()
+ // newest first; a link is not a file, so the link that points outside home is not even listed
+ assert.deepEqual(got.files.map((f) => f.name), ['reviews q3.csv', 'tickets.jsonl', 'survey.xlsx'])
+ assert.ok(!got.files.some((f) => ['photo.png', 'empty.csv', 'notes.txt', 'too-deep.csv', 'keys.csv', 'mail.csv', 'leads.tsv'].includes(f.name)))
+ const reviews = got.files.find((f) => f.name === 'reviews q3.csv')
+ assert.equal(reviews.folder, '~/Downloads')
+ assert.equal(reviews.size, CSV.length)
+ assert.equal(got.denied, false)
+})
+
+test('browse: folders and readable files, never hidden ones, never outside home', () => {
+ const { h, root } = home()
+ const p = createPicker({ home: h })
+ const top = p.browse('')
+ assert.equal(top.shown, '~')
+ assert.equal(top.parent, null, 'home is the top')
+ assert.deepEqual(top.folders.map((f) => f.name), ['Desktop', 'Documents', 'Downloads', 'Projects'])
+ const data = p.browse(join(h, 'Projects', 'data'))
+ assert.equal(data.shown, '~/Projects/data')
+ assert.equal(data.parent, join(h, 'Projects'))
+ assert.deepEqual(data.files.map((f) => f.name), ['leads.tsv'])
+ assert.equal(p.browse('~/Downloads').shown, '~/Downloads')
+ for (const bad of [root, '/', join(h, '.ssh'), join(h, 'Library'), join(h, 'Downloads', '..', '..')]) assert.equal(p.browse(bad).ok, false, bad)
+ assert.match(p.browse(join(h, 'nope')).error, /not there/)
+})
+
+test('read: a typed, pasted, quoted or escaped path; refusals say why', () => {
+ const { h, root } = home()
+ const p = createPicker({ home: h, maxBytes: 100 })
+ const want = join(h, 'Downloads', 'reviews q3.csv')
+ for (const typed of [want, '~/Downloads/reviews q3.csv', `"${want}"`, want.replace(/ /g, '\\ '), `file://${want.replace(/ /g, '%20')}`, ` ${want} `]) {
+ const got = p.read(typed)
+ assert.equal(got.error, undefined, typed)
+ assert.equal(got.name, 'reviews q3.csv')
+ assert.equal(got.buffer.toString(), CSV)
+ }
+ assert.match(p.read('').error, /path of a file/)
+ assert.match(p.read(join(h, 'Downloads', 'missing.csv')).error, /no file at/)
+ assert.match(p.read(join(root, 'outside.csv')).error, /inside your home folder/)
+ assert.match(p.read(join(h, 'Downloads', 'link-out.csv')).error, /inside your home folder/, 'a link that points outside home is outside home')
+ assert.match(p.read(join(h, '.ssh', 'keys.csv')).error, /inside your home folder/)
+ assert.match(p.read(join(h, 'Library', 'Mail', 'mail.csv')).error, /inside your home folder/)
+ assert.match(p.read(join(h, 'Downloads', 'photo.png')).error, /\.xlsx/)
+ assert.match(p.read(join(h, 'Downloads', 'notes.txt')).error, /\.xlsx/)
+ assert.match(p.read(join(h, 'Downloads')).error, /\.xlsx|folder/)
+ writeFileSync(join(h, 'Downloads', 'big.csv'), 'x'.repeat(101))
+ assert.match(p.read(join(h, 'Downloads', 'big.csv')).error, /over 0 MB|over \d+ MB/)
+})
+
+test('in the pane: list, browse, then open by path, and the file becomes the sheet', async () => {
+ const { h } = home()
+ const old = process.env.JEV_SHEETS_HOME
+ process.env.JEV_SHEETS_HOME = h
+ const ws = mkdtempSync(join(tmpdir(), 'jev-sheets-pick-'))
+ writeFileSync(join(ws, 'sheet.json'), readFileSync(join(HERE, '../template/sheet.json')))
+ const viewer = await startSheetsViewer({ workspace: ws, port: 0, autostart: false })
+ const ctl = async (cmd, body = {}) => (await fetch(`${viewer.url}/control`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ cmd, ...body }) })).json()
+ try {
+ const recent = await ctl('recentFiles')
+ assert.equal(recent.ok, true)
+ const pick = recent.files.find((f) => f.name === 'reviews q3.csv')
+ assert.ok(pick, 'the recent list has the reviews file')
+ assert.deepEqual((await ctl('browse', { dir: '~/Desktop' })).files.map((f) => f.name), ['tickets.jsonl'])
+ assert.deepEqual(await ctl('usePath', { path: pick.path }), { ok: true, file: 'reviews-q3.csv', rows: 2, total: 2, textColumn: 'review' })
+ const s = await (await fetch(`${viewer.url}/state`)).json()
+ assert.equal(s.own, true)
+ assert.equal(s.source.name, 'reviews-q3.csv')
+ assert.equal(readFileSync(join(ws, 'reviews-q3.csv'), 'utf8'), CSV, 'the picked file is copied into the workspace')
+ const bad = await ctl('usePath', { path: '/etc/hosts' })
+ assert.equal(bad.ok, false)
+ assert.match(bad.error, /inside your home folder/)
+ // a page on another site cannot list or open anything
+ assert.equal((await fetch(`${viewer.url}/control`, { method: 'POST', headers: { origin: 'https://evil.example', 'content-type': 'application/json' }, body: '{"cmd":"recentFiles"}' })).status, 403)
+ } finally {
+ await viewer.close()
+ if (old === undefined) delete process.env.JEV_SHEETS_HOME; else process.env.JEV_SHEETS_HOME = old
+ }
+})
+
+test('the pane offers its own chooser and does not lean on the system dialog', () => {
+ const html = readFileSync(join(HERE, '../viewer/index.html'), 'utf8')
+ const js = readFileSync(join(HERE, '../viewer/studio.js'), 'utf8')
+ for (const id of ['picker', 'tabRecent', 'tabBrowse', 'tabPaste', 'pathInput', 'pasteArea']) assert.ok(html.includes(`id="${id}"`), id)
+ assert.match(js, /\$\('pickBtn'\)\.addEventListener\('click', openPicker\)/, '"Choose a file" opens the built-in chooser')
+ assert.doesNotMatch(js, /navigator\.clipboard\.readText/, 'no clipboard read: web views block it')
+})
diff --git a/store/agents/jev-sheets/viewer/index.html b/store/agents/jev-sheets/viewer/index.html
index c61244082..91363e505 100644
--- a/store/agents/jev-sheets/viewer/index.html
+++ b/store/agents/jev-sheets/viewer/index.html
@@ -39,11 +39,11 @@
<div class="door-icon" aria-hidden="true"><svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M12 16V4M7 9l5-5 5 5"/><path d="M4 15v3a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-3"/></svg></div>
<div class="door-text">
<b id="doorTitle">Use your own file</b>
- <span id="doorSub">Drop an Excel or CSV file anywhere on this pane, or paste rows copied from Excel or Google Sheets. Reviews, survey answers, tickets, leads: one row per item. Then type a question and Jev answers it for every row.</span>
+ <span id="doorSub">Choose an Excel or CSV file, or paste rows copied from a spreadsheet. Reviews, survey answers, tickets, leads: one row per item. Then type a question and Jev answers it for every row.</span>
</div>
<div class="door-actions">
<button id="pickBtn" class="primary">Choose a file</button>
- <button id="pasteBtn" title="Copy rows in your spreadsheet, then click here. Or press Cmd+V or Ctrl+V anywhere on the pane.">Paste rows</button>
+ <button id="pasteBtn" title="Copy rows in your spreadsheet, then paste them into the box that opens">Paste rows</button>
<button id="downloadBtn" class="hidden" title="Every row with Jev's answer and confidence for each question">Download answers.csv</button>
<button id="sampleBtn" class="hidden" title="Go back to the made-up sample sheet">Back to the sample</button>
<input type="file" id="fileInput" class="hidden" accept=".xlsx,.csv,.tsv,.txt,.json,.jsonl,.ndjson">
@@ -102,6 +102,32 @@
</section>
</aside>
</main>
+ <div id="picker" class="picker hidden" role="dialog" aria-modal="true" aria-label="Choose a file">
+ <div class="picker-box">
+ <div class="picker-head">
+ <b>Choose a file</b>
+ <span class="dim">Excel, CSV, TSV, JSON or JSONL · files on the machine that runs this harness</span>
+ <button id="pickerClose" title="Close">✕</button>
+ </div>
+ <div class="picker-tabs">
+ <button id="tabRecent" class="on">Recent</button>
+ <button id="tabBrowse">Browse folders</button>
+ <button id="tabPaste">Paste rows</button>
+ </div>
+ <div id="pickerPath" class="picker-path hidden"></div>
+ <div id="pickerList" class="picker-list"></div>
+ <div id="pickerPaste" class="picker-paste hidden">
+ <textarea id="pasteArea" spellcheck="false" placeholder="Copy rows in Excel or Google Sheets and paste them here. With several columns, keep the header row. One column of plain lines works too."></textarea>
+ <div class="picker-row"><span id="pasteNote" class="dim"></span><button id="pasteUse" class="primary">Use these rows</button></div>
+ </div>
+ <form id="pathForm" class="picker-row">
+ <input id="pathInput" type="text" autocomplete="off" spellcheck="false" placeholder="…or paste a file's full path, like ~/Downloads/reviews.xlsx">
+ <button type="submit">Open</button>
+ <button type="button" id="systemPick" title="The system file dialog. It opens in a browser, not in the Harness desktop pane.">System dialog</button>
+ </form>
+ <div id="pickerMsg" class="picker-msg"></div>
+ </div>
+ </div>
<div id="dropVeil" class="drop-veil hidden"><div><b>Drop your file</b><span>Excel, CSV, TSV, JSON or JSONL, up to 32 MB. It is saved in this project folder. Its rows go to the Jev API to be answered, and nowhere else.</span></div></div>
<div id="toast" class="toast hidden"></div>
</body>
diff --git a/store/agents/jev-sheets/viewer/picker.mjs b/store/agents/jev-sheets/viewer/picker.mjs
new file mode 100644
index 000000000..fa51fe246
--- /dev/null
+++ b/store/agents/jev-sheets/viewer/picker.mjs
@@ -0,0 +1,94 @@
+// picker.mjs — a file chooser that does not need the web view's help.
+//
+// The Harness desktop pane is a WKWebView, and on macOS it never opens the system file dialog for
+// <input type="file">. The viewer runs on the person's machine, so it can list their files itself:
+// the newest spreadsheets in Downloads, Desktop and Documents, a folder browser, and open-by-path.
+//
+// Limits, on purpose: only inside the home folder, never into a hidden folder (so ~/.ssh and
+// ~/.config cannot be reached), only the file types the sheet can read, and nothing is read until
+// the person picks it. A picked file is copied into the workspace like a dropped one.
+import { readdirSync, statSync, readFileSync, realpathSync } from 'node:fs'
+import { homedir } from 'node:os'
+import { join, resolve, dirname, basename, extname, sep } from 'node:path'
+
+export const PICK_EXT = new Set(['.xlsx', '.csv', '.tsv', '.json', '.jsonl', '.ndjson'])
+const SKIP = new Set(['node_modules', 'Library', 'Applications', '$RECYCLE.BIN'])
+const RECENT_FOLDERS = ['Downloads', 'Desktop', 'Documents']
+
+/** @param {{ home?: string, maxBytes?: number }} o `home` can be set for tests (or JEV_SHEETS_HOME). */
+export function createPicker({ home = process.env.JEV_SHEETS_HOME || homedir(), maxBytes = 32 * 1024 * 1024 } = {}) {
+ let HOME
+ try { HOME = realpathSync(home) } catch { HOME = resolve(home) }
+ const inHome = (p) => p === HOME || p.startsWith(HOME + sep)
+ const visible = (name) => !name.startsWith('.') && !SKIP.has(name)
+ const tilde = (p) => (p === HOME ? '~' : p.startsWith(HOME + sep) ? '~' + p.slice(HOME.length) : p)
+ // Reachable: inside home, never through a hidden folder, never the system's ~/Library.
+ const okPath = (p) => { const parts = p.slice(HOME.length).split(sep).filter(Boolean); return inHome(p) && parts.every((s) => !s.startsWith('.')) && parts[0] !== 'Library' }
+ const info = (path, st) => ({ path, name: basename(path), folder: tilde(dirname(path)), size: st.size, mtimeMs: Math.round(st.mtimeMs) })
+
+ /** The newest readable spreadsheets in Downloads, Desktop and Documents (one folder deep). */
+ function recent(limit = 40) {
+ const out = []
+ let denied = 0
+ const scan = (dir, depth) => {
+ let entries
+ try { entries = readdirSync(dir, { withFileTypes: true }) } catch (e) { if (e.code === 'EPERM' || e.code === 'EACCES') denied++; return }
+ for (const e of entries) {
+ if (out.length > 5000 || !visible(e.name)) continue
+ const p = join(dir, e.name)
+ if (e.isDirectory()) { if (depth > 0) scan(p, depth - 1) } else if (e.isFile() && PICK_EXT.has(extname(e.name).toLowerCase())) {
+ try { const st = statSync(p); if (st.size > 0 && st.size <= maxBytes) out.push(info(p, st)) } catch { /* gone */ }
+ }
+ }
+ }
+ for (const f of RECENT_FOLDERS) scan(join(HOME, f), 1)
+ out.sort((a, b) => b.mtimeMs - a.mtimeMs)
+ return { files: out.slice(0, limit), denied: denied > 0, home: '~' }
+ }
+
+ /** One folder: its sub-folders and the files the sheet can read. */
+ function browse(dir) {
+ let at
+ try { at = realpathSync(resolve(expand(dir || '~'))) } catch { return { ok: false, error: 'that folder is not there' } }
+ if (!okPath(at)) return { ok: false, error: 'only folders inside your home folder can be opened here' }
+ let entries
+ try { entries = readdirSync(at, { withFileTypes: true }) } catch (e) { return { ok: false, error: e.code === 'EPERM' || e.code === 'EACCES' ? 'this app is not allowed to read that folder. Allow it in System Settings, Privacy and Security, Files and Folders' : 'that folder cannot be read' } }
+ const folders = [], files = []
+ for (const e of entries) {
+ if (!visible(e.name)) continue
+ const p = join(at, e.name)
+ if (e.isDirectory()) folders.push({ path: p, name: e.name })
+ else if (e.isFile() && PICK_EXT.has(extname(e.name).toLowerCase())) { try { files.push(info(p, statSync(p))) } catch { /* gone */ } }
+ }
+ const byName = (a, b) => a.name.localeCompare(b.name, undefined, { numeric: true, sensitivity: 'base' })
+ return { dir: at, shown: tilde(at), parent: at === HOME ? null : dirname(at), folders: folders.sort(byName).slice(0, 500), files: files.sort(byName).slice(0, 500) }
+ }
+
+ /** "~/Downloads/a b.csv", '/Users/me/a\ b.csv' or a quoted path, as typed or pasted. */
+ function expand(raw) {
+ let p = String(raw ?? '').trim().replace(/^file:\/\//, '')
+ if ((p.startsWith('"') && p.endsWith('"')) || (p.startsWith("'") && p.endsWith("'"))) p = p.slice(1, -1)
+ p = p.replace(/\\(.)/g, '$1') // a path dragged into a terminal escapes its spaces
+ try { p = decodeURIComponent(p) } catch { /* not URL-encoded */ }
+ if (p === '~') return HOME
+ if (p.startsWith('~/')) return join(HOME, p.slice(2))
+ return p
+ }
+
+ /** Read one picked file. Never throws: { name, buffer } or { error }. */
+ function read(raw) {
+ const typed = expand(raw)
+ if (!typed) return { error: 'Type or paste the path of a file.' }
+ let p
+ try { p = realpathSync(resolve(typed)) } catch { return { error: `There is no file at ${typed}` } }
+ if (!okPath(p)) return { error: 'Only files inside your home folder can be opened here. Copy the file there first, or give its path to the agent.' }
+ if (!PICK_EXT.has(extname(p).toLowerCase())) return { error: 'Use an Excel .xlsx file, or a .csv, .tsv, .json or .jsonl file.' }
+ let st
+ try { st = statSync(p) } catch { return { error: 'That file cannot be read.' } }
+ if (!st.isFile()) return { error: 'That is a folder, not a file.' }
+ if (st.size > maxBytes) return { error: `That file is over ${Math.round(maxBytes / 1024 / 1024)} MB.` }
+ try { return { name: basename(p), buffer: readFileSync(p) } } catch (e) { return { error: e.code === 'EPERM' || e.code === 'EACCES' ? 'This app is not allowed to read that file. Allow it in System Settings, Privacy and Security, Files and Folders.' : 'That file cannot be read.' } }
+ }
+
+ return { recent, browse, read }
+}
diff --git a/store/agents/jev-sheets/viewer/studio.css b/store/agents/jev-sheets/viewer/studio.css
index 3f925c945..2d83b8f9e 100644
--- a/store/agents/jev-sheets/viewer/studio.css
+++ b/store/agents/jev-sheets/viewer/studio.css
@@ -244,3 +244,31 @@
.find-n { position: relative; flex: none; font-variant-numeric: tabular-nums; font-weight: 700; }
.find-pct { position: relative; flex: none; width: 34px; text-align: right; color: var(--dim); font-variant-numeric: tabular-nums; }
.find-more { font-size: 10.5px; color: var(--faint); padding: 2px 8px; }
+
+/* ---- the pane's own file chooser (the desktop web view cannot open the system one) ---- */
+.picker { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(7, 8, 13, .72); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
+.picker-box { width: min(720px, 92vw); max-height: 84vh; display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line2); box-shadow: 0 24px 80px rgba(0, 0, 0, .6); }
+.picker-head { display: flex; align-items: baseline; gap: 10px; }
+.picker-head b { font-size: 15px; color: var(--ink); }
+.picker-head .dim { font-size: 11px; color: var(--dim); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.picker-head button { padding: 3px 9px; }
+.picker-tabs { display: flex; gap: 6px; }
+.picker-tabs button.on { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
+.picker-path { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--dim); }
+.picker-up { padding: 3px 9px; font-size: 11px; }
+.picker-list { flex: 1; min-height: 220px; max-height: 46vh; overflow: auto; display: flex; flex-direction: column; gap: 3px; padding-right: 4px; }
+.picker-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 8px 11px; border-radius: 9px; background: rgba(255, 255, 255, .025); border-color: transparent; font-weight: 500; }
+.picker-item:hover { border-color: var(--accent); }
+.picker-item.folder .pi-name::before { content: '▸ '; color: var(--dim); }
+.pi-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: 12.5px; }
+.pi-meta { flex: none; font-size: 11px; color: var(--faint); max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.picker-empty { padding: 26px 12px; text-align: center; font-size: 12px; line-height: 1.55; color: var(--dim); }
+.picker-paste { display: flex; flex-direction: column; gap: 8px; }
+.picker-paste textarea { width: 100%; height: 40vh; min-height: 200px; resize: vertical; padding: 10px; border-radius: 10px; border: 1px solid var(--line2); background: #0b0d14; color: var(--ink); font: 12px/1.5 var(--mono); outline: none; white-space: pre; }
+.picker-paste textarea:focus { border-color: var(--accent); }
+.picker-row { display: flex; align-items: center; gap: 8px; }
+.picker-row .dim { flex: 1; font-size: 11px; color: var(--dim); }
+.picker-row input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line2); background: #0b0d14; color: var(--ink); font: 12px var(--mono); outline: none; }
+.picker-row input:focus { border-color: var(--accent); }
+.picker-msg { min-height: 16px; font-size: 11.5px; color: var(--dim); }
+.picker-msg.bad { color: var(--bad); }
diff --git a/store/agents/jev-sheets/viewer/studio.js b/store/agents/jev-sheets/viewer/studio.js
index 65cf6eb93..4813b7de4 100644
--- a/store/agents/jev-sheets/viewer/studio.js
+++ b/store/agents/jev-sheets/viewer/studio.js
@@ -632,11 +632,12 @@ function renderDoor() {
$('doorSub').textContent = `${fmtN(i.used)}${i.total > i.used ? ` of ${fmtN(i.total)}` : ''} rows from your file. Jev reads the "${i.textColumn}" column, with the other columns as context. Answers are saved to answers.csv in this project folder.`
} else {
$('doorTitle').textContent = 'Use your own file'
- $('doorSub').textContent = 'Drop an Excel or CSV file anywhere on this pane, or paste rows copied from Excel or Google Sheets. Reviews, survey answers, tickets, leads: one row per item. Then type a question and Jev answers it for every row. Below is a made-up sample to try first.'
+ $('doorSub').textContent = 'Choose an Excel or CSV file, or paste rows copied from a spreadsheet. Reviews, survey answers, tickets, leads: one row per item. Then type a question and Jev answers it for every row. Below is a made-up sample to try first.'
}
}
-async function sendFile(file, name = file.name) {
- if (!file) return
+async function sendFile(file, name) {
+ if (!file) return null
+ name ??= file.name
if (file.size > 32 * 1024 * 1024) return toast('That file is over 32 MB. Cut it down or split it first.', true)
$('door').classList.add('busy'); $('doorTitle').textContent = `Reading ${name}…`
let j
@@ -645,10 +646,11 @@ async function sendFile(file, name = file.name) {
j = await r.json()
} catch { j = { ok: false, error: 'The viewer did not answer. Try again.' } }
$('door').classList.remove('busy')
- if (!j.ok) { renderDoor(); return toast(j.error || 'That file could not be read.', true) }
+ if (!j.ok) { renderDoor(); toast(j.error || 'That file could not be read.', true); return j }
select(null)
toast(`${fmtN(j.rows)} rows loaded from ${j.file}. Now type a question.`)
input.focus()
+ return j
}
/** Rows copied from a spreadsheet arrive as tab-separated text. One column of plain lines works too. */
function pastedFile(text) {
@@ -666,11 +668,85 @@ function usePasted(text) {
if (!f) return toast('Copy at least two rows in your spreadsheet first, then paste.', true)
sendFile(f.blob, f.name)
}
-$('pickBtn').addEventListener('click', () => $('fileInput').click())
-$('fileInput').addEventListener('change', (e) => { const f = e.target.files?.[0]; e.target.value = ''; sendFile(f) })
-$('pasteBtn').addEventListener('click', async () => {
- try { usePasted(await navigator.clipboard.readText()) } catch { toast('Click on the pane and press Cmd+V or Ctrl+V to paste your rows.') }
+// ---- the pane's own file chooser ---------------------------------------------------------------
+// The Harness desktop pane is a web view that never opens the system file dialog, so the viewer
+// lists the person's files itself. The system dialog stays as one button for ordinary browsers.
+const fmtSize = (n) => (n < 1024 ? `${n} B` : n < 1048576 ? `${Math.round(n / 1024)} KB` : `${(n / 1048576).toFixed(1)} MB`)
+function fmtAge(ms) {
+ const m = (Date.now() - ms) / 60000
+ return m < 1 ? 'just now' : m < 60 ? `${Math.round(m)} min ago` : m < 1440 ? `${Math.round(m / 60)} h ago` : m < 43200 ? `${Math.round(m / 1440)} d ago` : new Date(ms).toLocaleDateString()
+}
+function pickerMsg(text, bad) { const m = $('pickerMsg'); m.textContent = text || ''; m.className = 'picker-msg' + (bad ? ' bad' : '') }
+function fileRow(f, withFolder) {
+ const b = h('button', 'picker-item file')
+ b.append(h('span', 'pi-name', f.name), h('span', 'pi-meta', `${withFolder ? f.folder + ' · ' : ''}${fmtSize(f.size)} · ${fmtAge(f.mtimeMs)}`))
+ b.addEventListener('click', () => openPath(f.path))
+ return b
+}
+async function openPath(path) {
+ pickerMsg('Reading the file…')
+ const r = await post('usePath', { path })
+ if (!r.ok) return pickerMsg(r.error || 'That file could not be read.', true)
+ afterLoad(r)
+}
+function afterLoad(r) {
+ closePicker(); select(null)
+ toast(`${fmtN(r.rows)} rows loaded from ${r.file}. Now type a question.`)
+ input.focus()
+}
+function setTab(name) {
+ for (const t of ['Recent', 'Browse', 'Paste']) $('tab' + t).classList.toggle('on', t === name)
+ $('pickerList').classList.toggle('hidden', name === 'Paste')
+ $('pickerPaste').classList.toggle('hidden', name !== 'Paste')
+ $('pickerPath').classList.toggle('hidden', name !== 'Browse')
+ pickerMsg('')
+ if (name === 'Recent') showRecent(); else if (name === 'Browse') showFolder(''); else $('pasteArea').focus()
+}
+async function showRecent() {
+ const box = $('pickerList'); box.textContent = ''; box.append(h('div', 'picker-empty', 'Looking in Downloads, Desktop and Documents…'))
+ const r = await post('recentFiles')
+ box.textContent = ''
+ if (!r.ok) return pickerMsg(r.error || 'The viewer did not answer.', true)
+ for (const f of r.files) box.append(fileRow(f, true))
+ if (!r.files.length) box.append(h('div', 'picker-empty', r.denied ? 'This app is not allowed to look in Downloads, Desktop or Documents yet. Allow it in System Settings, Privacy and Security, Files and Folders. Or paste the file\'s path below.' : 'No spreadsheet found in Downloads, Desktop or Documents. Browse folders, or paste the file\'s path below.'))
+}
+async function showFolder(dir) {
+ const box = $('pickerList')
+ const r = await post('browse', { dir })
+ if (!r.ok) return pickerMsg(r.error || 'That folder could not be opened.', true)
+ pickerMsg('')
+ box.textContent = ''
+ const path = $('pickerPath'); path.textContent = ''
+ if (r.parent) { const up = h('button', 'picker-up', '↑ Up'); up.addEventListener('click', () => showFolder(r.parent)); path.append(up) }
+ path.append(h('span', '', r.shown))
+ for (const d of r.folders) { const b = h('button', 'picker-item folder'); b.append(h('span', 'pi-name', d.name), h('span', 'pi-meta', 'folder')); b.addEventListener('click', () => showFolder(d.path)); box.append(b) }
+ for (const f of r.files) box.append(fileRow(f, false))
+ if (!r.folders.length && !r.files.length) box.append(h('div', 'picker-empty', 'Nothing to open in this folder.'))
+ box.scrollTop = 0
+}
+function openPicker() { $('pathInput').value = ''; $('picker').classList.remove('hidden'); setTab('Recent') }
+function closePicker() { $('picker').classList.add('hidden'); pickerMsg('') }
+$('pickBtn').addEventListener('click', openPicker)
+$('pickerClose').addEventListener('click', closePicker)
+$('picker').addEventListener('pointerdown', (e) => { if (e.target === $('picker')) closePicker() })
+window.addEventListener('keydown', (e) => { if (e.key === 'Escape' && !$('picker').classList.contains('hidden')) closePicker() })
+$('tabRecent').addEventListener('click', () => setTab('Recent'))
+$('tabBrowse').addEventListener('click', () => setTab('Browse'))
+$('tabPaste').addEventListener('click', () => setTab('Paste'))
+$('pathForm').addEventListener('submit', (e) => { e.preventDefault(); const p = $('pathInput').value.trim(); if (p) openPath(p) })
+$('systemPick').addEventListener('click', () => $('fileInput').click())
+$('pasteArea').addEventListener('input', () => { const n = $('pasteArea').value.split('\n').filter((l) => l.trim()).length; $('pasteNote').textContent = n ? `${fmtN(n)} lines` : '' })
+$('pasteUse').addEventListener('click', async () => {
+ const f = pastedFile($('pasteArea').value)
+ if (!f) return pickerMsg('Paste at least two rows first.', true)
+ pickerMsg('Reading the rows…')
+ const r = await sendFile(f.blob, f.name)
+ if (!r?.ok) return pickerMsg(r?.error || 'Those rows could not be read.', true)
+ $('pasteArea').value = ''; $('pasteNote').textContent = ''
+ closePicker()
})
+$('fileInput').addEventListener('change', async (e) => { const f = e.target.files?.[0]; e.target.value = ''; const r = await sendFile(f); if (r?.ok) closePicker() })
+$('pasteBtn').addEventListener('click', () => { openPicker(); setTab('Paste') })
window.addEventListener('paste', (e) => {
if (/^(INPUT|TEXTAREA)$/.test(document.activeElement?.tagName ?? '')) return
const text = e.clipboardData?.getData('text/plain') ?? ''
diff --git a/store/agents/jev-sheets/viewer/viewer.mjs b/store/agents/jev-sheets/viewer/viewer.mjs
index 498000ccb..8a42e04d0 100644
--- a/store/agents/jev-sheets/viewer/viewer.mjs
+++ b/store/agents/jev-sheets/viewer/viewer.mjs
@@ -12,6 +12,7 @@ import { serveViewer, writeVerdict, watchConfig, watchPath, mulberry32, clean }
import { parseHeader, normalizeSheet, columnKey, judge, confidenceOf, levelOf, describeColumn, LIMITS } from './grammar.mjs'
import { sheetMock } from './mock.mjs'
import { loadSource } from './source.mjs'
+import { createPicker } from './picker.mjs'
import { writeFileSync, renameSync, readFileSync, existsSync, rmSync } from 'node:fs'
import { extname } from 'node:path'
@@ -49,6 +50,7 @@ export async function startSheetsViewer({ workspace, port = 0, autostart = true,
// Which live route is active (typesafe, cloudflare, openrouter), or null for the offline stand-in.
// Asked each time, because a key can arrive in the credentials file while the viewer runs.
const liveRoute = () => resolveCredentials()?.provider ?? null
+ const picker = createPicker()
const colById = (id) => columns.find((c) => c.id === id)
const mock = sheetMock(colById)
@@ -614,6 +616,14 @@ export async function startSheetsViewer({ workspace, port = 0, autostart = true,
computeOrder(); pushView(); return { filter }
}
case 'useSample': return useSample()
+ // The pane's own file chooser: the desktop web view cannot open the system one.
+ case 'recentFiles': return picker.recent()
+ case 'browse': return picker.browse(body.dir)
+ case 'usePath': {
+ const got = picker.read(body.path)
+ if (got.error) return { ok: false, error: got.error }
+ return upload(got.name, got.buffer)
+ }
case 'setReview': {
touch()
const v = Number(body.value)