2025-12-06 12:46:40 +09:00
|
|
|
"use client"
|
2025-12-03 21:49:34 +09:00
|
|
|
|
2025-12-17 14:50:07 +09:00
|
|
|
import {
|
|
|
|
|
Cloud,
|
|
|
|
|
FileText,
|
|
|
|
|
GitBranch,
|
|
|
|
|
Palette,
|
|
|
|
|
Terminal,
|
|
|
|
|
Zap,
|
|
|
|
|
} from "lucide-react"
|
2025-12-20 20:18:54 +05:30
|
|
|
import { useDictionary } from "@/hooks/use-dictionary"
|
2025-12-22 19:58:55 +05:30
|
|
|
import { getAssetUrl } from "@/lib/base-path"
|
2025-12-03 21:49:34 +09:00
|
|
|
|
|
|
|
|
interface ExampleCardProps {
|
2025-12-06 12:46:40 +09:00
|
|
|
icon: React.ReactNode
|
|
|
|
|
title: string
|
|
|
|
|
description: string
|
|
|
|
|
onClick: () => void
|
2025-12-10 21:32:35 +09:00
|
|
|
isNew?: boolean
|
2025-12-03 21:49:34 +09:00
|
|
|
}
|
|
|
|
|
|
2025-12-10 21:32:35 +09:00
|
|
|
function ExampleCard({
|
|
|
|
|
icon,
|
|
|
|
|
title,
|
|
|
|
|
description,
|
|
|
|
|
onClick,
|
|
|
|
|
isNew,
|
|
|
|
|
}: ExampleCardProps) {
|
2025-12-20 20:18:54 +05:30
|
|
|
const dict = useDictionary()
|
|
|
|
|
|
2025-12-03 21:49:34 +09:00
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
onClick={onClick}
|
2025-12-10 21:32:35 +09:00
|
|
|
className={`group w-full text-left p-4 rounded-xl border bg-card hover:bg-accent/50 hover:border-primary/30 transition-all duration-200 hover:shadow-sm ${
|
|
|
|
|
isNew
|
|
|
|
|
? "border-primary/40 ring-1 ring-primary/20"
|
|
|
|
|
: "border-border/60"
|
|
|
|
|
}`}
|
2025-12-03 21:49:34 +09:00
|
|
|
>
|
|
|
|
|
<div className="flex items-start gap-3">
|
2025-12-10 21:32:35 +09:00
|
|
|
<div
|
|
|
|
|
className={`w-9 h-9 rounded-lg flex items-center justify-center shrink-0 transition-colors ${
|
|
|
|
|
isNew
|
|
|
|
|
? "bg-primary/20 group-hover:bg-primary/25"
|
|
|
|
|
: "bg-primary/10 group-hover:bg-primary/15"
|
|
|
|
|
}`}
|
|
|
|
|
>
|
2025-12-03 21:49:34 +09:00
|
|
|
{icon}
|
|
|
|
|
</div>
|
|
|
|
|
<div className="min-w-0">
|
2025-12-10 21:32:35 +09:00
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<h3 className="text-sm font-medium text-foreground group-hover:text-primary transition-colors">
|
|
|
|
|
{title}
|
|
|
|
|
</h3>
|
|
|
|
|
{isNew && (
|
|
|
|
|
<span className="px-1.5 py-0.5 text-[10px] font-semibold bg-primary text-primary-foreground rounded">
|
2025-12-20 20:18:54 +05:30
|
|
|
{dict.common.new}
|
2025-12-10 21:32:35 +09:00
|
|
|
</span>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2025-12-03 21:49:34 +09:00
|
|
|
<p className="text-xs text-muted-foreground mt-0.5 line-clamp-2">
|
|
|
|
|
{description}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
2025-12-06 12:46:40 +09:00
|
|
|
)
|
2025-12-03 21:49:34 +09:00
|
|
|
}
|
|
|
|
|
|
2025-03-25 02:24:12 +00:00
|
|
|
export default function ExamplePanel({
|
|
|
|
|
setInput,
|
|
|
|
|
setFiles,
|
feat: add chat session history with IndexedDB persistence (#500)
* feat(session): add chat session history with IndexedDB storage
- Add session-storage.ts with IndexedDB wrapper using idb library
- Add use-session-manager.ts hook for session state management
- Add session-history-dropdown.tsx for session selection UI
- Integrate session system into chat-panel.tsx
- Auto-generate session titles from first user message
- Auto-save sessions on message completion
- Support session switching, deletion, and creation
- Migrate existing localStorage data to IndexedDB
- Add i18n translations for session history UI
* feat(session): improve history dropdown and persist diagram history
- Add time-based grouping (Today, Yesterday, This Week, Earlier)
- Add thumbnail previews using Next.js Image component
- Add staggered entrance animations with fade-in effects
- Improve active session indicator with left border accent
- Fix scrolling by using native overflow instead of ScrollArea
- Persist diagram version history to IndexedDB sessions
- Remove redundant diagram XML from localStorage
- Add i18n strings for time group labels (en, ja, zh)
* fix(session): prevent data loss on theme change and tab close
- Add isDrawioReady effect to restore diagram after DrawIO remount
- Add visibilitychange handler to save session when page becomes hidden
- Fix missing currentSessionId in saveCurrentSession dependency array
- Remove unused sanitizeMessages import from use-session-manager
* fix(session): fix diagram save and migration data loss bugs
- Add diagramHistory to save effect dependency array so diagram-only
edits trigger saves (previously only message changes did)
- Destructure stable sessionManager values to prevent unnecessary
effect re-runs on every render
- Add try-catch wrapper around debounced async save operation
- Make saveSession() return boolean to indicate success/failure
- Verify IndexedDB write succeeded before deleting localStorage data
during migration (prevents data loss if write silently fails)
- Keep localStorage data for retry if migration fails instead of
marking as complete anyway
* refactor(session): extract helpers to reduce code duplication
- Add syncUIWithSession helper to consolidate 4 duplicate UI sync blocks
- Add buildSessionData helper to consolidate 4 duplicate save logic blocks
- Remove unused saveTimeoutRef and its cleanup effect
- Net reduction of ~80 lines of duplicate code
* style(ui): improve history dropdown and delete dialog styling
- Change destructive color from coral to muted rose for refined look
- Make session history panel taller (400px fixed height)
- Fix popover alignment to prevent truncation
- Style delete button with soft red outline instead of solid fill
- Make delete dialog more compact (max-w-sm)
* fix(session): reset refs on new chat and show recent sessions
- Fix cached example diagrams not displaying after creating new session
- Reset previousXML, lastProcessedXmlRef and processedToolCalls when
messages become empty (new chat or session switch)
- Add recent chats section in empty chat state with collapsible examples
- Pass sessions and onSelectSession to ChatMessageDisplay
- Add loadedMessageIdsRef to skip animations on session restore
- Add debug console.log for diagram processing flow
* feat(session): add search bar and improve history UI
- Remove session history dropdown, use main panel instead
- Add search bar to filter history chats by title
- Show minutes (Xm ago) instead of "Just now" for recent sessions
- Scroll to top when switching to new/empty chat
- Remove title truncation limit for better searchability
- Remove debug console.log statements
* refactor: remove redundant code and fix nested button hydration error
- Remove unused 'sessions' from deleteSession dependency array
- Remove unused 'switchedTo' variable and simplify return type
- Remove unused 'restoredMessageIdsRef' (always empty)
- Fix nested button hydration error by using div with role=button
- Simplify handleDeleteSession callback
* fix(session): fix migration bug, improve metadata perf, truncate titles
- Fix migration retry loop when localStorage has empty array
- Use cursor-based iteration for getAllSessionMetadata
- Truncate session titles to 100 chars with ellipsis
* refactor: remove dead code and extract diagram length constant
- Remove unused exports: getAllSessions, createNewSession, updateSessionTitle
- Remove write-only CURRENT_SESSION_KEY and all localStorage calls
- Remove dead messagesEndRef and unused scroll effect
- Extract magic number 300 to MIN_REAL_DIAGRAM_LENGTH constant
- Add isRealDiagram() helper function for semantic clarity
2026-01-04 10:25:19 +09:00
|
|
|
minimal = false,
|
2025-03-25 02:24:12 +00:00
|
|
|
}: {
|
2025-12-06 12:46:40 +09:00
|
|
|
setInput: (input: string) => void
|
|
|
|
|
setFiles: (files: File[]) => void
|
feat: add chat session history with IndexedDB persistence (#500)
* feat(session): add chat session history with IndexedDB storage
- Add session-storage.ts with IndexedDB wrapper using idb library
- Add use-session-manager.ts hook for session state management
- Add session-history-dropdown.tsx for session selection UI
- Integrate session system into chat-panel.tsx
- Auto-generate session titles from first user message
- Auto-save sessions on message completion
- Support session switching, deletion, and creation
- Migrate existing localStorage data to IndexedDB
- Add i18n translations for session history UI
* feat(session): improve history dropdown and persist diagram history
- Add time-based grouping (Today, Yesterday, This Week, Earlier)
- Add thumbnail previews using Next.js Image component
- Add staggered entrance animations with fade-in effects
- Improve active session indicator with left border accent
- Fix scrolling by using native overflow instead of ScrollArea
- Persist diagram version history to IndexedDB sessions
- Remove redundant diagram XML from localStorage
- Add i18n strings for time group labels (en, ja, zh)
* fix(session): prevent data loss on theme change and tab close
- Add isDrawioReady effect to restore diagram after DrawIO remount
- Add visibilitychange handler to save session when page becomes hidden
- Fix missing currentSessionId in saveCurrentSession dependency array
- Remove unused sanitizeMessages import from use-session-manager
* fix(session): fix diagram save and migration data loss bugs
- Add diagramHistory to save effect dependency array so diagram-only
edits trigger saves (previously only message changes did)
- Destructure stable sessionManager values to prevent unnecessary
effect re-runs on every render
- Add try-catch wrapper around debounced async save operation
- Make saveSession() return boolean to indicate success/failure
- Verify IndexedDB write succeeded before deleting localStorage data
during migration (prevents data loss if write silently fails)
- Keep localStorage data for retry if migration fails instead of
marking as complete anyway
* refactor(session): extract helpers to reduce code duplication
- Add syncUIWithSession helper to consolidate 4 duplicate UI sync blocks
- Add buildSessionData helper to consolidate 4 duplicate save logic blocks
- Remove unused saveTimeoutRef and its cleanup effect
- Net reduction of ~80 lines of duplicate code
* style(ui): improve history dropdown and delete dialog styling
- Change destructive color from coral to muted rose for refined look
- Make session history panel taller (400px fixed height)
- Fix popover alignment to prevent truncation
- Style delete button with soft red outline instead of solid fill
- Make delete dialog more compact (max-w-sm)
* fix(session): reset refs on new chat and show recent sessions
- Fix cached example diagrams not displaying after creating new session
- Reset previousXML, lastProcessedXmlRef and processedToolCalls when
messages become empty (new chat or session switch)
- Add recent chats section in empty chat state with collapsible examples
- Pass sessions and onSelectSession to ChatMessageDisplay
- Add loadedMessageIdsRef to skip animations on session restore
- Add debug console.log for diagram processing flow
* feat(session): add search bar and improve history UI
- Remove session history dropdown, use main panel instead
- Add search bar to filter history chats by title
- Show minutes (Xm ago) instead of "Just now" for recent sessions
- Scroll to top when switching to new/empty chat
- Remove title truncation limit for better searchability
- Remove debug console.log statements
* refactor: remove redundant code and fix nested button hydration error
- Remove unused 'sessions' from deleteSession dependency array
- Remove unused 'switchedTo' variable and simplify return type
- Remove unused 'restoredMessageIdsRef' (always empty)
- Fix nested button hydration error by using div with role=button
- Simplify handleDeleteSession callback
* fix(session): fix migration bug, improve metadata perf, truncate titles
- Fix migration retry loop when localStorage has empty array
- Use cursor-based iteration for getAllSessionMetadata
- Truncate session titles to 100 chars with ellipsis
* refactor: remove dead code and extract diagram length constant
- Remove unused exports: getAllSessions, createNewSession, updateSessionTitle
- Remove write-only CURRENT_SESSION_KEY and all localStorage calls
- Remove dead messagesEndRef and unused scroll effect
- Extract magic number 300 to MIN_REAL_DIAGRAM_LENGTH constant
- Add isRealDiagram() helper function for semantic clarity
2026-01-04 10:25:19 +09:00
|
|
|
minimal?: boolean
|
2025-03-25 02:24:12 +00:00
|
|
|
}) {
|
2025-12-20 20:18:54 +05:30
|
|
|
const dict = useDictionary()
|
|
|
|
|
|
2025-03-25 02:24:12 +00:00
|
|
|
const handleReplicateFlowchart = async () => {
|
2025-12-06 12:46:40 +09:00
|
|
|
setInput("Replicate this flowchart.")
|
2025-03-25 02:24:12 +00:00
|
|
|
|
|
|
|
|
try {
|
2025-12-22 19:58:55 +05:30
|
|
|
const response = await fetch(getAssetUrl("/example.png"))
|
2025-12-06 12:46:40 +09:00
|
|
|
const blob = await response.blob()
|
|
|
|
|
const file = new File([blob], "example.png", { type: "image/png" })
|
|
|
|
|
setFiles([file])
|
2025-03-25 02:24:12 +00:00
|
|
|
} catch (error) {
|
2025-12-20 20:18:54 +05:30
|
|
|
console.error(dict.errors.failedToLoadExample, error)
|
2025-03-25 02:24:12 +00:00
|
|
|
}
|
2025-12-06 12:46:40 +09:00
|
|
|
}
|
2025-11-10 09:13:21 +09:00
|
|
|
|
|
|
|
|
const handleReplicateArchitecture = async () => {
|
2025-12-06 12:46:40 +09:00
|
|
|
setInput("Replicate this in aws style")
|
2025-11-10 09:13:21 +09:00
|
|
|
|
|
|
|
|
try {
|
2025-12-22 19:58:55 +05:30
|
|
|
const response = await fetch(getAssetUrl("/architecture.png"))
|
2025-12-06 12:46:40 +09:00
|
|
|
const blob = await response.blob()
|
2025-11-10 10:28:37 +09:00
|
|
|
const file = new File([blob], "architecture.png", {
|
|
|
|
|
type: "image/png",
|
2025-12-06 12:46:40 +09:00
|
|
|
})
|
|
|
|
|
setFiles([file])
|
2025-11-10 09:13:21 +09:00
|
|
|
} catch (error) {
|
2025-12-20 20:18:54 +05:30
|
|
|
console.error(dict.errors.failedToLoadExample, error)
|
2025-11-10 09:13:21 +09:00
|
|
|
}
|
2025-12-06 12:46:40 +09:00
|
|
|
}
|
2025-12-03 21:49:34 +09:00
|
|
|
|
2025-12-10 21:32:35 +09:00
|
|
|
const handlePdfExample = async () => {
|
|
|
|
|
setInput("Summarize this paper as a diagram")
|
|
|
|
|
|
|
|
|
|
try {
|
2025-12-22 19:58:55 +05:30
|
|
|
const response = await fetch(getAssetUrl("/chain-of-thought.txt"))
|
2025-12-10 21:32:35 +09:00
|
|
|
const blob = await response.blob()
|
|
|
|
|
const file = new File([blob], "chain-of-thought.txt", {
|
|
|
|
|
type: "text/plain",
|
|
|
|
|
})
|
|
|
|
|
setFiles([file])
|
|
|
|
|
} catch (error) {
|
2025-12-20 20:18:54 +05:30
|
|
|
console.error(dict.errors.failedToLoadExample, error)
|
2025-12-10 21:32:35 +09:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-25 02:24:12 +00:00
|
|
|
return (
|
feat: add chat session history with IndexedDB persistence (#500)
* feat(session): add chat session history with IndexedDB storage
- Add session-storage.ts with IndexedDB wrapper using idb library
- Add use-session-manager.ts hook for session state management
- Add session-history-dropdown.tsx for session selection UI
- Integrate session system into chat-panel.tsx
- Auto-generate session titles from first user message
- Auto-save sessions on message completion
- Support session switching, deletion, and creation
- Migrate existing localStorage data to IndexedDB
- Add i18n translations for session history UI
* feat(session): improve history dropdown and persist diagram history
- Add time-based grouping (Today, Yesterday, This Week, Earlier)
- Add thumbnail previews using Next.js Image component
- Add staggered entrance animations with fade-in effects
- Improve active session indicator with left border accent
- Fix scrolling by using native overflow instead of ScrollArea
- Persist diagram version history to IndexedDB sessions
- Remove redundant diagram XML from localStorage
- Add i18n strings for time group labels (en, ja, zh)
* fix(session): prevent data loss on theme change and tab close
- Add isDrawioReady effect to restore diagram after DrawIO remount
- Add visibilitychange handler to save session when page becomes hidden
- Fix missing currentSessionId in saveCurrentSession dependency array
- Remove unused sanitizeMessages import from use-session-manager
* fix(session): fix diagram save and migration data loss bugs
- Add diagramHistory to save effect dependency array so diagram-only
edits trigger saves (previously only message changes did)
- Destructure stable sessionManager values to prevent unnecessary
effect re-runs on every render
- Add try-catch wrapper around debounced async save operation
- Make saveSession() return boolean to indicate success/failure
- Verify IndexedDB write succeeded before deleting localStorage data
during migration (prevents data loss if write silently fails)
- Keep localStorage data for retry if migration fails instead of
marking as complete anyway
* refactor(session): extract helpers to reduce code duplication
- Add syncUIWithSession helper to consolidate 4 duplicate UI sync blocks
- Add buildSessionData helper to consolidate 4 duplicate save logic blocks
- Remove unused saveTimeoutRef and its cleanup effect
- Net reduction of ~80 lines of duplicate code
* style(ui): improve history dropdown and delete dialog styling
- Change destructive color from coral to muted rose for refined look
- Make session history panel taller (400px fixed height)
- Fix popover alignment to prevent truncation
- Style delete button with soft red outline instead of solid fill
- Make delete dialog more compact (max-w-sm)
* fix(session): reset refs on new chat and show recent sessions
- Fix cached example diagrams not displaying after creating new session
- Reset previousXML, lastProcessedXmlRef and processedToolCalls when
messages become empty (new chat or session switch)
- Add recent chats section in empty chat state with collapsible examples
- Pass sessions and onSelectSession to ChatMessageDisplay
- Add loadedMessageIdsRef to skip animations on session restore
- Add debug console.log for diagram processing flow
* feat(session): add search bar and improve history UI
- Remove session history dropdown, use main panel instead
- Add search bar to filter history chats by title
- Show minutes (Xm ago) instead of "Just now" for recent sessions
- Scroll to top when switching to new/empty chat
- Remove title truncation limit for better searchability
- Remove debug console.log statements
* refactor: remove redundant code and fix nested button hydration error
- Remove unused 'sessions' from deleteSession dependency array
- Remove unused 'switchedTo' variable and simplify return type
- Remove unused 'restoredMessageIdsRef' (always empty)
- Fix nested button hydration error by using div with role=button
- Simplify handleDeleteSession callback
* fix(session): fix migration bug, improve metadata perf, truncate titles
- Fix migration retry loop when localStorage has empty array
- Use cursor-based iteration for getAllSessionMetadata
- Truncate session titles to 100 chars with ellipsis
* refactor: remove dead code and extract diagram length constant
- Remove unused exports: getAllSessions, createNewSession, updateSessionTitle
- Remove write-only CURRENT_SESSION_KEY and all localStorage calls
- Remove dead messagesEndRef and unused scroll effect
- Extract magic number 300 to MIN_REAL_DIAGRAM_LENGTH constant
- Add isRealDiagram() helper function for semantic clarity
2026-01-04 10:25:19 +09:00
|
|
|
<div className={minimal ? "" : "py-6 px-2 animate-fade-in"}>
|
|
|
|
|
{!minimal && (
|
|
|
|
|
<>
|
|
|
|
|
{/* MCP Server Notice */}
|
|
|
|
|
<a
|
|
|
|
|
href="https://github.com/DayuanJiang/next-ai-draw-io/tree/main/packages/mcp-server"
|
|
|
|
|
target="_blank"
|
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
|
className="block mb-4 p-3 rounded-xl bg-gradient-to-r from-purple-500/10 to-blue-500/10 border border-purple-500/20 hover:border-purple-500/40 transition-colors group"
|
|
|
|
|
>
|
|
|
|
|
<div className="flex items-center gap-3">
|
|
|
|
|
<div className="w-8 h-8 rounded-lg bg-purple-500/20 flex items-center justify-center shrink-0">
|
|
|
|
|
<Terminal className="w-4 h-4 text-purple-500" />
|
|
|
|
|
</div>
|
|
|
|
|
<div className="min-w-0">
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<span className="text-sm font-medium text-foreground group-hover:text-purple-500 transition-colors">
|
|
|
|
|
{dict.examples.mcpServer}
|
|
|
|
|
</span>
|
|
|
|
|
<span className="px-1.5 py-0.5 text-[10px] font-semibold bg-purple-500 text-white rounded">
|
|
|
|
|
{dict.examples.preview}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<p className="text-xs text-muted-foreground">
|
|
|
|
|
{dict.examples.mcpDescription}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
2025-12-17 14:50:07 +09:00
|
|
|
</div>
|
feat: add chat session history with IndexedDB persistence (#500)
* feat(session): add chat session history with IndexedDB storage
- Add session-storage.ts with IndexedDB wrapper using idb library
- Add use-session-manager.ts hook for session state management
- Add session-history-dropdown.tsx for session selection UI
- Integrate session system into chat-panel.tsx
- Auto-generate session titles from first user message
- Auto-save sessions on message completion
- Support session switching, deletion, and creation
- Migrate existing localStorage data to IndexedDB
- Add i18n translations for session history UI
* feat(session): improve history dropdown and persist diagram history
- Add time-based grouping (Today, Yesterday, This Week, Earlier)
- Add thumbnail previews using Next.js Image component
- Add staggered entrance animations with fade-in effects
- Improve active session indicator with left border accent
- Fix scrolling by using native overflow instead of ScrollArea
- Persist diagram version history to IndexedDB sessions
- Remove redundant diagram XML from localStorage
- Add i18n strings for time group labels (en, ja, zh)
* fix(session): prevent data loss on theme change and tab close
- Add isDrawioReady effect to restore diagram after DrawIO remount
- Add visibilitychange handler to save session when page becomes hidden
- Fix missing currentSessionId in saveCurrentSession dependency array
- Remove unused sanitizeMessages import from use-session-manager
* fix(session): fix diagram save and migration data loss bugs
- Add diagramHistory to save effect dependency array so diagram-only
edits trigger saves (previously only message changes did)
- Destructure stable sessionManager values to prevent unnecessary
effect re-runs on every render
- Add try-catch wrapper around debounced async save operation
- Make saveSession() return boolean to indicate success/failure
- Verify IndexedDB write succeeded before deleting localStorage data
during migration (prevents data loss if write silently fails)
- Keep localStorage data for retry if migration fails instead of
marking as complete anyway
* refactor(session): extract helpers to reduce code duplication
- Add syncUIWithSession helper to consolidate 4 duplicate UI sync blocks
- Add buildSessionData helper to consolidate 4 duplicate save logic blocks
- Remove unused saveTimeoutRef and its cleanup effect
- Net reduction of ~80 lines of duplicate code
* style(ui): improve history dropdown and delete dialog styling
- Change destructive color from coral to muted rose for refined look
- Make session history panel taller (400px fixed height)
- Fix popover alignment to prevent truncation
- Style delete button with soft red outline instead of solid fill
- Make delete dialog more compact (max-w-sm)
* fix(session): reset refs on new chat and show recent sessions
- Fix cached example diagrams not displaying after creating new session
- Reset previousXML, lastProcessedXmlRef and processedToolCalls when
messages become empty (new chat or session switch)
- Add recent chats section in empty chat state with collapsible examples
- Pass sessions and onSelectSession to ChatMessageDisplay
- Add loadedMessageIdsRef to skip animations on session restore
- Add debug console.log for diagram processing flow
* feat(session): add search bar and improve history UI
- Remove session history dropdown, use main panel instead
- Add search bar to filter history chats by title
- Show minutes (Xm ago) instead of "Just now" for recent sessions
- Scroll to top when switching to new/empty chat
- Remove title truncation limit for better searchability
- Remove debug console.log statements
* refactor: remove redundant code and fix nested button hydration error
- Remove unused 'sessions' from deleteSession dependency array
- Remove unused 'switchedTo' variable and simplify return type
- Remove unused 'restoredMessageIdsRef' (always empty)
- Fix nested button hydration error by using div with role=button
- Simplify handleDeleteSession callback
* fix(session): fix migration bug, improve metadata perf, truncate titles
- Fix migration retry loop when localStorage has empty array
- Use cursor-based iteration for getAllSessionMetadata
- Truncate session titles to 100 chars with ellipsis
* refactor: remove dead code and extract diagram length constant
- Remove unused exports: getAllSessions, createNewSession, updateSessionTitle
- Remove write-only CURRENT_SESSION_KEY and all localStorage calls
- Remove dead messagesEndRef and unused scroll effect
- Extract magic number 300 to MIN_REAL_DIAGRAM_LENGTH constant
- Add isRealDiagram() helper function for semantic clarity
2026-01-04 10:25:19 +09:00
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
{/* Welcome section */}
|
|
|
|
|
<div className="text-center mb-6">
|
|
|
|
|
<h2 className="text-lg font-semibold text-foreground mb-2">
|
|
|
|
|
{dict.examples.title}
|
|
|
|
|
</h2>
|
|
|
|
|
<p className="text-sm text-muted-foreground max-w-xs mx-auto">
|
|
|
|
|
{dict.examples.subtitle}
|
2025-12-17 14:50:07 +09:00
|
|
|
</p>
|
|
|
|
|
</div>
|
feat: add chat session history with IndexedDB persistence (#500)
* feat(session): add chat session history with IndexedDB storage
- Add session-storage.ts with IndexedDB wrapper using idb library
- Add use-session-manager.ts hook for session state management
- Add session-history-dropdown.tsx for session selection UI
- Integrate session system into chat-panel.tsx
- Auto-generate session titles from first user message
- Auto-save sessions on message completion
- Support session switching, deletion, and creation
- Migrate existing localStorage data to IndexedDB
- Add i18n translations for session history UI
* feat(session): improve history dropdown and persist diagram history
- Add time-based grouping (Today, Yesterday, This Week, Earlier)
- Add thumbnail previews using Next.js Image component
- Add staggered entrance animations with fade-in effects
- Improve active session indicator with left border accent
- Fix scrolling by using native overflow instead of ScrollArea
- Persist diagram version history to IndexedDB sessions
- Remove redundant diagram XML from localStorage
- Add i18n strings for time group labels (en, ja, zh)
* fix(session): prevent data loss on theme change and tab close
- Add isDrawioReady effect to restore diagram after DrawIO remount
- Add visibilitychange handler to save session when page becomes hidden
- Fix missing currentSessionId in saveCurrentSession dependency array
- Remove unused sanitizeMessages import from use-session-manager
* fix(session): fix diagram save and migration data loss bugs
- Add diagramHistory to save effect dependency array so diagram-only
edits trigger saves (previously only message changes did)
- Destructure stable sessionManager values to prevent unnecessary
effect re-runs on every render
- Add try-catch wrapper around debounced async save operation
- Make saveSession() return boolean to indicate success/failure
- Verify IndexedDB write succeeded before deleting localStorage data
during migration (prevents data loss if write silently fails)
- Keep localStorage data for retry if migration fails instead of
marking as complete anyway
* refactor(session): extract helpers to reduce code duplication
- Add syncUIWithSession helper to consolidate 4 duplicate UI sync blocks
- Add buildSessionData helper to consolidate 4 duplicate save logic blocks
- Remove unused saveTimeoutRef and its cleanup effect
- Net reduction of ~80 lines of duplicate code
* style(ui): improve history dropdown and delete dialog styling
- Change destructive color from coral to muted rose for refined look
- Make session history panel taller (400px fixed height)
- Fix popover alignment to prevent truncation
- Style delete button with soft red outline instead of solid fill
- Make delete dialog more compact (max-w-sm)
* fix(session): reset refs on new chat and show recent sessions
- Fix cached example diagrams not displaying after creating new session
- Reset previousXML, lastProcessedXmlRef and processedToolCalls when
messages become empty (new chat or session switch)
- Add recent chats section in empty chat state with collapsible examples
- Pass sessions and onSelectSession to ChatMessageDisplay
- Add loadedMessageIdsRef to skip animations on session restore
- Add debug console.log for diagram processing flow
* feat(session): add search bar and improve history UI
- Remove session history dropdown, use main panel instead
- Add search bar to filter history chats by title
- Show minutes (Xm ago) instead of "Just now" for recent sessions
- Scroll to top when switching to new/empty chat
- Remove title truncation limit for better searchability
- Remove debug console.log statements
* refactor: remove redundant code and fix nested button hydration error
- Remove unused 'sessions' from deleteSession dependency array
- Remove unused 'switchedTo' variable and simplify return type
- Remove unused 'restoredMessageIdsRef' (always empty)
- Fix nested button hydration error by using div with role=button
- Simplify handleDeleteSession callback
* fix(session): fix migration bug, improve metadata perf, truncate titles
- Fix migration retry loop when localStorage has empty array
- Use cursor-based iteration for getAllSessionMetadata
- Truncate session titles to 100 chars with ellipsis
* refactor: remove dead code and extract diagram length constant
- Remove unused exports: getAllSessions, createNewSession, updateSessionTitle
- Remove write-only CURRENT_SESSION_KEY and all localStorage calls
- Remove dead messagesEndRef and unused scroll effect
- Extract magic number 300 to MIN_REAL_DIAGRAM_LENGTH constant
- Add isRealDiagram() helper function for semantic clarity
2026-01-04 10:25:19 +09:00
|
|
|
</>
|
|
|
|
|
)}
|
2025-12-03 21:49:34 +09:00
|
|
|
|
|
|
|
|
{/* Examples grid */}
|
|
|
|
|
<div className="space-y-3">
|
feat: add chat session history with IndexedDB persistence (#500)
* feat(session): add chat session history with IndexedDB storage
- Add session-storage.ts with IndexedDB wrapper using idb library
- Add use-session-manager.ts hook for session state management
- Add session-history-dropdown.tsx for session selection UI
- Integrate session system into chat-panel.tsx
- Auto-generate session titles from first user message
- Auto-save sessions on message completion
- Support session switching, deletion, and creation
- Migrate existing localStorage data to IndexedDB
- Add i18n translations for session history UI
* feat(session): improve history dropdown and persist diagram history
- Add time-based grouping (Today, Yesterday, This Week, Earlier)
- Add thumbnail previews using Next.js Image component
- Add staggered entrance animations with fade-in effects
- Improve active session indicator with left border accent
- Fix scrolling by using native overflow instead of ScrollArea
- Persist diagram version history to IndexedDB sessions
- Remove redundant diagram XML from localStorage
- Add i18n strings for time group labels (en, ja, zh)
* fix(session): prevent data loss on theme change and tab close
- Add isDrawioReady effect to restore diagram after DrawIO remount
- Add visibilitychange handler to save session when page becomes hidden
- Fix missing currentSessionId in saveCurrentSession dependency array
- Remove unused sanitizeMessages import from use-session-manager
* fix(session): fix diagram save and migration data loss bugs
- Add diagramHistory to save effect dependency array so diagram-only
edits trigger saves (previously only message changes did)
- Destructure stable sessionManager values to prevent unnecessary
effect re-runs on every render
- Add try-catch wrapper around debounced async save operation
- Make saveSession() return boolean to indicate success/failure
- Verify IndexedDB write succeeded before deleting localStorage data
during migration (prevents data loss if write silently fails)
- Keep localStorage data for retry if migration fails instead of
marking as complete anyway
* refactor(session): extract helpers to reduce code duplication
- Add syncUIWithSession helper to consolidate 4 duplicate UI sync blocks
- Add buildSessionData helper to consolidate 4 duplicate save logic blocks
- Remove unused saveTimeoutRef and its cleanup effect
- Net reduction of ~80 lines of duplicate code
* style(ui): improve history dropdown and delete dialog styling
- Change destructive color from coral to muted rose for refined look
- Make session history panel taller (400px fixed height)
- Fix popover alignment to prevent truncation
- Style delete button with soft red outline instead of solid fill
- Make delete dialog more compact (max-w-sm)
* fix(session): reset refs on new chat and show recent sessions
- Fix cached example diagrams not displaying after creating new session
- Reset previousXML, lastProcessedXmlRef and processedToolCalls when
messages become empty (new chat or session switch)
- Add recent chats section in empty chat state with collapsible examples
- Pass sessions and onSelectSession to ChatMessageDisplay
- Add loadedMessageIdsRef to skip animations on session restore
- Add debug console.log for diagram processing flow
* feat(session): add search bar and improve history UI
- Remove session history dropdown, use main panel instead
- Add search bar to filter history chats by title
- Show minutes (Xm ago) instead of "Just now" for recent sessions
- Scroll to top when switching to new/empty chat
- Remove title truncation limit for better searchability
- Remove debug console.log statements
* refactor: remove redundant code and fix nested button hydration error
- Remove unused 'sessions' from deleteSession dependency array
- Remove unused 'switchedTo' variable and simplify return type
- Remove unused 'restoredMessageIdsRef' (always empty)
- Fix nested button hydration error by using div with role=button
- Simplify handleDeleteSession callback
* fix(session): fix migration bug, improve metadata perf, truncate titles
- Fix migration retry loop when localStorage has empty array
- Use cursor-based iteration for getAllSessionMetadata
- Truncate session titles to 100 chars with ellipsis
* refactor: remove dead code and extract diagram length constant
- Remove unused exports: getAllSessions, createNewSession, updateSessionTitle
- Remove write-only CURRENT_SESSION_KEY and all localStorage calls
- Remove dead messagesEndRef and unused scroll effect
- Extract magic number 300 to MIN_REAL_DIAGRAM_LENGTH constant
- Add isRealDiagram() helper function for semantic clarity
2026-01-04 10:25:19 +09:00
|
|
|
{!minimal && (
|
|
|
|
|
<p className="text-xs font-medium text-muted-foreground uppercase tracking-wider px-1">
|
|
|
|
|
{dict.examples.quickExamples}
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
2025-12-03 21:49:34 +09:00
|
|
|
|
|
|
|
|
<div className="grid gap-2">
|
2025-12-10 21:32:35 +09:00
|
|
|
<ExampleCard
|
|
|
|
|
icon={<FileText className="w-4 h-4 text-primary" />}
|
2025-12-20 20:18:54 +05:30
|
|
|
title={dict.examples.paperToDiagram}
|
|
|
|
|
description={dict.examples.paperDescription}
|
2025-12-10 21:32:35 +09:00
|
|
|
onClick={handlePdfExample}
|
|
|
|
|
isNew
|
|
|
|
|
/>
|
|
|
|
|
|
2025-12-03 21:49:34 +09:00
|
|
|
<ExampleCard
|
|
|
|
|
icon={<Zap className="w-4 h-4 text-primary" />}
|
2025-12-20 20:18:54 +05:30
|
|
|
title={dict.examples.animatedDiagram}
|
|
|
|
|
description={dict.examples.animatedDescription}
|
2025-12-05 13:07:14 +08:00
|
|
|
onClick={() => {
|
2025-12-06 12:46:40 +09:00
|
|
|
setInput(
|
|
|
|
|
"Give me a **animated connector** diagram of transformer's architecture",
|
|
|
|
|
)
|
2025-12-05 13:07:14 +08:00
|
|
|
setFiles([])
|
|
|
|
|
}}
|
2025-12-03 21:49:34 +09:00
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<ExampleCard
|
|
|
|
|
icon={<Cloud className="w-4 h-4 text-primary" />}
|
2025-12-20 20:18:54 +05:30
|
|
|
title={dict.examples.awsArchitecture}
|
|
|
|
|
description={dict.examples.awsDescription}
|
2025-12-03 21:49:34 +09:00
|
|
|
onClick={handleReplicateArchitecture}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<ExampleCard
|
|
|
|
|
icon={<GitBranch className="w-4 h-4 text-primary" />}
|
2025-12-20 20:18:54 +05:30
|
|
|
title={dict.examples.replicateFlowchart}
|
|
|
|
|
description={dict.examples.replicateDescription}
|
2025-12-03 21:49:34 +09:00
|
|
|
onClick={handleReplicateFlowchart}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<ExampleCard
|
|
|
|
|
icon={<Palette className="w-4 h-4 text-primary" />}
|
2025-12-20 20:18:54 +05:30
|
|
|
title={dict.examples.creativeDrawing}
|
|
|
|
|
description={dict.examples.creativeDescription}
|
2025-12-05 13:07:14 +08:00
|
|
|
onClick={() => {
|
|
|
|
|
setInput("Draw a cat for me")
|
|
|
|
|
setFiles([])
|
|
|
|
|
}}
|
2025-12-03 21:49:34 +09:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<p className="text-[11px] text-muted-foreground/60 text-center mt-4">
|
2025-12-20 20:18:54 +05:30
|
|
|
{dict.examples.cachedNote}
|
2025-12-03 21:49:34 +09:00
|
|
|
</p>
|
2025-03-25 02:24:12 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-12-06 12:46:40 +09:00
|
|
|
)
|
2025-03-25 02:24:12 +00:00
|
|
|
}
|