feat(assistant): one AI tile for assistant, parsing and MCP, a planner-aware chat

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.
This commit is contained in:
Maurice
2026-10-21 20:55:06 +02:00
parent b64da26651
commit 123e27643d
142 changed files with 5456 additions and 1572 deletions
@@ -0,0 +1,48 @@
import { useMemo } from 'react';
import { useTranslation } from '../../i18n';
import { useTripStore } from '../../store/tripStore';
import type { ChangeItem } from './assistantParts';
import { useAssistantView } from './assistantViewContext';
/** The day a waiting change lands on: where its effect puts it, else the day its card names. */
function dayOf(item: ChangeItem): number | null {
return item.preview?.effect?.dayId ?? item.preview?.dayId ?? null;
}
export interface WeekDay {
id: number;
n: number;
weekday: string | null;
ids: string[];
}
/** A plan this wide reads as a week: the overview shows from three days on. */
const WEEK_FROM_DAYS = 3;
/**
* The days a card's waiting changes land on, in trip order, each with its
* changes; empty for a plan narrower than a week view.
*/
export function useWeekDays(pending: readonly ChangeItem[]): WeekDay[] {
const { locale } = useTranslation();
const { tripId } = useAssistantView();
const days = useTripStore((s) => (s.trip?.id === tripId ? s.days : null));
return useMemo(() => {
if (!days) return [];
const byDay = new Map<number, string[]>();
for (const item of pending) {
const id = dayOf(item);
if (id !== null) byDay.set(id, [...(byDay.get(id) ?? []), item.toolCallId]);
}
if (byDay.size < WEEK_FROM_DAYS) return [];
const weekdayOf = (date: string | null | undefined) =>
date && /^\d{4}-\d{2}-\d{2}$/.test(date)
? new Intl.DateTimeFormat(locale, { weekday: 'short', timeZone: 'UTC' }).format(new Date(`${date}T00:00:00Z`))
: null;
return days.flatMap((day, index) => {
const ids = byDay.get(day.id);
return ids ? [{ id: day.id, n: index + 1, weekday: weekdayOf(day.date), ids }] : [];
});
}, [days, pending, locale]);
}