feat: stack quick-capture box on chat page (no LLM)

Slim numeric input below the message box; posts to /session/stack and
drops a confirmation line into the Live Log without a chat turn.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G796GsLCvJQKVN7hwV2cDx
This commit is contained in:
2026-06-29 00:25:18 +00:00
parent 52839a9bc8
commit 8d709b9554
2 changed files with 80 additions and 0 deletions
+52
View File
@@ -124,6 +124,12 @@
<button id="sendBtn" aria-label="Send" title="Send (or ⌘/Ctrl+Enter)"></button>
</div>
<!-- Stack quick-capture (no LLM): type a number -> logs current stack -->
<div id="stackQuick">
<input id="stackQuickInput" type="number" inputmode="decimal" placeholder="Stack $" aria-label="Log current stack">
<button id="stackQuickBtn" type="button" title="Log stack (no chat)">Log</button>
</div>
<!-- Bottom tab bar (mobile only; hides while the keyboard is open) -->
<nav id="tabbar" aria-label="Primary navigation">
<a class="tab active" href="/" aria-current="page"><span class="ti">💬</span><span class="tl">Chat</span></a>
@@ -209,6 +215,52 @@
const API_URL = `${RELAY_BASE}/v1/chat/completions`;
const STREAM_URL = `${RELAY_BASE}/v1/chat/stream`;
// Stack quick-capture (no LLM): type a number -> POST /session/stack.
function stackQuickLog() {
const el = document.getElementById("stackQuickInput");
if (!el) return;
const raw = (el.value || "").replace(/[^0-9.]/g, "");
if (!raw) return;
const amount = Number(raw);
const content = document.getElementById("thinkingContent");
const empty = document.getElementById("thinkingEmpty");
fetch("/session/stack", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ amount })
}).then(r => r.json()).then(data => {
if (empty && empty.parentNode) empty.parentNode.removeChild(empty);
const line = document.createElement("div");
const t = new Date().toLocaleTimeString();
if (!data.ok) {
line.className = "log-line log-error";
line.textContent = "⚠ " + (data.error || "stack not logged");
} else {
line.className = "log-line log-info";
const net = (data.stack && data.stack.net != null)
? " (net " + (data.stack.net >= 0 ? "+" : "") + data.stack.net + ")" : "";
line.textContent = t + " 💰 $" + amount + " logged" + net;
el.value = "";
}
if (content) { content.appendChild(line); content.scrollTop = content.scrollHeight; }
}).catch(e => {
if (content) {
const line = document.createElement("div");
line.className = "log-line log-error";
line.textContent = "⚠ stack log failed: " + e.message;
content.appendChild(line);
}
});
}
(function wireStackQuick() {
const btn = document.getElementById("stackQuickBtn");
const inp = document.getElementById("stackQuickInput");
if (btn) btn.addEventListener("click", stackQuickLog);
if (inp) inp.addEventListener("keydown", function (e) {
if (e.key === "Enter") { e.preventDefault(); stackQuickLog(); }
});
})();
function generateSessionId() {
return "sess-" + Math.random().toString(36).substring(2, 10);
}
+28
View File
@@ -1231,3 +1231,31 @@ select:hover {
scroll-behavior: auto !important;
}
}
/* Stack quick-capture (2nd input box on the chat page) — logs without the LLM. */
#stackQuick {
display: flex;
gap: 8px;
align-items: center;
padding: 6px 12px;
border-top: 1px solid var(--border);
background: var(--bg-panel);
}
#stackQuick input {
flex: 1;
min-width: 0;
padding: 8px 10px;
background: var(--bg-elev);
color: inherit;
border: 1px solid var(--border);
border-radius: 8px;
}
#stackQuick button {
padding: 8px 14px;
background: var(--accent);
color: #000;
border: none;
border-radius: 8px;
font-weight: 600;
cursor: pointer;
}