Reference in New Issue
Block a user
Delete Branch "fix/ai-chat-current-page"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Исправление баг #43 (Хрупкость №1) — агент AI-чата не получал «текущую страницу».
Проблема
AiChatWindowсмонтирован в pathless-родительском layout-роуте, где сегмент:pageSlugне матчится. ПоэтомуuseParams()возвращал{}→pageSlug === undefined→usePageQueryотключён →openPageвсегда null. Агент никогда не получал контекст текущей страницы и не понимал «эта/текущая страница».Фикс (вариант A из issue)
Извлекаю
pageSlugчерезuseMatch("/s/:spaceSlug/p/:pageSlug")по полному pathname — матчится независимо от позиции компонента в дереве роутов. Поведение при отсутствии совпадения идентично прежнему (undefined → запрос отключён → openPage null).Ревью
APPROVE, проблем нет. Подтверждено: паттерн точно совпадает с роутом в App.tsx;
useParamsбольше нигде в файле не используется (импорт заменён чисто); query-key ключуется по строке pageId, а не по объекту match (стабильность сохранена); на redirect/share-роутах компонент вообще не рендерится.Проверка
tsc --noEmit— exit 0.Осталось в #43 (вне scope, НЕ закрывает issue)
get_current_page(берёт pageId из серверной сессии) ИЛИ скрытый префикс в user-сообщение — вариант C. Это серверная работа + новый tool, отдельным PR.🤖 Generated with Claude Code
AiChatWindow derived the open page via useParams(), but it's mounted in a pathless parent layout route where :pageSlug isn't matched, so useParams() returned {} and openPage was ALWAYS null — the agent never received current-page context (couldn't resolve 'this page'/'the current page'). Derive pageSlug from useMatch('/s/:spaceSlug/p/:pageSlug') against the full pathname instead, so it resolves regardless of where the component sits in the route tree. No-match behavior is unchanged (undefined -> query disabled -> openPage null). Addresses Hardness #1 of #43. Hardness #2 (proxy resilience: a get_current_page tool / hidden user-message context so identity doesn't depend on the system prompt surviving CLIProxyAPI) remains open. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>Ghost referenced this pull request2026-06-21 02:01:08 +03:00