From 1a127556491e4f29708d7db60e00b418251bb6b0 Mon Sep 17 00:00:00 2001 From: javis-bot Date: Mon, 16 Nov 2026 10:42:09 +0900 Subject: [PATCH] =?UTF-8?q?feat(app):=20=EB=8C=80=ED=99=94=20under=20?= =?UTF-8?q?=EB=8C=80=EC=8B=9C=EB=B3=B4=EB=93=9C,=20a=20current=20session?= =?UTF-8?q?=20view,=20shortcuts=20that=20follow=20the=20app=20icon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - The side menu has 대화 right under 대시보드. - 대화 screen: a "현재 세션" chip (off by default) shows only what came since the bot was last started. The controller keeps when the latest start began; history_query takes `session` and answers it back, so the count line names that start and a new start starts the list over. - Installer: the shortcuts' icon is a file named by its content (jarvis-.ico). Windows keeps an icon it has shown by its path, so after an update the desktop shortcuts kept the old icon. Every .lnk to jarvis.exe on the desktops and in the start menus (an earlier version's and the person's own too) now points at the new file, set by the 64-bit PowerShell: a 32-bit one reads Program Files links as Program Files (x86). Checked on the Windows VM: 0.1.6 to 0.1.9 left both desktop shortcuts old; to this build they and search show the new icon. Co-Authored-By: Claude Opus 5.5 --- app/shell/installer.nsi | 21 ++++++++++++++++++--- app/shell/installer.sh | 4 +++- app/src/admin.spec.md | 23 +++++++++++++++++------ app/src/admin_api.rs | 33 ++++++++++++++++++++++++++++++++- app/src/control.rs | 10 +++++++++- app/ui/app.js | 21 ++++++++++++++------- app/ui/index.html | 2 +- 7 files changed, 94 insertions(+), 20 deletions(-) diff --git a/app/shell/installer.nsi b/app/shell/installer.nsi index 4ef43bd..46b23ef 100644 --- a/app/shell/installer.nsi +++ b/app/shell/installer.nsi @@ -1,5 +1,5 @@ ; The Jarvis installer (admin.spec.md, "Installer"). Built on Linux by installer.sh with makensis: -; makensis -DVERSION=0.1.0 -DSRC= -DOUT= -DICON= -DWEBVIEW2= +; makensis -DVERSION=0.1.0 -DSRC= -DOUT= -DICON= -DICON_FILE=.ico> -DWEBVIEW2= ; -DUNINSTALL_LIST= installer.nsi ; Program Files, one administrator prompt; the data folder is chosen by the app's first-run wizard ; and never touched here. /S installs silently (the app's updates: /S /RUN starts the app afterwards). @@ -220,6 +220,10 @@ Section "Jarvis (필수)" SecMain SetOutPath "$INSTDIR" File "${SRC}/jarvis.exe" File "${SRC}/WebView2Loader.dll" + ; The shortcuts' icon, named by its content: Windows keeps an icon it has shown by the file's path, + ; so a changed icon under the old path would stay the old one on the desktop and in search. + Delete "$INSTDIR\jarvis-*.ico" + File "/oname=${ICON_FILE}" "${ICON}" File /r "${SRC}/python-src" File /r "${SRC}/display-driver" WriteUninstaller "$INSTDIR\uninstall.exe" @@ -237,11 +241,21 @@ Section "Jarvis (필수)" SecMain SectionEnd Section "시작 메뉴 바로 가기" SecStart - CreateShortCut "$SMPROGRAMS\Jarvis.lnk" "$INSTDIR\jarvis.exe" + CreateShortCut "$SMPROGRAMS\Jarvis.lnk" "$INSTDIR\jarvis.exe" "" "$INSTDIR\${ICON_FILE}" 0 SectionEnd Section /o "바탕 화면 바로 가기" SecDesktop - CreateShortCut "$DESKTOP\Jarvis.lnk" "$INSTDIR\jarvis.exe" + CreateShortCut "$DESKTOP\Jarvis.lnk" "$INSTDIR\jarvis.exe" "" "$INSTDIR\${ICON_FILE}" 0 +SectionEnd + +; Every shortcut to jarvis.exe on the desktops and in the start menus (the person's own too, and the +; installer's from an earlier version, which an update does not make again) shows this version's +; icon file; then Explorer redraws its icons. The 64-bit PowerShell (SysNative from this 32-bit +; installer): a 32-bit one reads a link to Program Files as one to Program Files (x86). +Section "-Icons" + nsExec::Exec `"$WINDIR\SysNative\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -NonInteractive -Command "$$w = New-Object -ComObject WScript.Shell; foreach ($$d in 'Desktop', 'CommonDesktopDirectory', 'Programs', 'CommonPrograms') { Get-ChildItem -LiteralPath ([Environment]::GetFolderPath($$d)) -Filter *.lnk -EA 0 | ForEach-Object { $$l = $$w.CreateShortcut($$_.FullName); if ($$l.TargetPath -ieq '$INSTDIR\jarvis.exe') { $$l.IconLocation = '$INSTDIR\${ICON_FILE},0'; $$l.Save() } } }"` + Pop $0 + System::Call 'shell32::SHChangeNotify(i 0x08000000, i 0, p 0, p 0)' ; SHCNE_ASSOCCHANGED SectionEnd Section "가상 모니터 드라이버" SecDriver @@ -303,6 +317,7 @@ Section "Uninstall" ; folder the person chose may hold other things; folders go only when empty. Delete "$INSTDIR\jarvis.exe" Delete "$INSTDIR\WebView2Loader.dll" + Delete "$INSTDIR\jarvis-*.ico" !include "${UNINSTALL_LIST}" Delete "$INSTDIR\uninstall.exe" RMDir "$INSTDIR" diff --git a/app/shell/installer.sh b/app/shell/installer.sh index 88a108b..b3ae24e 100755 --- a/app/shell/installer.sh +++ b/app/shell/installer.sh @@ -20,7 +20,9 @@ setup="$out/Jarvis-Setup-$version.exe" # The uninstall entry's size: what this setup installs, counted here. Counting the install folder on # the user's PC would also walk a data folder kept inside it (models, runtime: many thousand files). size_kb=$(cd "$out/Jarvis" && du -sk --apparent-size -c jarvis.exe WebView2Loader.dll python-src display-driver | tail -1 | cut -f1) -makensis -V2 -DVERSION="$version" -DSRC="$out/Jarvis" -DOUT="$setup" -DICON="$here/icons/icon.ico" \ +# The shortcuts' icon file is named by its content, so a new icon gets a path Windows has not seen. +icon_file="jarvis-$(sha256sum "$here/icons/icon.ico" | cut -c1-12).ico" +makensis -V2 -DVERSION="$version" -DSRC="$out/Jarvis" -DOUT="$setup" -DICON="$here/icons/icon.ico" -DICON_FILE="$icon_file" \ -DWEBVIEW2="$wv2" -DUNINSTALL_LIST="$list" -DSIZE_KB="$size_kb" ${NSIS_EXTRA:-} "$here/installer.nsi" (cd "$out" && sha256sum "Jarvis-Setup-$version.exe" > "Jarvis-Setup-$version.exe.sha256") echo "$setup" diff --git a/app/src/admin.spec.md b/app/src/admin.spec.md index 37922a8..084cd1f 100644 --- a/app/src/admin.spec.md +++ b/app/src/admin.spec.md @@ -232,17 +232,19 @@ records and "Traces"), so it works while the services are stopped. Nothing it re `thought` (a trace: the question, the answer or none, how long it took and its steps). 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, before, from, limit}`: the +- `history_query` `{said, answered, thought, via, person, channel, find, since, until, session, before, from, limit}`: the three kinds (each on unless false), where (`voice`, `chat`, `task`; a task has traces only), a person (their records, answers to them and traces of their questions), a channel, text the record or the trace's question, answer or steps contains (records folded like the store: NFKC, lower - case), Unix seconds from (inclusive) and to (exclusive), the cursors `before` (only items older + case), Unix seconds from (inclusive) and to (exclusive), `session` (only items from when the + latest service start of this app run began; none before the first start), the cursors `before` (only items older than it) and `from` (it and newer), each an item's `{at, key}`, and `limit` (1-2000, default 200). Items are ordered by time, then records before traces, then id, so paging by cursor never skips or repeats an item, even at equal times. Answers `{items, more, people, channels}`: the newest `limit` items in time order, whether older ones were left out, the people who spoke (their latest name) and the channels with records (with the - name given a chat channel in the settings). Without the file: no items and `missing: true`. + name given a chat channel in the settings), and `session`, when the latest start began (Unix + seconds, null before the first). Without the file: no items and `missing: true`. ## Activity (`app/src/activity.rs`) @@ -687,7 +689,7 @@ back as Korean messages for the screen. The Tauri shell passes the screens' `inv | `service_start` / `service_stop` / `service_restart` / `dashboard` | the controller and its snapshot; start and restart run in the background, stop also cancels a start | | `discord_channel_info` `{id}` / `channel_sync_status` | a channel's Discord name and topic / each synced chat channel's last result (above) | | `notes_list` / `note_update` `{id, text}` / `note_delete` `{id}` | everyone's personal notes (above) / change one's text / delete one | -| `history_query` `{said, answered, thought, via, person, channel, find, since, until, before, from, limit}` | the 대화 screen's records and answer traces (above, "Conversations") | +| `history_query` `{said, answered, thought, via, person, channel, find, since, until, session, before, from, limit}` | the 대화 screen's records and answer traces (above, "Conversations") | | `activity_list` `{limit}` | what Jarvis did (above, "Activity"), newest first | | `schedules_list` / `schedule_delete` `{id}` | every person's schedules (above), soonest first, with IDs as strings / delete one | | `collect_results` `{target, limit}` | `{targets, items}`: every target folder with results, and the collected items newest first (`target` null: every target; `limit` 1-500, default 100) | @@ -706,6 +708,7 @@ 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 대시보드. - **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 @@ -739,7 +742,10 @@ Plain HTML, CSS and an ES module, no build step, dark theme after `DESIGN.md`. A 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 - kinds as chips, where (음성, 채팅, 정기 작업), person, channel, one day and text; "실시간" (on by + 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 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 @@ -837,7 +843,12 @@ come with the first-run wizard into the data folder, which the installer never t installed later from the features screen, with the reason the app wrote (UTF-8), and the app is installed all the same; never in a silent install, so an update neither asks nor brings back a driver the person removed). - Shortcuts are for every user of the PC. + Shortcuts are for every user of the PC. Their icon is a file next to `jarvis.exe` named by its + content (`jarvis-.ico`; the old one is deleted), because Windows keeps an icon it + has shown by its path and a changed icon under the old path stays old on the desktop and in + search. After the shortcuts, every `.lnk` to `jarvis.exe` on the desktops and in the start menus + (the installing user's and every user's, the person's own and an earlier version's included) + gets this icon file, and Explorer is told to redraw (`SHCNE_ASSOCCHANGED`). - The WebView2 runtime is installed with Microsoft's bootstrapper (inside the installer) only when the PC has none, before any file is copied. When it is still missing afterwards the installer asks to retry or cancel; silently it stops with exit code 3, nothing installed and nothing diff --git a/app/src/admin_api.rs b/app/src/admin_api.rs index 7a5554d..0e7f790 100644 --- a/app/src/admin_api.rs +++ b/app/src/admin_api.rs @@ -410,10 +410,17 @@ impl AdminApi { let dir = self.dir()?; let text = |k: &str| args.get(k).and_then(Value::as_str).map(str::trim).filter(|s| !s.is_empty()).map(String::from); let flag = |k: &str| args.get(k).and_then(Value::as_bool).unwrap_or(true); + // The current session: from when the latest start began (none yet: nothing to show). + let session = self.controller.lock().unwrap().as_ref().and_then(|c| c.session_start()); + let only_session = args.get("session").and_then(Value::as_bool).unwrap_or(false); + let mut since = args.get("since").and_then(Value::as_f64); + if only_session { + since = Some(since.unwrap_or(f64::MIN).max(session.unwrap_or(f64::INFINITY))); + } let q = crate::history_view::Query { said: flag("said"), answered: flag("answered"), thought: flag("thought"), via: text("via"), person: text("person"), channel: text("channel"), find: text("find"), - since: args.get("since").and_then(Value::as_f64), until: args.get("until").and_then(Value::as_f64), + since, until: args.get("until").and_then(Value::as_f64), before: args.get("before").and_then(crate::history_view::Cursor::of), from: args.get("from").and_then(crate::history_view::Cursor::of), limit: args.get("limit").and_then(Value::as_u64).map_or(crate::history_view::DEFAULT_LIMIT, |n| n as usize), @@ -428,6 +435,7 @@ impl AdminApi { let name = named.iter().find(|c| Some(c.id.to_string().as_str()) == ch["id"].as_str()).map(|c| c.name.clone()); ch["name"] = json!(name.unwrap_or_default()); } + v["session"] = json!(session); Ok(v) } "activity_list" => { @@ -611,6 +619,29 @@ mod tests { assert_eq!(v["items"][0]["type"], "thought"); } + #[tokio::test] + async fn the_current_session_shows_only_what_came_since_the_latest_start() { + let (a, base) = api("api-history-session"); + let data = base.join("d"); + a.call("folder_choose", json!({"path": data.to_string_lossy()})).await.unwrap(); + std::fs::create_dir_all(data.join("memory")).unwrap(); + let c = rusqlite::Connection::open(data.join("memory").join("history.sqlite")).unwrap(); + c.execute_batch(crate::history_view::TEST_SCHEMA).unwrap(); + let rec = |ts: f64, text: &str| c.execute("INSERT INTO history(ts, kind, channel_id, author_id, author_name, text, norm) \ + VALUES (?, 'voice', 'vc', '1', 'Alice', ?, ?)", rusqlite::params![ts, text, text]).unwrap(); + rec(1.0, "지난번 말"); + let texts = |v: &Value| v["items"].as_array().unwrap().iter().map(|i| i["text"].as_str().unwrap().to_string()).collect::>(); + // Not started yet in this app run: no session, so nothing in it. + let v = a.call("history_query", json!({"session": true})).await.unwrap(); + assert_eq!((texts(&v), v["session"].clone()), (Vec::::new(), Value::Null)); + a.call("service_start", json!({})).await.unwrap(); + let started = a.call("history_query", json!({})).await.unwrap()["session"].as_f64().unwrap(); + rec(started + 1.0, "이번 말"); + assert_eq!(texts(&a.call("history_query", json!({"session": true})).await.unwrap()), ["이번 말"]); + assert_eq!(texts(&a.call("history_query", json!({})).await.unwrap()), ["지난번 말", "이번 말"]); + a.shutdown().await.unwrap(); + } + #[tokio::test] async fn the_activity_screen_reads_the_newest_entries() { let (a, base) = api("api-activity"); diff --git a/app/src/control.rs b/app/src/control.rs index eec1564..be88e14 100644 --- a/app/src/control.rs +++ b/app/src/control.rs @@ -69,6 +69,8 @@ struct Inner { /// The latest speech speed saved (equal to the settings file's): a start may have read the /// settings before it was saved, so the services get it again once they run. tts_speed: Option, + /// When the latest start began (Unix seconds): the 대화 screen's current session. + session: Option, } pub struct Controller { @@ -80,13 +82,18 @@ pub struct Controller { impl Controller { pub fn new(host: impl Host) -> Arc { Arc::new(Self { host: Box::new(host), inner: Mutex::new(Inner { state: State::Stopped, error: None, running: None, - dashboard: Arc::default(), feeder: None, stop_asked: false, tts_speed: None }), usage: tokio::sync::Mutex::new(None) }) + dashboard: Arc::default(), feeder: None, stop_asked: false, tts_speed: None, session: None }), usage: tokio::sync::Mutex::new(None) }) } pub fn state(&self) -> State { self.inner.lock().unwrap().state } + /// When the latest start began (Unix seconds), none before the first start of this app run. + pub fn session_start(&self) -> Option { + self.inner.lock().unwrap().session + } + /// Start from stopped or failed; a failed start leaves nothing running. pub async fn start(&self) -> Result<(), String> { self.begin_start()?; @@ -112,6 +119,7 @@ impl Controller { i.state = State::Starting; i.error = None; i.stop_asked = false; + i.session = Some(chrono::Utc::now().timestamp_millis() as f64 / 1000.0); self.host.prepare_start(); Ok(()) } diff --git a/app/ui/app.js b/app/ui/app.js index a6690fe..072a7f2 100644 --- a/app/ui/app.js +++ b/app/ui/app.js @@ -442,6 +442,7 @@ function traceStep(s) { function conversationScreen() { const chip = (label, on = true) => { const c = h("input", { type: "checkbox", checked: on }); return [c, h("label", { class: "chip" }, c, label)]; }; const [said, saidChip] = chip("사람 말"), [answered, answeredChip] = chip("자비스 말"), [thought, thoughtChip] = chip("자비스 생각"); + const [session, sessionChip] = chip("현재 세션", false); // from when the bot was last started const via = h("select", {}, h("option", { value: "" }, "모든 곳"), Object.entries(VIA).map(([v, t]) => h("option", { value: v }, t))); const person = h("select", {}, h("option", { value: "" }, "모든 사람")); const channel = h("select", {}, h("option", { value: "" }, "모든 채널")); @@ -451,7 +452,7 @@ function conversationScreen() { const open = new Set(); // traces the user opened stay open across refreshes // `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; + let expandAll = false, sig = null, page = empty(), missing = false, sessionAt = null; let epoch = 0, liveSeq = 0, first = true, loadingOlder = false; const box = h("div", { class: "talk" }); const summary = h("div", { class: "small muted" }); @@ -496,13 +497,13 @@ function conversationScreen() { const since = day.value ? new Date(day.value + "T00:00:00").getTime() / 1000 : null; return { said: said.checked, answered: answered.checked, thought: thought.checked, via: via.value || null, person: person.value || null, channel: channel.value || null, find: find.value || null, - since, until: since == null ? null : since + 86400 }; + since, until: since == null ? null : since + 86400, session: session.checked }; } function render(keepTop = false) { const items = page.older.concat(page.shown); // The whole items, so an edited message or a changed answer is redrawn too. - const s = JSON.stringify([items, expandAll, page.hasOlder, missing]); + const s = JSON.stringify([items, expandAll, page.hasOlder, missing, session.checked, sessionAt]); if (s === sig) return; sig = s; const stick = box.scrollTop + box.clientHeight >= box.scrollHeight - 30, fromBottom = box.scrollHeight - box.scrollTop; @@ -514,10 +515,13 @@ function conversationScreen() { kids.push(item(i)); } box.replaceChildren(...(kids.length ? kids : [h("div", { class: "muted" }, - missing ? "아직 대화 기록이 없습니다. 서비스를 켜고 자비스와 이야기하면 여기에 나옵니다." : "조건에 맞는 기록이 없습니다.")])); + missing ? "아직 대화 기록이 없습니다. 서비스를 켜고 자비스와 이야기하면 여기에 나옵니다." + : session.checked && sessionAt == null ? "앱을 켠 뒤 아직 봇을 시작하지 않았습니다. 대시보드에서 시작하면 그때부터의 대화가 여기에 나옵니다." + : "조건에 맞는 기록이 없습니다.")])); more.hidden = !page.hasOlder; const n = (t) => items.filter((i) => i.type === t).length; - summary.textContent = `사람 말 ${n("said")} · 자비스 말 ${n("answered")} · 생각 ${n("thought")}` + (page.hasOlder ? " (이전 기록 더 있음)" : ""); + summary.textContent = (session.checked && sessionAt != null ? `${dayOf(sessionAt)} ${timeOf(sessionAt)}에 시작한 봇부터 · ` : "") + + `사람 말 ${n("said")} · 자비스 말 ${n("answered")} · 생각 ${n("thought")}` + (page.hasOlder ? " (이전 기록 더 있음)" : ""); if (keepTop) box.scrollTop = box.scrollHeight - fromBottom; else if (stick || first) box.scrollTop = box.scrollHeight; first = false; @@ -537,6 +541,9 @@ function conversationScreen() { if (ep !== epoch || my !== liveSeq) return; lists(r); missing = !!r.missing; + // A new start while the current session is shown: its window starts over at the new start. + if (session.checked && sessionAt != null && r.session !== sessionAt) { sessionAt = r.session; reload(); return; } + sessionAt = r.session ?? null; page = withLive(page, r.items, r.more); render(); } catch (e) { fail(e); } @@ -562,11 +569,11 @@ function conversationScreen() { const reload = () => { epoch++; sig = null; page = empty(); first = true; loadingOlder = more.disabled = false; load(); }; - for (const el of [said, answered, thought, via, person, channel, day]) el.addEventListener("change", reload); + for (const el of [said, answered, thought, session, via, person, channel, day]) el.addEventListener("change", reload); find.addEventListener("input", () => { clearTimeout(find.t); find.t = setTimeout(reload, 300); }); const view = h("div", {}, h("h1", {}, "대화"), h("div", { class: "card filters" }, - h("div", { class: "row" }, saidChip, answeredChip, thoughtChip), + 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(); } }, "생각 모두 펼치기/접기"), diff --git a/app/ui/index.html b/app/ui/index.html index 9832cc7..007c7bb 100644 --- a/app/ui/index.html +++ b/app/ui/index.html @@ -12,6 +12,7 @@