Compare commits
2 Commits
app-v0.1.9
...
app-v0.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d8801b691 | ||
|
|
1a12755649 |
2
app/Cargo.lock
generated
2
app/Cargo.lock
generated
@@ -1520,7 +1520,7 @@ checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jarvis-app"
|
name = "jarvis-app"
|
||||||
version = "0.1.9"
|
version = "0.1.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "jarvis-app"
|
name = "jarvis-app"
|
||||||
version = "0.1.9"
|
version = "0.1.10"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.85"
|
rust-version = "1.85"
|
||||||
description = "Jarvis v2 Windows app core: Discord voice, voice worker supervisor, chat channels"
|
description = "Jarvis v2 Windows app core: Discord voice, voice worker supervisor, chat channels"
|
||||||
|
|||||||
4
app/shell/Cargo.lock
generated
4
app/shell/Cargo.lock
generated
@@ -2637,7 +2637,7 @@ checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jarvis-app"
|
name = "jarvis-app"
|
||||||
version = "0.1.9"
|
version = "0.1.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
@@ -2666,7 +2666,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jarvis-shell"
|
name = "jarvis-shell"
|
||||||
version = "0.1.9"
|
version = "0.1.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jarvis-app",
|
"jarvis-app",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "jarvis-shell"
|
name = "jarvis-shell"
|
||||||
version = "0.1.9"
|
version = "0.1.10"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.85"
|
rust-version = "1.85"
|
||||||
description = "Jarvis v2 management app window (Tauri 2 over the app core's AdminApi)"
|
description = "Jarvis v2 management app window (Tauri 2 over the app core's AdminApi)"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
; The Jarvis installer (admin.spec.md, "Installer"). Built on Linux by installer.sh with makensis:
|
; The Jarvis installer (admin.spec.md, "Installer"). Built on Linux by installer.sh with makensis:
|
||||||
; makensis -DVERSION=0.1.0 -DSRC=<Jarvis folder> -DOUT=<setup.exe> -DICON=<icon.ico> -DWEBVIEW2=<bootstrapper>
|
; makensis -DVERSION=0.1.0 -DSRC=<Jarvis folder> -DOUT=<setup.exe> -DICON=<icon.ico> -DICON_FILE=<jarvis-<hash>.ico> -DWEBVIEW2=<bootstrapper>
|
||||||
; -DUNINSTALL_LIST=<the Delete/RMDir lines of the installed files> installer.nsi
|
; -DUNINSTALL_LIST=<the Delete/RMDir lines of the installed files> installer.nsi
|
||||||
; Program Files, one administrator prompt; the data folder is chosen by the app's first-run wizard
|
; 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).
|
; 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"
|
SetOutPath "$INSTDIR"
|
||||||
File "${SRC}/jarvis.exe"
|
File "${SRC}/jarvis.exe"
|
||||||
File "${SRC}/WebView2Loader.dll"
|
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}/python-src"
|
||||||
File /r "${SRC}/display-driver"
|
File /r "${SRC}/display-driver"
|
||||||
WriteUninstaller "$INSTDIR\uninstall.exe"
|
WriteUninstaller "$INSTDIR\uninstall.exe"
|
||||||
@@ -237,11 +241,21 @@ Section "Jarvis (필수)" SecMain
|
|||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
Section "시작 메뉴 바로 가기" SecStart
|
Section "시작 메뉴 바로 가기" SecStart
|
||||||
CreateShortCut "$SMPROGRAMS\Jarvis.lnk" "$INSTDIR\jarvis.exe"
|
CreateShortCut "$SMPROGRAMS\Jarvis.lnk" "$INSTDIR\jarvis.exe" "" "$INSTDIR\${ICON_FILE}" 0
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
|
||||||
Section /o "바탕 화면 바로 가기" SecDesktop
|
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
|
SectionEnd
|
||||||
|
|
||||||
Section "가상 모니터 드라이버" SecDriver
|
Section "가상 모니터 드라이버" SecDriver
|
||||||
@@ -303,6 +317,7 @@ Section "Uninstall"
|
|||||||
; folder the person chose may hold other things; folders go only when empty.
|
; folder the person chose may hold other things; folders go only when empty.
|
||||||
Delete "$INSTDIR\jarvis.exe"
|
Delete "$INSTDIR\jarvis.exe"
|
||||||
Delete "$INSTDIR\WebView2Loader.dll"
|
Delete "$INSTDIR\WebView2Loader.dll"
|
||||||
|
Delete "$INSTDIR\jarvis-*.ico"
|
||||||
!include "${UNINSTALL_LIST}"
|
!include "${UNINSTALL_LIST}"
|
||||||
Delete "$INSTDIR\uninstall.exe"
|
Delete "$INSTDIR\uninstall.exe"
|
||||||
RMDir "$INSTDIR"
|
RMDir "$INSTDIR"
|
||||||
|
|||||||
@@ -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 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).
|
# 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)
|
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"
|
-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")
|
(cd "$out" && sha256sum "Jarvis-Setup-$version.exe" > "Jarvis-Setup-$version.exe.sha256")
|
||||||
echo "$setup"
|
echo "$setup"
|
||||||
|
|||||||
@@ -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
|
`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
|
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.
|
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
|
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
|
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
|
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).
|
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
|
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
|
repeats an item, even at equal times. Answers
|
||||||
`{items, more, people, channels}`: the newest `limit` items in time order, whether older ones
|
`{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
|
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`)
|
## 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 |
|
| `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) |
|
| `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 |
|
| `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 |
|
| `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 |
|
| `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) |
|
| `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/`)
|
## Screens (`app/ui/`)
|
||||||
|
|
||||||
Plain HTML, CSS and an ES module, no build step, dark theme after `DESIGN.md`. All text is Korean.
|
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,
|
- **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
|
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
|
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,
|
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. 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
|
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
|
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
|
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 later from the features screen, with the reason the app wrote (UTF-8), and the app is
|
||||||
installed all the same; never in a
|
installed all the same; never in a
|
||||||
silent install, so an update neither asks nor brings back a driver the person removed).
|
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-<sha256 prefix>.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 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
|
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
|
asks to retry or cancel; silently it stops with exit code 3, nothing installed and nothing
|
||||||
|
|||||||
@@ -410,10 +410,17 @@ impl AdminApi {
|
|||||||
let dir = self.dir()?;
|
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 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);
|
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 {
|
let q = crate::history_view::Query {
|
||||||
said: flag("said"), answered: flag("answered"), thought: flag("thought"),
|
said: flag("said"), answered: flag("answered"), thought: flag("thought"),
|
||||||
via: text("via"), person: text("person"), channel: text("channel"), find: text("find"),
|
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),
|
before: args.get("before").and_then(crate::history_view::Cursor::of),
|
||||||
from: args.get("from").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),
|
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());
|
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());
|
ch["name"] = json!(name.unwrap_or_default());
|
||||||
}
|
}
|
||||||
|
v["session"] = json!(session);
|
||||||
Ok(v)
|
Ok(v)
|
||||||
}
|
}
|
||||||
"activity_list" => {
|
"activity_list" => {
|
||||||
@@ -611,6 +619,29 @@ mod tests {
|
|||||||
assert_eq!(v["items"][0]["type"], "thought");
|
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::<Vec<_>>();
|
||||||
|
// 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::<String>::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]
|
#[tokio::test]
|
||||||
async fn the_activity_screen_reads_the_newest_entries() {
|
async fn the_activity_screen_reads_the_newest_entries() {
|
||||||
let (a, base) = api("api-activity");
|
let (a, base) = api("api-activity");
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ struct Inner {
|
|||||||
/// The latest speech speed saved (equal to the settings file's): a start may have read the
|
/// 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.
|
/// settings before it was saved, so the services get it again once they run.
|
||||||
tts_speed: Option<f64>,
|
tts_speed: Option<f64>,
|
||||||
|
/// When the latest start began (Unix seconds): the 대화 screen's current session.
|
||||||
|
session: Option<f64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Controller {
|
pub struct Controller {
|
||||||
@@ -80,13 +82,18 @@ pub struct Controller {
|
|||||||
impl Controller {
|
impl Controller {
|
||||||
pub fn new(host: impl Host) -> Arc<Self> {
|
pub fn new(host: impl Host) -> Arc<Self> {
|
||||||
Arc::new(Self { host: Box::new(host), inner: Mutex::new(Inner { state: State::Stopped, error: None, running: None,
|
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 {
|
pub fn state(&self) -> State {
|
||||||
self.inner.lock().unwrap().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<f64> {
|
||||||
|
self.inner.lock().unwrap().session
|
||||||
|
}
|
||||||
|
|
||||||
/// Start from stopped or failed; a failed start leaves nothing running.
|
/// Start from stopped or failed; a failed start leaves nothing running.
|
||||||
pub async fn start(&self) -> Result<(), String> {
|
pub async fn start(&self) -> Result<(), String> {
|
||||||
self.begin_start()?;
|
self.begin_start()?;
|
||||||
@@ -112,6 +119,7 @@ impl Controller {
|
|||||||
i.state = State::Starting;
|
i.state = State::Starting;
|
||||||
i.error = None;
|
i.error = None;
|
||||||
i.stop_asked = false;
|
i.stop_asked = false;
|
||||||
|
i.session = Some(chrono::Utc::now().timestamp_millis() as f64 / 1000.0);
|
||||||
self.host.prepare_start();
|
self.host.prepare_start();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -442,6 +442,7 @@ function traceStep(s) {
|
|||||||
function conversationScreen() {
|
function conversationScreen() {
|
||||||
const chip = (label, on = true) => { const c = h("input", { type: "checkbox", checked: on }); return [c, h("label", { class: "chip" }, c, label)]; };
|
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 [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 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 person = h("select", {}, h("option", { value: "" }, "모든 사람"));
|
||||||
const channel = 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
|
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;
|
// `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.
|
// 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;
|
let epoch = 0, liveSeq = 0, first = true, loadingOlder = false;
|
||||||
const box = h("div", { class: "talk" });
|
const box = h("div", { class: "talk" });
|
||||||
const summary = h("div", { class: "small muted" });
|
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;
|
const since = day.value ? new Date(day.value + "T00:00:00").getTime() / 1000 : null;
|
||||||
return { said: said.checked, answered: answered.checked, thought: thought.checked,
|
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,
|
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) {
|
function render(keepTop = false) {
|
||||||
const items = page.older.concat(page.shown);
|
const items = page.older.concat(page.shown);
|
||||||
// The whole items, so an edited message or a changed answer is redrawn too.
|
// 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;
|
if (s === sig) return;
|
||||||
sig = s;
|
sig = s;
|
||||||
const stick = box.scrollTop + box.clientHeight >= box.scrollHeight - 30, fromBottom = box.scrollHeight - box.scrollTop;
|
const stick = box.scrollTop + box.clientHeight >= box.scrollHeight - 30, fromBottom = box.scrollHeight - box.scrollTop;
|
||||||
@@ -514,10 +515,13 @@ function conversationScreen() {
|
|||||||
kids.push(item(i));
|
kids.push(item(i));
|
||||||
}
|
}
|
||||||
box.replaceChildren(...(kids.length ? kids : [h("div", { class: "muted" },
|
box.replaceChildren(...(kids.length ? kids : [h("div", { class: "muted" },
|
||||||
missing ? "아직 대화 기록이 없습니다. 서비스를 켜고 자비스와 이야기하면 여기에 나옵니다." : "조건에 맞는 기록이 없습니다.")]));
|
missing ? "아직 대화 기록이 없습니다. 서비스를 켜고 자비스와 이야기하면 여기에 나옵니다."
|
||||||
|
: session.checked && sessionAt == null ? "앱을 켠 뒤 아직 봇을 시작하지 않았습니다. 대시보드에서 시작하면 그때부터의 대화가 여기에 나옵니다."
|
||||||
|
: "조건에 맞는 기록이 없습니다.")]));
|
||||||
more.hidden = !page.hasOlder;
|
more.hidden = !page.hasOlder;
|
||||||
const n = (t) => items.filter((i) => i.type === t).length;
|
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;
|
if (keepTop) box.scrollTop = box.scrollHeight - fromBottom;
|
||||||
else if (stick || first) box.scrollTop = box.scrollHeight;
|
else if (stick || first) box.scrollTop = box.scrollHeight;
|
||||||
first = false;
|
first = false;
|
||||||
@@ -537,6 +541,9 @@ function conversationScreen() {
|
|||||||
if (ep !== epoch || my !== liveSeq) return;
|
if (ep !== epoch || my !== liveSeq) return;
|
||||||
lists(r);
|
lists(r);
|
||||||
missing = !!r.missing;
|
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);
|
page = withLive(page, r.items, r.more);
|
||||||
render();
|
render();
|
||||||
} catch (e) { fail(e); }
|
} catch (e) { fail(e); }
|
||||||
@@ -562,11 +569,11 @@ function conversationScreen() {
|
|||||||
const reload = () => {
|
const reload = () => {
|
||||||
epoch++; sig = null; page = empty(); first = true; loadingOlder = more.disabled = false; load();
|
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); });
|
find.addEventListener("input", () => { clearTimeout(find.t); find.t = setTimeout(reload, 300); });
|
||||||
const view = h("div", {}, h("h1", {}, "대화"),
|
const view = h("div", {}, h("h1", {}, "대화"),
|
||||||
h("div", { class: "card filters" },
|
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" }, via, person, channel, day, find),
|
||||||
h("div", { class: "row" }, h("label", { class: "row small muted" }, live, "실시간"),
|
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; if (!expandAll) open.clear(); sig = null; load(); } }, "생각 모두 펼치기/접기"),
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<nav class="side">
|
<nav class="side">
|
||||||
<div class="brand">Jarvis</div>
|
<div class="brand">Jarvis</div>
|
||||||
<button data-screen="dashboard" class="nav">대시보드</button>
|
<button data-screen="dashboard" class="nav">대시보드</button>
|
||||||
|
<button data-screen="conversations" class="nav">대화</button>
|
||||||
<button data-screen="bot" class="nav">봇</button>
|
<button data-screen="bot" class="nav">봇</button>
|
||||||
<button data-screen="channels" class="nav">채널·호출</button>
|
<button data-screen="channels" class="nav">채널·호출</button>
|
||||||
<button data-screen="chat" class="nav">채팅 채널</button>
|
<button data-screen="chat" class="nav">채팅 채널</button>
|
||||||
@@ -22,7 +23,6 @@
|
|||||||
<button data-screen="schedule" class="nav">예약</button>
|
<button data-screen="schedule" class="nav">예약</button>
|
||||||
<button data-screen="pcControl" class="nav">PC 제어</button>
|
<button data-screen="pcControl" class="nav">PC 제어</button>
|
||||||
<button data-screen="notes" class="nav">사람별 지침</button>
|
<button data-screen="notes" class="nav">사람별 지침</button>
|
||||||
<button data-screen="conversations" class="nav">대화</button>
|
|
||||||
<button data-screen="activity" class="nav">한 일</button>
|
<button data-screen="activity" class="nav">한 일</button>
|
||||||
<button data-screen="game" class="nav">게임 모드</button>
|
<button data-screen="game" class="nav">게임 모드</button>
|
||||||
<button data-screen="app" class="nav">앱</button>
|
<button data-screen="app" class="nav">앱</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user