Improve UI interactions and responsiveness across components

This commit is contained in:
Chris Scott committed 2025-12-26 16:33:35 -05:00
1 parent 64b36b8d83
commit d701d07a5b
4 files changed
+62 -35

No files matched your search

@@ -170,7 +170,8 @@ function TreeNode({ file, level, onFileSelect, onDirectoryClick, selectedFile, o
if (e.key === 'Enter') handleRenameSubmit()
if (e.key === 'Escape') handleRenameCancel()
}}
className="h-6 text-sm"
onClick={(e) => e.stopPropagation()}
className="h-10"
autoFocus
/>
) : (
@@ -98,7 +98,7 @@ export function RepoDetailHeader({
<DropdownMenuContent align="end">
{!isWorktree && currentBranch && (
<>
<DropdownMenuItem onClick={(e) => e.stopPropagation()}>
<div className="px-2 py-1.5">
<BranchSwitcher
repoId={repoId}
currentBranch={currentBranch}
@@ -107,7 +107,7 @@ export function RepoDetailHeader({
iconOnly={false}
className="w-full"
/>
</DropdownMenuItem>
</div>
<div className="h-px bg-border my-1" />
</>
)}
@@ -6,9 +6,11 @@ interface ContextUsageIndicatorProps {
opcodeUrl: string | null
sessionID: string | undefined
directory?: string
isConnected: boolean
isReconnecting?: boolean
}
export function ContextUsageIndicator({ opcodeUrl, sessionID, directory }: ContextUsageIndicatorProps) {
export function ContextUsageIndicator({ opcodeUrl, sessionID, directory, isConnected, isReconnecting }: ContextUsageIndicatorProps) {
const { totalTokens, contextLimit, usagePercentage, currentModel, isLoading } = useContextUsage(opcodeUrl, sessionID, directory)
const [modelName, setModelName] = useState<string>('')
@@ -46,6 +48,14 @@ export function ContextUsageIndicator({ opcodeUrl, sessionID, directory }: Conte
)
}
if (isReconnecting) {
return <span className="text-xs text-yellow-700 dark:text-yellow-400 font-medium">Reconnecting...</span>
}
if (!isConnected) {
return <span className="text-xs text-muted-foreground font-medium">Disconnected</span>
}
if (!modelName) {
return (
<div className="flex items-center gap-2">
@@ -54,18 +64,16 @@ export function ContextUsageIndicator({ opcodeUrl, sessionID, directory }: Conte
)
}
const getUsageColor = (percentage: number) => {
if (percentage < 50) return 'bg-green-700 dark:bg-green-400'
if (percentage < 80) return 'bg-yellow-700 dark:bg-yellow-400'
return 'bg-red-700 dark:bg-red-400'
}
const getUsageTextColor = (percentage: number) => {
if (percentage < 50) return 'text-green-700 dark:text-green-400'
if (percentage < 80) return 'text-yellow-700 dark:text-yellow-400'
return 'text-red-700 dark:text-red-400'
}
if (isReconnecting) {
return null
}
if (!contextLimit) {
return (
<div className="flex items-center gap-2">
@@ -77,12 +85,6 @@ export function ContextUsageIndicator({ opcodeUrl, sessionID, directory }: Conte
return (
<div className="flex items-center gap-2">
<div className="flex items-center gap-2 min-w-0">
<div className="w-16 h-2 bg-muted rounded-full overflow-hidden border border-border">
<div
className={`h-full transition-all duration-300 ${getUsageColor(usagePercentage || 0)}`}
style={{ width: `${Math.min(usagePercentage || 0, 100)}%` }}
/>
</div>
<span className={`text-xs font-medium whitespace-nowrap ${getUsageTextColor(usagePercentage || 0)}`}>
{totalTokens.toLocaleString()} / {contextLimit.toLocaleString()}
</span>
@@ -2,7 +2,8 @@ import { BackButton } from "@/components/ui/back-button";
import { ContextUsageIndicator } from "@/components/session/ContextUsageIndicator";
import { BranchSwitcher } from "@/components/repo/BranchSwitcher";
import { Button } from "@/components/ui/button";
import { Loader2, Settings, CornerUpLeft, Plug, FolderOpen } from "lucide-react";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
import { Loader2, Settings, CornerUpLeft, Plug, FolderOpen, MoreVertical } from "lucide-react";
import { useState } from "react";
interface Repo {
@@ -147,11 +148,13 @@ export function SessionDetailHeader({
</div>
</div>
<div className="flex items-center gap-2 sm:gap-4 flex-shrink-0">
<div className="hidden sm:block">
<div>
<ContextUsageIndicator
opcodeUrl={opcodeUrl}
sessionID={sessionId}
directory={repoDirectory}
isConnected={isConnected}
isReconnecting={isReconnecting}
/>
</div>
<BranchSwitcher
@@ -163,25 +166,11 @@ export function SessionDetailHeader({
className="max-w-[80px] sm:w-[140px] sm:max-w-[140px]"
iconOnly
/>
<div className="flex items-center gap-1 sm:gap-2">
<div
className={`w-1.5 h-1.5 sm:w-2 sm:h-2 rounded-full ${
isConnected
? "bg-green-500"
: isReconnecting
? "bg-yellow-500 animate-pulse"
: "bg-red-500"
}`}
/>
<span className="text-xs text-muted-foreground hidden sm:inline">
{isConnected ? "Connected" : isReconnecting ? "Reconnecting..." : "Disconnected"}
</span>
</div>
<Button
variant="ghost"
size="icon"
onClick={onFileBrowserOpen}
className="text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200 h-8 w-8"
className="hidden sm:flex text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200 h-8 w-8"
title="Files"
>
<FolderOpen className="w-4 h-4" />
@@ -190,7 +179,7 @@ export function SessionDetailHeader({
variant="ghost"
size="icon"
onClick={onMcpDialogOpen}
className="text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200 h-8 w-8"
className="hidden sm:flex text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200 h-8 w-8"
title="MCP Servers"
>
<Plug className="w-4 h-4" />
@@ -199,11 +188,46 @@ export function SessionDetailHeader({
variant="ghost"
size="icon"
onClick={onSettingsOpen}
className="text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200 h-8 w-8"
className="hidden sm:flex text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200 h-8 w-8"
title="Settings"
>
<Settings className="w-4 h-4" />
</Button>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="ghost"
size="icon"
className="sm:hidden text-muted-foreground hover:text-foreground hover:bg-accent transition-all duration-200 h-8 w-8"
title="Options"
>
<MoreVertical className="w-4 h-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<div className="px-2 py-1.5">
<BranchSwitcher
repoId={repoId}
currentBranch={currentBranch}
isWorktree={repo.isWorktree}
repoUrl={repo.repoUrl}
repoLocalPath={repo.localPath}
iconOnly={false}
className="w-full"
/>
</div>
<div className="h-px bg-border my-1" />
<DropdownMenuItem onClick={onFileBrowserOpen}>
<FolderOpen className="w-4 h-4 mr-2" /> Files
</DropdownMenuItem>
<DropdownMenuItem onClick={onMcpDialogOpen}>
<Plug className="w-4 h-4 mr-2" /> MCP
</DropdownMenuItem>
<DropdownMenuItem onClick={onSettingsOpen}>
<Settings className="w-4 h-4 mr-2" /> Settings
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
</div>