diff --git a/app/src/admin.spec.md b/app/src/admin.spec.md index ed75f35..cc40009 100644 --- a/app/src/admin.spec.md +++ b/app/src/admin.spec.md @@ -229,7 +229,8 @@ records and "Traces"), so it works while the services are stopped. Nothing it re - Each item is `said` (a voice transcript, or a chat message by someone other than Jarvis), `answered` (a spoken answer, or Jarvis's own chat message; to whom, when it answers someone) or - `thought` (a trace: the question, the answer or none, how long it took and its steps). Jarvis's + `thought` (a trace: the question, the answer or none, how long it took and its steps so far, at + the time it was asked; `pending` while the answer is being made, with `ms` 0 until it ends). Jarvis's chat messages are known by the bot's user id (the first part of the stored token is that id in base64) and by the author of any chat answer to someone. - `history_query` `{said, answered, thought, via, person, channel, find, since, until, session, before, from, limit}`: the @@ -708,7 +709,8 @@ its data folder, and again after each one is saved. The log hub writes to the da ## Screens (`app/ui/`) Plain HTML, CSS and an ES module, no build step, dark theme after `DESIGN.md`. All text is Korean. -The side menu has 대화 right under 대시보드 and 앱 last. +The side menu has 대화 right under 대시보드 and 앱 last; there is no separate update screen (updates +are on the 앱 screen). - **First-run wizard** (while `firstRun`): data folder (free space, warning under 200 GB), PC check, the model to download, Discord bot (token check with the @@ -733,20 +735,24 @@ The side menu has 대화 right under 대시보드 and 앱 last. newest 100, filtered by any target that has results, each with its time, title, link and the start of its text shown as plain text). The 예약 screen has `schedule.chatChannel` and every person's schedules (next time or "다시 울리지 않음", repeat, who and how they asked, kind and text as plain text, the last - outcome, delete). The 앱 screen has `app.closeButton` (완전 종료 or 트레이로 최소화) with a note - that the tray icon opens the window again and its menu quits; saving it needs no restart. + outcome, delete). The 앱 screen has the update card (below) first, then `app.closeButton` (완전 종료 + or 트레이로 최소화) with a note that the tray icon opens the window again and its menu quits; + saving it needs no restart. - **사람별 지침**: every person's notes (name and ID, the text in a box, save and delete). - **대화**: what people said, Jarvis's answers and how each answer was made, in time order with a date line between days; people's words on the left, Jarvis's on the right with whom it answered, each with its time, voice or chat and channel, and a copy button. A trace is a closed card (whose question, how many tool calls, seconds, no answer) that opens to the question, the records and notes it was given, the tools offered, the plan, the model's thinking, each tool call (name, - arguments, success, failure or skipped and why, its result) and the answer. Filters: the three + arguments, success, failure or skipped and why, its result) and the answer. A trace sits at the + time it was asked and is there while the answer is made (`pending`, "답을 만드는 중"): it fills in + step by step, and one seen being made is open and stays open with its answer unless the user + closes it. Filters: the three kinds as chips, "현재 세션" (off by default: only items since the bot was last started, `session`; the count line starts with that start's date and time, and with no start yet in this app run the list says so; a new start while it is on starts the list over from that start), where (음성, 채팅, 정기 작업), person, channel, one day and text; "실시간" (on by - default) re-reads the live window every 3 seconds: every item from its first one on (`from`, up to + default) re-reads the live window every second while a trace in it is being made, else every 3 seconds: every item from its first one on (`from`, up to 2,000). Only items in that window change on screen, an edited message included; items paged back past it stay as they were loaded (edits and deletes there show after a reload of the screen). The screen redraws only when an item changed, keeping the cards the user opened open and the scroll @@ -759,9 +765,10 @@ The side menu has 대화 right under 대시보드 and 앱 last. shown. The paging is `app/ui/talk.js`, pure, checked by `node --test app/tests/ui/talk.test.mjs`. - **한 일**: the activity (time, kind, target, who asked, outcome and why it failed), newest 200, with a refresh button. -- **업데이트**: the version here, the state, "다시 확인", "받기" (with its percentage) and "설치하고 - 다시 시작", and the release's notes as plain text. The app checks once when the main screens open; - a newer release renames the button "업데이트 (새 버전)" and says so once. +- **업데이트** (a card on the 앱 screen, re-read every second while it is shown): the version here, + the state, "다시 확인", "받기" (with its percentage) and "설치하고 다시 시작", and the release's + notes as plain text. The app checks once when the main screens open; a newer release renames the + 앱 button "앱 (새 버전)" and says so once. - **Logs**: tab, level and text filters, pause, live follow (lines after the last seen), "최근 오류 복사" (to the clipboard; over 2,000 characters it suggests the zip), and the zip export by days. diff --git a/app/ui/app.js b/app/ui/app.js index 072a7f2..dc02c72 100644 --- a/app/ui/app.js +++ b/app/ui/app.js @@ -449,7 +449,9 @@ function conversationScreen() { const day = h("input", { type: "date" }); const find = h("input", { type: "text", placeholder: "찾기 (말, 답, 생각)", style: "max-width:220px" }); const live = h("input", { type: "checkbox", class: "switch", checked: true }); - const open = new Set(); // traces the user opened stay open across refreshes + // Traces the user opened stay open across refreshes, and so does one seen while being made + // unless the user closed it. + const open = new Set(), shut = new Set(); // `page`: the live window and the older pages (talk.js). Each filter change starts a new epoch; // answers from an earlier epoch, and live answers older than the newest one asked, are dropped. let expandAll = false, sig = null, page = empty(), missing = false, sessionAt = null; @@ -474,15 +476,20 @@ function conversationScreen() { const where = h("span", { class: "small muted" }, timeOf(i.at), " · ", VIA[i.via] || i.via, i.channel ? " · " + channelName(i.channel) : ""); if (i.type === "thought") { const tools = (i.steps || []).filter((s) => s.kind === "tool" && !s.skipped).length; + const summary = h("summary", {}, h("span", { class: "who" }, "자비스 생각"), " ", + h("span", { class: "small muted" }, `${i.who.name || i.who.id}의 말에 답하며`, tools ? ` · 도구 ${tools}번` : "", + i.pending ? " · 답을 만드는 중" : ` · ${(i.ms / 1000).toFixed(1)}초${i.answer ? "" : " · 답 없음"}`), " ", where); + if (i.pending && !shut.has(i.key)) open.add(i.key); // stays open with its answer once done const d = h("details", { class: "msg thought", open: expandAll || open.has(i.key) }, - h("summary", {}, h("span", { class: "who" }, "자비스 생각"), " ", - h("span", { class: "small muted" }, `${i.who.name || i.who.id}의 말에 답하며`, tools ? ` · 도구 ${tools}번` : "", - ` · ${(i.ms / 1000).toFixed(1)}초`, i.answer ? "" : " · 답 없음"), " ", where), + summary, h("div", { class: "steps" }, h("div", { class: "step-row" }, h("div", { class: "k" }, "받은 말"), h("div", {}, i.question)), (i.steps || []).map(traceStep), - h("div", { class: "step-row" }, h("div", { class: "k" }, "답"), i.answer ? h("div", {}, i.answer) : h("span", { class: "badge bad" }, "답하지 못함")))); - d.addEventListener("toggle", () => (d.open ? open.add(i.key) : open.delete(i.key))); + h("div", { class: "step-row" }, h("div", { class: "k" }, "답"), i.pending ? h("div", {}, h("span", { class: "badge warn" }, "만드는 중")) + : i.answer ? h("div", {}, i.answer) : h("span", { class: "badge bad" }, "답하지 못함")))); + summary.addEventListener("click", () => { + if (d.open) { open.delete(i.key); shut.add(i.key); } else { open.add(i.key); shut.delete(i.key); } + }); return d; } const mine = i.type === "answered"; @@ -576,12 +583,18 @@ function conversationScreen() { h("div", { class: "row" }, saidChip, answeredChip, thoughtChip, sessionChip), h("div", { class: "row" }, via, person, channel, day, find), h("div", { class: "row" }, h("label", { class: "row small muted" }, live, "실시간"), - h("button", { class: "btn", onclick: () => { expandAll = !expandAll; if (!expandAll) open.clear(); sig = null; load(); } }, "생각 모두 펼치기/접기"), + h("button", { class: "btn", onclick: () => { expandAll = !expandAll; open.clear(); shut.clear(); sig = null; load(); } }, "생각 모두 펼치기/접기"), h("button", { class: "btn", onclick: () => { sig = null; load(); } }, "새로 고침"), summary)), - h("div", { class: "hint", style: "margin:8px 0" }, "사람이 한 말, 자비스의 답, 자비스가 답을 만든 과정(참고한 기록, 고른 도구, 계획, 도구 호출과 결과, 모델 생각)을 시간순으로 보여 줍니다. 모델 생각은 생각 모드가 켜진 답에만 있습니다. 생각 기록은 30일 동안 둡니다. 실시간으로 다시 읽는 것은 최근 2,000개까지이고, 그보다 앞서 불러온 기록의 수정과 삭제는 화면을 다시 열면 보입니다."), + h("div", { class: "hint", style: "margin:8px 0" }, "사람이 한 말, 자비스의 답, 자비스가 답을 만든 과정(참고한 기록, 고른 도구, 계획, 도구 호출과 결과, 모델 생각)을 시간순으로 보여 줍니다. 자비스가 말을 알아들은 순간 생각이 나타나고, 답을 만드는 동안 단계가 하나씩 채워집니다. 모델 생각은 생각 모드가 켜진 답에만 있습니다. 생각 기록은 30일 동안 둡니다. 실시간으로 다시 읽는 것은 최근 2,000개까지이고, 그보다 앞서 불러온 기록의 수정과 삭제는 화면을 다시 열면 보입니다."), h("div", { class: "row", style: "justify-content:center" }, more), box); load(); - return { view, tick: () => live.checked && load() }; + // Every second while an answer is being made, so its trace fills in as it goes; else every 3 seconds. + let ticks = 0; + const tick = () => { + const making = page.shown.some((i) => i.pending); + if (live.checked && (making || ++ticks % 3 === 0)) load(); + }; + return { view, tick }; } async function settingsScreen(screen, title, extra) { @@ -825,8 +838,8 @@ function logsScreen() { // ---- update ------------------------------------------------------------------------------------- -/** The update screen: the version here, the newest release, its download and install. */ -function updateScreen() { +/** The 앱 screen's update card: the version here, the newest release, its download and install. */ +function updateCard() { const body = h("div"); let key = null; async function tick() { @@ -844,7 +857,7 @@ function updateScreen() { const line = { idle: "아직 확인하지 않았습니다", checking: "확인하는 중…", upToDate: "최신 버전입니다", available: `새 버전 ${u.latest?.version}이 있습니다`, downloading: `받는 중${pct != null ? ` ${pct}%` : ""}`, ready: `${u.latest?.version}을 설치할 준비가 됐습니다`, failed: u.error ?? "실패했습니다" }[u.phase] ?? u.phase; - body.replaceChildren(h("div", { class: "card" }, + body.replaceChildren(h("div", { class: "card" }, h("h2", {}, "업데이트"), h("div", { class: "kv" }, h("span", { class: "k" }, "현재 버전"), h("span", {}, u.current), h("span", { class: "k" }, "상태"), h("span", { style: u.phase === "failed" ? "color:var(--bad)" : "" }, line)), h("div", { class: "row", style: "margin-top:12px" }, @@ -856,15 +869,15 @@ function updateScreen() { h("pre", { class: "small", style: "white-space:pre-wrap" }, u.latest.notes)) : ""); } tick(); - return { view: h("div", {}, h("h1", {}, "업데이트"), body), tick }; + return { view: body, tick }; } /** Look for a new version once when the app opens; the nav button says so when there is one. */ async function checkUpdate() { try { const u = await api("update_check"); - if (u.latest) { $("#nav-update").textContent = "업데이트 (새 버전)"; toast(`새 버전 ${u.latest.version}이 있습니다. 업데이트 화면에서 설치할 수 있습니다.`); } - } catch (e) { /* offline: the update screen shows why */ } + if (u.latest) { $("#nav-app").textContent = "앱 (새 버전)"; toast(`새 버전 ${u.latest.version}이 있습니다. 앱 화면에서 설치할 수 있습니다.`); } + } catch (e) { /* offline: the 앱 screen shows why */ } } // ---- navigation --------------------------------------------------------------------------------- @@ -901,18 +914,20 @@ async function show(name) { if (name === "dashboard") { screen.replaceChildren(); await refresh(); ticker = setInterval(refresh, 1000); return; } if (name === "logs") { const l = logsScreen(); screen.replaceChildren(l.view); ticker = setInterval(l.tick, 1000); return; } if (name === "activity") { screen.replaceChildren(activityScreen()); return; } - if (name === "conversations") { const c = conversationScreen(); screen.replaceChildren(c.view); ticker = setInterval(c.tick, 3000); return; } + if (name === "conversations") { const c = conversationScreen(); screen.replaceChildren(c.view); ticker = setInterval(c.tick, 1000); return; } if (name === "notes") { screen.replaceChildren(notesScreen()); return; } - if (name === "update") { const u = updateScreen(); screen.replaceChildren(u.view); ticker = setInterval(u.tick, 1000); return; } const titles = { bot: "봇", channels: "채널·호출", chat: "채팅 채널", memory: "대화 기억", model: "모델", features: "기능", collect: "백그라운드 수집", game: "게임 모드", schedule: "예약", pcControl: "PC 제어", app: "앱" }; + const update = name === "app" ? updateCard() : null; const extra = name === "bot" ? await tokenCard() : name === "features" ? await displayDriverCard() - : name === "app" ? h("div", { class: "hint", style: "margin-bottom:12px" }, "트레이로 최소화하면 창만 숨고 봇과 서비스는 계속 돕니다. 작업 표시줄 오른쪽의 Jarvis 아이콘을 누르면 창이 다시 열리고, 아이콘의 오른쪽 클릭 메뉴에서 완전 종료할 수 있습니다. 저장하면 바로 적용됩니다.") : null; + : name === "app" ? h("div", {}, update.view, h("div", { class: "hint", style: "margin:12px 0" }, "트레이로 최소화하면 창만 숨고 봇과 서비스는 계속 돕니다. 작업 표시줄 오른쪽의 Jarvis 아이콘을 누르면 창이 다시 열리고, 아이콘의 오른쪽 클릭 메뉴에서 완전 종료할 수 있습니다. 저장하면 바로 적용됩니다.")) : null; const view = await settingsScreen(name, titles[name], extra); if (name === "collect") view.append(await collectResults()); if (name === "schedule") view.append(await scheduleList()); if (name === "pcControl") view.append(await permissionsCard()); - if (my === gen) screen.replaceChildren(view); + if (my !== gen) return; + screen.replaceChildren(view); + if (update) ticker = setInterval(update.tick, 1000); } catch (e) { fail(e); } } diff --git a/app/ui/index.html b/app/ui/index.html index 7794e11..cd7d2f4 100644 --- a/app/ui/index.html +++ b/app/ui/index.html @@ -26,8 +26,7 @@ - - +