支持folder主界面多语言
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useEffect, useMemo, useRef, useState } from "react"
|
||||
import { ChevronRight, FileIcon } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
import { useFolderContext } from "@/contexts/folder-context"
|
||||
import { useTabContext } from "@/contexts/tab-context"
|
||||
import type { LiveMessage } from "@/contexts/acp-connections-context"
|
||||
@@ -77,8 +78,15 @@ function mergeLiveTurns(params: {
|
||||
liveMessage: LiveMessage | null
|
||||
connStatus: ConnectionStatus | null
|
||||
pendingPromptText: string | null
|
||||
fallbackPromptText: string
|
||||
}): MessageTurn[] {
|
||||
const { turns, liveMessage, connStatus, pendingPromptText } = params
|
||||
const {
|
||||
turns,
|
||||
liveMessage,
|
||||
connStatus,
|
||||
pendingPromptText,
|
||||
fallbackPromptText,
|
||||
} = params
|
||||
if (!liveMessage || connStatus !== "prompting") return turns
|
||||
|
||||
const liveBlocks = liveMessage.content.flatMap((block) => {
|
||||
@@ -118,7 +126,7 @@ function mergeLiveTurns(params: {
|
||||
id: `live-user-${liveMessage.id}`,
|
||||
role: "user",
|
||||
blocks: [
|
||||
{ type: "text", text: pendingPromptText?.trim() || "Current response" },
|
||||
{ type: "text", text: pendingPromptText?.trim() || fallbackPromptText },
|
||||
],
|
||||
timestamp: now,
|
||||
})
|
||||
@@ -145,6 +153,7 @@ function SessionFilesContent({
|
||||
connStatus: ConnectionStatus | null
|
||||
pendingPromptText: string | null
|
||||
}) {
|
||||
const t = useTranslations("Folder.sessionFiles")
|
||||
const { detail, loading, refetch } = useDbMessageDetail(conversationId)
|
||||
const { openSessionFileDiff } = useWorkspaceContext()
|
||||
const { folder } = useFolderContext()
|
||||
@@ -166,8 +175,9 @@ function SessionFilesContent({
|
||||
liveMessage,
|
||||
connStatus,
|
||||
pendingPromptText,
|
||||
fallbackPromptText: t("currentResponse"),
|
||||
}),
|
||||
[detail?.turns, liveMessage, connStatus, pendingPromptText]
|
||||
[detail?.turns, liveMessage, connStatus, pendingPromptText, t]
|
||||
)
|
||||
const groups = useMemo(
|
||||
() => (turns.length > 0 ? extractSessionFilesGrouped(turns) : []),
|
||||
@@ -182,7 +192,7 @@ function SessionFilesContent({
|
||||
) => {
|
||||
openSessionFileDiff(
|
||||
filePath,
|
||||
diffContent ?? `No diff data available for ${filePath}`,
|
||||
diffContent ?? t("noDiffDataAvailable", { filePath }),
|
||||
`msg-${groupIndex + 1}-chg-${changeIndex + 1}`
|
||||
)
|
||||
}
|
||||
@@ -190,7 +200,9 @@ function SessionFilesContent({
|
||||
if (loading) {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-full p-4">
|
||||
<p className="text-xs text-muted-foreground text-center">Loading...</p>
|
||||
<p className="text-xs text-muted-foreground text-center">
|
||||
{t("loading")}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -199,7 +211,7 @@ function SessionFilesContent({
|
||||
return (
|
||||
<div className="flex items-center justify-center h-full p-4">
|
||||
<p className="text-xs text-muted-foreground text-center">
|
||||
No file changes found in this conversation
|
||||
{t("noFileChangesInConversation")}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
@@ -258,12 +270,10 @@ function SessionFilesContent({
|
||||
</p>
|
||||
<div className="mt-2 flex flex-wrap items-center gap-1.5">
|
||||
<span className="rounded-md border border-border bg-muted/40 px-1.5 py-0.5 text-[10px] text-muted-foreground">
|
||||
{group.files.length}{" "}
|
||||
{group.files.length === 1 ? "change" : "changes"}
|
||||
{t("changeCount", { count: group.files.length })}
|
||||
</span>
|
||||
<span className="rounded-md border border-border bg-muted/40 px-1.5 py-0.5 text-[10px] text-muted-foreground">
|
||||
{uniqueFileCount}{" "}
|
||||
{uniqueFileCount === 1 ? "File" : "Files"}
|
||||
{t("fileCount", { count: uniqueFileCount })}
|
||||
</span>
|
||||
<span className="inline-flex items-center gap-1 rounded-md border border-border bg-muted/40 px-1.5 py-0.5 font-mono text-[10px] text-foreground">
|
||||
<CommitFileAdditions
|
||||
@@ -338,7 +348,7 @@ function SessionFilesContent({
|
||||
</p>
|
||||
{isRemoved ? (
|
||||
<span className="inline-flex shrink-0 items-center rounded-md border border-destructive/30 bg-destructive/10 px-1.5 py-0.5 font-mono text-[10px] text-destructive">
|
||||
Remove
|
||||
{t("remove")}
|
||||
</span>
|
||||
) : (
|
||||
<span className="inline-flex shrink-0 items-center gap-1 rounded-md border border-border bg-muted/40 px-1.5 py-0.5 font-mono text-[10px] text-foreground">
|
||||
@@ -366,6 +376,7 @@ function SessionFilesContent({
|
||||
}
|
||||
|
||||
export function SessionFilesTab() {
|
||||
const t = useTranslations("Folder.sessionFiles")
|
||||
const { tabs, activeTabId } = useTabContext()
|
||||
|
||||
const activeTab = tabs.find((t) => t.id === activeTabId)
|
||||
@@ -378,7 +389,7 @@ export function SessionFilesTab() {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-full p-4">
|
||||
<p className="text-xs text-muted-foreground text-center">
|
||||
Open a conversation to see its file changes
|
||||
{t("openConversationToSeeChanges")}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
@@ -388,7 +399,7 @@ export function SessionFilesTab() {
|
||||
return (
|
||||
<div className="flex items-center justify-center h-full p-4">
|
||||
<p className="text-xs text-muted-foreground text-center">
|
||||
No file changes found in this conversation
|
||||
{t("noFileChangesInConversation")}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useCallback, useState } from "react"
|
||||
import { FileDiff, Folder, FolderPen, GitCommit } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
import {
|
||||
useAuxPanelContext,
|
||||
type AuxPanelTab,
|
||||
@@ -13,6 +14,7 @@ import { GitLogTab } from "./aux-panel-git-log-tab"
|
||||
import { SessionFilesTab } from "./aux-panel-session-files-tab"
|
||||
|
||||
export function AuxPanel() {
|
||||
const t = useTranslations("Folder.auxPanel.tabs")
|
||||
const { isOpen, activeTab, setActiveTab } = useAuxPanelContext()
|
||||
const [hasMountedFileTree, setHasMountedFileTree] = useState(
|
||||
activeTab === "file_tree"
|
||||
@@ -54,16 +56,32 @@ export function AuxPanel() {
|
||||
variant="line"
|
||||
className="h-10 w-full shrink-0 justify-start border-b border-border px-3 group-data-horizontal/tabs:h-10"
|
||||
>
|
||||
<TabsTrigger value="session_files" title="Diff" aria-label="Diff">
|
||||
<TabsTrigger
|
||||
value="session_files"
|
||||
title={t("diff")}
|
||||
aria-label={t("diff")}
|
||||
>
|
||||
<FileDiff className="h-3.5 w-3.5" />
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="file_tree" title="Files" aria-label="Files">
|
||||
<TabsTrigger
|
||||
value="file_tree"
|
||||
title={t("files")}
|
||||
aria-label={t("files")}
|
||||
>
|
||||
<Folder className="h-3.5 w-3.5" />
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="changes" title="Changes" aria-label="Changes">
|
||||
<TabsTrigger
|
||||
value="changes"
|
||||
title={t("changes")}
|
||||
aria-label={t("changes")}
|
||||
>
|
||||
<FolderPen className="h-3.5 w-3.5" />
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="git_log" title="Commits" aria-label="Commits">
|
||||
<TabsTrigger
|
||||
value="git_log"
|
||||
title={t("commits")}
|
||||
aria-label={t("commits")}
|
||||
>
|
||||
<GitCommit className="h-3.5 w-3.5" />
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useState } from "react"
|
||||
import { ChevronDown, Folder, FolderOpen, GitBranch } from "lucide-react"
|
||||
import { open } from "@tauri-apps/plugin-dialog"
|
||||
import { useTranslations } from "next-intl"
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
@@ -22,13 +23,14 @@ import { CloneDialog } from "@/components/welcome/clone-dialog"
|
||||
import type { FolderHistoryEntry } from "@/lib/types"
|
||||
|
||||
export function FolderNameDropdown() {
|
||||
const t = useTranslations("Folder.folderNameDropdown")
|
||||
const { folder } = useFolderContext()
|
||||
const [openFolders, setOpenFolders] = useState<FolderHistoryEntry[]>([])
|
||||
const [history, setHistory] = useState<FolderHistoryEntry[]>([])
|
||||
const [cloneOpen, setCloneOpen] = useState(false)
|
||||
|
||||
const folderPath = folder?.path ?? ""
|
||||
const folderName = folder?.name ?? "文件夹"
|
||||
const folderName = folder?.name ?? t("fallbackFolderName")
|
||||
|
||||
async function handleOpenChange(open: boolean) {
|
||||
if (open) {
|
||||
@@ -77,16 +79,16 @@ export function FolderNameDropdown() {
|
||||
<DropdownMenuContent className="min-w-64" align="start">
|
||||
<DropdownMenuItem onSelect={handleOpenFolder}>
|
||||
<FolderOpen className="h-3.5 w-3.5 shrink-0" />
|
||||
Open Folder
|
||||
{t("openFolder")}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onSelect={() => setCloneOpen(true)}>
|
||||
<GitBranch className="h-3.5 w-3.5 shrink-0" />
|
||||
Clone Repository
|
||||
{t("cloneRepository")}
|
||||
</DropdownMenuItem>
|
||||
{openFolders.length > 0 && (
|
||||
<>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuLabel>已打开</DropdownMenuLabel>
|
||||
<DropdownMenuLabel>{t("opened")}</DropdownMenuLabel>
|
||||
{openFolders.map((entry) => (
|
||||
<DropdownMenuItem
|
||||
key={entry.path}
|
||||
@@ -114,7 +116,7 @@ export function FolderNameDropdown() {
|
||||
{history.length > 0 && (
|
||||
<>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuLabel>最近打开</DropdownMenuLabel>
|
||||
<DropdownMenuLabel>{t("recentOpen")}</DropdownMenuLabel>
|
||||
{history.map((entry) => (
|
||||
<DropdownMenuItem
|
||||
key={entry.path}
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
Search,
|
||||
Settings,
|
||||
} from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
import { getGitBranch, openFolderWindow, openSettingsWindow } from "@/lib/tauri"
|
||||
import { useFolderContext } from "@/contexts/folder-context"
|
||||
import { Button } from "@/components/ui/button"
|
||||
@@ -41,22 +42,24 @@ import { SearchCommandDialog } from "@/components/conversations/search-command-d
|
||||
const MODE_TABS = [
|
||||
{
|
||||
mode: "conversation",
|
||||
title: "会话模式",
|
||||
titleKey: "conversation",
|
||||
icon: MessageSquare,
|
||||
},
|
||||
{
|
||||
mode: "fusion",
|
||||
title: "融合模式",
|
||||
titleKey: "fusion",
|
||||
icon: Columns2,
|
||||
},
|
||||
{
|
||||
mode: "files",
|
||||
title: "文件模式",
|
||||
titleKey: "files",
|
||||
icon: FileCode2,
|
||||
},
|
||||
] as const
|
||||
|
||||
export function FolderTitleBar() {
|
||||
const tModes = useTranslations("Folder.modes")
|
||||
const tTitleBar = useTranslations("Folder.folderTitleBar")
|
||||
const { folder } = useFolderContext()
|
||||
const { isOpen, toggle } = useSidebarContext()
|
||||
const { isOpen: auxPanelOpen, toggle: toggleAuxPanel } = useAuxPanelContext()
|
||||
@@ -212,7 +215,7 @@ export function FolderTitleBar() {
|
||||
center={
|
||||
<div
|
||||
role="tablist"
|
||||
aria-label="工作区模式"
|
||||
aria-label={tModes("workspaceModesAria")}
|
||||
className="relative flex h-[27px] items-center rounded-full border border-border/80 bg-background/80 p-0.5"
|
||||
>
|
||||
<div
|
||||
@@ -222,6 +225,7 @@ export function FolderTitleBar() {
|
||||
{MODE_TABS.map((item) => {
|
||||
const Icon = item.icon
|
||||
const isActive = mode === item.mode
|
||||
const title = tModes(item.titleKey)
|
||||
return (
|
||||
<div
|
||||
key={item.mode}
|
||||
@@ -235,8 +239,8 @@ export function FolderTitleBar() {
|
||||
onClick={() => setMode(item.mode)}
|
||||
onKeyDown={(event) => handleModeKeyDown(event, item.mode)}
|
||||
onMouseDown={(event) => event.preventDefault()}
|
||||
title={item.title}
|
||||
aria-label={item.title}
|
||||
title={title}
|
||||
aria-label={title}
|
||||
aria-selected={isActive}
|
||||
>
|
||||
<Icon
|
||||
@@ -259,7 +263,13 @@ export function FolderTitleBar() {
|
||||
size="icon"
|
||||
className="h-6 w-6 hover:text-foreground/80"
|
||||
onClick={toggle}
|
||||
title={`${isOpen ? "Hide Sidebar" : "Show Sidebar"} (${formatShortcutLabel(shortcuts.toggle_sidebar, isMac)})`}
|
||||
title={tTitleBar("withShortcut", {
|
||||
label: tTitleBar(isOpen ? "hideSidebar" : "showSidebar"),
|
||||
shortcut: formatShortcutLabel(
|
||||
shortcuts.toggle_sidebar,
|
||||
isMac
|
||||
),
|
||||
})}
|
||||
>
|
||||
<PanelLeft className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
@@ -268,7 +278,13 @@ export function FolderTitleBar() {
|
||||
size="icon"
|
||||
className={`h-6 w-6 hover:text-foreground/80 ${terminalOpen ? "bg-accent" : ""}`}
|
||||
onClick={() => toggleTerminal()}
|
||||
title={`Toggle Terminal (${formatShortcutLabel(shortcuts.toggle_terminal, isMac)})`}
|
||||
title={tTitleBar("withShortcut", {
|
||||
label: tTitleBar("toggleTerminal"),
|
||||
shortcut: formatShortcutLabel(
|
||||
shortcuts.toggle_terminal,
|
||||
isMac
|
||||
),
|
||||
})}
|
||||
>
|
||||
<PanelBottom className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
@@ -277,7 +293,13 @@ export function FolderTitleBar() {
|
||||
size="icon"
|
||||
className={`h-6 w-6 hover:text-foreground/80 ${auxPanelOpen ? "bg-accent" : ""}`}
|
||||
onClick={toggleAuxPanel}
|
||||
title={`Toggle Auxiliary Panel (${formatShortcutLabel(shortcuts.toggle_aux_panel, isMac)})`}
|
||||
title={tTitleBar("withShortcut", {
|
||||
label: tTitleBar("toggleAuxPanel"),
|
||||
shortcut: formatShortcutLabel(
|
||||
shortcuts.toggle_aux_panel,
|
||||
isMac
|
||||
),
|
||||
})}
|
||||
>
|
||||
<PanelRight className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
@@ -286,7 +308,10 @@ export function FolderTitleBar() {
|
||||
size="icon"
|
||||
className="h-6 w-6 hover:text-foreground/80"
|
||||
onClick={() => setSearchOpen(true)}
|
||||
title={`Search (${formatShortcutLabel(shortcuts.toggle_search, isMac)})`}
|
||||
title={tTitleBar("withShortcut", {
|
||||
label: tTitleBar("search"),
|
||||
shortcut: formatShortcutLabel(shortcuts.toggle_search, isMac),
|
||||
})}
|
||||
>
|
||||
<Search className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
@@ -295,7 +320,10 @@ export function FolderTitleBar() {
|
||||
size="icon"
|
||||
className="h-6 w-6 hover:text-foreground/80"
|
||||
onClick={handleOpenSettings}
|
||||
title={`Open Settings (${formatShortcutLabel(shortcuts.open_settings, isMac)})`}
|
||||
title={tTitleBar("withShortcut", {
|
||||
label: tTitleBar("openSettings"),
|
||||
shortcut: formatShortcutLabel(shortcuts.open_settings, isMac),
|
||||
})}
|
||||
>
|
||||
<Settings className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useCallback, useRef } from "react"
|
||||
import { ChevronsDownUp, ChevronsUpDown, Crosshair, Plus } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
import { useFolderContext } from "@/contexts/folder-context"
|
||||
import { useTabContext } from "@/contexts/tab-context"
|
||||
import { useSidebarContext } from "@/contexts/sidebar-context"
|
||||
@@ -12,6 +13,7 @@ import {
|
||||
import { Button } from "@/components/ui/button"
|
||||
|
||||
export function Sidebar() {
|
||||
const t = useTranslations("Folder.sidebar")
|
||||
const { folder } = useFolderContext()
|
||||
const { openNewConversationTab } = useTabContext()
|
||||
const { isOpen } = useSidebarContext()
|
||||
@@ -27,14 +29,14 @@ export function Sidebar() {
|
||||
return (
|
||||
<aside className="group/sidebar flex h-full min-h-0 flex-col overflow-hidden bg-sidebar text-sidebar-foreground select-none">
|
||||
<div className="flex h-10 items-center justify-between border-b border-border px-4">
|
||||
<h2 className="text-xs font-bold">Conversations</h2>
|
||||
<h2 className="text-xs font-bold">{t("title")}</h2>
|
||||
<div className="flex items-center gap-0.5 opacity-0 transition-opacity group-hover/sidebar:opacity-100">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-6 w-6 shrink-0 text-muted-foreground"
|
||||
onClick={() => listRef.current?.scrollToActive()}
|
||||
title="Locate Active Conversation"
|
||||
title={t("locateActiveConversation")}
|
||||
>
|
||||
<Crosshair className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
@@ -43,7 +45,7 @@ export function Sidebar() {
|
||||
size="icon"
|
||||
className="h-6 w-6 shrink-0 text-muted-foreground"
|
||||
onClick={() => listRef.current?.expandAll()}
|
||||
title="Expand All Groups"
|
||||
title={t("expandAllGroups")}
|
||||
>
|
||||
<ChevronsUpDown className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
@@ -52,7 +54,7 @@ export function Sidebar() {
|
||||
size="icon"
|
||||
className="h-6 w-6 shrink-0 text-muted-foreground"
|
||||
onClick={() => listRef.current?.collapseAll()}
|
||||
title="Collapse All Groups"
|
||||
title={t("collapseAllGroups")}
|
||||
>
|
||||
<ChevronsDownUp className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
@@ -61,7 +63,7 @@ export function Sidebar() {
|
||||
size="icon"
|
||||
className="h-6 w-6 shrink-0 text-muted-foreground"
|
||||
onClick={handleNewConversation}
|
||||
title="New Conversation"
|
||||
title={t("newConversation")}
|
||||
>
|
||||
<Plus className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { CircleAlert, X, Trash2 } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
import {
|
||||
useAlertContext,
|
||||
type AlertLevel,
|
||||
@@ -110,6 +111,7 @@ function AlertActionButton({ action }: { action: AlertAction }) {
|
||||
}
|
||||
|
||||
export function StatusBarAlerts() {
|
||||
const t = useTranslations("Folder.statusBar.alerts")
|
||||
const { alerts, hasAlerts, dismissAlert, clearAll } = useAlertContext()
|
||||
|
||||
return (
|
||||
@@ -124,7 +126,7 @@ export function StatusBarAlerts() {
|
||||
</PopoverTrigger>
|
||||
<PopoverContent side="top" align="end" className="w-80 p-3">
|
||||
<div className="flex items-center justify-between mb-2">
|
||||
<span className="text-xs font-medium">告警</span>
|
||||
<span className="text-xs font-medium">{t("title")}</span>
|
||||
{hasAlerts && (
|
||||
<button
|
||||
onClick={clearAll}
|
||||
@@ -135,7 +137,7 @@ export function StatusBarAlerts() {
|
||||
)}
|
||||
</div>
|
||||
{!hasAlerts ? (
|
||||
<div className="text-xs text-muted-foreground py-2">暂无告警信息</div>
|
||||
<div className="text-xs text-muted-foreground py-2">{t("empty")}</div>
|
||||
) : (
|
||||
<div className="space-y-2 max-h-56 overflow-y-auto">
|
||||
{alerts.map((alert) => (
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useCallback, useMemo, useSyncExternalStore } from "react"
|
||||
import { Unplug } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
import { useConnectionStore } from "@/contexts/acp-connections-context"
|
||||
import { useTabContext } from "@/contexts/tab-context"
|
||||
import { useFolderContext } from "@/contexts/folder-context"
|
||||
@@ -15,24 +16,35 @@ import {
|
||||
import { AGENT_LABELS } from "@/lib/types"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const STATUS_STYLE: Record<string, { className: string; title: string }> = {
|
||||
connected: { className: "opacity-100", title: "Connected" },
|
||||
type ConnectionStatusLabelKey =
|
||||
| "connected"
|
||||
| "connecting"
|
||||
| "downloading"
|
||||
| "prompting"
|
||||
| "error"
|
||||
|
||||
const STATUS_STYLE: Record<
|
||||
string,
|
||||
{ className: string; labelKey: ConnectionStatusLabelKey }
|
||||
> = {
|
||||
connected: { className: "opacity-100", labelKey: "connected" },
|
||||
connecting: {
|
||||
className: "opacity-100 animate-pulse",
|
||||
title: "Connecting...",
|
||||
labelKey: "connecting",
|
||||
},
|
||||
downloading: {
|
||||
className: "opacity-100 animate-pulse",
|
||||
title: "Downloading...",
|
||||
labelKey: "downloading",
|
||||
},
|
||||
prompting: {
|
||||
className: "opacity-100 animate-pulse",
|
||||
title: "Responding...",
|
||||
labelKey: "prompting",
|
||||
},
|
||||
error: { className: "opacity-50", title: "Connection error" },
|
||||
error: { className: "opacity-50", labelKey: "error" },
|
||||
}
|
||||
|
||||
export function StatusBarConnection() {
|
||||
const t = useTranslations("Folder.statusBar.connection")
|
||||
const store = useConnectionStore()
|
||||
const { tabs, activeTabId } = useTabContext()
|
||||
const { conversations } = useFolderContext()
|
||||
@@ -89,7 +101,7 @@ export function StatusBarConnection() {
|
||||
{model && <span>{model}</span>}
|
||||
</div>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top">Disconnected</TooltipContent>
|
||||
<TooltipContent side="top">{t("disconnected")}</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
)
|
||||
@@ -99,10 +111,11 @@ export function StatusBarConnection() {
|
||||
if (!style) return null
|
||||
|
||||
const label = AGENT_LABELS[agentType]
|
||||
const statusLabel = t(style.labelKey)
|
||||
const tooltipText =
|
||||
status === "error" && activeConn?.error
|
||||
? `${label} - ${activeConn.error}`
|
||||
: `${label} - ${style.title}`
|
||||
? t("tooltipError", { agent: label, error: activeConn.error })
|
||||
: t("tooltip", { agent: label, status: statusLabel })
|
||||
|
||||
return (
|
||||
<TooltipProvider>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useMemo } from "react"
|
||||
import { BarChart3 } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
import { useFolderContext } from "@/contexts/folder-context"
|
||||
import { AGENT_LABELS } from "@/lib/types"
|
||||
import { AgentIcon } from "@/components/agent-icon"
|
||||
@@ -12,6 +13,7 @@ import {
|
||||
} from "@/components/ui/popover"
|
||||
|
||||
export function StatusBarStats() {
|
||||
const t = useTranslations("Folder.statusBar.stats")
|
||||
const { stats } = useFolderContext()
|
||||
|
||||
const activeAgents = useMemo(
|
||||
@@ -26,7 +28,9 @@ export function StatusBarStats() {
|
||||
<PopoverTrigger asChild>
|
||||
<button className="flex items-center gap-1.5 hover:text-foreground transition-colors">
|
||||
<BarChart3 className="h-3 w-3" />
|
||||
<span>{stats.total_conversations} conversations</span>
|
||||
<span>
|
||||
{t("conversations", { count: stats.total_conversations })}
|
||||
</span>
|
||||
<span className="flex items-center gap-1 ml-1">
|
||||
{activeAgents.map((a) => (
|
||||
<AgentIcon
|
||||
@@ -40,8 +44,10 @@ export function StatusBarStats() {
|
||||
</PopoverTrigger>
|
||||
<PopoverContent side="top" align="start" className="w-64 p-3">
|
||||
<div className="text-xs font-medium mb-2">
|
||||
{stats.total_conversations} conversations / {stats.total_messages}{" "}
|
||||
messages
|
||||
{t("summary", {
|
||||
conversations: stats.total_conversations,
|
||||
messages: stats.total_messages,
|
||||
})}
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
{activeAgents.map((a) => (
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { Clock } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
import { useTaskContext } from "@/contexts/task-context"
|
||||
import { Skeleton } from "@/components/ui/skeleton"
|
||||
import {
|
||||
@@ -18,6 +19,7 @@ function Spinner({ className }: { className?: string }) {
|
||||
}
|
||||
|
||||
export function StatusBarTasks() {
|
||||
const t = useTranslations("Folder.statusBar.tasks")
|
||||
const { tasks } = useTaskContext()
|
||||
|
||||
if (tasks.length === 0) return null
|
||||
@@ -45,7 +47,7 @@ export function StatusBarTasks() {
|
||||
</button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent side="top" align="end" className="w-72 p-3">
|
||||
<div className="text-xs font-medium mb-2">任务</div>
|
||||
<div className="text-xs font-medium mb-2">{t("title")}</div>
|
||||
<div className="space-y-2 max-h-48 overflow-y-auto">
|
||||
{tasks.map((task) => (
|
||||
<div key={task.id} className="space-y-1">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { Coins } from "lucide-react"
|
||||
import { useTranslations } from "next-intl"
|
||||
import { useSessionStats } from "@/contexts/session-stats-context"
|
||||
import {
|
||||
Popover,
|
||||
@@ -29,6 +30,7 @@ function formatPercent(percent: number | null): string {
|
||||
}
|
||||
|
||||
export function StatusBarTokens() {
|
||||
const t = useTranslations("Folder.statusBar.tokens")
|
||||
const { sessionStats } = useSessionStats()
|
||||
const usage = sessionStats?.total_usage
|
||||
|
||||
@@ -55,17 +57,20 @@ export function StatusBarTokens() {
|
||||
|
||||
const dashOffset = ICON_CIRCUMFERENCE * (1 - (contextPercent ?? 0) / 100)
|
||||
|
||||
const rows: { label: string; value: number }[] = []
|
||||
const rows: {
|
||||
key: "input" | "output" | "cacheRead" | "cacheWrite" | "total"
|
||||
value: number
|
||||
}[] = []
|
||||
if (hasUsage) {
|
||||
rows.push(
|
||||
{ label: "Input", value: usage.input_tokens },
|
||||
{ label: "Output", value: usage.output_tokens },
|
||||
{ label: "Cache Read", value: usage.cache_read_input_tokens },
|
||||
{ label: "Cache Write", value: usage.cache_creation_input_tokens }
|
||||
{ key: "input", value: usage.input_tokens },
|
||||
{ key: "output", value: usage.output_tokens },
|
||||
{ key: "cacheRead", value: usage.cache_read_input_tokens },
|
||||
{ key: "cacheWrite", value: usage.cache_creation_input_tokens }
|
||||
)
|
||||
}
|
||||
if (total != null) {
|
||||
rows.push({ label: "Total", value: total })
|
||||
rows.push({ key: "total", value: total })
|
||||
}
|
||||
|
||||
const hasTokenSection = rows.length > 0
|
||||
@@ -79,7 +84,7 @@ export function StatusBarTokens() {
|
||||
{hasContext ? (
|
||||
<>
|
||||
<svg
|
||||
aria-label="Context window usage"
|
||||
aria-label={t("contextWindowUsageAria")}
|
||||
className="size-3.5"
|
||||
viewBox={`0 0 ${ICON_VIEWBOX} ${ICON_VIEWBOX}`}
|
||||
>
|
||||
@@ -127,7 +132,7 @@ export function StatusBarTokens() {
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-center justify-between gap-2 text-xs font-medium whitespace-nowrap">
|
||||
<span>Context Window</span>
|
||||
<span>{t("contextWindow")}</span>
|
||||
<span className="tabular-nums shrink-0">
|
||||
{formatPercent(contextPercent)}
|
||||
</span>
|
||||
@@ -139,7 +144,7 @@ export function StatusBarTokens() {
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-center justify-between text-xs leading-none text-muted-foreground">
|
||||
<span>Used / Max</span>
|
||||
<span>{t("usedMax")}</span>
|
||||
<span className="tabular-nums">
|
||||
{contextUsed == null || contextMax == null
|
||||
? "--"
|
||||
@@ -151,19 +156,19 @@ export function StatusBarTokens() {
|
||||
{hasTokenSection ? (
|
||||
<>
|
||||
<div className="mb-0 mt-0.5 text-xs leading-none font-medium">
|
||||
Token Usage
|
||||
{t("tokenUsage")}
|
||||
</div>
|
||||
<div className="space-y-0">
|
||||
{rows.map((row) => (
|
||||
<div
|
||||
key={row.label}
|
||||
key={row.key}
|
||||
className={`flex items-center justify-between py-0.5 text-xs leading-none ${
|
||||
row.label === "Total"
|
||||
row.key === "total"
|
||||
? "mt-0.5 border-t border-border pt-0.5 font-medium"
|
||||
: "text-muted-foreground"
|
||||
}`}
|
||||
>
|
||||
<span>{row.label}</span>
|
||||
<span>{t(row.key)}</span>
|
||||
<span className="tabular-nums">
|
||||
{formatNumber(row.value)}
|
||||
</span>
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
import { useEffect, useState } from "react"
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window"
|
||||
import { useTranslations } from "next-intl"
|
||||
import { usePlatform } from "@/hooks/use-platform"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
export function WindowControls() {
|
||||
const t = useTranslations("Folder.windowControls")
|
||||
const { isWindows } = usePlatform()
|
||||
const [isMaximized, setIsMaximized] = useState(false)
|
||||
|
||||
@@ -75,8 +77,8 @@ export function WindowControls() {
|
||||
console.error("[WindowControls] failed to minimize:", err)
|
||||
})
|
||||
}}
|
||||
aria-label="Minimize window"
|
||||
title="Minimize"
|
||||
aria-label={t("minimizeWindow")}
|
||||
title={t("minimize")}
|
||||
>
|
||||
<MinimizeIcon />
|
||||
</button>
|
||||
@@ -88,8 +90,8 @@ export function WindowControls() {
|
||||
console.error("[WindowControls] failed to toggle maximize:", err)
|
||||
})
|
||||
}}
|
||||
aria-label={isMaximized ? "Restore window" : "Maximize window"}
|
||||
title={isMaximized ? "Restore" : "Maximize"}
|
||||
aria-label={t(isMaximized ? "restoreWindow" : "maximizeWindow")}
|
||||
title={t(isMaximized ? "restore" : "maximize")}
|
||||
>
|
||||
{isMaximized ? <RestoreIcon /> : <MaximizeIcon />}
|
||||
</button>
|
||||
@@ -104,8 +106,8 @@ export function WindowControls() {
|
||||
console.error("[WindowControls] failed to close:", err)
|
||||
})
|
||||
}}
|
||||
aria-label="Close window"
|
||||
title="Close"
|
||||
aria-label={t("closeWindow")}
|
||||
title={t("close")}
|
||||
>
|
||||
<CloseIcon />
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user