feat(app): chat channel name/topic sync, TTS speed, safe window close

Review follow-ups to M5.

- Chat channel names and topics (app/src/channel_sync.rs): a channel with
  syncDiscord (default on) gets its name and description as its Discord
  name and topic when saved; registering fills them from Discord;
  Discord's form of the name is written back; a topic over 1,024
  characters is refused before saving; a rate-limited edit is pending and
  retried once by itself with the latest text; a missing permission fails
  with the reason and the app keeps the text. Commands
  discord_channel_info and channel_sync_status. Checked on real Discord
  with a temporary channel (fill, edit, rate limit, automatic retry).
- voice.tts.speed (0.5-2.0) on the model screen, passed to the worker as
  --melo-speed. MeloTTS's Korean model has one voice, so no voice choice.
- Closing the window runs AdminApi::shutdown first: an install in
  progress is cancelled and waited for, the services stop, a failed run's
  leftovers (Strata) are cleared (Controller::shutdown). If that fails the
  window stays open with the reason; closing again quits.
- WebView2 data goes in the data folder (cache/webview), or a temp scratch
  folder before one is chosen, removed at the next start: %APPDATA%\JarvisBot
  holds only the location file.
- Command output that is not UTF-8 (CP949 on a PC without the UTF-8
  option) is decoded in the OEM code page instead of ending the reading.

Verified on the win-ci VM: closing during the install leaves no process,
no --location keeps only location.json under %APPDATA%, the unit tests on
Windows 168/168.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 19:23:26 +09:00
parent 76144fb19b
commit 91d0109139
18 changed files with 895 additions and 65 deletions

View File

@@ -129,14 +129,27 @@ function editor(f, value) {
}
function chatChannelsEditor(f, value) {
const flags = [["read", "읽기", true], ["send", "보내기", true], ["edit", "수정", true], ["react", "반응", true],
["delete", "삭제", false], ["pin", "고정", false]];
const flags = [["syncDiscord", "디스코드 반영", true], ["read", "읽기", true], ["send", "보내기", true], ["edit", "수정", true],
["react", "반응", true], ["delete", "삭제", false], ["pin", "고정", false]];
const body = h("tbody");
const SYNC = { applied: "반영됨", pending: "잠시 뒤 반영", failed: "반영 못 함" };
const statusCells = new Map();
const addRow = (c = {}) => {
const tr = h("tr", {},
h("td", {}, h("input", { type: "text", value: c.id ?? "", placeholder: "채널 ID", "data-k": "id" })),
h("td", {}, h("input", { type: "text", value: c.name ?? "", placeholder: "이름", "data-k": "name" })),
h("td", {}, h("input", { type: "text", value: c.description ?? "", placeholder: "무엇에 쓰는 채널인지", "data-k": "description" })),
const id = h("input", { type: "text", value: c.id ?? "", placeholder: "채널 ID", "data-k": "id" });
const name = h("input", { type: "text", value: c.name ?? "", placeholder: "이름", "data-k": "name" });
const desc = h("input", { type: "text", value: c.description ?? "", placeholder: "무엇에 쓰는 채널인지", "data-k": "description" });
// A newly registered channel starts with its Discord name and topic.
id.addEventListener("change", async () => {
if (!id.value.trim() || (name.value && desc.value)) return;
try {
const info = await api("discord_channel_info", { id: id.value.trim() });
if (!name.value) name.value = info.name;
if (!desc.value) desc.value = info.topic;
} catch (e) { fail(e); }
});
const status = h("td", { class: "small muted" });
if (c.id) statusCells.set(c.id, status);
const tr = h("tr", {}, h("td", {}, id), h("td", {}, name), h("td", {}, desc),
flags.map(([k, , d]) => {
const box = h("input", { type: "checkbox", "data-k": k });
box.checked = c[k] ?? d;
@@ -145,11 +158,18 @@ function chatChannelsEditor(f, value) {
h("td", {}, h("select", { "data-k": "answer" },
h("option", { value: "wakeWord", selected: (c.answer ?? "wakeWord") === "wakeWord" }, "호출어"),
h("option", { value: "everything", selected: c.answer === "everything" }, "모든 글"))),
status,
h("td", {}, h("button", { class: "btn", onclick: () => tr.remove() }, "삭제")));
body.append(tr);
};
(value || []).forEach(addRow);
const table = h("table", {}, h("thead", {}, h("tr", {}, ["ID", "이름", "설명", ...flags.map((x) => x[1]), "대답", ""]
api("channel_sync_status").then((st) => {
for (const [cid, s] of Object.entries(st)) {
const cell = statusCells.get(cid);
if (cell) { cell.textContent = SYNC[s.state] ?? s.state; cell.title = s.reason ?? ""; }
}
}).catch(() => {});
const table = h("table", {}, h("thead", {}, h("tr", {}, ["ID", "이름", "설명", ...flags.map((x) => x[1]), "대답", "디스코드", ""]
.map((t) => h("th", {}, t)))), body);
const read = () => [...body.rows].map((tr) => {
const c = {};
@@ -173,6 +193,15 @@ async function settingsScreen(screen, title, extra) {
if (!Object.keys(changes).length) return toast("바뀐 것이 없습니다");
const r = await api("settings_apply", { changes });
Object.assign(view, changes);
const sync = r.sync || [];
if (sync.length) {
const n = (k) => sync.filter((x) => x.state === k).length;
const failed = sync.filter((x) => x.state === "failed").map((x) => x.reason);
toast(`저장했습니다. 디스코드 반영: ${n("applied")}개 반영${n("pending") ? `, ${n("pending")}개 잠시 뒤 반영` : ""}`
+ (failed.length ? `, ${failed.length}개 못 함(${failed[0]})` : ""), failed.length > 0);
show(current); // Discord's form of the names, and the status column
return;
}
toast(r.restartNeeded ? "저장했습니다. 다시 시작하면 적용됩니다." : "저장했습니다.");
} catch (e) { fail(e); }
};
@@ -558,4 +587,10 @@ async function start() {
for (const b of document.querySelectorAll(".nav")) b.onclick = () => show(b.dataset.screen);
show("dashboard");
}
// The window tells what closing does: stopping what runs first, or that it could not.
if (window.__TAURI__?.event) {
window.__TAURI__.event.listen("closing", () => toast("실행 중인 것을 정리하고 종료합니다…"));
window.__TAURI__.event.listen("close-failed", (e) =>
toast(`정리를 끝내지 못해 창을 닫지 않았습니다: ${e.payload}. 한 번 더 닫으면 그대로 종료합니다.`, true));
}
start().catch(fail);