Open any picture thumbnail in the shared picview

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-03 03:24:39 -08:00
1 parent 1eef797dc0
commit c26759fd88
10 files changed
+495 -254

No files matched your search

+107 -30
View File
@@ -32,12 +32,17 @@
<link rel="modulepreload" href="/screens/looks.js" />
<link rel="modulepreload" href="/screens/prefs-dialog.js" />
<link rel="modulepreload" href="/screens/agents-view.js" />
<link rel="modulepreload" href="/screens/agents/agents-data.js" />
<link rel="modulepreload" href="/screens/agents/agents-list-editor.js" />
<link rel="modulepreload" href="/screens/agents/agents-summary.js" />
<link rel="modulepreload" href="/screens/agents/agents-form.js" />
<link rel="modulepreload" href="/screens/cleanup.js" />
<link rel="modulepreload" href="/screens/help-dialog.js" />
<link rel="modulepreload" href="/screens/workspace.js" />
<link rel="modulepreload" href="/screens/ask.js" />
<link rel="modulepreload" href="/screens/notepad.js" />
<link rel="modulepreload" href="/screens/activities.js" />
<link rel="modulepreload" href="/screens/setup.js" />
<link rel="modulepreload" href="/activities.js" />
<link rel="modulepreload" href="/tones.js" />
<link rel="modulepreload" href="/net.js" />
@@ -288,6 +293,7 @@
resting arms; adrift shows none at all. -->
<g class="arms a-rest"><g class="arm"><path d="M3 18 L1.3 21" /><circle cx="1.3" cy="21" r="0.85" /></g><g class="arm"><path d="M19 18 L20.7 21" /><circle cx="20.7" cy="21" r="0.85" /></g></g>
<g class="arms a-point"><g class="arm"><path d="M3 18 L1.3 21" /><circle cx="1.3" cy="21" r="0.85" /></g><g class="arm wave"><path d="M19 17.5 L21.4 14.9" /><circle cx="21.4" cy="14.9" r="0.85" /></g></g>
<g class="arms a-setup"><g class="arm"><path d="M3 18 L1.3 21" /><circle cx="1.3" cy="21" r="0.85" /></g><g class="arm wave"><path d="M19 17.5 L21.4 14.9" /><circle cx="21.4" cy="14.9" r="0.85" /></g></g>
<g class="arms a-work"><g class="arm pump-l"><path d="M3 18 L1.1 20.6" /><circle cx="1.1" cy="20.6" r="0.85" /></g><g class="arm pump-r"><path d="M19 18 L20.9 20.6" /><circle cx="20.9" cy="20.6" r="0.85" /></g></g>
<g class="arms a-done"><g class="arm"><path d="M3 16.5 L1.1 13.7" /><circle cx="1.1" cy="13.7" r="0.85" /></g><g class="arm"><path d="M19 16.5 L20.9 13.7" /><circle cx="20.9" cy="13.7" r="0.85" /></g></g>
<g class="arms a-gone"><g class="arm"><path d="M3 18.6 L2.5 22.2" /><circle cx="2.5" cy="22.2" r="0.85" /></g><g class="arm"><path d="M19 18.6 L19.5 22.2" /><circle cx="19.5" cy="22.2" r="0.85" /></g></g>
@@ -826,6 +832,28 @@
</g>
</g>
</svg>
<!-- Agent setup: waving hello at a terminal window, its prompt waiting
for the command line that brings an agent. -->
<svg class="pose pose-setup" data-pose="setup" viewBox="0 4 240 216" aria-hidden="true" focusable="false">
<ellipse class="shadow" cx="106" cy="198" rx="34" ry="5" />
<ellipse class="shadow" cx="198" cy="198" rx="24" ry="4" />
<g class="bob">
<g transform="translate(-14 0)">
<rect class="fl foot f1" x="94" y="179" width="20" height="10" rx="5" />
<rect class="fl foot f2" x="126" y="179" width="20" height="10" rx="5" />
<rect class="sh" x="80" y="72" width="80" height="108" rx="16" />
<path class="ln" d="M80 126 L66 150" /><circle class="fl" cx="66" cy="150" r="5.5" />
<path class="ln" d="M160 118 L176 92" /><circle class="fl" cx="176" cy="92" r="5.5" />
<g class="in-look"><path class="ey blink" d="M124 86 L127.64 94.98 L137.31 95.67 L129.9 101.92 L132.23 111.33 L124 106.2 L115.77 111.33 L118.1 101.92 L110.69 95.67 L120.36 94.98 Z" /></g>
<path class="es" d="M112 122 Q120 128 128 122" />
</g>
</g>
<g class="prop">
<rect class="lt" x="172" y="146" width="52" height="38" rx="5" />
<path class="lt" d="M182 158 L188 164 L182 170" />
<path class="lt" d="M194 170 L206 170" />
</g>
</svg>
</template>
<!-- The Help dialog's content, cloned into #help-modal the first time ? is
@@ -920,6 +948,9 @@
<circle cx="15" cy="12" r="1.8" />
<circle cx="7" cy="17" r="1.8" />
</symbol>
<symbol id="hi-setup" viewBox="0 0 24 24" fill="none">
<path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.8-3.8a6 6 0 0 1-8 8l-6.9 6.9a2.12 2.12 0 0 1-3-3l6.9-6.9a6 6 0 0 1 8-8l-3.8 3.8z" />
</symbol>
<symbol id="hi-privacy" viewBox="0 0 24 24" fill="none">
<rect x="5" y="10.5" width="14" height="10" rx="2" />
<path d="M8 10.5V8a4 4 0 0 1 8 0v2.5M12 14.5v2" />
@@ -2030,16 +2061,12 @@
example "Task 5 of 9: the rate limiter". Tasks are counted within the
phase, and the progress bar counts the same way: "5 of 9 done".
</p>
<h4>The task list and the phase file</h4>
<h4>The phase file</h4>
<ul>
<li>
The phase's task list has its own tab, and each task ticks as soon as
it is finished and saved.
</li>
<li>
The phase file itself, such as <code>phase-3.md</code>, is in the tab
beside it: what has to be true before the phase starts, and every
task in full, not just the checklist.
The phase file, such as <code>phase-3.md</code>, has its own tab:
what has to be true before the phase starts, and every task in
full, each one ticking as soon as it is finished and saved.
</li>
</ul>
<h4>Questions along the way</h4>
@@ -3225,7 +3252,7 @@
Nothing here is saved as you type. Each form has its own
<strong>Save</strong> and <strong>Discard</strong>, and an
<strong>Unsaved</strong> badge while it holds a change. Leaving a form
with an unsaved change (another tab, Back to summary, Close) asks
with an unsaved change (another tab, another agent, Close) asks
first: save it, discard it, or keep editing.
</p>
<h4>System</h4>
@@ -3306,7 +3333,59 @@
</ul>
</section>
<!-- Tab 19: Privacy and where things are saved -->
<!-- Tab 19: Setting up an agent -->
<section class="help-panel" data-tab="setup">
<h3>Setting up an agent</h3>
<p class="help-lead">
Plan2Code runs an AI agent for you. When this page shows, it could
not find one on this computer, so its whole job is getting you one.
</p>
<h4>What the states mean</h4>
<p>
Each agent on the page says what Plan2Code found when it looked:
</p>
<ul>
<li>
<strong>Found</strong>: the agent is installed and ready. Pick it
and Plan2Code starts it.
</li>
<li>
<strong>Found outside PATH</strong>: the agent is installed, but
your computer's PATH does not know it, so Plan2Code cannot start
it by name yet.
</li>
<li>
<strong>Not found</strong>: the agent is not installed, or not
anywhere Plan2Code looks. Its install lines are right there, each
with a Copy button.
</li>
</ul>
<p>
After you install one, press <strong>Check again</strong>: the page
re-checks without you restarting anything.
</p>
<h4>Found outside PATH</h4>
<p>
<strong>Use it from here</strong> saves the location Plan2Code found,
so the agent works without you touching PATH at all. If you would
rather fix PATH yourself, the page shows the steps for your computer.
</p>
<h4>Templates</h4>
<p>
Under the agents are <strong>templates</strong>: starting setups for
agents Plan2Code does not ship. Using one opens the same form as
adding an agent by hand, already filled in; nothing is saved until
you press Save.
</p>
<h4>Signing in is yours</h4>
<p>
Some agents ask you to sign in or enter an API key the first time
they run. Only you can do that, in the agent's own window:
Plan2Code never signs in, types a key or accepts terms for you.
</p>
</section>
<!-- Tab 20: Privacy and where things are saved -->
<section class="help-panel" data-tab="privacy">
<h3>Privacy and where things are saved</h3>
<p class="help-lead">
@@ -3438,16 +3517,14 @@
</section>
<section class="prefs-panel" data-tab="agents">
<div class="prefs-agents" data-section="agents">
<p class="help" id="agents-intro">Most people never need to change this. Plan2Code finds the agents installed on this machine and ships an up-to-date model list with every release.</p>
<table class="prefs-agents-table" id="agents-table">
<thead>
<tr><th scope="col">Agent</th><th scope="col" class="prefs-agents-models">Models</th><th scope="col">On this machine</th><th scope="col"></th></tr>
</thead>
<tbody></tbody>
</table>
<button type="button" class="btn small" id="agents-add">Add agent</button>
<span class="help" id="agents-status" role="status"></span>
<div id="agents-form" class="prefs-agents-form" hidden></div>
<p class="help" id="agents-intro" data-av="intro">Most people never need to change this. Plan2Code finds the agents installed on this machine and ships an up-to-date model list with every release.</p>
<div class="split" id="agents-split">
<div class="split-list" id="agents-table" data-av="table">
<button type="button" class="btn small ghost split-add" id="agents-add" data-av="add">Add agent</button>
</div>
<div class="split-pane" id="agents-form" data-av="form"></div>
</div>
<span class="help" id="agents-status" data-av="status" role="status"></span>
</div>
</section>
<section class="prefs-panel" data-tab="system">
@@ -3546,7 +3623,7 @@
</fieldset>
<fieldset class="modal-ranges">
<legend>Instruction</legend>
<textarea id="subagents-instruction" rows="4" maxlength="2000" aria-label="Instruction"></textarea>
<div id="subagents-instruction"></div>
<div class="models-actions">
<button type="button" class="btn small ghost" id="subagents-default">Reset to default</button>
<span class="help">Passed to the agent as written, at its next check-in.</span>
@@ -3616,15 +3693,15 @@
</div>
</dialog>
<!-- The Notebook's full-screen picture preview, opened over the Notebook
from a thumbnail by screens/notepad.js. -->
<dialog class="modal notepad-preview" id="notepad-preview" aria-label="Image preview">
<img class="notepad-preview-img" id="notepad-preview-img" alt="" />
<button type="button" class="notepad-preview-step is-prev" id="notepad-preview-prev" aria-label="Previous image">‹</button>
<button type="button" class="notepad-preview-step is-next" id="notepad-preview-next" aria-label="Next image">›</button>
<div class="notepad-preview-bar">
<p class="notepad-preview-count" id="notepad-preview-count" aria-live="polite"></p>
<button type="button" class="btn small notepad-preview-close" id="notepad-preview-close">Close</button>
<!-- The page's full-screen picture preview, opened over whatever is on
screen from any thumbnail by openPicview() in uploads.js. -->
<dialog class="modal picview" id="picview" aria-label="Image preview">
<img class="picview-img" id="picview-img" alt="" />
<button type="button" class="picview-step is-prev" id="picview-prev" aria-label="Previous image">‹</button>
<button type="button" class="picview-step is-next" id="picview-next" aria-label="Next image">›</button>
<div class="picview-bar">
<p class="picview-count" id="picview-count" aria-live="polite"></p>
<button type="button" class="btn small picview-close" id="picview-close">Close</button>
</div>
</dialog>
+49 -21
View File
@@ -6,8 +6,9 @@ import { finish, activity, agentAdrift, isDashboard, selSpec, byId, isOpen, loop
import { el, md, isMac, lightDismiss, shortTime } from "../render.js";
import { startersFor } from "../starters.js";
import { looks } from "../looks.js";
import { thumbs, uploadUrl, docChip, attachTray, CHAT_IMAGES, attachFiles, incomingFiles, deleteUrl, sentAttachments, noteImages, attachRow } from "../uploads.js";
import { thumbs, uploadUrl, docChip, attachTray, CHAT_IMAGES, attachFiles, incomingFiles, deleteUrl, sentAttachments, noteImages, attachRow, openPicview, refocusThumb } from "../uploads.js";
import { attachMentions } from "../mention-box.js";
import { makeMdField } from "../md-field.js";
import { pickerAccept, attachmentKind, noteAwaiting, threadWho, threadText } from "../answers.js";
import { postJson } from "../net.js";
import { CHECKIN_LINE, helperRows, showSwitch, switchLabel, defaultInstruction, PATHFINDER_RESEARCH_LINE, STRENGTHS, DEFAULT_STRENGTH, STRENGTH_HELP } from "../subagents.js";
@@ -26,6 +27,10 @@ export const declineOpen = new Map();
const deciding = new Set();
// The Subagents dialog's instruction box, a Markdown field made once in
// wireAsk into its #subagents-instruction mount.
let instrField = null;
// The frame's chat block, with `offline` worked out now rather than when the
// frame was sent: the agent comes and goes between frames, and /ping keeps
// agentLastSeen current. The frame's own verdict stands when there is no clock.
@@ -125,7 +130,11 @@ function askStarters(ss) {
function askRow(r, ss, notes) {
if (r.kind === "decision") {
const row = el("div", "ask-row decision");
row.appendChild(el("p", "ask-decision", r.decision !== "approve" ? "You declined the edit." : r.done ? "You approved the edit." : "You approved the edit, please wait..."));
const working = r.decision === "approve" && !r.done;
const line = el("p", working ? "ask-decision working" : "ask-decision");
if (working) line.appendChild(el("span", "spinner tiny"));
line.appendChild(document.createTextNode(r.decision !== "approve" ? "You declined the edit." : r.done ? "You approved the edit." : "You approved the edit, please wait..."));
row.appendChild(line);
if (r.text) row.appendChild(el("p", "ask-text", r.text));
return row;
}
@@ -153,14 +162,26 @@ function askRow(r, ss, notes) {
const hasFiles = r.files && r.files.length;
if (hasImages || hasFiles) {
const tray = el("div", "attach-tray");
for (const img of r.images || []) {
// A message echoed by the server has no key (it keeps path and name), so
// the thumbnail's refocus token is the picture's own URL, which is unique
// and the same for a pending send and its echo: the token survives a
// redraw while the picview is open.
(r.images || []).forEach((img, i) => {
const fig = el("figure", "attach-thumb is-ready");
fig.dataset.key = uploadUrl(img);
const pic = el("img");
pic.src = thumbs.get(img.key) || uploadUrl(img);
pic.alt = img.name || "image";
fig.appendChild(pic);
const open = el("button", "attach-open");
open.type = "button";
open.appendChild(pic);
open.addEventListener("click", () => {
const slides = (r.images || []).map((x) => ({ url: uploadUrl(x), alt: x.name || "image" }));
openPicview(slides, i, () => refocusThumb(fig.dataset.key));
});
fig.appendChild(open);
tray.appendChild(fig);
}
});
for (const file of r.files || []) tray.appendChild(docChip(file, "ready"));
row.appendChild(tray);
}
@@ -271,14 +292,15 @@ function askComposer(ss) {
}
if (page.local.chat.images.length) comp.appendChild(attachTray(CHAT_IMAGES, page.local.chat.images));
const ta = el("textarea");
ta.id = "ask-input";
ta.placeholder = "Ask anything about this project";
ta.value = page.local.chat.draft || "";
ta.disabled = !ss.canType;
ta.setAttribute("aria-label", "Your question");
const ta = makeMdField({
id: "ask-input",
placeholder: "Ask anything about this project",
label: "Your question",
value: page.local.chat.draft || "",
disabled: !ss.canType,
});
attachMentions(ta);
comp.appendChild(ta);
comp.appendChild(ta.el);
const row = el("div", "ask-actions");
const add = el("button", "btn small ghost", "+ Attach file");
@@ -680,10 +702,12 @@ export function renderAside() {
if (attached.length) wrap.appendChild(attachTray(item.id, attached));
const ta = el("textarea");
ta.id = id;
ta.placeholder = "Goes with your next send. It does not answer the question.";
ta.value = page.local.drafts[id] || "";
const ta = makeMdField({
id,
placeholder: "Goes with your next send. It does not answer the question.",
label: "Add a note, attach a file, or ask something",
value: page.local.drafts[id] || "",
});
attachMentions(ta);
ta.addEventListener("input", () => {
setDraft(id, ta.value);
@@ -697,7 +721,8 @@ export function renderAside() {
if (!e.clipboardData.getData("text/plain")) e.preventDefault();
attachFiles(item.id, files);
});
wrap.appendChild(ta);
label.addEventListener("click", () => ta.focus());
wrap.appendChild(ta.el);
aside.appendChild(wrap);
aside.scrollTop = place;
}
@@ -779,7 +804,7 @@ export function openSubagents() {
for (const radio of document.querySelectorAll('input[name="subagents-on"]')) {
radio.checked = radio.value === (on ? "on" : "off");
}
$("subagents-instruction").value = page.subagentsFrame.instruction ?? defaultInstruction(page.S.workflow);
instrField.value = page.subagentsFrame.instruction ?? defaultInstruction(page.S.workflow);
$("subagents-max").value = String(page.subagentsFrame.max);
const strength = STRENGTHS.includes(page.subagentsFrame.strength) ? page.subagentsFrame.strength : DEFAULT_STRENGTH;
for (const radio of document.querySelectorAll('input[name="subagents-strength"]')) radio.checked = radio.value === strength;
@@ -801,7 +826,8 @@ export function openSubagents() {
export function syncSubagentsFields() {
const picked = document.querySelector('input[name="subagents-on"]:checked');
const off = !picked || picked.value !== "on";
for (const id of ["subagents-instruction", "subagents-max", "subagents-default"]) $(id).disabled = off;
instrField.disabled = off;
for (const id of ["subagents-max", "subagents-default"]) $(id).disabled = off;
for (const radio of document.querySelectorAll('input[name="subagents-strength"]')) radio.disabled = off;
}
@@ -825,7 +851,7 @@ export async function saveSubagents() {
const save = $("subagents-save");
const status = $("subagents-status");
const picked = document.querySelector('input[name="subagents-on"]:checked');
const text = $("subagents-instruction").value.trim();
const text = instrField.value.trim();
// The shipped default is stored as null, so a later release's wording
// reaches everyone who never changed it.
const instruction = text === defaultInstruction(page.S.workflow) ? null : text;
@@ -853,12 +879,14 @@ export const askOfflineFlipped = () => (askState().send.state === "offline") !==
// The Subagents dialog's buttons, and dropping files onto the notes panel.
export function wireAsk() {
instrField = makeMdField({ className: "subagents-instruction", label: "Instruction", maxLength: 2000 });
$("subagents-instruction").appendChild(instrField.el);
for (const radio of document.querySelectorAll('input[name="subagents-on"]')) radio.addEventListener("change", syncSubagentsFields);
for (const radio of document.querySelectorAll('input[name="subagents-strength"]')) radio.addEventListener("change", syncStrengthHelp);
lightDismiss($("subagents-modal"));
$("btn-subagents").addEventListener("click", openSubagents);
$("subagents-default").addEventListener("click", () => {
$("subagents-instruction").value = defaultInstruction(page.S.workflow);
instrField.value = defaultInstruction(page.S.workflow);
});
$("subagents-save").addEventListener("click", saveSubagents);
$("subagents-cancel").addEventListener("click", () => $("subagents-modal").close());
+12 -57
View File
@@ -26,14 +26,13 @@ import {
nextSave,
noteBytes,
saveStatus,
step,
tabNameProblem,
tabSwitch,
unsaved,
} from "../notepad.js";
import { el, lightDismiss } from "../render.js";
import { postJson } from "../net.js";
import { reencode } from "../uploads.js";
import { reencode, openPicview } from "../uploads.js";
import { createTabs } from "../notepad-tabs.js";
import { skillFor } from "../skills.js";
@@ -629,7 +628,7 @@ export async function addNotepadImages(files) {
function thumbItem(entry, n) {
const item = el("li", `attach-thumb notepad-thumb is-${entry.status}`);
item.dataset.key = entry.key;
const open = el("button", "notepad-thumb-open");
const open = el("button", "attach-open");
open.type = "button";
const src = entry.thumb || entry.url;
if (src) {
@@ -690,7 +689,7 @@ function thumbItem(entry, n) {
}
// The controls a thumbnail can hold the focus on, by class.
const THUMB_CONTROLS = ["notepad-thumb-open", "notepad-thumb-delete", "notepad-ask-keep", "notepad-ask-delete", "notepad-retry"];
const THUMB_CONTROLS = ["attach-open", "notepad-thumb-delete", "notepad-ask-keep", "notepad-ask-delete", "notepad-retry"];
// Every redraw rebuilds the thumbnails, which would drop a focused button
// out of the page: the focus goes back to the same control, or to that
@@ -703,7 +702,7 @@ function drawStrip() {
const control = was && THUMB_CONTROLS.find((cls) => active.classList.contains(cls));
strip.replaceChildren(...images.map((entry, i) => thumbItem(entry, i + 1)));
if (!was) return;
if (!(control && focusIn(was.dataset.key, "." + control)) && !focusIn(was.dataset.key, ".notepad-thumb-open")) {
if (!(control && focusIn(was.dataset.key, "." + control)) && !focusIn(was.dataset.key, ".attach-open")) {
$("notepad-add").focus();
}
}
@@ -748,7 +747,7 @@ async function remove(entry) {
drop(entry.key);
drawStrip();
const next = images[at] || images[at - 1];
if (next) focusIn(next.key, ".notepad-thumb-open");
if (next) focusIn(next.key, ".attach-open");
else $("notepad-add").focus();
}
@@ -768,58 +767,15 @@ function takeStored(list, tabId) {
/* ------------------------------------------------------------ preview */
// What the preview steps through (the pictures with a stored copy, as they
// stood when it opened), which one shows, and the thumbnail it opened from.
let viewing = { list: [], index: -1, from: null };
function showAt(index) {
const { list } = viewing;
const entry = list[index];
viewing.index = index;
const pic = $("notepad-preview-img");
pic.src = entry.url;
pic.alt = `Notebook image ${images.indexOf(entry) + 1}`;
$("notepad-preview-count").textContent = `${index + 1} of ${list.length}`;
$("notepad-preview-prev").hidden = $("notepad-preview-next").hidden = list.length < 2;
}
// The shared picview over the strip's pictures (those with a stored copy, as
// they stand now); closing it puts the focus back on the opening thumbnail.
function openPreview(entry) {
const list = images.filter((img) => img.url);
const index = list.indexOf(entry);
if (index < 0) return;
viewing = { list, index, from: entry.key };
showAt(index);
const dlg = $("notepad-preview");
if (!dlg.open) dlg.showModal();
$("notepad-preview-close").focus();
}
function move(delta) {
const index = step(viewing.index, delta, viewing.list.length);
if (index >= 0) showAt(index);
}
// Esc is taken here and closes the preview alone: left to the browser, it
// could reach the Notebook underneath too.
function wirePreview() {
const dlg = $("notepad-preview");
$("notepad-preview-prev").addEventListener("click", () => move(-1));
$("notepad-preview-next").addEventListener("click", () => move(1));
$("notepad-preview-close").addEventListener("click", () => dlg.close());
dlg.addEventListener("keydown", (e) => {
if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
e.preventDefault();
move(e.key === "ArrowLeft" ? -1 : 1);
} else if (e.key === "Escape") {
e.preventDefault();
e.stopPropagation();
dlg.close();
}
});
dlg.addEventListener("close", () => {
$("notepad-preview-img").removeAttribute("src");
focusIn(viewing.from, ".notepad-thumb-open");
});
openPicview(
list.map((img) => ({ url: img.url, alt: `Notebook image ${images.indexOf(img) + 1}` })),
list.indexOf(entry),
() => focusIn(entry.key, ".attach-open"),
);
}
// A paste is a picture paste when it carries image files and no plain text:
@@ -948,7 +904,6 @@ export function wireNotepad() {
});
lightDismiss(dlg);
wireImages(dlg);
wirePreview();
$("btn-notepad").addEventListener("click", openNotepad);
$("notepad-close").addEventListener("click", () => dlg.close());
$("notepad-tab-new").addEventListener("click", () => openNameForm("new"));
+5 -77
View File
@@ -3,6 +3,8 @@
/* The top bar's Notebook button: drawn and lit like the Subagents button. */
.notepad-btn { border-color: var(--rule-2); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
/* `hidden` loses to the display above without this (agent-less sessions hide it). */
.notepad-btn[hidden] { display: none; }
.btn.notepad-btn { padding: 0 8px; align-self: stretch; }
.notepad-btn .notepad-label { font-size: 13px; line-height: 1; }
.notepad-btn .np-band { fill: var(--ink-2); stroke: none; }
@@ -78,22 +80,10 @@
background: var(--accent-soft);
}
/* One thumbnail: the picture is a button that opens the preview, with the
tray's round X in its corner, and the inline delete question or the upload
state laid over it. */
/* One thumbnail: the picture is a button that opens the picview (the shared
.attach-open in shell.css), with the tray's round X in its corner, and the
inline delete question or the upload state laid over it. */
.notepad-thumb.attach-thumb { width: 88px; height: 88px; }
.notepad-thumb-open {
display: block;
width: 100%;
height: 100%;
padding: 0;
border: 0;
background: none;
cursor: zoom-in;
}
.notepad-thumb-open:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.notepad-thumb.is-uploading .notepad-thumb-open,
.notepad-thumb.is-failed .notepad-thumb-open { cursor: default; }
.notepad-thumb .attach-overlay p { margin: 0; padding: 0 4px; }
.notepad-thumb .attach-overlay .btn.tiny { margin: 0; padding: 1px 6px; font-size: 10.5px; }
.notepad-ask {
@@ -102,68 +92,6 @@
}
.notepad-ask-row { display: flex; gap: 4px; }
/* The full-screen preview: the whole viewport, the picture contained in it,
on a near-black backdrop in both themes (a picture is judged against dark,
whatever the page's theme), so its colors are fixed, not tokens. */
.modal.notepad-preview {
inset: 0;
width: 100vw;
height: 100vh;
max-width: none;
max-height: none;
margin: 0;
padding: 0;
border: 0;
border-radius: 0;
background: transparent;
box-shadow: none;
color: #f4f1ec;
}
.modal.notepad-preview[open] {
display: grid;
grid-template-columns: 72px minmax(0, 1fr) 72px;
grid-template-rows: minmax(0, 1fr) auto;
}
.modal.notepad-preview::backdrop { background: rgba(8, 8, 8, 0.92); }
.notepad-preview-img {
grid-column: 2;
grid-row: 1;
place-self: center;
max-width: 100%;
max-height: 100%;
object-fit: contain;
padding-top: 24px;
}
.notepad-preview-step {
grid-row: 1;
place-self: center;
width: 44px;
height: 44px;
padding: 0;
border: 1px solid rgba(255, 255, 255, 0.35);
border-radius: 50%;
background: rgba(0, 0, 0, 0.45);
color: #fff;
font: 600 28px/1 var(--sans);
cursor: pointer;
}
.notepad-preview-step.is-prev { grid-column: 1; }
.notepad-preview-step.is-next { grid-column: 3; }
.notepad-preview-step:hover,
.notepad-preview-step:focus-visible { border-color: #fff; background: rgba(255, 255, 255, 0.14); }
.notepad-preview-step[hidden] { display: none; }
.notepad-preview-bar {
grid-column: 1 / -1;
grid-row: 2;
display: flex;
align-items: center;
justify-content: center;
gap: 16px;
padding: 12px 16px 20px;
}
.notepad-preview-count { margin: 0; font-size: 13.5px; color: rgba(255, 255, 255, 0.8); }
.btn.notepad-preview-close { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.35); color: #fff; }
.btn.notepad-preview-close:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }
.modal.notepad .modal-actions { flex: none; align-items: center; margin-top: 14px; }
.notepad-status { margin: 0 auto 0 0; min-height: 1.4em; font-size: 12.5px; color: var(--ink-3); }
.notepad-status.is-problem { color: var(--warn); }
+4 -20
View File
@@ -60,7 +60,7 @@
.modal.notepad { width: 100%; height: 100%; margin: 0; padding: 18px 16px 16px; border: 0; border-radius: 0; }
.modal.notepad .notepad-add,
.modal.notepad .modal-actions .btn,
.btn.notepad-preview-close { min-height: 44px; }
.btn.picview-close { min-height: 44px; }
.notepad-images { flex-direction: column; align-items: stretch; }
.notepad-tabbar { flex-wrap: wrap; }
.modal.notepad .notepad-tab-new,
@@ -70,7 +70,7 @@
.notepad-tab-x { width: 32px; }
.notepad-add { align-self: flex-start; }
.notepad-thumb .notepad-thumb-delete { width: 30px; height: 30px; font-size: 18px; }
.modal.notepad-preview[open] { grid-template-columns: 52px minmax(0, 1fr) 52px; }
.modal.picview[open] { grid-template-columns: 52px minmax(0, 1fr) 52px; }
}
@media (prefers-reduced-motion: reduce) {
@@ -95,26 +95,10 @@
#btn-send { animation: none; }
}
/* User Preferences: the launcher's model menu. */
.models-note { font-size: 0.9em; opacity: 0.85; }
.models-note p, .models-note ul { margin: 0 0 6px; }
.models-note ul { padding-left: 18px; }
.models-list { display: grid; gap: 4px; max-height: 160px; overflow: auto; }
.models-list:empty { display: none; }
.models-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.models-row.locked { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); font-size: 0.88em; opacity: 0.75; }
.models-row input { min-width: 0; }
/* User Preferences: action rows (Cleanup's scan/delete buttons share this
class; the model menu's own rules moved to agents.css). */
.models-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.models-actions .help.error { color: var(--danger, #d64545); }
.agent-field { display: grid; gap: 4px; min-width: 0; }
.agent-field > span, .agent-field > label { font-size: 0.85em; opacity: 0.85; }
.agent-rows { display: grid; gap: 4px; }
.agent-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: center; }
.agent-row.model { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
.agent-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.agent-foot .help { margin: 0; }
.agent-foot .agent-test-result { flex: 1 1 auto; }
.agent-error { margin: 0; color: var(--danger, #d64545); font-size: 0.9em; }
/* User Preferences: Cleanup's list of what would go, shown before anything
is deleted. */
+85 -4
View File
@@ -404,10 +404,10 @@ h1 {
.aside-empty { color: var(--ink-3); font-size: 13px; font-style: italic; }
/* The note box takes whatever height the panel has left, never under 160px.
Scoped here so the page-wide textarea minimum still holds everywhere else. */
Scoped here so the page-wide box minimum still holds everywhere else. */
.aside { display: flex; flex-direction: column; }
.aside > .field { flex: 1 0 auto; display: flex; flex-direction: column; min-height: 0; }
.aside textarea { flex: 1 1 auto; min-height: 160px; resize: vertical; }
.aside .md-host { flex: 1 1 auto; min-height: 160px; resize: vertical; }
.aside.is-dropping {
outline: 2px dashed var(--accent);
@@ -426,6 +426,20 @@ h1 {
flex: none;
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* The picture in a thumbnail is a button that opens the picview, with the
tray's round X in its corner and the upload state laid over it. */
.attach-open {
display: block;
width: 100%;
height: 100%;
padding: 0;
border: 0;
background: none;
cursor: zoom-in;
}
.attach-open:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.attach-thumb.is-uploading .attach-open,
.attach-thumb.is-failed .attach-open { cursor: default; }
.attach-remove {
position: absolute; top: 3px; right: 3px; z-index: 2;
width: 20px; height: 20px; padding: 0;
@@ -470,6 +484,73 @@ h1 {
.attach-link { color: inherit; text-decoration: none; border-radius: 8px; }
.attach-link:hover .attach-thumb, .attach-link:focus-visible .attach-thumb { border-color: var(--accent); }
.attach-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The same hover border a linked thumbnail gets, for a thumbnail whose own
button opens the picview. */
.attach-thumb:has(.attach-open:hover) { border-color: var(--accent); }
/* The full-screen picture preview: the whole viewport, the picture contained
in it, on a near-black backdrop in both themes (a picture is judged against
dark, whatever the page's theme), so its colors are fixed, not tokens. */
.modal.picview {
inset: 0;
width: 100vw;
height: 100vh;
max-width: none;
max-height: none;
margin: 0;
padding: 0;
border: 0;
border-radius: 0;
background: transparent;
box-shadow: none;
color: #f4f1ec;
}
.modal.picview[open] {
display: grid;
grid-template-columns: 72px minmax(0, 1fr) 72px;
grid-template-rows: minmax(0, 1fr) auto;
}
.modal.picview::backdrop { background: rgba(8, 8, 8, 0.92); }
.picview-img {
grid-column: 2;
grid-row: 1;
place-self: center;
max-width: 100%;
max-height: 100%;
object-fit: contain;
padding-top: 24px;
}
.picview-step {
grid-row: 1;
place-self: center;
width: 44px;
height: 44px;
padding: 0;
border: 1px solid rgba(255, 255, 255, 0.35);
border-radius: 50%;
background: rgba(0, 0, 0, 0.45);
color: #fff;
font: 600 28px/1 var(--sans);
cursor: pointer;
}
.picview-step.is-prev { grid-column: 1; }
.picview-step.is-next { grid-column: 3; }
.picview-step:hover,
.picview-step:focus-visible { border-color: #fff; background: rgba(255, 255, 255, 0.14); }
.picview-step[hidden] { display: none; }
.picview-bar {
grid-column: 1 / -1;
grid-row: 2;
display: flex;
align-items: center;
justify-content: center;
gap: 16px;
padding: 12px 16px 20px;
}
.picview-count { margin: 0; font-size: 13.5px; color: rgba(255, 255, 255, 0.8); }
.btn.picview-close { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.35); color: #fff; }
.btn.picview-close:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }
.msg.pending { border-style: dashed; border-color: var(--stage); background: transparent; }
.ask-row .attach-chip { padding-right: 10px; }
@@ -547,8 +628,8 @@ kbd {
}
.waiting-pane h2 { font: 600 23px/1.3 var(--serif); color: var(--ink); margin: 0; }
.waiting-pane p { max-width: 70ch; margin: 0; }
/* The words that open the tasks tab: bold in the highlight color, a button
that reads as part of the sentence. */
/* The words that open the live task view (the phase-file tab on a build):
bold in the highlight color, a button that reads as part of the sentence. */
.waiting-jump {
font: inherit;
font-weight: 700;
+114 -14
View File
@@ -1,4 +1,4 @@
// Plan2Code Web Console - pictures and documents attached to a note: chips, trays, re-encoding, upload, retry; defines only.
// Plan2Code Web Console - pictures and documents attached to a note: chips, trays, re-encoding, upload, retry, the shared picture preview; defines only.
//
// Shared by the question cards and the Ask pane, so neither imports the other.
@@ -19,6 +19,7 @@ import {
} from "./answers.js";
import { hooks, page, saveNow, redraw } from "./state.js";
import { CHAT_MAX_ATTACHMENTS } from "./chat.js";
import { step } from "./notepad.js";
// The chat's images live under local.chat, not beside the notes: the card
// send gathers every entry of local.images, and a chat picture is not a note.
@@ -91,12 +92,26 @@ export function attachTray(itemId, attached) {
if (attachmentKind(img) === "file") fig = docChip(img, img.status);
else {
fig = el("figure", "attach-thumb is-" + img.status);
fig.dataset.key = img.key;
const src = thumbs.get(img.key) || img.url;
if (src) {
const pic = el("img");
pic.src = src;
pic.alt = img.name;
fig.appendChild(pic);
// The picture fills a button that opens the picview; inert until the
// upload lands (the spinner or Retry overlay covers it meanwhile).
const open = el("button", "attach-open");
open.type = "button";
open.appendChild(pic);
if (img.status === "ready" && (img.url || img.path)) {
open.addEventListener("click", () => {
const slides = attached
.filter((x) => attachmentKind(x) !== "file" && x.status === "ready" && (x.url || x.path))
.map((x) => ({ key: x.key, url: uploadUrl(x), alt: x.name || "image" }));
openPicview(slides, slides.findIndex((s) => s.key === img.key), () => refocusThumb(img.key));
});
} else open.setAttribute("aria-disabled", "true");
fig.appendChild(open);
}
}
const rm = el("button", "attach-remove", "×");
@@ -366,30 +381,115 @@ export function heldNotes() {
return draftedNotes().filter((n) => n.held);
}
// A sent note's attachments as links: an image opens full size, a document
// opens in its own tab. The page serves both by the upload's own file name.
// A sent note's attachments: an image's thumbnail opens the picview like every
// other tray's (the refocus token is its URL, sent entries carrying no key), a
// document stays a link that opens in its own tab.
export function sentAttachments(note) {
const entries = [
...(note.images || []).map((e) => ({ ...e, kind: "image" })),
...(note.files || []).map((e) => ({ ...e, kind: "file" })),
];
if (!entries.length) return null;
const slides = entries.filter((e) => e.kind === "image").map((e) => ({ url: uploadUrl(e), alt: e.name || "image" }));
const tray = el("div", "attach-tray");
for (const e of entries) {
const a = el("a", "attach-link");
a.href = uploadUrl(e);
a.target = "_blank";
a.rel = "noopener";
a.title = e.name || "attachment";
if (e.kind === "image") {
const url = uploadUrl(e);
const fig = el("figure", "attach-thumb is-ready");
fig.dataset.key = url;
const pic = el("img");
pic.src = a.href;
pic.src = url;
pic.alt = e.name || "image";
fig.appendChild(pic);
a.appendChild(fig);
} else a.appendChild(docChip({ name: e.name || "file" }, "ready"));
tray.appendChild(a);
const open = el("button", "attach-open");
open.type = "button";
open.appendChild(pic);
open.addEventListener("click", () => openPicview(slides, slides.findIndex((s) => s.url === url), () => refocusThumb(url)));
fig.appendChild(open);
tray.appendChild(fig);
} else {
const a = el("a", "attach-link");
a.href = uploadUrl(e);
a.target = "_blank";
a.rel = "noopener";
a.title = e.name || "attachment";
a.appendChild(docChip({ name: e.name || "file" }, "ready"));
tray.appendChild(a);
}
}
return tray;
}
/* ------------------------------------------------------------ picview */
// The page's one full-screen picture preview (the #picview dialog in
// index.html), opened from any thumbnail: the Notebook's strip, the note
// trays and sent pictures all land here. `slides` is the set it steps
// through as [{ url, alt }], `index` where it starts, and `restore` (a
// function, optional) gets the focus back when it closes.
let viewing = { list: [], index: -1, restore: null };
let picviewWired = false;
// Focus the open button of the thumbnail with this key again; whether found.
// The tray may have redrawn while the preview was up, so the lookup runs at
// close time, not from a held element. Exported for the trays uploads.js does
// not draw itself (sent Ask messages).
export function refocusThumb(key) {
const btn = key && document.querySelector(`[data-key="${CSS.escape(key)}"] .attach-open`);
if (!btn) return false;
btn.focus();
return true;
}
function picviewAt(index) {
const { list } = viewing;
const entry = list[index];
viewing.index = index;
const pic = document.getElementById("picview-img");
pic.src = entry.url;
pic.alt = entry.alt || "";
document.getElementById("picview-count").textContent = `${index + 1} of ${list.length}`;
document.getElementById("picview-prev").hidden = document.getElementById("picview-next").hidden = list.length < 2;
}
const picviewStep = (delta) => {
const index = step(viewing.index, delta, viewing.list.length);
if (index >= 0) picviewAt(index);
};
// Bound on first use: the arrows and Esc (kept from whatever sits under the
// dialog, as the Notebook is), the close button, and the focus restore.
function wirePicview() {
if (picviewWired) return;
picviewWired = true;
const dlg = document.getElementById("picview");
document.getElementById("picview-prev").addEventListener("click", () => picviewStep(-1));
document.getElementById("picview-next").addEventListener("click", () => picviewStep(1));
document.getElementById("picview-close").addEventListener("click", () => dlg.close());
dlg.addEventListener("keydown", (e) => {
if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
e.preventDefault();
picviewStep(e.key === "ArrowLeft" ? -1 : 1);
} else if (e.key === "Escape") {
e.preventDefault();
e.stopPropagation();
dlg.close();
}
});
dlg.addEventListener("close", () => {
document.getElementById("picview-img").removeAttribute("src");
const restore = viewing.restore;
viewing = { list: [], index: -1, restore: null };
if (restore) restore();
});
}
export function openPicview(slides, index, restore) {
const list = (Array.isArray(slides) ? slides : []).filter((s) => s && s.url);
if (index < 0 || index >= list.length) return;
wirePicview();
viewing = { list, index, restore: typeof restore === "function" ? restore : null };
picviewAt(index);
const dlg = document.getElementById("picview");
if (!dlg.open) dlg.showModal();
document.getElementById("picview-close").focus();
}