mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-14 00:01:03 +00:00
b64da26651
Adds an in-app assistant that reads and plans the open trip. Users connect their own provider (Sign in with ChatGPT, or an Anthropic, OpenAI, Gemini or OpenRouter key) or use the one the admin set up, including a custom OpenAI-compatible server. It is an addon and only shows while a connection is usable. The chat runs on the existing MCP tools, pinned to the trip. Every change is held as a change card the user applies or discards, and applied changes can be undone. On the desktop it is a floating window that can be moved and resized; on the phone it is fullscreen. Search results show as place cards that can go onto a day, weather lookups as a strip, proposed places as ghost markers on the map with a before/after switch, and an answer can be shared into the trip chat. Booking files can be dropped in and are read into change cards.
72 lines
1.8 KiB
TypeScript
72 lines
1.8 KiB
TypeScript
import { create } from 'zustand'
|
|
import { addonsApi } from '../api/client'
|
|
|
|
interface Addon {
|
|
id: string
|
|
name: string
|
|
description?: string
|
|
type: string
|
|
icon: string
|
|
enabled: boolean
|
|
config?: Record<string, unknown>
|
|
fields?: Array<{
|
|
key: string
|
|
label: string
|
|
input_type: string
|
|
placeholder?: string | null
|
|
required: boolean
|
|
secret: boolean
|
|
settings_key?: string | null
|
|
payload_key?: string | null
|
|
sort_order: number
|
|
}>
|
|
}
|
|
|
|
interface AddonState {
|
|
addons: Addon[]
|
|
bagTracking: boolean
|
|
/** Tours is on and the admin allows wanderer under it. */
|
|
toursWanderer: boolean
|
|
/** Tours is on and the admin offers OpenHikingMap in its planner (MAP-01). */
|
|
toursHikingMap: boolean
|
|
/** Tours is on and the admin offers CyclOSM in its planner (BIK-06). */
|
|
toursCycleMap: boolean
|
|
/** The collab chat is on: the admin can switch it off inside the collab addon. */
|
|
collabChat: boolean
|
|
loaded: boolean
|
|
loadAddons: () => Promise<void>
|
|
isEnabled: (id: string) => boolean
|
|
}
|
|
|
|
export const useAddonStore = create<AddonState>((set, get) => ({
|
|
addons: [],
|
|
bagTracking: false,
|
|
toursWanderer: false,
|
|
toursHikingMap: false,
|
|
toursCycleMap: false,
|
|
collabChat: true,
|
|
loaded: false,
|
|
|
|
loadAddons: async () => {
|
|
try {
|
|
const data = await addonsApi.enabled()
|
|
set({ addons: data.addons || [], bagTracking: !!data.bagTracking,
|
|
toursWanderer: !!data.toursWanderer,
|
|
toursHikingMap: !!data.toursHikingMap,
|
|
toursCycleMap: !!data.toursCycleMap,
|
|
collabChat: data.collabFeatures?.chat !== false,
|
|
loaded: true,
|
|
})
|
|
} catch {
|
|
set({ loaded: true })
|
|
}
|
|
},
|
|
|
|
isEnabled: (id: string) => {
|
|
if (id === 'memories') {
|
|
return get().addons.some(a => a.type === 'photo_provider' && a.enabled)
|
|
}
|
|
return get().addons.some(a => a.id === id && a.enabled)
|
|
},
|
|
}))
|