From b67417115c6c775a108a03488aa5b8c6a62b79a9 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 1 Dec 2025 14:34:06 -0600 Subject: [PATCH] Display template used to start project at top of messages history --- src/components/Shakespeare/ChatPane.tsx | 68 +++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index 88529db3..4b084b6d 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -46,6 +46,7 @@ import { Quilly } from '@/components/Quilly'; import { ShakespeareLogo } from '@/components/ShakespeareLogo'; import { ChatInput } from '@/components/Shakespeare/ChatInput'; import { buildMessageContent } from '@/lib/buildMessageContent'; +import { DotAI } from '@/lib/DotAI'; // Clean interfaces now handled by proper hooks @@ -88,6 +89,8 @@ export const ChatPane = forwardRef(({ const [showOnboarding, setShowOnboarding] = useState(false); const [isStuck, setIsStuck] = useState(false); const [aiError, setAIError] = useState(null); + const [templateInfo, setTemplateInfo] = useState<{ name: string; description: string; url: string } | null>(null); + const [showTemplateInfo, setShowTemplateInfo] = useState(false); // Determine which error to show - console error takes priority over AI errors const displayError = consoleError || aiError; @@ -252,6 +255,52 @@ export const ChatPane = forwardRef(({ onAIError, }); + // Check if we should show the template info banner + useEffect(() => { + const checkTemplateInfo = async () => { + try { + // Only check if we have at least 1 message + if (messages.length === 0) { + setShowTemplateInfo(false); + return; + } + + const projectCwd = `${projectsPath}/${projectId}`; + const dotAI = new DotAI(fs, projectCwd); + + // Check if template.json exists + const template = await dotAI.readTemplate(); + if (!template) { + setShowTemplateInfo(false); + return; + } + + // Check if exactly 1 history file exists + const historyDirExists = await dotAI.historyDirExists(); + if (!historyDirExists) { + setShowTemplateInfo(false); + return; + } + + const historyDir = `${projectCwd}/.git/ai/history`; + const files = await fs.readdir(historyDir); + const historyFiles = files.filter(file => file.endsWith('.jsonl')); + + if (historyFiles.length === 1) { + setTemplateInfo(template); + setShowTemplateInfo(true); + } else { + setShowTemplateInfo(false); + } + } catch (error) { + console.warn('Failed to check template info:', error); + setShowTemplateInfo(false); + } + }; + + checkTemplateInfo(); + }, [fs, projectsPath, projectId, messages.length]); + // Handle console error help requests const handleConsoleErrorHelp = useCallback(async () => { const tool = new ReadConsoleMessagesTool(); @@ -502,6 +551,25 @@ export const ChatPane = forwardRef(({
+ {/* Template info banner - shown when conditions are met */} + {showTemplateInfo && templateInfo && ( +
+
+ + Started with{' '} + + {templateInfo.name} + + +
+
+ )} + {/* Empty state when no messages and not loading */} {messages.length === 0 && !streamingMessage && !isLoading && (