feat(assistant): support the managed TREK gateway

This commit is contained in:
Maurice
2026-12-01 00:27:08 +01:00
parent fa23f94ee8
commit 00e98b8711
19 changed files with 207 additions and 39 deletions
+4 -6
View File
@@ -37,7 +37,6 @@ import {
type WindowRect,
} from './assistantMapModel';
import { applyChunk, closeUndo, markDecisions } from './assistantMessages';
import { useAuthStore } from './authStore';
import { useSettingsStore } from './settingsStore';
import { useTripStore } from './tripStore';
@@ -124,7 +123,7 @@ interface UndoBlockResult {
interface AssistantState {
/**
* What the assistant runs on for this user; null until loaded, while no addon
* opens /api/ai (aiRoutesOpen) and on a managed install, and the assistant stays hidden then.
* opens /api/ai (aiRoutesOpen). Otherwise the assistant stays hidden.
*/
status: AiStatusResponse | null;
window: { open: boolean; minimized: boolean };
@@ -325,7 +324,7 @@ export function chatOf(state: Pick<AssistantState, 'byTrip'>, key: AssistantChat
* Whether the addons open /api/ai: the server opens it while the assistant or
* AI parsing is on, the two sharing one connection, and answers 404 while
* both are off. Closed until the addon list is in. A selector on the addon
* store; a managed install refuses /api/ai whatever it says (loadStatus).
* store. The server's status response decides availability on managed installs.
*/
export function aiRoutesOpen({
loaded,
@@ -586,9 +585,8 @@ function backToAfter(byTrip: Record<number, AssistantTripChat>): Record<number,
function shellActions(ctx: Ctx) {
return {
loadStatus: async () => {
// While /api/ai is closed the request could only get a 404, or the 403 of a managed install: nothing is asked,
// and the assistant stays hidden. The managed flag comes with the app config, which can land after the addons.
if (useAuthStore.getState().managed || !aiRoutesOpen(useAddonStore.getState())) {
// When both addons are off the status route is closed.
if (!aiRoutesOpen(useAddonStore.getState())) {
ctx.set({ status: null });
return;
}