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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user