A personal assistant that lives on your desktop, remembers what matters, and can use your Mac for you.
TypeScript
fix(ui): show why the app cannot reach its assistant
Alan Buscaglia8705ab0d9b86
diff --git a/packages/ui/src/App.tsx b/packages/ui/src/App.tsxindex a90d70b..2880138 100644--- a/packages/ui/src/App.tsx+++ b/packages/ui/src/App.tsx@@ -63,6 +63,8 @@ export function App() {function Assistant({ surface }: { surface: Surface }) {const [info, setInfo] = useState<ConnectionInfo | undefined>(undefined);const [missingToken, setMissingToken] = useState(false);+ /** Why the desktop app could not reach its assistant, in the app's own words (S35.2). */+ const [unreachable, setUnreachable] = useState<string>();const [focusKey, setFocusKey] = useState(0);const { state, send, dismiss, dispatch } = useDot(info);// Files go to the daemon over HTTP, with the same access key as the WebSocket (S31.2).@@ -103,7 +105,11 @@ function Assistant({ surface }: { surface: Surface }) {useEffect(() => {if (inDesktop()) {- connectionInfo().then(setInfo, () => setMissingToken(true));+ connectionInfo().then(setInfo, (error: unknown) => {+ const reason = typeof error === "string" ? error : error instanceof Error ? error.message : "";+ if (reason) setUnreachable(reason);+ else setMissingToken(true);+ });return;}const found = browserConnection();@@ -162,11 +168,12 @@ function Assistant({ surface }: { surface: Surface }) {/>);}- if (missingToken) {+ if (unreachable !== undefined || missingToken) {return (<div className="chat chat-web"><div className="status" role="status">- This page needs your access key. Open it from the Gentle Dot menu (Open in browser).+ {unreachable ??+ "This page needs your access key. Open it from the Gentle Dot menu (Open in browser)."}</div></div>);diff --git a/packages/ui/test/settings.test.tsx b/packages/ui/test/settings.test.tsxindex 6baeea0..9aac243 100644--- a/packages/ui/test/settings.test.tsx+++ b/packages/ui/test/settings.test.tsx@@ -137,6 +137,21 @@ describe("recording a key combination", () => {});});+describe("when the app cannot reach its assistant (S35.2)", () => {+ it("the panel shows the app's own reason, not the browser's access-key note", async () => {+ const reason =+ "Another Gentle Dot assistant is already running on port 4317. Stop it, then choose Restart assistant.";+ const fallback = h.invoke.getMockImplementation();+ h.invoke = vi.fn(async (command: string, args?: Record<string, unknown>) => {+ if (command === "connection_info") throw reason;+ return fallback?.(command, args);+ });+ await renderApp("?surface=panel");+ expect(await screen.findByRole("status")).toHaveTextContent(reason);+ expect(screen.queryByText(/needs your access key/)).toBeNull();+ });+});+describe("the Settings screen (S33.1)", () => {it("opens from a gear in the desktop panel header", async () => {const settings = await openSettings();