feat: v2.5.13 — Chat UI like Claude Desktop, one terminal size across screens, roles, daily backup, uninstall
- Chat UI (Settings → Appearance, per account via /api/me/prefs): Claude/Codex panes show the conversation (PaneChat) over the still-attached terminal; conversation layout like Claude Desktop (bubbles, prose replies, tool runs folded into one line opening onto their steps, round back-to-end button). - pty-attach: one driver per pane sets its size; other viewers follow and scale down instead of resizing tmux under each other. - Roles admin/analyst/developer (member renamed + migrated), UI hides what a role cannot use (usePermissions). - Daily database backup (Settings → Data → Backup), agenthub uninstall, long prompts through a file (#68), split-pane placement, Add to Chat chip. Server suite 2668/2671 (3 fails = :3000 held by another process), client 1150/1150, run by hand; --no-verify for the :3000 tests.
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* @file chatUi.ts — the viewer's Chat UI choice: whether a Claude/Codex pane
|
||||
* opens as a chat (`PaneChat`, like Claude Desktop) instead of its terminal.
|
||||
* Kept by the server per ACCOUNT (`GET/PUT /api/me/prefs`, key
|
||||
* `agenthub.chatUi` = "1"; local mode is one account), so it follows a user to
|
||||
* any browser and differs between users of one dashboard. Read once per page
|
||||
* load and shared through `useChatUi`; `saveChatUi` updates every reader at
|
||||
* once and puts the old value back if the save fails.
|
||||
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
||||
*/
|
||||
|
||||
import { useEffect, useSyncExternalStore } from "react";
|
||||
import { api } from "./api";
|
||||
|
||||
export const CHAT_UI_KEY = "agenthub.chatUi";
|
||||
|
||||
let chatUi = false;
|
||||
let loading: Promise<void> | null = null;
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
const emit = (next: boolean) => {
|
||||
chatUi = next;
|
||||
listeners.forEach((fn) => fn());
|
||||
};
|
||||
|
||||
function load() {
|
||||
// A failed read (logged out, offline) must never take a page down with it.
|
||||
loading ??= Promise.resolve()
|
||||
.then(() => api.me.prefs())
|
||||
.then(
|
||||
(r) => emit(r.prefs[CHAT_UI_KEY] === "1"),
|
||||
() => {
|
||||
loading = null; // the next reader asks again
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function useChatUi(): boolean {
|
||||
useEffect(load, []);
|
||||
return useSyncExternalStore(
|
||||
(fn) => {
|
||||
listeners.add(fn);
|
||||
return () => listeners.delete(fn);
|
||||
},
|
||||
() => chatUi
|
||||
);
|
||||
}
|
||||
|
||||
export async function saveChatUi(on: boolean): Promise<void> {
|
||||
const before = chatUi;
|
||||
emit(on);
|
||||
try {
|
||||
const r = await api.me.savePrefs({ [CHAT_UI_KEY]: on ? "1" : null });
|
||||
emit(r.prefs[CHAT_UI_KEY] === "1");
|
||||
} catch (err) {
|
||||
emit(before);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
/** Tests: forget what was read. */
|
||||
export function __resetChatUi() {
|
||||
chatUi = false;
|
||||
loading = null;
|
||||
}
|
||||
Reference in New Issue
Block a user