mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-23 23:46:35 +00:00
123e27643d
The three AI addons share one tile in the integration column; a dialog holds the connection, the assistant's limits and AI parsing, which now reads with the assistant's connection unless an install keeps its own. Existing parsing configs stay where they are and keep winning. The chat sees the map on screen, offers next questions under an answer, shows its live step in the window head, previews waiting changes inside the day list, checks whether a day still works, folds a multi-day plan into a week grid, keeps per-trip notes and can estimate costs. An empty or cut-off answer gets one push instead of ending silently, and the assistant's own step and size limits are raised.
24 lines
848 B
TypeScript
24 lines
848 B
TypeScript
import { useState } from 'react';
|
|
import { useSearchParams } from 'react-router';
|
|
import type { Addon } from './addonModel';
|
|
import { usesConnection } from './aiAddons';
|
|
|
|
/**
|
|
* The AI tile behind both admin shells: its three switches, how many are on,
|
|
* and the settings dialog. The dialog opens by itself when OpenRouter's
|
|
* sign-in returns here (`?ai=openrouter`), since the connection form that
|
|
* finishes it lives inside.
|
|
*/
|
|
export function useAiAddonTile(aiAddons: Addon[]) {
|
|
const [params] = useSearchParams();
|
|
const [open, setOpen] = useState(() => params.get('ai') === 'openrouter');
|
|
const canSetUp = usesConnection(aiAddons);
|
|
return {
|
|
enabledCount: aiAddons.filter((a) => a.enabled).length,
|
|
canSetUp,
|
|
dialogOpen: open && canSetUp,
|
|
openDialog: () => setOpen(true),
|
|
closeDialog: () => setOpen(false),
|
|
};
|
|
}
|