feat(web): explain a failed open, keep the dialog, and follow instance_state
Opening a project showed a toast on success and a bare code (`E_FORBIDDEN`) on failure: no reason, no retry, and a workspace card that kept claiming "Instance stopped" because `instance_state` frames were dropped by the socket layer. - The dialog validates a non-absolute path inline, sends `alias` (the field the daemon persists), maps the daemon's status/code/message to a specific sentence (`~` expansions, missing directory, roots allowlist, permissions), and keeps itself open on a spawn failure with the daemon's reason plus a retry that re-sends only `instance.ensure`. - `lib/ws` handles `instance_state` by invalidating `workspaces`/`health` (coalesced at 250 ms across sockets) so the grid reflects reality. - A never-started workspace renders as "not started · opens on demand" instead of "stopped", and a degraded/stopped instance shows `instance.reason`.
This commit is contained in:
1 parent
b95ff6055b
commit
d5d205a7eb
11 files changed
+673
-21
No files matched your search
@@ -17,7 +17,7 @@ import { useConnectionStore } from "@/stores/connection";
|
||||
import { useSessionsStore } from "@/stores/sessions";
|
||||
import { useWorkspacesStore } from "@/stores/workspaces";
|
||||
import { Link, Outlet, useNavigate, useRouterState } from "@tanstack/react-router";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
function RouteTitle({ pathname }: { pathname: string }) {
|
||||
const { t } = useTranslation();
|
||||
@@ -105,6 +105,7 @@ export function AppShell() {
|
||||
const wsState = useConnectionStore((state) => state.wsState);
|
||||
const setWsState = useConnectionStore((state) => state.setWsState);
|
||||
const disconnect = useConnectionStore((state) => state.disconnect);
|
||||
const queryClient = useQueryClient();
|
||||
const isConnect = pathname.startsWith("/connect");
|
||||
// The chat page owns its own socket and already publishes wsState.
|
||||
const ownsSocket = !pathname.startsWith("/chat");
|
||||
@@ -173,6 +174,9 @@ export function AppShell() {
|
||||
const client = new PiWsClient({
|
||||
url: defaultWsUrl(),
|
||||
token: getDeviceToken(),
|
||||
// `instance_state` frames otherwise go nowhere on these pages: the card
|
||||
// grid reads the workspace row, so invalidate it (coalesced in ws.ts).
|
||||
queryClient,
|
||||
handlers: {
|
||||
onState: (state: WsConnectionState) => {
|
||||
if (active) setWsState(state);
|
||||
@@ -192,7 +196,7 @@ export function AppShell() {
|
||||
active = false;
|
||||
client.close();
|
||||
};
|
||||
}, [disconnect, href, isConnect, navigate, ownsSocket, paired, setWsState]);
|
||||
}, [disconnect, href, isConnect, navigate, ownsSocket, paired, queryClient, setWsState]);
|
||||
|
||||
/** ⌘K / Ctrl-K opens the palette on every navigation page (never on /connect). */
|
||||
useEffect(() => {
|
||||
|
||||
Reference in new issue
Block a user