mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +00:00
Merge remote-tracking branch 'origin/main' into nuke-ngit
This commit is contained in:
6 files changed
+86
-22
No files matched your search
@@ -288,6 +288,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
messages,
|
messages,
|
||||||
streamingMessage,
|
streamingMessage,
|
||||||
isLoading: internalIsLoading,
|
isLoading: internalIsLoading,
|
||||||
|
isLoadingHistory,
|
||||||
totalCost,
|
totalCost,
|
||||||
lastInputTokens,
|
lastInputTokens,
|
||||||
addMessage,
|
addMessage,
|
||||||
@@ -701,8 +702,53 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Loading skeleton while loading history */}
|
||||||
|
{isLoadingHistory && (
|
||||||
|
<div className="space-y-6">
|
||||||
|
{/* User message skeleton */}
|
||||||
|
<div className="flex justify-end py-6">
|
||||||
|
<div className="max-w-[80%] bg-secondary rounded-2xl rounded-br-md px-4 py-3">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Skeleton className="h-4 w-64" />
|
||||||
|
<Skeleton className="h-4 w-48" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Assistant message skeleton */}
|
||||||
|
<div className="flex py-6">
|
||||||
|
<div className="flex-1 min-w-0">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Skeleton className="h-4 w-full" />
|
||||||
|
<Skeleton className="h-4 w-5/6" />
|
||||||
|
<Skeleton className="h-4 w-4/5" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Another user message skeleton */}
|
||||||
|
<div className="flex justify-end py-6">
|
||||||
|
<div className="max-w-[80%] bg-secondary rounded-2xl rounded-br-md px-4 py-3">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Skeleton className="h-4 w-56" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Another assistant message skeleton */}
|
||||||
|
<div className="flex py-6">
|
||||||
|
<div className="flex-1 min-w-0">
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Skeleton className="h-4 w-full" />
|
||||||
|
<Skeleton className="h-4 w-11/12" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Empty state when no messages and not loading */}
|
{/* Empty state when no messages and not loading */}
|
||||||
{messages.length === 0 && !streamingMessage && !isLoading && (
|
{!isLoadingHistory && messages.length === 0 && !streamingMessage && !isLoading && (
|
||||||
<div className="flex-1 flex items-center justify-center min-h-[400px]">
|
<div className="flex-1 flex items-center justify-center min-h-[400px]">
|
||||||
<div className="text-center space-y-4 max-w-md mx-auto">
|
<div className="text-center space-y-4 max-w-md mx-auto">
|
||||||
<div className="mb-6">
|
<div className="mb-6">
|
||||||
@@ -726,7 +772,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{messages.map((message, index) => {
|
{!isLoadingHistory && messages.map((message, index) => {
|
||||||
// Find the corresponding tool call for tool messages
|
// Find the corresponding tool call for tool messages
|
||||||
let toolCall: OpenAI.Chat.Completions.ChatCompletionMessageToolCall | undefined = undefined;
|
let toolCall: OpenAI.Chat.Completions.ChatCompletionMessageToolCall | undefined = undefined;
|
||||||
if (message.role === 'tool') {
|
if (message.role === 'tool') {
|
||||||
@@ -749,7 +795,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
{renderStreamingMessage()}
|
{!isLoadingHistory && renderStreamingMessage()}
|
||||||
|
|
||||||
{/* Error Alert (Console or AI) - Don't show while assistant is loading */}
|
{/* Error Alert (Console or AI) - Don't show while assistant is loading */}
|
||||||
{displayError && !isLoading && (
|
{displayError && !isLoading && (
|
||||||
|
|||||||
@@ -526,6 +526,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
className="h-8 gap-2 relative"
|
className="h-8 gap-2 relative"
|
||||||
>
|
>
|
||||||
<Bug className="h-4 w-4" />
|
<Bug className="h-4 w-4" />
|
||||||
|
<span className="hidden lg:inline">Logs</span>
|
||||||
{hasConsoleErrors && (
|
{hasConsoleErrors && (
|
||||||
<span className="absolute -top-1 -right-1 h-3 w-3 rounded-full border-2 border-background bg-red-500" />
|
<span className="absolute -top-1 -right-1 h-3 w-3 rounded-full border-2 border-background bg-red-500" />
|
||||||
)}
|
)}
|
||||||
@@ -618,7 +619,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={toggleFullscreen}
|
onClick={toggleFullscreen}
|
||||||
className="h-8 w-8 p-0"
|
className="h-8 w-8 p-0"
|
||||||
title={isFullscreen ? 'Exit immersive view' : 'Enter immersive view'}
|
title={isFullscreen ? 'Exit fullscreen' : 'Enter fullscreen'}
|
||||||
>
|
>
|
||||||
{isFullscreen ? (
|
{isFullscreen ? (
|
||||||
<Shrink className="h-4 w-4" />
|
<Shrink className="h-4 w-4" />
|
||||||
@@ -661,6 +662,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
) : (
|
) : (
|
||||||
<Hammer className="h-4 w-4" />
|
<Hammer className="h-4 w-4" />
|
||||||
)}
|
)}
|
||||||
|
<span className="hidden lg:inline">Build</span>
|
||||||
</Button>
|
</Button>
|
||||||
{(!isMobile && onToggleView && isPreviewable) && (
|
{(!isMobile && onToggleView && isPreviewable) && (
|
||||||
<Button
|
<Button
|
||||||
@@ -670,6 +672,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
className="h-8 gap-2"
|
className="h-8 gap-2"
|
||||||
>
|
>
|
||||||
<Code className="h-4 w-4" />
|
<Code className="h-4 w-4" />
|
||||||
|
<span className="hidden lg:inline">Code</span>
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
<ConsoleDropdown />
|
<ConsoleDropdown />
|
||||||
@@ -837,6 +840,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
className="gap-2 text-muted-foreground hover:text-foreground"
|
className="gap-2 text-muted-foreground hover:text-foreground"
|
||||||
>
|
>
|
||||||
<Terminal className="h-4 w-4" />
|
<Terminal className="h-4 w-4" />
|
||||||
|
<span className="hidden lg:inline">Terminal</span>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -851,6 +855,7 @@ export function PreviewPane({ projectId, activeTab, onToggleView, isPreviewable
|
|||||||
className="gap-2 text-muted-foreground hover:text-foreground"
|
className="gap-2 text-muted-foreground hover:text-foreground"
|
||||||
>
|
>
|
||||||
<Terminal className="h-4 w-4" />
|
<Terminal className="h-4 w-4" />
|
||||||
|
<span className="hidden lg:inline">Terminal</span>
|
||||||
</Button>
|
</Button>
|
||||||
<GitStatusIndicator projectId={projectId} />
|
<GitStatusIndicator projectId={projectId} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -253,14 +253,6 @@ export function SyncStep({ projectId, remoteUrl }: SyncStepProps) {
|
|||||||
<h3 className="font-semibold">{providerInfo?.name}</h3>
|
<h3 className="font-semibold">{providerInfo?.name}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-1">
|
<div className="flex items-center gap-1">
|
||||||
<Button
|
|
||||||
variant="ghost"
|
|
||||||
size="icon"
|
|
||||||
className="h-8 w-8"
|
|
||||||
onClick={handleOpenExternal}
|
|
||||||
>
|
|
||||||
<ExternalLink className="h-4 w-4" />
|
|
||||||
</Button>
|
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button variant="ghost" size="icon" className="h-8 w-8">
|
<Button variant="ghost" size="icon" className="h-8 w-8">
|
||||||
@@ -297,6 +289,14 @@ export function SyncStep({ projectId, remoteUrl }: SyncStepProps) {
|
|||||||
<Copy className="h-4 w-4" />
|
<Copy className="h-4 w-4" />
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="outline"
|
||||||
|
onClick={handleOpenExternal}
|
||||||
|
className="shrink-0 h-10"
|
||||||
|
>
|
||||||
|
<ExternalLink className="h-4 w-4" />
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ export function BrowserAddressBar({
|
|||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={onRefresh}
|
onClick={onRefresh}
|
||||||
className="size-6 absolute right-1 top-1/2 -translate-y-1/2 hover:bg-muted/50 rounded-full transition-colors group"
|
className="size-6 absolute right-1 top-1/2 -translate-y-1/2 hover:bg-muted/50 rounded-full transition-colors group px-1.5"
|
||||||
title="Refresh"
|
title="Refresh"
|
||||||
>
|
>
|
||||||
<RefreshCw className="size-3 text-muted-foreground transition-colors group-hover:text-foreground" />
|
<RefreshCw className="size-3 text-muted-foreground transition-colors group-hover:text-foreground" />
|
||||||
|
|||||||
+15
-8
@@ -43,16 +43,22 @@ export function useAIChat({
|
|||||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||||
const [totalCost, setTotalCost] = useState<number>(0);
|
const [totalCost, setTotalCost] = useState<number>(0);
|
||||||
const [lastInputTokens, setLastInputTokens] = useState<number>(0);
|
const [lastInputTokens, setLastInputTokens] = useState<number>(0);
|
||||||
|
const [isLoadingHistory, setIsLoadingHistory] = useState<boolean>(true);
|
||||||
|
|
||||||
const initSession = useCallback(async () => {
|
const initSession = useCallback(async () => {
|
||||||
// Load or update session
|
setIsLoadingHistory(true);
|
||||||
const session = await sessionManager.loadSession(projectId, tools, customTools, maxSteps);
|
try {
|
||||||
// Initialize individual state variables from existing session
|
// Load or update session
|
||||||
setMessages([...session.messages]);
|
const session = await sessionManager.loadSession(projectId, tools, customTools, maxSteps);
|
||||||
setStreamingMessage(session.streamingMessage ? { ...session.streamingMessage } : undefined);
|
// Initialize individual state variables from existing session
|
||||||
setIsLoading(session.isLoading);
|
setMessages([...session.messages]);
|
||||||
setTotalCost(session.totalCost || 0);
|
setStreamingMessage(session.streamingMessage ? { ...session.streamingMessage } : undefined);
|
||||||
setLastInputTokens(session.lastInputTokens || 0);
|
setIsLoading(session.isLoading);
|
||||||
|
setTotalCost(session.totalCost || 0);
|
||||||
|
setLastInputTokens(session.lastInputTokens || 0);
|
||||||
|
} finally {
|
||||||
|
setIsLoadingHistory(false);
|
||||||
|
}
|
||||||
}, [sessionManager, projectId, tools, customTools, maxSteps]);
|
}, [sessionManager, projectId, tools, customTools, maxSteps]);
|
||||||
|
|
||||||
// Initialize session
|
// Initialize session
|
||||||
@@ -166,6 +172,7 @@ export function useAIChat({
|
|||||||
messages,
|
messages,
|
||||||
streamingMessage,
|
streamingMessage,
|
||||||
isLoading,
|
isLoading,
|
||||||
|
isLoadingHistory,
|
||||||
totalCost,
|
totalCost,
|
||||||
lastInputTokens,
|
lastInputTokens,
|
||||||
sendMessage,
|
sendMessage,
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import { useGitFetch } from '@/hooks/useGitFetch';
|
|||||||
import { useQueryClient } from '@tanstack/react-query';
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
import JSZip from 'jszip';
|
import JSZip from 'jszip';
|
||||||
import { cn } from '@/lib/utils';
|
import { cn } from '@/lib/utils';
|
||||||
|
import { useProjectSessionStatus } from '@/hooks/useProjectSessionStatus';
|
||||||
|
|
||||||
export function ProjectView() {
|
export function ProjectView() {
|
||||||
const { projectId } = useParams<{ projectId: string }>();
|
const { projectId } = useParams<{ projectId: string }>();
|
||||||
@@ -72,6 +73,7 @@ export function ProjectView() {
|
|||||||
|
|
||||||
const build = useBuildProject(projectId!);
|
const build = useBuildProject(projectId!);
|
||||||
const { data: isPreviewable = false } = useIsProjectPreviewable(projectId!);
|
const { data: isPreviewable = false } = useIsProjectPreviewable(projectId!);
|
||||||
|
const { hasRunningSessions } = useProjectSessionStatus(projectId || '');
|
||||||
|
|
||||||
// Automatically fetch from remote to keep git status updated
|
// Automatically fetch from remote to keep git status updated
|
||||||
useGitFetch(projectId ? `${projectsPath}/${projectId}` : undefined);
|
useGitFetch(projectId ? `${projectsPath}/${projectId}` : undefined);
|
||||||
@@ -402,7 +404,11 @@ export function ProjectView() {
|
|||||||
className={cn("flex-1 rounded-none mobile-nav-button text-muted-foreground", { "text-foreground": mobileView === 'chat' })}
|
className={cn("flex-1 rounded-none mobile-nav-button text-muted-foreground", { "text-foreground": mobileView === 'chat' })}
|
||||||
disabled={!project}
|
disabled={!project}
|
||||||
>
|
>
|
||||||
<MessageSquare className="h-4 w-4 mr-1" />
|
{project && hasRunningSessions ? (
|
||||||
|
<Loader2 className="h-4 w-4 mr-1 animate-spin text-blue-600 dark:text-blue-400" />
|
||||||
|
) : (
|
||||||
|
<MessageSquare className="h-4 w-4 mr-1" />
|
||||||
|
)}
|
||||||
{t('chat')}
|
{t('chat')}
|
||||||
</Button>
|
</Button>
|
||||||
{isPreviewable && (
|
{isPreviewable && (
|
||||||
|
|||||||
Reference in new issue
Block a user