Warn about a too-long tab name as you type

AI Assisted
This commit is contained in:
jparkerweb committed 2026-11-08 08:17:08 -08:00
1 parent 9f4ee75c0b
commit 4ca53ccf3a
5 files changed
+43 -2

No files matched your search

+4
View File
@@ -11,6 +11,10 @@ All notable changes to Plan2Code will be documented in this file.
- **web console**: the **Install page** link on the agent setup page now opens in your default browser inside the desktop app. It did nothing there, because the page was not told it was running in the app.
- **web console**: a note you have sent now shows a small spinner in front of "Sent, waiting for Plan2Code" in the Notes panel, so it is clear Plan2Code is still working on it. The spinner hides when the agent has gone quiet, so a dead session is not mistaken for a slow one.
### 🔧 Changed
- **web console**: the Notebook's tab name dialog now counts characters as you type (such as `41/40`), warns the moment a name passes the 40 character limit and disables Save until it fits, instead of only saying so after you press Save.
## v3.0.3
### 🐛 Fixed
+12
View File
@@ -477,6 +477,17 @@ test("New tab asks for a name, refuses a bad or duplicate one, and Escape backs
await s.page.fill("#notepad-name", " ");
await s.page.click("#notepad-name-save");
assert.equal(await nameError(s), "Give the tab a name.");
await s.page.fill("#notepad-name", "x".repeat(40));
assert.equal(await s.page.locator("#notepad-name-count").textContent(), "40/40");
assert.equal(await s.page.locator("#notepad-name-save").isDisabled(), false, "40 characters still saves");
await s.page.fill("#notepad-name", "x".repeat(41));
// The warning and the count show as you type, before Save is pressed.
assert.match(await nameError(s), /40 characters or fewer/);
assert.equal(await s.page.locator("#notepad-name-count").textContent(), "41/40");
assert.equal(await s.page.locator("#notepad-name-save").isDisabled(), true, "Save waits until the name fits");
await s.page.fill("#notepad-name", "x".repeat(40));
assert.equal(await nameError(s), "", "the warning goes once it fits");
assert.equal(await s.page.locator("#notepad-name-save").isDisabled(), false);
await s.page.fill("#notepad-name", "x".repeat(41));
await s.page.keyboard.press("Enter");
assert.match(await nameError(s), /40 characters or fewer/);
@@ -582,6 +593,7 @@ test("Double-click opens the rename modal with the name selected; F2 works too,
await s.page.locator("#notepad-name-dlg[open]").waitFor();
assert.equal(await s.page.locator("#notepad-name-label").textContent(), "Rename this tab");
assert.equal(await s.page.inputValue("#notepad-name"), "Ideas");
assert.equal(await s.page.locator("#notepad-name-count").textContent(), "5/40", "Rename shows the count too");
assert.equal(await s.page.evaluate(() => document.getElementById("notepad-name").selectionEnd - document.getElementById("notepad-name").selectionStart), 5, "the name is selected");
// Its own name is not a duplicate; another tab's is.
await s.page.keyboard.press("Enter");
+3 -1
View File
@@ -3786,7 +3786,8 @@
<dialog class="modal notepad-sub" id="notepad-name-dlg" aria-labelledby="notepad-name-label">
<form class="notepad-name-form" id="notepad-name-form" novalidate>
<h2 id="notepad-name-label">Name this tab</h2>
<input type="text" id="notepad-name" autocomplete="off" spellcheck="false" aria-describedby="notepad-name-error" />
<input type="text" id="notepad-name" autocomplete="off" spellcheck="false" aria-describedby="notepad-name-error notepad-name-count" />
<p class="help notepad-name-count" id="notepad-name-count"></p>
<p class="help notepad-name-error" id="notepad-name-error" aria-live="polite"></p>
<div class="modal-actions">
<button type="button" class="btn ghost" id="notepad-name-cancel">Cancel</button>
@@ -4102,6 +4103,7 @@
<div class="footer-actions">
<span class="hint" id="send-hint"></span>
<button type="button" class="btn ghost" id="btn-clear" hidden>Clear</button>
<button type="button" class="btn" id="btn-dashboard" hidden>Back to the dashboard</button>
<button type="button" class="btn primary" id="btn-send" disabled>Send to Plan2Code</button>
</div>
</footer>
+22 -1
View File
@@ -19,6 +19,7 @@ import {
NOT_LOADED,
SAVE_START,
TAB_ID_RE,
TAB_NAME_MAX,
cleanTabName,
errorSentence,
keepsText,
@@ -274,7 +275,7 @@ function drawTabs() {
drawSent();
$("notepad-tab-new").disabled = busy;
$("notepad-empty-new").disabled = busy;
$("notepad-name-save").disabled = busy;
$("notepad-name-save").disabled = busy || nameTooLong();
}
// Put a read tab on screen: its text, its pictures, the bar. `keep` leaves
@@ -390,6 +391,24 @@ function nameError(sentence) {
$("notepad-name").focus();
}
// The name as the server would count it: trimmed, inner spaces collapsed.
const nameLength = () => [...$("notepad-name").value.trim().replace(/\s+/g, " ")].length;
const nameTooLong = () => nameLength() > TAB_NAME_MAX;
// The count under the box, and the too-long warning and Save as you type,
// not only once Save is pressed. Other problems are still said on Save.
let liveWarning = false;
function paintNameCount() {
const over = nameTooLong();
const count = $("notepad-name-count");
count.textContent = `${nameLength()}/${TAB_NAME_MAX}`;
count.classList.toggle("over", over);
if (over) $("notepad-name-error").textContent = tabNameProblem([], $("notepad-name").value);
else if (liveWarning) $("notepad-name-error").textContent = "";
liveWarning = over;
$("notepad-name-save").disabled = busy || over;
}
function openNameForm(mode) {
if (busy || (mode === "rename" && !activeId)) return;
closeDelete();
@@ -399,6 +418,7 @@ function openNameForm(mode) {
if (!$("notepad-name-dlg").open) $("notepad-name-dlg").showModal();
const input = $("notepad-name");
input.value = mode === "rename" ? nameOf(activeId) : "";
paintNameCount();
input.focus();
input.select();
}
@@ -911,6 +931,7 @@ export function wireNotepad() {
$("notepad-delete-keep").addEventListener("click", () => closeDelete(true));
$("notepad-delete-go").addEventListener("click", confirmDelete);
$("notepad-name-cancel").addEventListener("click", () => closeNameForm());
$("notepad-name").addEventListener("input", paintNameCount);
$("notepad-name-form").addEventListener("submit", (e) => {
e.preventDefault();
submitName();
@@ -199,6 +199,8 @@
font: inherit;
}
.notepad-name-form input:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.notepad-name-count { margin: 4px 0 0; text-align: right; font-variant-numeric: tabular-nums; }
.notepad-name-count.over { color: var(--warn); }
.notepad-name-error { min-height: 1.2em; margin: 6px 0 0; }
.notepad-name-error:not(:empty) { color: var(--warn); }
.modal.notepad-delete { border-color: var(--warn); }