Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/__tests__/smoke-test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -80,7 +80,8 @@ async function runSmokeTests() {
results.push({ name: route.name, status: 'PASS', details, consoleErrors, loadTimeMs: elapsed });
} catch (err: unknown) {
const elapsed = Date.now() - start;
results.push({ name: route.name, status: 'FAIL', details: err instanceof Error ? err.message : String(err), consoleErrors, loadTimeMs: elapsed });
const message = err instanceof Error ? err.message : String(err);
results.push({ name: route.name, status: 'FAIL', details: message, consoleErrors, loadTimeMs: elapsed });
}
await page.close();
}
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/unit/db-shutdown.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
* 4. Data persists across close/reopen cycles
*/

import { describe, it, before, afterEach } from 'node:test';
import { describe, it, afterEach } from 'node:test';
import assert from 'node:assert/strict';
import path from 'path';
import os from 'os';
Expand All@@ -23,7 +23,6 @@ process.env.CLAUDE_GUI_DATA_DIR = tmpDir;
// Use require to avoid top-level await issues with CJS output
/* eslint-disable @typescript-eslint/no-require-imports */
const { getDb, closeDb, createSession, getSession } = require('../../lib/db') as typeof import('../../lib/db');

describe('closeDb', () => {
afterEach(() => {
// Ensure DB is closed after each test
Expand Down
1 change: 1 addition & 0 deletions src/app/api/settings/app/route.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import { getSetting, setSetting } from '@/lib/db';
const ALLOWED_KEYS = [
'anthropic_auth_token',
'anthropic_base_url',
'locale',
'dangerously_skip_permissions',
];

Expand Down
20 changes: 11 additions & 9 deletions src/app/chat/[id]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ import { HugeiconsIcon } from "@hugeicons/react";
import { Loading02Icon, PencilEdit01Icon } from "@hugeicons/core-free-icons";
import { Input } from '@/components/ui/input';
import { usePanel } from '@/hooks/usePanel';
import { useTranslation } from '@/hooks/useTranslation';

interface ChatSessionPageProps {
params: Promise<{ id: string }>;
Expand All@@ -27,11 +28,12 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
const [editTitle, setEditTitle] = useState('');
const titleInputRef = useRef<HTMLInputElement>(null);
const { setWorkingDirectory, setSessionId, setSessionTitle: setPanelSessionTitle, setPanelOpen } = usePanel();
const { t } = useTranslation();

const handleStartEditTitle = useCallback(() => {
setEditTitle(sessionTitle || 'New Conversation');
setEditTitle(sessionTitle || t('chatSession.newConversation'));
setIsEditingTitle(true);
}, [sessionTitle]);
}, [sessionTitle, t]);

const handleSaveTitle = useCallback(async () => {
const trimmed = editTitle.trim();
Expand DownExpand Up@@ -84,7 +86,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
}
setSessionId(id);
setPanelOpen(true);
const title = data.session.title || 'New Conversation';
const title = data.session.title || t('chatSession.newConversation');
setSessionTitle(title);
setPanelSessionTitle(title);
setSessionModel(data.session.model || '');
Expand All@@ -97,7 +99,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
}

loadSession();
}, [id, setWorkingDirectory, setSessionId, setPanelSessionTitle, setPanelOpen]);
}, [id, setWorkingDirectory, setSessionId, setPanelSessionTitle, setPanelOpen, t]);

useEffect(() => {
// Reset state when switching sessions
Expand All@@ -114,7 +116,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
if (cancelled) return;
if (!res.ok) {
if (res.status === 404) {
setError('Session not found');
setError(t('chatSession.sessionNotFound'));
return;
}
throw new Error('Failed to load messages');
Expand All@@ -123,9 +125,9 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
if (cancelled) return;
setMessages(data.messages);
setHasMore(data.hasMore ?? false);
} catch (err) {
} catch {
if (cancelled) return;
setError(err instanceof Error ? err.message : 'Failed to load messages');
setError(t('chatSession.failedToLoad'));
} finally {
if (!cancelled) setLoading(false);
}
Expand All@@ -134,7 +136,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
loadMessages();

return () => { cancelled = true; };
}, [id]);
}, [id, t]);

if (loading) {
return (
Expand All@@ -150,7 +152,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
<div className="text-center space-y-2">
<p className="text-destructive font-medium">{error}</p>
<Link href="/chat" className="text-sm text-muted-foreground hover:underline">
Start a new chat
{t('chatSession.startNewChat')}
</Link>
</div>
</div>
Expand Down
56 changes: 41 additions & 15 deletions src/app/chat/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,8 @@ import type { Message, SSEEvent, SessionResponse, TokenUsage, PermissionRequestE
import { MessageList } from '@/components/chat/MessageList';
import { MessageInput } from '@/components/chat/MessageInput';
import { usePanel } from '@/hooks/usePanel';
import { useTranslation } from '@/hooks/useTranslation';
import { buildHelpContent } from '@/lib/help-content';

interface ToolUseInfo {
id: string;
Expand All@@ -18,16 +20,25 @@ interface ToolResultInfo {
content: string;
}

type UserFacingError = Error & { userMessage?: string };

function makeUserFacingError(userMessage: string, technicalMessage?: string): UserFacingError {
const error = new Error(technicalMessage || userMessage) as UserFacingError;
error.userMessage = userMessage;
return error;
}

export default function NewChatPage() {
const router = useRouter();
const { setWorkingDirectory, setPanelOpen, setPendingApprovalSessionId } = usePanel();
const { setPendingApprovalSessionId } = usePanel();
const { t } = useTranslation();
const [messages, setMessages] = useState<Message[]>([]);
const [streamingContent, setStreamingContent] = useState('');
const [isStreaming, setIsStreaming] = useState(false);
const [toolUses, setToolUses] = useState<ToolUseInfo[]>([]);
const [toolResults, setToolResults] = useState<ToolResultInfo[]>([]);
const [statusText, setStatusText] = useState<string | undefined>();
const [workingDir, setWorkingDir] = useState('');
const workingDir = '';
const [mode, setMode] = useState('code');
const [currentModel, setCurrentModel] = useState('sonnet');
const [pendingPermission, setPendingPermission] = useState<PermissionRequestEvent | null>(null);
Expand DownExpand Up@@ -84,7 +95,7 @@ export default function NewChatPage() {
id: 'hint-' + Date.now(),
session_id: '',
role: 'assistant',
content: '**Please select a project directory first.** Use the folder picker in the toolbar below to choose a working directory before sending a message.',
content: `**${t('input.selectProjectFolder')}**`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand DownExpand Up@@ -119,7 +130,13 @@ export default function NewChatPage() {

if (!createRes.ok) {
const errBody = await createRes.json().catch(() => ({}));
throw new Error(errBody.error || `Failed to create session (${createRes.status})`);
const technicalMessage = typeof errBody.error === 'string'
? errBody.error
: `Failed to create session (${createRes.status})`;
throw makeUserFacingError(
t('chat.failedToCreateSession', { status: createRes.status }),
technicalMessage,
);
}

const { session }: SessionResponse = await createRes.json();
Expand DownExpand Up@@ -148,8 +165,11 @@ export default function NewChatPage() {
});

if (!response.ok) {
const err = await response.json();
throw new Error(err.error || 'Failed to send message');
const err = await response.json().catch(() => ({}));
const technicalMessage = typeof err.error === 'string'
? err.error
: `Failed to send message (${response.status})`;
throw makeUserFacingError(t('chat.failedToSend'), technicalMessage);
}

const reader = response.body?.getReader();
Expand DownExpand Up@@ -203,7 +223,7 @@ export default function NewChatPage() {
try {
const parsed = JSON.parse(event.data);
if (parsed._progress) {
setStatusText(`Running ${parsed.tool_name}... (${Math.round(parsed.elapsed_time_seconds)}s)`);
setStatusText(t('chat.running', { tool: parsed.tool_name, seconds: Math.round(parsed.elapsed_time_seconds) }));
break;
}
} catch {
Expand All@@ -219,7 +239,7 @@ export default function NewChatPage() {
try {
const statusData = JSON.parse(event.data);
if (statusData.session_id) {
setStatusText(`Connected (${statusData.model || 'claude'})`);
setStatusText(t('chat.connected', { model: statusData.model || 'claude' }));
setTimeout(() => setStatusText(undefined), 2000);
} else if (statusData.notification) {
setStatusText(statusData.message || statusData.title || undefined);
Expand DownExpand Up@@ -251,7 +271,7 @@ export default function NewChatPage() {
break;
}
case 'error': {
accumulated += '\n\n**Error:** ' + event.data;
accumulated += '\n\n**' + t('chat.error') + ':** ' + event.data;
setStreamingContent(accumulated);
break;
}
Expand DownExpand Up@@ -286,12 +306,18 @@ export default function NewChatPage() {
router.push(`/chat/${sessionId}`);
}
} else {
const errMsg = error instanceof Error ? error.message : 'Unknown error';
const errMsg =
typeof error === 'object' &&
error !== null &&
'userMessage' in error &&
typeof (error as UserFacingError).userMessage === 'string'
? (error as UserFacingError).userMessage!
: t('chat.failedToSend');
const errorMessage: Message = {
id: 'temp-error-' + Date.now(),
session_id: '',
role: 'assistant',
content: `**Error:** ${errMsg}`,
content: `**${t('chat.error')}:** ${errMsg}`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -310,7 +336,7 @@ export default function NewChatPage() {
abortControllerRef.current = null;
}
},
[isStreaming, router, workingDir, mode, currentModel, setPendingApprovalSessionId]
[isStreaming, router, workingDir, mode, currentModel, setPendingApprovalSessionId, t]
);

const handleCommand = useCallback((command: string) => {
Expand All@@ -320,7 +346,7 @@ export default function NewChatPage() {
id: 'cmd-' + Date.now(),
session_id: '',
role: 'assistant',
content: `## Available Commands\n\n- **/help** - Show this help message\n- **/clear** - Clear conversation history\n- **/compact** - Compress conversation context\n- **/cost** - Show token usage statistics\n- **/doctor** - Check system health\n- **/init** - Initialize CLAUDE.md\n- **/review** - Start code review\n- **/terminal-setup** - Configure terminal\n\n**Tips:**\n- Type \`@\` to mention files\n- Use Shift+Enter for new line\n- Select a project folder to enable file operations`,
content: buildHelpContent(t),
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -335,7 +361,7 @@ export default function NewChatPage() {
id: 'cmd-' + Date.now(),
session_id: '',
role: 'assistant',
content: `## Token Usage\n\nToken usage tracking is available after sending messages. Check the token count displayed at the bottom of each assistant response.`,
content: `${t('chat.tokenUsageTitle')}\n\n${t('chat.noTokenUsage')}`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -345,7 +371,7 @@ export default function NewChatPage() {
default:
sendFirstMessage(command);
}
}, [sendFirstMessage]);
}, [sendFirstMessage, t]);

return (
<div className="flex h-full min-h-0 flex-col">
Expand Down
8 changes: 5 additions & 3 deletions src/app/extensions/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@

import { Suspense, useState } from "react";
import { useSearchParams } from "next/navigation";
import { useTranslation } from "@/hooks/useTranslation";
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { HugeiconsIcon } from "@hugeicons/react";
import { Loading02Icon } from "@hugeicons/core-free-icons";
Expand All@@ -28,15 +29,16 @@ function ExtensionsPageInner() {
const searchParams = useSearchParams();
const initialTab = (searchParams.get("tab") as ExtTab) || "skills";
const [tab, setTab] = useState<ExtTab>(initialTab);
const { t } = useTranslation();

return (
<div className="flex h-full flex-col">
<div className="px-6 pt-4 pb-0">
<h1 className="text-xl font-semibold mb-3">Extensions</h1>
<h1 className="text-xl font-semibold mb-3">{t('extensions.title')}</h1>
<Tabs value={tab} onValueChange={(v) => setTab(v as ExtTab)}>
<TabsList>
<TabsTrigger value="skills">Skills</TabsTrigger>
<TabsTrigger value="mcp">MCP Servers</TabsTrigger>
<TabsTrigger value="skills">{t('extensions.skills')}</TabsTrigger>
<TabsTrigger value="mcp">{t('extensions.mcpServers')}</TabsTrigger>
</TabsList>
</Tabs>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/app/layout.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { ThemeProvider } from "@/components/layout/ThemeProvider";
import { I18nProvider } from "@/components/layout/I18nProvider";
import { AppShell } from "@/components/layout/AppShell";

const geistSans = Geist({
Expand DownExpand Up@@ -30,7 +31,9 @@ export default function RootLayout({
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
<ThemeProvider>
<AppShell>{children}</AppShell>
<I18nProvider>
<AppShell>{children}</AppShell>
</I18nProvider>
</ThemeProvider>
</body>
</html>
Expand Down
27 changes: 16 additions & 11 deletions src/components/ai-elements/tool-actions-group.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@ import {
} from "@hugeicons/core-free-icons";
import { ChevronRightIcon } from 'lucide-react';
import { cn } from '@/lib/utils';
import { useTranslation } from '@/hooks/useTranslation';

// ---------------------------------------------------------------------------
// Types
Expand DownExpand Up@@ -194,15 +195,14 @@ function getRunningDescription(tools: ToolAction[]): string {
export function ToolActionsGroup({
tools,
isStreaming = false,
streamingToolOutput: _streamingToolOutput,
}: ToolActionsGroupProps) {
const hasRunningTool = tools.some((t) => t.result === undefined);
const { t } = useTranslation();

// Track whether user has manually toggled and their chosen state
const [userExpandedState, setUserExpandedState] = useState<boolean | null>(null);

// Derived: if user has toggled, use their choice; otherwise auto-expand based on streaming state
const expanded = userExpandedState !== null ? userExpandedState : (hasRunningTool || isStreaming);
const autoExpanded = hasRunningTool || isStreaming;
const [userToggled, setUserToggled] = useState(false);
const [manualExpanded, setManualExpanded] = useState(false);
const expanded = userToggled ? manualExpanded : autoExpanded;

if (tools.length === 0) return null;

Expand All@@ -211,15 +211,20 @@ export function ToolActionsGroup({
const runningDesc = getRunningDescription(tools);

const handleToggle = () => {
setUserExpandedState((prev) => prev !== null ? !prev : !expanded);
if (!userToggled) {
setUserToggled(true);
setManualExpanded(!autoExpanded);
return;
}

setManualExpanded((prev) => !prev);
};

// Build summary text parts
const summaryParts: string[] = [];
if (runningCount > 0) summaryParts.push(`${runningCount} running`);
if (doneCount > 0) summaryParts.push(`${doneCount} completed`);
if (runningCount === 0 && isStreaming) summaryParts.push('generating response');
if (summaryParts.length === 0) summaryParts.push(`${tools.length} actions`);
if (runningCount > 0) summaryParts.push(`${runningCount} ${t('toolActions.running')}`);
if (doneCount > 0) summaryParts.push(`${doneCount} ${t('toolActions.completed')}`);
if (summaryParts.length === 0) summaryParts.push(`${tools.length} ${t('toolActions.actions')}`);

return (
<div className="w-[min(100%,48rem)]">
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
feat(i18n): 添加日语 (ja) 翻译 by gy212 · Pull Request #91 · op7418/CodePilot · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/__tests__/smoke-test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -80,7 +80,8 @@ async function runSmokeTests() {
results.push({ name: route.name, status: 'PASS', details, consoleErrors, loadTimeMs: elapsed });
} catch (err: unknown) {
const elapsed = Date.now() - start;
results.push({ name: route.name, status: 'FAIL', details: err instanceof Error ? err.message : String(err), consoleErrors, loadTimeMs: elapsed });
const message = err instanceof Error ? err.message : String(err);
results.push({ name: route.name, status: 'FAIL', details: message, consoleErrors, loadTimeMs: elapsed });
}
await page.close();
}
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/unit/db-shutdown.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
* 4. Data persists across close/reopen cycles
*/

import { describe, it, before, afterEach } from 'node:test';
import { describe, it, afterEach } from 'node:test';
import assert from 'node:assert/strict';
import path from 'path';
import os from 'os';
Expand All@@ -23,7 +23,6 @@ process.env.CLAUDE_GUI_DATA_DIR = tmpDir;
// Use require to avoid top-level await issues with CJS output
/* eslint-disable @typescript-eslint/no-require-imports */
const { getDb, closeDb, createSession, getSession } = require('../../lib/db') as typeof import('../../lib/db');

describe('closeDb', () => {
afterEach(() => {
// Ensure DB is closed after each test
Expand Down
1 change: 1 addition & 0 deletions src/app/api/settings/app/route.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import { getSetting, setSetting } from '@/lib/db';
const ALLOWED_KEYS = [
'anthropic_auth_token',
'anthropic_base_url',
'locale',
'dangerously_skip_permissions',
];

Expand Down
20 changes: 11 additions & 9 deletions src/app/chat/[id]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ import { HugeiconsIcon } from "@hugeicons/react";
import { Loading02Icon, PencilEdit01Icon } from "@hugeicons/core-free-icons";
import { Input } from '@/components/ui/input';
import { usePanel } from '@/hooks/usePanel';
import { useTranslation } from '@/hooks/useTranslation';

interface ChatSessionPageProps {
params: Promise<{ id: string }>;
Expand All@@ -27,11 +28,12 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
const [editTitle, setEditTitle] = useState('');
const titleInputRef = useRef<HTMLInputElement>(null);
const { setWorkingDirectory, setSessionId, setSessionTitle: setPanelSessionTitle, setPanelOpen } = usePanel();
const { t } = useTranslation();

const handleStartEditTitle = useCallback(() => {
setEditTitle(sessionTitle || 'New Conversation');
setEditTitle(sessionTitle || t('chatSession.newConversation'));
setIsEditingTitle(true);
}, [sessionTitle]);
}, [sessionTitle, t]);

const handleSaveTitle = useCallback(async () => {
const trimmed = editTitle.trim();
Expand DownExpand Up@@ -84,7 +86,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
}
setSessionId(id);
setPanelOpen(true);
const title = data.session.title || 'New Conversation';
const title = data.session.title || t('chatSession.newConversation');
setSessionTitle(title);
setPanelSessionTitle(title);
setSessionModel(data.session.model || '');
Expand All@@ -97,7 +99,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
}

loadSession();
}, [id, setWorkingDirectory, setSessionId, setPanelSessionTitle, setPanelOpen]);
}, [id, setWorkingDirectory, setSessionId, setPanelSessionTitle, setPanelOpen, t]);

useEffect(() => {
// Reset state when switching sessions
Expand All@@ -114,7 +116,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
if (cancelled) return;
if (!res.ok) {
if (res.status === 404) {
setError('Session not found');
setError(t('chatSession.sessionNotFound'));
return;
}
throw new Error('Failed to load messages');
Expand All@@ -123,9 +125,9 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
if (cancelled) return;
setMessages(data.messages);
setHasMore(data.hasMore ?? false);
} catch (err) {
} catch {
if (cancelled) return;
setError(err instanceof Error ? err.message : 'Failed to load messages');
setError(t('chatSession.failedToLoad'));
} finally {
if (!cancelled) setLoading(false);
}
Expand All@@ -134,7 +136,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
loadMessages();

return () => { cancelled = true; };
}, [id]);
}, [id, t]);

if (loading) {
return (
Expand All@@ -150,7 +152,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
<div className="text-center space-y-2">
<p className="text-destructive font-medium">{error}</p>
<Link href="/chat" className="text-sm text-muted-foreground hover:underline">
Start a new chat
{t('chatSession.startNewChat')}
</Link>
</div>
</div>
Expand Down
56 changes: 41 additions & 15 deletions src/app/chat/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,8 @@ import type { Message, SSEEvent, SessionResponse, TokenUsage, PermissionRequestE
import { MessageList } from '@/components/chat/MessageList';
import { MessageInput } from '@/components/chat/MessageInput';
import { usePanel } from '@/hooks/usePanel';
import { useTranslation } from '@/hooks/useTranslation';
import { buildHelpContent } from '@/lib/help-content';

interface ToolUseInfo {
id: string;
Expand All@@ -18,16 +20,25 @@ interface ToolResultInfo {
content: string;
}

type UserFacingError = Error & { userMessage?: string };

function makeUserFacingError(userMessage: string, technicalMessage?: string): UserFacingError {
const error = new Error(technicalMessage || userMessage) as UserFacingError;
error.userMessage = userMessage;
return error;
}

export default function NewChatPage() {
const router = useRouter();
const { setWorkingDirectory, setPanelOpen, setPendingApprovalSessionId } = usePanel();
const { setPendingApprovalSessionId } = usePanel();
const { t } = useTranslation();
const [messages, setMessages] = useState<Message[]>([]);
const [streamingContent, setStreamingContent] = useState('');
const [isStreaming, setIsStreaming] = useState(false);
const [toolUses, setToolUses] = useState<ToolUseInfo[]>([]);
const [toolResults, setToolResults] = useState<ToolResultInfo[]>([]);
const [statusText, setStatusText] = useState<string | undefined>();
const [workingDir, setWorkingDir] = useState('');
const workingDir = '';
const [mode, setMode] = useState('code');
const [currentModel, setCurrentModel] = useState('sonnet');
const [pendingPermission, setPendingPermission] = useState<PermissionRequestEvent | null>(null);
Expand DownExpand Up@@ -84,7 +95,7 @@ export default function NewChatPage() {
id: 'hint-' + Date.now(),
session_id: '',
role: 'assistant',
content: '**Please select a project directory first.** Use the folder picker in the toolbar below to choose a working directory before sending a message.',
content: `**${t('input.selectProjectFolder')}**`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand DownExpand Up@@ -119,7 +130,13 @@ export default function NewChatPage() {

if (!createRes.ok) {
const errBody = await createRes.json().catch(() => ({}));
throw new Error(errBody.error || `Failed to create session (${createRes.status})`);
const technicalMessage = typeof errBody.error === 'string'
? errBody.error
: `Failed to create session (${createRes.status})`;
throw makeUserFacingError(
t('chat.failedToCreateSession', { status: createRes.status }),
technicalMessage,
);
}

const { session }: SessionResponse = await createRes.json();
Expand DownExpand Up@@ -148,8 +165,11 @@ export default function NewChatPage() {
});

if (!response.ok) {
const err = await response.json();
throw new Error(err.error || 'Failed to send message');
const err = await response.json().catch(() => ({}));
const technicalMessage = typeof err.error === 'string'
? err.error
: `Failed to send message (${response.status})`;
throw makeUserFacingError(t('chat.failedToSend'), technicalMessage);
}

const reader = response.body?.getReader();
Expand DownExpand Up@@ -203,7 +223,7 @@ export default function NewChatPage() {
try {
const parsed = JSON.parse(event.data);
if (parsed._progress) {
setStatusText(`Running ${parsed.tool_name}... (${Math.round(parsed.elapsed_time_seconds)}s)`);
setStatusText(t('chat.running', { tool: parsed.tool_name, seconds: Math.round(parsed.elapsed_time_seconds) }));
break;
}
} catch {
Expand All@@ -219,7 +239,7 @@ export default function NewChatPage() {
try {
const statusData = JSON.parse(event.data);
if (statusData.session_id) {
setStatusText(`Connected (${statusData.model || 'claude'})`);
setStatusText(t('chat.connected', { model: statusData.model || 'claude' }));
setTimeout(() => setStatusText(undefined), 2000);
} else if (statusData.notification) {
setStatusText(statusData.message || statusData.title || undefined);
Expand DownExpand Up@@ -251,7 +271,7 @@ export default function NewChatPage() {
break;
}
case 'error': {
accumulated += '\n\n**Error:** ' + event.data;
accumulated += '\n\n**' + t('chat.error') + ':** ' + event.data;
setStreamingContent(accumulated);
break;
}
Expand DownExpand Up@@ -286,12 +306,18 @@ export default function NewChatPage() {
router.push(`/chat/${sessionId}`);
}
} else {
const errMsg = error instanceof Error ? error.message : 'Unknown error';
const errMsg =
typeof error === 'object' &&
error !== null &&
'userMessage' in error &&
typeof (error as UserFacingError).userMessage === 'string'
? (error as UserFacingError).userMessage!
: t('chat.failedToSend');
const errorMessage: Message = {
id: 'temp-error-' + Date.now(),
session_id: '',
role: 'assistant',
content: `**Error:** ${errMsg}`,
content: `**${t('chat.error')}:** ${errMsg}`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -310,7 +336,7 @@ export default function NewChatPage() {
abortControllerRef.current = null;
}
},
[isStreaming, router, workingDir, mode, currentModel, setPendingApprovalSessionId]
[isStreaming, router, workingDir, mode, currentModel, setPendingApprovalSessionId, t]
);

const handleCommand = useCallback((command: string) => {
Expand All@@ -320,7 +346,7 @@ export default function NewChatPage() {
id: 'cmd-' + Date.now(),
session_id: '',
role: 'assistant',
content: `## Available Commands\n\n- **/help** - Show this help message\n- **/clear** - Clear conversation history\n- **/compact** - Compress conversation context\n- **/cost** - Show token usage statistics\n- **/doctor** - Check system health\n- **/init** - Initialize CLAUDE.md\n- **/review** - Start code review\n- **/terminal-setup** - Configure terminal\n\n**Tips:**\n- Type \`@\` to mention files\n- Use Shift+Enter for new line\n- Select a project folder to enable file operations`,
content: buildHelpContent(t),
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -335,7 +361,7 @@ export default function NewChatPage() {
id: 'cmd-' + Date.now(),
session_id: '',
role: 'assistant',
content: `## Token Usage\n\nToken usage tracking is available after sending messages. Check the token count displayed at the bottom of each assistant response.`,
content: `${t('chat.tokenUsageTitle')}\n\n${t('chat.noTokenUsage')}`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -345,7 +371,7 @@ export default function NewChatPage() {
default:
sendFirstMessage(command);
}
}, [sendFirstMessage]);
}, [sendFirstMessage, t]);

return (
<div className="flex h-full min-h-0 flex-col">
Expand Down
8 changes: 5 additions & 3 deletions src/app/extensions/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@

import { Suspense, useState } from "react";
import { useSearchParams } from "next/navigation";
import { useTranslation } from "@/hooks/useTranslation";
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { HugeiconsIcon } from "@hugeicons/react";
import { Loading02Icon } from "@hugeicons/core-free-icons";
Expand All@@ -28,15 +29,16 @@ function ExtensionsPageInner() {
const searchParams = useSearchParams();
const initialTab = (searchParams.get("tab") as ExtTab) || "skills";
const [tab, setTab] = useState<ExtTab>(initialTab);
const { t } = useTranslation();

return (
<div className="flex h-full flex-col">
<div className="px-6 pt-4 pb-0">
<h1 className="text-xl font-semibold mb-3">Extensions</h1>
<h1 className="text-xl font-semibold mb-3">{t('extensions.title')}</h1>
<Tabs value={tab} onValueChange={(v) => setTab(v as ExtTab)}>
<TabsList>
<TabsTrigger value="skills">Skills</TabsTrigger>
<TabsTrigger value="mcp">MCP Servers</TabsTrigger>
<TabsTrigger value="skills">{t('extensions.skills')}</TabsTrigger>
<TabsTrigger value="mcp">{t('extensions.mcpServers')}</TabsTrigger>
</TabsList>
</Tabs>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/app/layout.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { ThemeProvider } from "@/components/layout/ThemeProvider";
import { I18nProvider } from "@/components/layout/I18nProvider";
import { AppShell } from "@/components/layout/AppShell";

const geistSans = Geist({
Expand DownExpand Up@@ -30,7 +31,9 @@ export default function RootLayout({
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
<ThemeProvider>
<AppShell>{children}</AppShell>
<I18nProvider>
<AppShell>{children}</AppShell>
</I18nProvider>
</ThemeProvider>
</body>
</html>
Expand Down
27 changes: 16 additions & 11 deletions src/components/ai-elements/tool-actions-group.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@ import {
} from "@hugeicons/core-free-icons";
import { ChevronRightIcon } from 'lucide-react';
import { cn } from '@/lib/utils';
import { useTranslation } from '@/hooks/useTranslation';

// ---------------------------------------------------------------------------
// Types
Expand DownExpand Up@@ -194,15 +195,14 @@ function getRunningDescription(tools: ToolAction[]): string {
export function ToolActionsGroup({
tools,
isStreaming = false,
streamingToolOutput: _streamingToolOutput,
}: ToolActionsGroupProps) {
const hasRunningTool = tools.some((t) => t.result === undefined);
const { t } = useTranslation();

// Track whether user has manually toggled and their chosen state
const [userExpandedState, setUserExpandedState] = useState<boolean | null>(null);

// Derived: if user has toggled, use their choice; otherwise auto-expand based on streaming state
const expanded = userExpandedState !== null ? userExpandedState : (hasRunningTool || isStreaming);
const autoExpanded = hasRunningTool || isStreaming;
const [userToggled, setUserToggled] = useState(false);
const [manualExpanded, setManualExpanded] = useState(false);
const expanded = userToggled ? manualExpanded : autoExpanded;

if (tools.length === 0) return null;

Expand All@@ -211,15 +211,20 @@ export function ToolActionsGroup({
const runningDesc = getRunningDescription(tools);

const handleToggle = () => {
setUserExpandedState((prev) => prev !== null ? !prev : !expanded);
if (!userToggled) {
setUserToggled(true);
setManualExpanded(!autoExpanded);
return;
}

setManualExpanded((prev) => !prev);
};

// Build summary text parts
const summaryParts: string[] = [];
if (runningCount > 0) summaryParts.push(`${runningCount} running`);
if (doneCount > 0) summaryParts.push(`${doneCount} completed`);
if (runningCount === 0 && isStreaming) summaryParts.push('generating response');
if (summaryParts.length === 0) summaryParts.push(`${tools.length} actions`);
if (runningCount > 0) summaryParts.push(`${runningCount} ${t('toolActions.running')}`);
if (doneCount > 0) summaryParts.push(`${doneCount} ${t('toolActions.completed')}`);
if (summaryParts.length === 0) summaryParts.push(`${tools.length} ${t('toolActions.actions')}`);

return (
<div className="w-[min(100%,48rem)]">
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' feat(i18n): 添加日语 (ja) 翻译 by gy212 · Pull Request #91 · op7418/CodePilot · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/__tests__/smoke-test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -80,7 +80,8 @@ async function runSmokeTests() {
results.push({ name: route.name, status: 'PASS', details, consoleErrors, loadTimeMs: elapsed });
} catch (err: unknown) {
const elapsed = Date.now() - start;
results.push({ name: route.name, status: 'FAIL', details: err instanceof Error ? err.message : String(err), consoleErrors, loadTimeMs: elapsed });
const message = err instanceof Error ? err.message : String(err);
results.push({ name: route.name, status: 'FAIL', details: message, consoleErrors, loadTimeMs: elapsed });
}
await page.close();
}
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/unit/db-shutdown.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
* 4. Data persists across close/reopen cycles
*/

import { describe, it, before, afterEach } from 'node:test';
import { describe, it, afterEach } from 'node:test';
import assert from 'node:assert/strict';
import path from 'path';
import os from 'os';
Expand All@@ -23,7 +23,6 @@ process.env.CLAUDE_GUI_DATA_DIR = tmpDir;
// Use require to avoid top-level await issues with CJS output
/* eslint-disable @typescript-eslint/no-require-imports */
const { getDb, closeDb, createSession, getSession } = require('../../lib/db') as typeof import('../../lib/db');

describe('closeDb', () => {
afterEach(() => {
// Ensure DB is closed after each test
Expand Down
1 change: 1 addition & 0 deletions src/app/api/settings/app/route.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import { getSetting, setSetting } from '@/lib/db';
const ALLOWED_KEYS = [
'anthropic_auth_token',
'anthropic_base_url',
'locale',
'dangerously_skip_permissions',
];

Expand Down
20 changes: 11 additions & 9 deletions src/app/chat/[id]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ import { HugeiconsIcon } from "@hugeicons/react";
import { Loading02Icon, PencilEdit01Icon } from "@hugeicons/core-free-icons";
import { Input } from '@/components/ui/input';
import { usePanel } from '@/hooks/usePanel';
import { useTranslation } from '@/hooks/useTranslation';

interface ChatSessionPageProps {
params: Promise<{ id: string }>;
Expand All@@ -27,11 +28,12 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
const [editTitle, setEditTitle] = useState('');
const titleInputRef = useRef<HTMLInputElement>(null);
const { setWorkingDirectory, setSessionId, setSessionTitle: setPanelSessionTitle, setPanelOpen } = usePanel();
const { t } = useTranslation();

const handleStartEditTitle = useCallback(() => {
setEditTitle(sessionTitle || 'New Conversation');
setEditTitle(sessionTitle || t('chatSession.newConversation'));
setIsEditingTitle(true);
}, [sessionTitle]);
}, [sessionTitle, t]);

const handleSaveTitle = useCallback(async () => {
const trimmed = editTitle.trim();
Expand DownExpand Up@@ -84,7 +86,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
}
setSessionId(id);
setPanelOpen(true);
const title = data.session.title || 'New Conversation';
const title = data.session.title || t('chatSession.newConversation');
setSessionTitle(title);
setPanelSessionTitle(title);
setSessionModel(data.session.model || '');
Expand All@@ -97,7 +99,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
}

loadSession();
}, [id, setWorkingDirectory, setSessionId, setPanelSessionTitle, setPanelOpen]);
}, [id, setWorkingDirectory, setSessionId, setPanelSessionTitle, setPanelOpen, t]);

useEffect(() => {
// Reset state when switching sessions
Expand All@@ -114,7 +116,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
if (cancelled) return;
if (!res.ok) {
if (res.status === 404) {
setError('Session not found');
setError(t('chatSession.sessionNotFound'));
return;
}
throw new Error('Failed to load messages');
Expand All@@ -123,9 +125,9 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
if (cancelled) return;
setMessages(data.messages);
setHasMore(data.hasMore ?? false);
} catch (err) {
} catch {
if (cancelled) return;
setError(err instanceof Error ? err.message : 'Failed to load messages');
setError(t('chatSession.failedToLoad'));
} finally {
if (!cancelled) setLoading(false);
}
Expand All@@ -134,7 +136,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
loadMessages();

return () => { cancelled = true; };
}, [id]);
}, [id, t]);

if (loading) {
return (
Expand All@@ -150,7 +152,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
<div className="text-center space-y-2">
<p className="text-destructive font-medium">{error}</p>
<Link href="/chat" className="text-sm text-muted-foreground hover:underline">
Start a new chat
{t('chatSession.startNewChat')}
</Link>
</div>
</div>
Expand Down
56 changes: 41 additions & 15 deletions src/app/chat/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,8 @@ import type { Message, SSEEvent, SessionResponse, TokenUsage, PermissionRequestE
import { MessageList } from '@/components/chat/MessageList';
import { MessageInput } from '@/components/chat/MessageInput';
import { usePanel } from '@/hooks/usePanel';
import { useTranslation } from '@/hooks/useTranslation';
import { buildHelpContent } from '@/lib/help-content';

interface ToolUseInfo {
id: string;
Expand All@@ -18,16 +20,25 @@ interface ToolResultInfo {
content: string;
}

type UserFacingError = Error & { userMessage?: string };

function makeUserFacingError(userMessage: string, technicalMessage?: string): UserFacingError {
const error = new Error(technicalMessage || userMessage) as UserFacingError;
error.userMessage = userMessage;
return error;
}

export default function NewChatPage() {
const router = useRouter();
const { setWorkingDirectory, setPanelOpen, setPendingApprovalSessionId } = usePanel();
const { setPendingApprovalSessionId } = usePanel();
const { t } = useTranslation();
const [messages, setMessages] = useState<Message[]>([]);
const [streamingContent, setStreamingContent] = useState('');
const [isStreaming, setIsStreaming] = useState(false);
const [toolUses, setToolUses] = useState<ToolUseInfo[]>([]);
const [toolResults, setToolResults] = useState<ToolResultInfo[]>([]);
const [statusText, setStatusText] = useState<string | undefined>();
const [workingDir, setWorkingDir] = useState('');
const workingDir = '';
const [mode, setMode] = useState('code');
const [currentModel, setCurrentModel] = useState('sonnet');
const [pendingPermission, setPendingPermission] = useState<PermissionRequestEvent | null>(null);
Expand DownExpand Up@@ -84,7 +95,7 @@ export default function NewChatPage() {
id: 'hint-' + Date.now(),
session_id: '',
role: 'assistant',
content: '**Please select a project directory first.** Use the folder picker in the toolbar below to choose a working directory before sending a message.',
content: `**${t('input.selectProjectFolder')}**`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand DownExpand Up@@ -119,7 +130,13 @@ export default function NewChatPage() {

if (!createRes.ok) {
const errBody = await createRes.json().catch(() => ({}));
throw new Error(errBody.error || `Failed to create session (${createRes.status})`);
const technicalMessage = typeof errBody.error === 'string'
? errBody.error
: `Failed to create session (${createRes.status})`;
throw makeUserFacingError(
t('chat.failedToCreateSession', { status: createRes.status }),
technicalMessage,
);
}

const { session }: SessionResponse = await createRes.json();
Expand DownExpand Up@@ -148,8 +165,11 @@ export default function NewChatPage() {
});

if (!response.ok) {
const err = await response.json();
throw new Error(err.error || 'Failed to send message');
const err = await response.json().catch(() => ({}));
const technicalMessage = typeof err.error === 'string'
? err.error
: `Failed to send message (${response.status})`;
throw makeUserFacingError(t('chat.failedToSend'), technicalMessage);
}

const reader = response.body?.getReader();
Expand DownExpand Up@@ -203,7 +223,7 @@ export default function NewChatPage() {
try {
const parsed = JSON.parse(event.data);
if (parsed._progress) {
setStatusText(`Running ${parsed.tool_name}... (${Math.round(parsed.elapsed_time_seconds)}s)`);
setStatusText(t('chat.running', { tool: parsed.tool_name, seconds: Math.round(parsed.elapsed_time_seconds) }));
break;
}
} catch {
Expand All@@ -219,7 +239,7 @@ export default function NewChatPage() {
try {
const statusData = JSON.parse(event.data);
if (statusData.session_id) {
setStatusText(`Connected (${statusData.model || 'claude'})`);
setStatusText(t('chat.connected', { model: statusData.model || 'claude' }));
setTimeout(() => setStatusText(undefined), 2000);
} else if (statusData.notification) {
setStatusText(statusData.message || statusData.title || undefined);
Expand DownExpand Up@@ -251,7 +271,7 @@ export default function NewChatPage() {
break;
}
case 'error': {
accumulated += '\n\n**Error:** ' + event.data;
accumulated += '\n\n**' + t('chat.error') + ':** ' + event.data;
setStreamingContent(accumulated);
break;
}
Expand DownExpand Up@@ -286,12 +306,18 @@ export default function NewChatPage() {
router.push(`/chat/${sessionId}`);
}
} else {
const errMsg = error instanceof Error ? error.message : 'Unknown error';
const errMsg =
typeof error === 'object' &&
error !== null &&
'userMessage' in error &&
typeof (error as UserFacingError).userMessage === 'string'
? (error as UserFacingError).userMessage!
: t('chat.failedToSend');
const errorMessage: Message = {
id: 'temp-error-' + Date.now(),
session_id: '',
role: 'assistant',
content: `**Error:** ${errMsg}`,
content: `**${t('chat.error')}:** ${errMsg}`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -310,7 +336,7 @@ export default function NewChatPage() {
abortControllerRef.current = null;
}
},
[isStreaming, router, workingDir, mode, currentModel, setPendingApprovalSessionId]
[isStreaming, router, workingDir, mode, currentModel, setPendingApprovalSessionId, t]
);

const handleCommand = useCallback((command: string) => {
Expand All@@ -320,7 +346,7 @@ export default function NewChatPage() {
id: 'cmd-' + Date.now(),
session_id: '',
role: 'assistant',
content: `## Available Commands\n\n- **/help** - Show this help message\n- **/clear** - Clear conversation history\n- **/compact** - Compress conversation context\n- **/cost** - Show token usage statistics\n- **/doctor** - Check system health\n- **/init** - Initialize CLAUDE.md\n- **/review** - Start code review\n- **/terminal-setup** - Configure terminal\n\n**Tips:**\n- Type \`@\` to mention files\n- Use Shift+Enter for new line\n- Select a project folder to enable file operations`,
content: buildHelpContent(t),
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -335,7 +361,7 @@ export default function NewChatPage() {
id: 'cmd-' + Date.now(),
session_id: '',
role: 'assistant',
content: `## Token Usage\n\nToken usage tracking is available after sending messages. Check the token count displayed at the bottom of each assistant response.`,
content: `${t('chat.tokenUsageTitle')}\n\n${t('chat.noTokenUsage')}`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -345,7 +371,7 @@ export default function NewChatPage() {
default:
sendFirstMessage(command);
}
}, [sendFirstMessage]);
}, [sendFirstMessage, t]);

return (
<div className="flex h-full min-h-0 flex-col">
Expand Down
8 changes: 5 additions & 3 deletions src/app/extensions/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@

import { Suspense, useState } from "react";
import { useSearchParams } from "next/navigation";
import { useTranslation } from "@/hooks/useTranslation";
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { HugeiconsIcon } from "@hugeicons/react";
import { Loading02Icon } from "@hugeicons/core-free-icons";
Expand All@@ -28,15 +29,16 @@ function ExtensionsPageInner() {
const searchParams = useSearchParams();
const initialTab = (searchParams.get("tab") as ExtTab) || "skills";
const [tab, setTab] = useState<ExtTab>(initialTab);
const { t } = useTranslation();

return (
<div className="flex h-full flex-col">
<div className="px-6 pt-4 pb-0">
<h1 className="text-xl font-semibold mb-3">Extensions</h1>
<h1 className="text-xl font-semibold mb-3">{t('extensions.title')}</h1>
<Tabs value={tab} onValueChange={(v) => setTab(v as ExtTab)}>
<TabsList>
<TabsTrigger value="skills">Skills</TabsTrigger>
<TabsTrigger value="mcp">MCP Servers</TabsTrigger>
<TabsTrigger value="skills">{t('extensions.skills')}</TabsTrigger>
<TabsTrigger value="mcp">{t('extensions.mcpServers')}</TabsTrigger>
</TabsList>
</Tabs>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/app/layout.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { ThemeProvider } from "@/components/layout/ThemeProvider";
import { I18nProvider } from "@/components/layout/I18nProvider";
import { AppShell } from "@/components/layout/AppShell";

const geistSans = Geist({
Expand DownExpand Up@@ -30,7 +31,9 @@ export default function RootLayout({
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
<ThemeProvider>
<AppShell>{children}</AppShell>
<I18nProvider>
<AppShell>{children}</AppShell>
</I18nProvider>
</ThemeProvider>
</body>
</html>
Expand Down
27 changes: 16 additions & 11 deletions src/components/ai-elements/tool-actions-group.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@ import {
} from "@hugeicons/core-free-icons";
import { ChevronRightIcon } from 'lucide-react';
import { cn } from '@/lib/utils';
import { useTranslation } from '@/hooks/useTranslation';

// ---------------------------------------------------------------------------
// Types
Expand DownExpand Up@@ -194,15 +195,14 @@ function getRunningDescription(tools: ToolAction[]): string {
export function ToolActionsGroup({
tools,
isStreaming = false,
streamingToolOutput: _streamingToolOutput,
}: ToolActionsGroupProps) {
const hasRunningTool = tools.some((t) => t.result === undefined);
const { t } = useTranslation();

// Track whether user has manually toggled and their chosen state
const [userExpandedState, setUserExpandedState] = useState<boolean | null>(null);

// Derived: if user has toggled, use their choice; otherwise auto-expand based on streaming state
const expanded = userExpandedState !== null ? userExpandedState : (hasRunningTool || isStreaming);
const autoExpanded = hasRunningTool || isStreaming;
const [userToggled, setUserToggled] = useState(false);
const [manualExpanded, setManualExpanded] = useState(false);
const expanded = userToggled ? manualExpanded : autoExpanded;

if (tools.length === 0) return null;

Expand All@@ -211,15 +211,20 @@ export function ToolActionsGroup({
const runningDesc = getRunningDescription(tools);

const handleToggle = () => {
setUserExpandedState((prev) => prev !== null ? !prev : !expanded);
if (!userToggled) {
setUserToggled(true);
setManualExpanded(!autoExpanded);
return;
}

setManualExpanded((prev) => !prev);
};

// Build summary text parts
const summaryParts: string[] = [];
if (runningCount > 0) summaryParts.push(`${runningCount} running`);
if (doneCount > 0) summaryParts.push(`${doneCount} completed`);
if (runningCount === 0 && isStreaming) summaryParts.push('generating response');
if (summaryParts.length === 0) summaryParts.push(`${tools.length} actions`);
if (runningCount > 0) summaryParts.push(`${runningCount} ${t('toolActions.running')}`);
if (doneCount > 0) summaryParts.push(`${doneCount} ${t('toolActions.completed')}`);
if (summaryParts.length === 0) summaryParts.push(`${tools.length} ${t('toolActions.actions')}`);

return (
<div className="w-[min(100%,48rem)]">
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' feat(i18n): 添加日语 (ja) 翻译 by gy212 · Pull Request #91 · op7418/CodePilot · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/__tests__/smoke-test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -80,7 +80,8 @@ async function runSmokeTests() {
results.push({ name: route.name, status: 'PASS', details, consoleErrors, loadTimeMs: elapsed });
} catch (err: unknown) {
const elapsed = Date.now() - start;
results.push({ name: route.name, status: 'FAIL', details: err instanceof Error ? err.message : String(err), consoleErrors, loadTimeMs: elapsed });
const message = err instanceof Error ? err.message : String(err);
results.push({ name: route.name, status: 'FAIL', details: message, consoleErrors, loadTimeMs: elapsed });
}
await page.close();
}
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/unit/db-shutdown.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
* 4. Data persists across close/reopen cycles
*/

import { describe, it, before, afterEach } from 'node:test';
import { describe, it, afterEach } from 'node:test';
import assert from 'node:assert/strict';
import path from 'path';
import os from 'os';
Expand All@@ -23,7 +23,6 @@ process.env.CLAUDE_GUI_DATA_DIR = tmpDir;
// Use require to avoid top-level await issues with CJS output
/* eslint-disable @typescript-eslint/no-require-imports */
const { getDb, closeDb, createSession, getSession } = require('../../lib/db') as typeof import('../../lib/db');

describe('closeDb', () => {
afterEach(() => {
// Ensure DB is closed after each test
Expand Down
1 change: 1 addition & 0 deletions src/app/api/settings/app/route.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import { getSetting, setSetting } from '@/lib/db';
const ALLOWED_KEYS = [
'anthropic_auth_token',
'anthropic_base_url',
'locale',
'dangerously_skip_permissions',
];

Expand Down
20 changes: 11 additions & 9 deletions src/app/chat/[id]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ import { HugeiconsIcon } from "@hugeicons/react";
import { Loading02Icon, PencilEdit01Icon } from "@hugeicons/core-free-icons";
import { Input } from '@/components/ui/input';
import { usePanel } from '@/hooks/usePanel';
import { useTranslation } from '@/hooks/useTranslation';

interface ChatSessionPageProps {
params: Promise<{ id: string }>;
Expand All@@ -27,11 +28,12 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
const [editTitle, setEditTitle] = useState('');
const titleInputRef = useRef<HTMLInputElement>(null);
const { setWorkingDirectory, setSessionId, setSessionTitle: setPanelSessionTitle, setPanelOpen } = usePanel();
const { t } = useTranslation();

const handleStartEditTitle = useCallback(() => {
setEditTitle(sessionTitle || 'New Conversation');
setEditTitle(sessionTitle || t('chatSession.newConversation'));
setIsEditingTitle(true);
}, [sessionTitle]);
}, [sessionTitle, t]);

const handleSaveTitle = useCallback(async () => {
const trimmed = editTitle.trim();
Expand DownExpand Up@@ -84,7 +86,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
}
setSessionId(id);
setPanelOpen(true);
const title = data.session.title || 'New Conversation';
const title = data.session.title || t('chatSession.newConversation');
setSessionTitle(title);
setPanelSessionTitle(title);
setSessionModel(data.session.model || '');
Expand All@@ -97,7 +99,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
}

loadSession();
}, [id, setWorkingDirectory, setSessionId, setPanelSessionTitle, setPanelOpen]);
}, [id, setWorkingDirectory, setSessionId, setPanelSessionTitle, setPanelOpen, t]);

useEffect(() => {
// Reset state when switching sessions
Expand All@@ -114,7 +116,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
if (cancelled) return;
if (!res.ok) {
if (res.status === 404) {
setError('Session not found');
setError(t('chatSession.sessionNotFound'));
return;
}
throw new Error('Failed to load messages');
Expand All@@ -123,9 +125,9 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
if (cancelled) return;
setMessages(data.messages);
setHasMore(data.hasMore ?? false);
} catch (err) {
} catch {
if (cancelled) return;
setError(err instanceof Error ? err.message : 'Failed to load messages');
setError(t('chatSession.failedToLoad'));
} finally {
if (!cancelled) setLoading(false);
}
Expand All@@ -134,7 +136,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
loadMessages();

return () => { cancelled = true; };
}, [id]);
}, [id, t]);

if (loading) {
return (
Expand All@@ -150,7 +152,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
<div className="text-center space-y-2">
<p className="text-destructive font-medium">{error}</p>
<Link href="/chat" className="text-sm text-muted-foreground hover:underline">
Start a new chat
{t('chatSession.startNewChat')}
</Link>
</div>
</div>
Expand Down
56 changes: 41 additions & 15 deletions src/app/chat/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,8 @@ import type { Message, SSEEvent, SessionResponse, TokenUsage, PermissionRequestE
import { MessageList } from '@/components/chat/MessageList';
import { MessageInput } from '@/components/chat/MessageInput';
import { usePanel } from '@/hooks/usePanel';
import { useTranslation } from '@/hooks/useTranslation';
import { buildHelpContent } from '@/lib/help-content';

interface ToolUseInfo {
id: string;
Expand All@@ -18,16 +20,25 @@ interface ToolResultInfo {
content: string;
}

type UserFacingError = Error & { userMessage?: string };

function makeUserFacingError(userMessage: string, technicalMessage?: string): UserFacingError {
const error = new Error(technicalMessage || userMessage) as UserFacingError;
error.userMessage = userMessage;
return error;
}

export default function NewChatPage() {
const router = useRouter();
const { setWorkingDirectory, setPanelOpen, setPendingApprovalSessionId } = usePanel();
const { setPendingApprovalSessionId } = usePanel();
const { t } = useTranslation();
const [messages, setMessages] = useState<Message[]>([]);
const [streamingContent, setStreamingContent] = useState('');
const [isStreaming, setIsStreaming] = useState(false);
const [toolUses, setToolUses] = useState<ToolUseInfo[]>([]);
const [toolResults, setToolResults] = useState<ToolResultInfo[]>([]);
const [statusText, setStatusText] = useState<string | undefined>();
const [workingDir, setWorkingDir] = useState('');
const workingDir = '';
const [mode, setMode] = useState('code');
const [currentModel, setCurrentModel] = useState('sonnet');
const [pendingPermission, setPendingPermission] = useState<PermissionRequestEvent | null>(null);
Expand DownExpand Up@@ -84,7 +95,7 @@ export default function NewChatPage() {
id: 'hint-' + Date.now(),
session_id: '',
role: 'assistant',
content: '**Please select a project directory first.** Use the folder picker in the toolbar below to choose a working directory before sending a message.',
content: `**${t('input.selectProjectFolder')}**`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand DownExpand Up@@ -119,7 +130,13 @@ export default function NewChatPage() {

if (!createRes.ok) {
const errBody = await createRes.json().catch(() => ({}));
throw new Error(errBody.error || `Failed to create session (${createRes.status})`);
const technicalMessage = typeof errBody.error === 'string'
? errBody.error
: `Failed to create session (${createRes.status})`;
throw makeUserFacingError(
t('chat.failedToCreateSession', { status: createRes.status }),
technicalMessage,
);
}

const { session }: SessionResponse = await createRes.json();
Expand DownExpand Up@@ -148,8 +165,11 @@ export default function NewChatPage() {
});

if (!response.ok) {
const err = await response.json();
throw new Error(err.error || 'Failed to send message');
const err = await response.json().catch(() => ({}));
const technicalMessage = typeof err.error === 'string'
? err.error
: `Failed to send message (${response.status})`;
throw makeUserFacingError(t('chat.failedToSend'), technicalMessage);
}

const reader = response.body?.getReader();
Expand DownExpand Up@@ -203,7 +223,7 @@ export default function NewChatPage() {
try {
const parsed = JSON.parse(event.data);
if (parsed._progress) {
setStatusText(`Running ${parsed.tool_name}... (${Math.round(parsed.elapsed_time_seconds)}s)`);
setStatusText(t('chat.running', { tool: parsed.tool_name, seconds: Math.round(parsed.elapsed_time_seconds) }));
break;
}
} catch {
Expand All@@ -219,7 +239,7 @@ export default function NewChatPage() {
try {
const statusData = JSON.parse(event.data);
if (statusData.session_id) {
setStatusText(`Connected (${statusData.model || 'claude'})`);
setStatusText(t('chat.connected', { model: statusData.model || 'claude' }));
setTimeout(() => setStatusText(undefined), 2000);
} else if (statusData.notification) {
setStatusText(statusData.message || statusData.title || undefined);
Expand DownExpand Up@@ -251,7 +271,7 @@ export default function NewChatPage() {
break;
}
case 'error': {
accumulated += '\n\n**Error:** ' + event.data;
accumulated += '\n\n**' + t('chat.error') + ':** ' + event.data;
setStreamingContent(accumulated);
break;
}
Expand DownExpand Up@@ -286,12 +306,18 @@ export default function NewChatPage() {
router.push(`/chat/${sessionId}`);
}
} else {
const errMsg = error instanceof Error ? error.message : 'Unknown error';
const errMsg =
typeof error === 'object' &&
error !== null &&
'userMessage' in error &&
typeof (error as UserFacingError).userMessage === 'string'
? (error as UserFacingError).userMessage!
: t('chat.failedToSend');
const errorMessage: Message = {
id: 'temp-error-' + Date.now(),
session_id: '',
role: 'assistant',
content: `**Error:** ${errMsg}`,
content: `**${t('chat.error')}:** ${errMsg}`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -310,7 +336,7 @@ export default function NewChatPage() {
abortControllerRef.current = null;
}
},
[isStreaming, router, workingDir, mode, currentModel, setPendingApprovalSessionId]
[isStreaming, router, workingDir, mode, currentModel, setPendingApprovalSessionId, t]
);

const handleCommand = useCallback((command: string) => {
Expand All@@ -320,7 +346,7 @@ export default function NewChatPage() {
id: 'cmd-' + Date.now(),
session_id: '',
role: 'assistant',
content: `## Available Commands\n\n- **/help** - Show this help message\n- **/clear** - Clear conversation history\n- **/compact** - Compress conversation context\n- **/cost** - Show token usage statistics\n- **/doctor** - Check system health\n- **/init** - Initialize CLAUDE.md\n- **/review** - Start code review\n- **/terminal-setup** - Configure terminal\n\n**Tips:**\n- Type \`@\` to mention files\n- Use Shift+Enter for new line\n- Select a project folder to enable file operations`,
content: buildHelpContent(t),
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -335,7 +361,7 @@ export default function NewChatPage() {
id: 'cmd-' + Date.now(),
session_id: '',
role: 'assistant',
content: `## Token Usage\n\nToken usage tracking is available after sending messages. Check the token count displayed at the bottom of each assistant response.`,
content: `${t('chat.tokenUsageTitle')}\n\n${t('chat.noTokenUsage')}`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -345,7 +371,7 @@ export default function NewChatPage() {
default:
sendFirstMessage(command);
}
}, [sendFirstMessage]);
}, [sendFirstMessage, t]);

return (
<div className="flex h-full min-h-0 flex-col">
Expand Down
8 changes: 5 additions & 3 deletions src/app/extensions/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@

import { Suspense, useState } from "react";
import { useSearchParams } from "next/navigation";
import { useTranslation } from "@/hooks/useTranslation";
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { HugeiconsIcon } from "@hugeicons/react";
import { Loading02Icon } from "@hugeicons/core-free-icons";
Expand All@@ -28,15 +29,16 @@ function ExtensionsPageInner() {
const searchParams = useSearchParams();
const initialTab = (searchParams.get("tab") as ExtTab) || "skills";
const [tab, setTab] = useState<ExtTab>(initialTab);
const { t } = useTranslation();

return (
<div className="flex h-full flex-col">
<div className="px-6 pt-4 pb-0">
<h1 className="text-xl font-semibold mb-3">Extensions</h1>
<h1 className="text-xl font-semibold mb-3">{t('extensions.title')}</h1>
<Tabs value={tab} onValueChange={(v) => setTab(v as ExtTab)}>
<TabsList>
<TabsTrigger value="skills">Skills</TabsTrigger>
<TabsTrigger value="mcp">MCP Servers</TabsTrigger>
<TabsTrigger value="skills">{t('extensions.skills')}</TabsTrigger>
<TabsTrigger value="mcp">{t('extensions.mcpServers')}</TabsTrigger>
</TabsList>
</Tabs>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/app/layout.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { ThemeProvider } from "@/components/layout/ThemeProvider";
import { I18nProvider } from "@/components/layout/I18nProvider";
import { AppShell } from "@/components/layout/AppShell";

const geistSans = Geist({
Expand DownExpand Up@@ -30,7 +31,9 @@ export default function RootLayout({
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
<ThemeProvider>
<AppShell>{children}</AppShell>
<I18nProvider>
<AppShell>{children}</AppShell>
</I18nProvider>
</ThemeProvider>
</body>
</html>
Expand Down
27 changes: 16 additions & 11 deletions src/components/ai-elements/tool-actions-group.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@ import {
} from "@hugeicons/core-free-icons";
import { ChevronRightIcon } from 'lucide-react';
import { cn } from '@/lib/utils';
import { useTranslation } from '@/hooks/useTranslation';

// ---------------------------------------------------------------------------
// Types
Expand DownExpand Up@@ -194,15 +195,14 @@ function getRunningDescription(tools: ToolAction[]): string {
export function ToolActionsGroup({
tools,
isStreaming = false,
streamingToolOutput: _streamingToolOutput,
}: ToolActionsGroupProps) {
const hasRunningTool = tools.some((t) => t.result === undefined);
const { t } = useTranslation();

// Track whether user has manually toggled and their chosen state
const [userExpandedState, setUserExpandedState] = useState<boolean | null>(null);

// Derived: if user has toggled, use their choice; otherwise auto-expand based on streaming state
const expanded = userExpandedState !== null ? userExpandedState : (hasRunningTool || isStreaming);
const autoExpanded = hasRunningTool || isStreaming;
const [userToggled, setUserToggled] = useState(false);
const [manualExpanded, setManualExpanded] = useState(false);
const expanded = userToggled ? manualExpanded : autoExpanded;

if (tools.length === 0) return null;

Expand All@@ -211,15 +211,20 @@ export function ToolActionsGroup({
const runningDesc = getRunningDescription(tools);

const handleToggle = () => {
setUserExpandedState((prev) => prev !== null ? !prev : !expanded);
if (!userToggled) {
setUserToggled(true);
setManualExpanded(!autoExpanded);
return;
}

setManualExpanded((prev) => !prev);
};

// Build summary text parts
const summaryParts: string[] = [];
if (runningCount > 0) summaryParts.push(`${runningCount} running`);
if (doneCount > 0) summaryParts.push(`${doneCount} completed`);
if (runningCount === 0 && isStreaming) summaryParts.push('generating response');
if (summaryParts.length === 0) summaryParts.push(`${tools.length} actions`);
if (runningCount > 0) summaryParts.push(`${runningCount} ${t('toolActions.running')}`);
if (doneCount > 0) summaryParts.push(`${doneCount} ${t('toolActions.completed')}`);
if (summaryParts.length === 0) summaryParts.push(`${tools.length} ${t('toolActions.actions')}`);

return (
<div className="w-[min(100%,48rem)]">
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' feat(i18n): 添加日语 (ja) 翻译 by gy212 · Pull Request #91 · op7418/CodePilot · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/__tests__/smoke-test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -80,7 +80,8 @@ async function runSmokeTests() {
results.push({ name: route.name, status: 'PASS', details, consoleErrors, loadTimeMs: elapsed });
} catch (err: unknown) {
const elapsed = Date.now() - start;
results.push({ name: route.name, status: 'FAIL', details: err instanceof Error ? err.message : String(err), consoleErrors, loadTimeMs: elapsed });
const message = err instanceof Error ? err.message : String(err);
results.push({ name: route.name, status: 'FAIL', details: message, consoleErrors, loadTimeMs: elapsed });
}
await page.close();
}
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/unit/db-shutdown.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
* 4. Data persists across close/reopen cycles
*/

import { describe, it, before, afterEach } from 'node:test';
import { describe, it, afterEach } from 'node:test';
import assert from 'node:assert/strict';
import path from 'path';
import os from 'os';
Expand All@@ -23,7 +23,6 @@ process.env.CLAUDE_GUI_DATA_DIR = tmpDir;
// Use require to avoid top-level await issues with CJS output
/* eslint-disable @typescript-eslint/no-require-imports */
const { getDb, closeDb, createSession, getSession } = require('../../lib/db') as typeof import('../../lib/db');

describe('closeDb', () => {
afterEach(() => {
// Ensure DB is closed after each test
Expand Down
1 change: 1 addition & 0 deletions src/app/api/settings/app/route.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import { getSetting, setSetting } from '@/lib/db';
const ALLOWED_KEYS = [
'anthropic_auth_token',
'anthropic_base_url',
'locale',
'dangerously_skip_permissions',
];

Expand Down
20 changes: 11 additions & 9 deletions src/app/chat/[id]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ import { HugeiconsIcon } from "@hugeicons/react";
import { Loading02Icon, PencilEdit01Icon } from "@hugeicons/core-free-icons";
import { Input } from '@/components/ui/input';
import { usePanel } from '@/hooks/usePanel';
import { useTranslation } from '@/hooks/useTranslation';

interface ChatSessionPageProps {
params: Promise<{ id: string }>;
Expand All@@ -27,11 +28,12 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
const [editTitle, setEditTitle] = useState('');
const titleInputRef = useRef<HTMLInputElement>(null);
const { setWorkingDirectory, setSessionId, setSessionTitle: setPanelSessionTitle, setPanelOpen } = usePanel();
const { t } = useTranslation();

const handleStartEditTitle = useCallback(() => {
setEditTitle(sessionTitle || 'New Conversation');
setEditTitle(sessionTitle || t('chatSession.newConversation'));
setIsEditingTitle(true);
}, [sessionTitle]);
}, [sessionTitle, t]);

const handleSaveTitle = useCallback(async () => {
const trimmed = editTitle.trim();
Expand DownExpand Up@@ -84,7 +86,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
}
setSessionId(id);
setPanelOpen(true);
const title = data.session.title || 'New Conversation';
const title = data.session.title || t('chatSession.newConversation');
setSessionTitle(title);
setPanelSessionTitle(title);
setSessionModel(data.session.model || '');
Expand All@@ -97,7 +99,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
}

loadSession();
}, [id, setWorkingDirectory, setSessionId, setPanelSessionTitle, setPanelOpen]);
}, [id, setWorkingDirectory, setSessionId, setPanelSessionTitle, setPanelOpen, t]);

useEffect(() => {
// Reset state when switching sessions
Expand All@@ -114,7 +116,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
if (cancelled) return;
if (!res.ok) {
if (res.status === 404) {
setError('Session not found');
setError(t('chatSession.sessionNotFound'));
return;
}
throw new Error('Failed to load messages');
Expand All@@ -123,9 +125,9 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
if (cancelled) return;
setMessages(data.messages);
setHasMore(data.hasMore ?? false);
} catch (err) {
} catch {
if (cancelled) return;
setError(err instanceof Error ? err.message : 'Failed to load messages');
setError(t('chatSession.failedToLoad'));
} finally {
if (!cancelled) setLoading(false);
}
Expand All@@ -134,7 +136,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
loadMessages();

return () => { cancelled = true; };
}, [id]);
}, [id, t]);

if (loading) {
return (
Expand All@@ -150,7 +152,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
<div className="text-center space-y-2">
<p className="text-destructive font-medium">{error}</p>
<Link href="/chat" className="text-sm text-muted-foreground hover:underline">
Start a new chat
{t('chatSession.startNewChat')}
</Link>
</div>
</div>
Expand Down
56 changes: 41 additions & 15 deletions src/app/chat/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,8 @@ import type { Message, SSEEvent, SessionResponse, TokenUsage, PermissionRequestE
import { MessageList } from '@/components/chat/MessageList';
import { MessageInput } from '@/components/chat/MessageInput';
import { usePanel } from '@/hooks/usePanel';
import { useTranslation } from '@/hooks/useTranslation';
import { buildHelpContent } from '@/lib/help-content';

interface ToolUseInfo {
id: string;
Expand All@@ -18,16 +20,25 @@ interface ToolResultInfo {
content: string;
}

type UserFacingError = Error & { userMessage?: string };

function makeUserFacingError(userMessage: string, technicalMessage?: string): UserFacingError {
const error = new Error(technicalMessage || userMessage) as UserFacingError;
error.userMessage = userMessage;
return error;
}

export default function NewChatPage() {
const router = useRouter();
const { setWorkingDirectory, setPanelOpen, setPendingApprovalSessionId } = usePanel();
const { setPendingApprovalSessionId } = usePanel();
const { t } = useTranslation();
const [messages, setMessages] = useState<Message[]>([]);
const [streamingContent, setStreamingContent] = useState('');
const [isStreaming, setIsStreaming] = useState(false);
const [toolUses, setToolUses] = useState<ToolUseInfo[]>([]);
const [toolResults, setToolResults] = useState<ToolResultInfo[]>([]);
const [statusText, setStatusText] = useState<string | undefined>();
const [workingDir, setWorkingDir] = useState('');
const workingDir = '';
const [mode, setMode] = useState('code');
const [currentModel, setCurrentModel] = useState('sonnet');
const [pendingPermission, setPendingPermission] = useState<PermissionRequestEvent | null>(null);
Expand DownExpand Up@@ -84,7 +95,7 @@ export default function NewChatPage() {
id: 'hint-' + Date.now(),
session_id: '',
role: 'assistant',
content: '**Please select a project directory first.** Use the folder picker in the toolbar below to choose a working directory before sending a message.',
content: `**${t('input.selectProjectFolder')}**`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand DownExpand Up@@ -119,7 +130,13 @@ export default function NewChatPage() {

if (!createRes.ok) {
const errBody = await createRes.json().catch(() => ({}));
throw new Error(errBody.error || `Failed to create session (${createRes.status})`);
const technicalMessage = typeof errBody.error === 'string'
? errBody.error
: `Failed to create session (${createRes.status})`;
throw makeUserFacingError(
t('chat.failedToCreateSession', { status: createRes.status }),
technicalMessage,
);
}

const { session }: SessionResponse = await createRes.json();
Expand DownExpand Up@@ -148,8 +165,11 @@ export default function NewChatPage() {
});

if (!response.ok) {
const err = await response.json();
throw new Error(err.error || 'Failed to send message');
const err = await response.json().catch(() => ({}));
const technicalMessage = typeof err.error === 'string'
? err.error
: `Failed to send message (${response.status})`;
throw makeUserFacingError(t('chat.failedToSend'), technicalMessage);
}

const reader = response.body?.getReader();
Expand DownExpand Up@@ -203,7 +223,7 @@ export default function NewChatPage() {
try {
const parsed = JSON.parse(event.data);
if (parsed._progress) {
setStatusText(`Running ${parsed.tool_name}... (${Math.round(parsed.elapsed_time_seconds)}s)`);
setStatusText(t('chat.running', { tool: parsed.tool_name, seconds: Math.round(parsed.elapsed_time_seconds) }));
break;
}
} catch {
Expand All@@ -219,7 +239,7 @@ export default function NewChatPage() {
try {
const statusData = JSON.parse(event.data);
if (statusData.session_id) {
setStatusText(`Connected (${statusData.model || 'claude'})`);
setStatusText(t('chat.connected', { model: statusData.model || 'claude' }));
setTimeout(() => setStatusText(undefined), 2000);
} else if (statusData.notification) {
setStatusText(statusData.message || statusData.title || undefined);
Expand DownExpand Up@@ -251,7 +271,7 @@ export default function NewChatPage() {
break;
}
case 'error': {
accumulated += '\n\n**Error:** ' + event.data;
accumulated += '\n\n**' + t('chat.error') + ':** ' + event.data;
setStreamingContent(accumulated);
break;
}
Expand DownExpand Up@@ -286,12 +306,18 @@ export default function NewChatPage() {
router.push(`/chat/${sessionId}`);
}
} else {
const errMsg = error instanceof Error ? error.message : 'Unknown error';
const errMsg =
typeof error === 'object' &&
error !== null &&
'userMessage' in error &&
typeof (error as UserFacingError).userMessage === 'string'
? (error as UserFacingError).userMessage!
: t('chat.failedToSend');
const errorMessage: Message = {
id: 'temp-error-' + Date.now(),
session_id: '',
role: 'assistant',
content: `**Error:** ${errMsg}`,
content: `**${t('chat.error')}:** ${errMsg}`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -310,7 +336,7 @@ export default function NewChatPage() {
abortControllerRef.current = null;
}
},
[isStreaming, router, workingDir, mode, currentModel, setPendingApprovalSessionId]
[isStreaming, router, workingDir, mode, currentModel, setPendingApprovalSessionId, t]
);

const handleCommand = useCallback((command: string) => {
Expand All@@ -320,7 +346,7 @@ export default function NewChatPage() {
id: 'cmd-' + Date.now(),
session_id: '',
role: 'assistant',
content: `## Available Commands\n\n- **/help** - Show this help message\n- **/clear** - Clear conversation history\n- **/compact** - Compress conversation context\n- **/cost** - Show token usage statistics\n- **/doctor** - Check system health\n- **/init** - Initialize CLAUDE.md\n- **/review** - Start code review\n- **/terminal-setup** - Configure terminal\n\n**Tips:**\n- Type \`@\` to mention files\n- Use Shift+Enter for new line\n- Select a project folder to enable file operations`,
content: buildHelpContent(t),
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -335,7 +361,7 @@ export default function NewChatPage() {
id: 'cmd-' + Date.now(),
session_id: '',
role: 'assistant',
content: `## Token Usage\n\nToken usage tracking is available after sending messages. Check the token count displayed at the bottom of each assistant response.`,
content: `${t('chat.tokenUsageTitle')}\n\n${t('chat.noTokenUsage')}`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -345,7 +371,7 @@ export default function NewChatPage() {
default:
sendFirstMessage(command);
}
}, [sendFirstMessage]);
}, [sendFirstMessage, t]);

return (
<div className="flex h-full min-h-0 flex-col">
Expand Down
8 changes: 5 additions & 3 deletions src/app/extensions/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@

import { Suspense, useState } from "react";
import { useSearchParams } from "next/navigation";
import { useTranslation } from "@/hooks/useTranslation";
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { HugeiconsIcon } from "@hugeicons/react";
import { Loading02Icon } from "@hugeicons/core-free-icons";
Expand All@@ -28,15 +29,16 @@ function ExtensionsPageInner() {
const searchParams = useSearchParams();
const initialTab = (searchParams.get("tab") as ExtTab) || "skills";
const [tab, setTab] = useState<ExtTab>(initialTab);
const { t } = useTranslation();

return (
<div className="flex h-full flex-col">
<div className="px-6 pt-4 pb-0">
<h1 className="text-xl font-semibold mb-3">Extensions</h1>
<h1 className="text-xl font-semibold mb-3">{t('extensions.title')}</h1>
<Tabs value={tab} onValueChange={(v) => setTab(v as ExtTab)}>
<TabsList>
<TabsTrigger value="skills">Skills</TabsTrigger>
<TabsTrigger value="mcp">MCP Servers</TabsTrigger>
<TabsTrigger value="skills">{t('extensions.skills')}</TabsTrigger>
<TabsTrigger value="mcp">{t('extensions.mcpServers')}</TabsTrigger>
</TabsList>
</Tabs>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/app/layout.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { ThemeProvider } from "@/components/layout/ThemeProvider";
import { I18nProvider } from "@/components/layout/I18nProvider";
import { AppShell } from "@/components/layout/AppShell";

const geistSans = Geist({
Expand DownExpand Up@@ -30,7 +31,9 @@ export default function RootLayout({
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
<ThemeProvider>
<AppShell>{children}</AppShell>
<I18nProvider>
<AppShell>{children}</AppShell>
</I18nProvider>
</ThemeProvider>
</body>
</html>
Expand Down
27 changes: 16 additions & 11 deletions src/components/ai-elements/tool-actions-group.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@ import {
} from "@hugeicons/core-free-icons";
import { ChevronRightIcon } from 'lucide-react';
import { cn } from '@/lib/utils';
import { useTranslation } from '@/hooks/useTranslation';

// ---------------------------------------------------------------------------
// Types
Expand DownExpand Up@@ -194,15 +195,14 @@ function getRunningDescription(tools: ToolAction[]): string {
export function ToolActionsGroup({
tools,
isStreaming = false,
streamingToolOutput: _streamingToolOutput,
}: ToolActionsGroupProps) {
const hasRunningTool = tools.some((t) => t.result === undefined);
const { t } = useTranslation();

// Track whether user has manually toggled and their chosen state
const [userExpandedState, setUserExpandedState] = useState<boolean | null>(null);

// Derived: if user has toggled, use their choice; otherwise auto-expand based on streaming state
const expanded = userExpandedState !== null ? userExpandedState : (hasRunningTool || isStreaming);
const autoExpanded = hasRunningTool || isStreaming;
const [userToggled, setUserToggled] = useState(false);
const [manualExpanded, setManualExpanded] = useState(false);
const expanded = userToggled ? manualExpanded : autoExpanded;

if (tools.length === 0) return null;

Expand All@@ -211,15 +211,20 @@ export function ToolActionsGroup({
const runningDesc = getRunningDescription(tools);

const handleToggle = () => {
setUserExpandedState((prev) => prev !== null ? !prev : !expanded);
if (!userToggled) {
setUserToggled(true);
setManualExpanded(!autoExpanded);
return;
}

setManualExpanded((prev) => !prev);
};

// Build summary text parts
const summaryParts: string[] = [];
if (runningCount > 0) summaryParts.push(`${runningCount} running`);
if (doneCount > 0) summaryParts.push(`${doneCount} completed`);
if (runningCount === 0 && isStreaming) summaryParts.push('generating response');
if (summaryParts.length === 0) summaryParts.push(`${tools.length} actions`);
if (runningCount > 0) summaryParts.push(`${runningCount} ${t('toolActions.running')}`);
if (doneCount > 0) summaryParts.push(`${doneCount} ${t('toolActions.completed')}`);
if (summaryParts.length === 0) summaryParts.push(`${tools.length} ${t('toolActions.actions')}`);

return (
<div className="w-[min(100%,48rem)]">
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' feat(i18n): 添加日语 (ja) 翻译 by gy212 · Pull Request #91 · op7418/CodePilot · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/__tests__/smoke-test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -80,7 +80,8 @@ async function runSmokeTests() {
results.push({ name: route.name, status: 'PASS', details, consoleErrors, loadTimeMs: elapsed });
} catch (err: unknown) {
const elapsed = Date.now() - start;
results.push({ name: route.name, status: 'FAIL', details: err instanceof Error ? err.message : String(err), consoleErrors, loadTimeMs: elapsed });
const message = err instanceof Error ? err.message : String(err);
results.push({ name: route.name, status: 'FAIL', details: message, consoleErrors, loadTimeMs: elapsed });
}
await page.close();
}
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/unit/db-shutdown.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
* 4. Data persists across close/reopen cycles
*/

import { describe, it, before, afterEach } from 'node:test';
import { describe, it, afterEach } from 'node:test';
import assert from 'node:assert/strict';
import path from 'path';
import os from 'os';
Expand All@@ -23,7 +23,6 @@ process.env.CLAUDE_GUI_DATA_DIR = tmpDir;
// Use require to avoid top-level await issues with CJS output
/* eslint-disable @typescript-eslint/no-require-imports */
const { getDb, closeDb, createSession, getSession } = require('../../lib/db') as typeof import('../../lib/db');

describe('closeDb', () => {
afterEach(() => {
// Ensure DB is closed after each test
Expand Down
1 change: 1 addition & 0 deletions src/app/api/settings/app/route.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import { getSetting, setSetting } from '@/lib/db';
const ALLOWED_KEYS = [
'anthropic_auth_token',
'anthropic_base_url',
'locale',
'dangerously_skip_permissions',
];

Expand Down
20 changes: 11 additions & 9 deletions src/app/chat/[id]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ import { HugeiconsIcon } from "@hugeicons/react";
import { Loading02Icon, PencilEdit01Icon } from "@hugeicons/core-free-icons";
import { Input } from '@/components/ui/input';
import { usePanel } from '@/hooks/usePanel';
import { useTranslation } from '@/hooks/useTranslation';

interface ChatSessionPageProps {
params: Promise<{ id: string }>;
Expand All@@ -27,11 +28,12 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
const [editTitle, setEditTitle] = useState('');
const titleInputRef = useRef<HTMLInputElement>(null);
const { setWorkingDirectory, setSessionId, setSessionTitle: setPanelSessionTitle, setPanelOpen } = usePanel();
const { t } = useTranslation();

const handleStartEditTitle = useCallback(() => {
setEditTitle(sessionTitle || 'New Conversation');
setEditTitle(sessionTitle || t('chatSession.newConversation'));
setIsEditingTitle(true);
}, [sessionTitle]);
}, [sessionTitle, t]);

const handleSaveTitle = useCallback(async () => {
const trimmed = editTitle.trim();
Expand DownExpand Up@@ -84,7 +86,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
}
setSessionId(id);
setPanelOpen(true);
const title = data.session.title || 'New Conversation';
const title = data.session.title || t('chatSession.newConversation');
setSessionTitle(title);
setPanelSessionTitle(title);
setSessionModel(data.session.model || '');
Expand All@@ -97,7 +99,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
}

loadSession();
}, [id, setWorkingDirectory, setSessionId, setPanelSessionTitle, setPanelOpen]);
}, [id, setWorkingDirectory, setSessionId, setPanelSessionTitle, setPanelOpen, t]);

useEffect(() => {
// Reset state when switching sessions
Expand All@@ -114,7 +116,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
if (cancelled) return;
if (!res.ok) {
if (res.status === 404) {
setError('Session not found');
setError(t('chatSession.sessionNotFound'));
return;
}
throw new Error('Failed to load messages');
Expand All@@ -123,9 +125,9 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
if (cancelled) return;
setMessages(data.messages);
setHasMore(data.hasMore ?? false);
} catch (err) {
} catch {
if (cancelled) return;
setError(err instanceof Error ? err.message : 'Failed to load messages');
setError(t('chatSession.failedToLoad'));
} finally {
if (!cancelled) setLoading(false);
}
Expand All@@ -134,7 +136,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
loadMessages();

return () => { cancelled = true; };
}, [id]);
}, [id, t]);

if (loading) {
return (
Expand All@@ -150,7 +152,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
<div className="text-center space-y-2">
<p className="text-destructive font-medium">{error}</p>
<Link href="/chat" className="text-sm text-muted-foreground hover:underline">
Start a new chat
{t('chatSession.startNewChat')}
</Link>
</div>
</div>
Expand Down
56 changes: 41 additions & 15 deletions src/app/chat/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,8 @@ import type { Message, SSEEvent, SessionResponse, TokenUsage, PermissionRequestE
import { MessageList } from '@/components/chat/MessageList';
import { MessageInput } from '@/components/chat/MessageInput';
import { usePanel } from '@/hooks/usePanel';
import { useTranslation } from '@/hooks/useTranslation';
import { buildHelpContent } from '@/lib/help-content';

interface ToolUseInfo {
id: string;
Expand All@@ -18,16 +20,25 @@ interface ToolResultInfo {
content: string;
}

type UserFacingError = Error & { userMessage?: string };

function makeUserFacingError(userMessage: string, technicalMessage?: string): UserFacingError {
const error = new Error(technicalMessage || userMessage) as UserFacingError;
error.userMessage = userMessage;
return error;
}

export default function NewChatPage() {
const router = useRouter();
const { setWorkingDirectory, setPanelOpen, setPendingApprovalSessionId } = usePanel();
const { setPendingApprovalSessionId } = usePanel();
const { t } = useTranslation();
const [messages, setMessages] = useState<Message[]>([]);
const [streamingContent, setStreamingContent] = useState('');
const [isStreaming, setIsStreaming] = useState(false);
const [toolUses, setToolUses] = useState<ToolUseInfo[]>([]);
const [toolResults, setToolResults] = useState<ToolResultInfo[]>([]);
const [statusText, setStatusText] = useState<string | undefined>();
const [workingDir, setWorkingDir] = useState('');
const workingDir = '';
const [mode, setMode] = useState('code');
const [currentModel, setCurrentModel] = useState('sonnet');
const [pendingPermission, setPendingPermission] = useState<PermissionRequestEvent | null>(null);
Expand DownExpand Up@@ -84,7 +95,7 @@ export default function NewChatPage() {
id: 'hint-' + Date.now(),
session_id: '',
role: 'assistant',
content: '**Please select a project directory first.** Use the folder picker in the toolbar below to choose a working directory before sending a message.',
content: `**${t('input.selectProjectFolder')}**`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand DownExpand Up@@ -119,7 +130,13 @@ export default function NewChatPage() {

if (!createRes.ok) {
const errBody = await createRes.json().catch(() => ({}));
throw new Error(errBody.error || `Failed to create session (${createRes.status})`);
const technicalMessage = typeof errBody.error === 'string'
? errBody.error
: `Failed to create session (${createRes.status})`;
throw makeUserFacingError(
t('chat.failedToCreateSession', { status: createRes.status }),
technicalMessage,
);
}

const { session }: SessionResponse = await createRes.json();
Expand DownExpand Up@@ -148,8 +165,11 @@ export default function NewChatPage() {
});

if (!response.ok) {
const err = await response.json();
throw new Error(err.error || 'Failed to send message');
const err = await response.json().catch(() => ({}));
const technicalMessage = typeof err.error === 'string'
? err.error
: `Failed to send message (${response.status})`;
throw makeUserFacingError(t('chat.failedToSend'), technicalMessage);
}

const reader = response.body?.getReader();
Expand DownExpand Up@@ -203,7 +223,7 @@ export default function NewChatPage() {
try {
const parsed = JSON.parse(event.data);
if (parsed._progress) {
setStatusText(`Running ${parsed.tool_name}... (${Math.round(parsed.elapsed_time_seconds)}s)`);
setStatusText(t('chat.running', { tool: parsed.tool_name, seconds: Math.round(parsed.elapsed_time_seconds) }));
break;
}
} catch {
Expand All@@ -219,7 +239,7 @@ export default function NewChatPage() {
try {
const statusData = JSON.parse(event.data);
if (statusData.session_id) {
setStatusText(`Connected (${statusData.model || 'claude'})`);
setStatusText(t('chat.connected', { model: statusData.model || 'claude' }));
setTimeout(() => setStatusText(undefined), 2000);
} else if (statusData.notification) {
setStatusText(statusData.message || statusData.title || undefined);
Expand DownExpand Up@@ -251,7 +271,7 @@ export default function NewChatPage() {
break;
}
case 'error': {
accumulated += '\n\n**Error:** ' + event.data;
accumulated += '\n\n**' + t('chat.error') + ':** ' + event.data;
setStreamingContent(accumulated);
break;
}
Expand DownExpand Up@@ -286,12 +306,18 @@ export default function NewChatPage() {
router.push(`/chat/${sessionId}`);
}
} else {
const errMsg = error instanceof Error ? error.message : 'Unknown error';
const errMsg =
typeof error === 'object' &&
error !== null &&
'userMessage' in error &&
typeof (error as UserFacingError).userMessage === 'string'
? (error as UserFacingError).userMessage!
: t('chat.failedToSend');
const errorMessage: Message = {
id: 'temp-error-' + Date.now(),
session_id: '',
role: 'assistant',
content: `**Error:** ${errMsg}`,
content: `**${t('chat.error')}:** ${errMsg}`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -310,7 +336,7 @@ export default function NewChatPage() {
abortControllerRef.current = null;
}
},
[isStreaming, router, workingDir, mode, currentModel, setPendingApprovalSessionId]
[isStreaming, router, workingDir, mode, currentModel, setPendingApprovalSessionId, t]
);

const handleCommand = useCallback((command: string) => {
Expand All@@ -320,7 +346,7 @@ export default function NewChatPage() {
id: 'cmd-' + Date.now(),
session_id: '',
role: 'assistant',
content: `## Available Commands\n\n- **/help** - Show this help message\n- **/clear** - Clear conversation history\n- **/compact** - Compress conversation context\n- **/cost** - Show token usage statistics\n- **/doctor** - Check system health\n- **/init** - Initialize CLAUDE.md\n- **/review** - Start code review\n- **/terminal-setup** - Configure terminal\n\n**Tips:**\n- Type \`@\` to mention files\n- Use Shift+Enter for new line\n- Select a project folder to enable file operations`,
content: buildHelpContent(t),
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -335,7 +361,7 @@ export default function NewChatPage() {
id: 'cmd-' + Date.now(),
session_id: '',
role: 'assistant',
content: `## Token Usage\n\nToken usage tracking is available after sending messages. Check the token count displayed at the bottom of each assistant response.`,
content: `${t('chat.tokenUsageTitle')}\n\n${t('chat.noTokenUsage')}`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -345,7 +371,7 @@ export default function NewChatPage() {
default:
sendFirstMessage(command);
}
}, [sendFirstMessage]);
}, [sendFirstMessage, t]);

return (
<div className="flex h-full min-h-0 flex-col">
Expand Down
8 changes: 5 additions & 3 deletions src/app/extensions/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@

import { Suspense, useState } from "react";
import { useSearchParams } from "next/navigation";
import { useTranslation } from "@/hooks/useTranslation";
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { HugeiconsIcon } from "@hugeicons/react";
import { Loading02Icon } from "@hugeicons/core-free-icons";
Expand All@@ -28,15 +29,16 @@ function ExtensionsPageInner() {
const searchParams = useSearchParams();
const initialTab = (searchParams.get("tab") as ExtTab) || "skills";
const [tab, setTab] = useState<ExtTab>(initialTab);
const { t } = useTranslation();

return (
<div className="flex h-full flex-col">
<div className="px-6 pt-4 pb-0">
<h1 className="text-xl font-semibold mb-3">Extensions</h1>
<h1 className="text-xl font-semibold mb-3">{t('extensions.title')}</h1>
<Tabs value={tab} onValueChange={(v) => setTab(v as ExtTab)}>
<TabsList>
<TabsTrigger value="skills">Skills</TabsTrigger>
<TabsTrigger value="mcp">MCP Servers</TabsTrigger>
<TabsTrigger value="skills">{t('extensions.skills')}</TabsTrigger>
<TabsTrigger value="mcp">{t('extensions.mcpServers')}</TabsTrigger>
</TabsList>
</Tabs>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/app/layout.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { ThemeProvider } from "@/components/layout/ThemeProvider";
import { I18nProvider } from "@/components/layout/I18nProvider";
import { AppShell } from "@/components/layout/AppShell";

const geistSans = Geist({
Expand DownExpand Up@@ -30,7 +31,9 @@ export default function RootLayout({
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
<ThemeProvider>
<AppShell>{children}</AppShell>
<I18nProvider>
<AppShell>{children}</AppShell>
</I18nProvider>
</ThemeProvider>
</body>
</html>
Expand Down
27 changes: 16 additions & 11 deletions src/components/ai-elements/tool-actions-group.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@ import {
} from "@hugeicons/core-free-icons";
import { ChevronRightIcon } from 'lucide-react';
import { cn } from '@/lib/utils';
import { useTranslation } from '@/hooks/useTranslation';

// ---------------------------------------------------------------------------
// Types
Expand DownExpand Up@@ -194,15 +195,14 @@ function getRunningDescription(tools: ToolAction[]): string {
export function ToolActionsGroup({
tools,
isStreaming = false,
streamingToolOutput: _streamingToolOutput,
}: ToolActionsGroupProps) {
const hasRunningTool = tools.some((t) => t.result === undefined);
const { t } = useTranslation();

// Track whether user has manually toggled and their chosen state
const [userExpandedState, setUserExpandedState] = useState<boolean | null>(null);

// Derived: if user has toggled, use their choice; otherwise auto-expand based on streaming state
const expanded = userExpandedState !== null ? userExpandedState : (hasRunningTool || isStreaming);
const autoExpanded = hasRunningTool || isStreaming;
const [userToggled, setUserToggled] = useState(false);
const [manualExpanded, setManualExpanded] = useState(false);
const expanded = userToggled ? manualExpanded : autoExpanded;

if (tools.length === 0) return null;

Expand All@@ -211,15 +211,20 @@ export function ToolActionsGroup({
const runningDesc = getRunningDescription(tools);

const handleToggle = () => {
setUserExpandedState((prev) => prev !== null ? !prev : !expanded);
if (!userToggled) {
setUserToggled(true);
setManualExpanded(!autoExpanded);
return;
}

setManualExpanded((prev) => !prev);
};

// Build summary text parts
const summaryParts: string[] = [];
if (runningCount > 0) summaryParts.push(`${runningCount} running`);
if (doneCount > 0) summaryParts.push(`${doneCount} completed`);
if (runningCount === 0 && isStreaming) summaryParts.push('generating response');
if (summaryParts.length === 0) summaryParts.push(`${tools.length} actions`);
if (runningCount > 0) summaryParts.push(`${runningCount} ${t('toolActions.running')}`);
if (doneCount > 0) summaryParts.push(`${doneCount} ${t('toolActions.completed')}`);
if (summaryParts.length === 0) summaryParts.push(`${tools.length} ${t('toolActions.actions')}`);

return (
<div className="w-[min(100%,48rem)]">
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' feat(i18n): 添加日语 (ja) 翻译 by gy212 · Pull Request #91 · op7418/CodePilot · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/__tests__/smoke-test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -80,7 +80,8 @@ async function runSmokeTests() {
results.push({ name: route.name, status: 'PASS', details, consoleErrors, loadTimeMs: elapsed });
} catch (err: unknown) {
const elapsed = Date.now() - start;
results.push({ name: route.name, status: 'FAIL', details: err instanceof Error ? err.message : String(err), consoleErrors, loadTimeMs: elapsed });
const message = err instanceof Error ? err.message : String(err);
results.push({ name: route.name, status: 'FAIL', details: message, consoleErrors, loadTimeMs: elapsed });
}
await page.close();
}
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/unit/db-shutdown.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
* 4. Data persists across close/reopen cycles
*/

import { describe, it, before, afterEach } from 'node:test';
import { describe, it, afterEach } from 'node:test';
import assert from 'node:assert/strict';
import path from 'path';
import os from 'os';
Expand All@@ -23,7 +23,6 @@ process.env.CLAUDE_GUI_DATA_DIR = tmpDir;
// Use require to avoid top-level await issues with CJS output
/* eslint-disable @typescript-eslint/no-require-imports */
const { getDb, closeDb, createSession, getSession } = require('../../lib/db') as typeof import('../../lib/db');

describe('closeDb', () => {
afterEach(() => {
// Ensure DB is closed after each test
Expand Down
1 change: 1 addition & 0 deletions src/app/api/settings/app/route.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import { getSetting, setSetting } from '@/lib/db';
const ALLOWED_KEYS = [
'anthropic_auth_token',
'anthropic_base_url',
'locale',
'dangerously_skip_permissions',
];

Expand Down
20 changes: 11 additions & 9 deletions src/app/chat/[id]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ import { HugeiconsIcon } from "@hugeicons/react";
import { Loading02Icon, PencilEdit01Icon } from "@hugeicons/core-free-icons";
import { Input } from '@/components/ui/input';
import { usePanel } from '@/hooks/usePanel';
import { useTranslation } from '@/hooks/useTranslation';

interface ChatSessionPageProps {
params: Promise<{ id: string }>;
Expand All@@ -27,11 +28,12 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
const [editTitle, setEditTitle] = useState('');
const titleInputRef = useRef<HTMLInputElement>(null);
const { setWorkingDirectory, setSessionId, setSessionTitle: setPanelSessionTitle, setPanelOpen } = usePanel();
const { t } = useTranslation();

const handleStartEditTitle = useCallback(() => {
setEditTitle(sessionTitle || 'New Conversation');
setEditTitle(sessionTitle || t('chatSession.newConversation'));
setIsEditingTitle(true);
}, [sessionTitle]);
}, [sessionTitle, t]);

const handleSaveTitle = useCallback(async () => {
const trimmed = editTitle.trim();
Expand DownExpand Up@@ -84,7 +86,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
}
setSessionId(id);
setPanelOpen(true);
const title = data.session.title || 'New Conversation';
const title = data.session.title || t('chatSession.newConversation');
setSessionTitle(title);
setPanelSessionTitle(title);
setSessionModel(data.session.model || '');
Expand All@@ -97,7 +99,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
}

loadSession();
}, [id, setWorkingDirectory, setSessionId, setPanelSessionTitle, setPanelOpen]);
}, [id, setWorkingDirectory, setSessionId, setPanelSessionTitle, setPanelOpen, t]);

useEffect(() => {
// Reset state when switching sessions
Expand All@@ -114,7 +116,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
if (cancelled) return;
if (!res.ok) {
if (res.status === 404) {
setError('Session not found');
setError(t('chatSession.sessionNotFound'));
return;
}
throw new Error('Failed to load messages');
Expand All@@ -123,9 +125,9 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
if (cancelled) return;
setMessages(data.messages);
setHasMore(data.hasMore ?? false);
} catch (err) {
} catch {
if (cancelled) return;
setError(err instanceof Error ? err.message : 'Failed to load messages');
setError(t('chatSession.failedToLoad'));
} finally {
if (!cancelled) setLoading(false);
}
Expand All@@ -134,7 +136,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
loadMessages();

return () => { cancelled = true; };
}, [id]);
}, [id, t]);

if (loading) {
return (
Expand All@@ -150,7 +152,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
<div className="text-center space-y-2">
<p className="text-destructive font-medium">{error}</p>
<Link href="/chat" className="text-sm text-muted-foreground hover:underline">
Start a new chat
{t('chatSession.startNewChat')}
</Link>
</div>
</div>
Expand Down
56 changes: 41 additions & 15 deletions src/app/chat/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,8 @@ import type { Message, SSEEvent, SessionResponse, TokenUsage, PermissionRequestE
import { MessageList } from '@/components/chat/MessageList';
import { MessageInput } from '@/components/chat/MessageInput';
import { usePanel } from '@/hooks/usePanel';
import { useTranslation } from '@/hooks/useTranslation';
import { buildHelpContent } from '@/lib/help-content';

interface ToolUseInfo {
id: string;
Expand All@@ -18,16 +20,25 @@ interface ToolResultInfo {
content: string;
}

type UserFacingError = Error & { userMessage?: string };

function makeUserFacingError(userMessage: string, technicalMessage?: string): UserFacingError {
const error = new Error(technicalMessage || userMessage) as UserFacingError;
error.userMessage = userMessage;
return error;
}

export default function NewChatPage() {
const router = useRouter();
const { setWorkingDirectory, setPanelOpen, setPendingApprovalSessionId } = usePanel();
const { setPendingApprovalSessionId } = usePanel();
const { t } = useTranslation();
const [messages, setMessages] = useState<Message[]>([]);
const [streamingContent, setStreamingContent] = useState('');
const [isStreaming, setIsStreaming] = useState(false);
const [toolUses, setToolUses] = useState<ToolUseInfo[]>([]);
const [toolResults, setToolResults] = useState<ToolResultInfo[]>([]);
const [statusText, setStatusText] = useState<string | undefined>();
const [workingDir, setWorkingDir] = useState('');
const workingDir = '';
const [mode, setMode] = useState('code');
const [currentModel, setCurrentModel] = useState('sonnet');
const [pendingPermission, setPendingPermission] = useState<PermissionRequestEvent | null>(null);
Expand DownExpand Up@@ -84,7 +95,7 @@ export default function NewChatPage() {
id: 'hint-' + Date.now(),
session_id: '',
role: 'assistant',
content: '**Please select a project directory first.** Use the folder picker in the toolbar below to choose a working directory before sending a message.',
content: `**${t('input.selectProjectFolder')}**`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand DownExpand Up@@ -119,7 +130,13 @@ export default function NewChatPage() {

if (!createRes.ok) {
const errBody = await createRes.json().catch(() => ({}));
throw new Error(errBody.error || `Failed to create session (${createRes.status})`);
const technicalMessage = typeof errBody.error === 'string'
? errBody.error
: `Failed to create session (${createRes.status})`;
throw makeUserFacingError(
t('chat.failedToCreateSession', { status: createRes.status }),
technicalMessage,
);
}

const { session }: SessionResponse = await createRes.json();
Expand DownExpand Up@@ -148,8 +165,11 @@ export default function NewChatPage() {
});

if (!response.ok) {
const err = await response.json();
throw new Error(err.error || 'Failed to send message');
const err = await response.json().catch(() => ({}));
const technicalMessage = typeof err.error === 'string'
? err.error
: `Failed to send message (${response.status})`;
throw makeUserFacingError(t('chat.failedToSend'), technicalMessage);
}

const reader = response.body?.getReader();
Expand DownExpand Up@@ -203,7 +223,7 @@ export default function NewChatPage() {
try {
const parsed = JSON.parse(event.data);
if (parsed._progress) {
setStatusText(`Running ${parsed.tool_name}... (${Math.round(parsed.elapsed_time_seconds)}s)`);
setStatusText(t('chat.running', { tool: parsed.tool_name, seconds: Math.round(parsed.elapsed_time_seconds) }));
break;
}
} catch {
Expand All@@ -219,7 +239,7 @@ export default function NewChatPage() {
try {
const statusData = JSON.parse(event.data);
if (statusData.session_id) {
setStatusText(`Connected (${statusData.model || 'claude'})`);
setStatusText(t('chat.connected', { model: statusData.model || 'claude' }));
setTimeout(() => setStatusText(undefined), 2000);
} else if (statusData.notification) {
setStatusText(statusData.message || statusData.title || undefined);
Expand DownExpand Up@@ -251,7 +271,7 @@ export default function NewChatPage() {
break;
}
case 'error': {
accumulated += '\n\n**Error:** ' + event.data;
accumulated += '\n\n**' + t('chat.error') + ':** ' + event.data;
setStreamingContent(accumulated);
break;
}
Expand DownExpand Up@@ -286,12 +306,18 @@ export default function NewChatPage() {
router.push(`/chat/${sessionId}`);
}
} else {
const errMsg = error instanceof Error ? error.message : 'Unknown error';
const errMsg =
typeof error === 'object' &&
error !== null &&
'userMessage' in error &&
typeof (error as UserFacingError).userMessage === 'string'
? (error as UserFacingError).userMessage!
: t('chat.failedToSend');
const errorMessage: Message = {
id: 'temp-error-' + Date.now(),
session_id: '',
role: 'assistant',
content: `**Error:** ${errMsg}`,
content: `**${t('chat.error')}:** ${errMsg}`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -310,7 +336,7 @@ export default function NewChatPage() {
abortControllerRef.current = null;
}
},
[isStreaming, router, workingDir, mode, currentModel, setPendingApprovalSessionId]
[isStreaming, router, workingDir, mode, currentModel, setPendingApprovalSessionId, t]
);

const handleCommand = useCallback((command: string) => {
Expand All@@ -320,7 +346,7 @@ export default function NewChatPage() {
id: 'cmd-' + Date.now(),
session_id: '',
role: 'assistant',
content: `## Available Commands\n\n- **/help** - Show this help message\n- **/clear** - Clear conversation history\n- **/compact** - Compress conversation context\n- **/cost** - Show token usage statistics\n- **/doctor** - Check system health\n- **/init** - Initialize CLAUDE.md\n- **/review** - Start code review\n- **/terminal-setup** - Configure terminal\n\n**Tips:**\n- Type \`@\` to mention files\n- Use Shift+Enter for new line\n- Select a project folder to enable file operations`,
content: buildHelpContent(t),
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -335,7 +361,7 @@ export default function NewChatPage() {
id: 'cmd-' + Date.now(),
session_id: '',
role: 'assistant',
content: `## Token Usage\n\nToken usage tracking is available after sending messages. Check the token count displayed at the bottom of each assistant response.`,
content: `${t('chat.tokenUsageTitle')}\n\n${t('chat.noTokenUsage')}`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -345,7 +371,7 @@ export default function NewChatPage() {
default:
sendFirstMessage(command);
}
}, [sendFirstMessage]);
}, [sendFirstMessage, t]);

return (
<div className="flex h-full min-h-0 flex-col">
Expand Down
8 changes: 5 additions & 3 deletions src/app/extensions/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@

import { Suspense, useState } from "react";
import { useSearchParams } from "next/navigation";
import { useTranslation } from "@/hooks/useTranslation";
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { HugeiconsIcon } from "@hugeicons/react";
import { Loading02Icon } from "@hugeicons/core-free-icons";
Expand All@@ -28,15 +29,16 @@ function ExtensionsPageInner() {
const searchParams = useSearchParams();
const initialTab = (searchParams.get("tab") as ExtTab) || "skills";
const [tab, setTab] = useState<ExtTab>(initialTab);
const { t } = useTranslation();

return (
<div className="flex h-full flex-col">
<div className="px-6 pt-4 pb-0">
<h1 className="text-xl font-semibold mb-3">Extensions</h1>
<h1 className="text-xl font-semibold mb-3">{t('extensions.title')}</h1>
<Tabs value={tab} onValueChange={(v) => setTab(v as ExtTab)}>
<TabsList>
<TabsTrigger value="skills">Skills</TabsTrigger>
<TabsTrigger value="mcp">MCP Servers</TabsTrigger>
<TabsTrigger value="skills">{t('extensions.skills')}</TabsTrigger>
<TabsTrigger value="mcp">{t('extensions.mcpServers')}</TabsTrigger>
</TabsList>
</Tabs>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/app/layout.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { ThemeProvider } from "@/components/layout/ThemeProvider";
import { I18nProvider } from "@/components/layout/I18nProvider";
import { AppShell } from "@/components/layout/AppShell";

const geistSans = Geist({
Expand DownExpand Up@@ -30,7 +31,9 @@ export default function RootLayout({
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
<ThemeProvider>
<AppShell>{children}</AppShell>
<I18nProvider>
<AppShell>{children}</AppShell>
</I18nProvider>
</ThemeProvider>
</body>
</html>
Expand Down
27 changes: 16 additions & 11 deletions src/components/ai-elements/tool-actions-group.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@ import {
} from "@hugeicons/core-free-icons";
import { ChevronRightIcon } from 'lucide-react';
import { cn } from '@/lib/utils';
import { useTranslation } from '@/hooks/useTranslation';

// ---------------------------------------------------------------------------
// Types
Expand DownExpand Up@@ -194,15 +195,14 @@ function getRunningDescription(tools: ToolAction[]): string {
export function ToolActionsGroup({
tools,
isStreaming = false,
streamingToolOutput: _streamingToolOutput,
}: ToolActionsGroupProps) {
const hasRunningTool = tools.some((t) => t.result === undefined);
const { t } = useTranslation();

// Track whether user has manually toggled and their chosen state
const [userExpandedState, setUserExpandedState] = useState<boolean | null>(null);

// Derived: if user has toggled, use their choice; otherwise auto-expand based on streaming state
const expanded = userExpandedState !== null ? userExpandedState : (hasRunningTool || isStreaming);
const autoExpanded = hasRunningTool || isStreaming;
const [userToggled, setUserToggled] = useState(false);
const [manualExpanded, setManualExpanded] = useState(false);
const expanded = userToggled ? manualExpanded : autoExpanded;

if (tools.length === 0) return null;

Expand All@@ -211,15 +211,20 @@ export function ToolActionsGroup({
const runningDesc = getRunningDescription(tools);

const handleToggle = () => {
setUserExpandedState((prev) => prev !== null ? !prev : !expanded);
if (!userToggled) {
setUserToggled(true);
setManualExpanded(!autoExpanded);
return;
}

setManualExpanded((prev) => !prev);
};

// Build summary text parts
const summaryParts: string[] = [];
if (runningCount > 0) summaryParts.push(`${runningCount} running`);
if (doneCount > 0) summaryParts.push(`${doneCount} completed`);
if (runningCount === 0 && isStreaming) summaryParts.push('generating response');
if (summaryParts.length === 0) summaryParts.push(`${tools.length} actions`);
if (runningCount > 0) summaryParts.push(`${runningCount} ${t('toolActions.running')}`);
if (doneCount > 0) summaryParts.push(`${doneCount} ${t('toolActions.completed')}`);
if (summaryParts.length === 0) summaryParts.push(`${tools.length} ${t('toolActions.actions')}`);

return (
<div className="w-[min(100%,48rem)]">
Expand Down
Loading
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); feat(i18n): 添加日语 (ja) 翻译 by gy212 · Pull Request #91 · op7418/CodePilot · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/__tests__/smoke-test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -80,7 +80,8 @@ async function runSmokeTests() {
results.push({ name: route.name, status: 'PASS', details, consoleErrors, loadTimeMs: elapsed });
} catch (err: unknown) {
const elapsed = Date.now() - start;
results.push({ name: route.name, status: 'FAIL', details: err instanceof Error ? err.message : String(err), consoleErrors, loadTimeMs: elapsed });
const message = err instanceof Error ? err.message : String(err);
results.push({ name: route.name, status: 'FAIL', details: message, consoleErrors, loadTimeMs: elapsed });
}
await page.close();
}
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/unit/db-shutdown.test.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
* 4. Data persists across close/reopen cycles
*/

import { describe, it, before, afterEach } from 'node:test';
import { describe, it, afterEach } from 'node:test';
import assert from 'node:assert/strict';
import path from 'path';
import os from 'os';
Expand All@@ -23,7 +23,6 @@ process.env.CLAUDE_GUI_DATA_DIR = tmpDir;
// Use require to avoid top-level await issues with CJS output
/* eslint-disable @typescript-eslint/no-require-imports */
const { getDb, closeDb, createSession, getSession } = require('../../lib/db') as typeof import('../../lib/db');

describe('closeDb', () => {
afterEach(() => {
// Ensure DB is closed after each test
Expand Down
1 change: 1 addition & 0 deletions src/app/api/settings/app/route.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,6 +9,7 @@ import { getSetting, setSetting } from '@/lib/db';
const ALLOWED_KEYS = [
'anthropic_auth_token',
'anthropic_base_url',
'locale',
'dangerously_skip_permissions',
];

Expand Down
20 changes: 11 additions & 9 deletions src/app/chat/[id]/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,6 +8,7 @@ import { HugeiconsIcon } from "@hugeicons/react";
import { Loading02Icon, PencilEdit01Icon } from "@hugeicons/core-free-icons";
import { Input } from '@/components/ui/input';
import { usePanel } from '@/hooks/usePanel';
import { useTranslation } from '@/hooks/useTranslation';

interface ChatSessionPageProps {
params: Promise<{ id: string }>;
Expand All@@ -27,11 +28,12 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
const [editTitle, setEditTitle] = useState('');
const titleInputRef = useRef<HTMLInputElement>(null);
const { setWorkingDirectory, setSessionId, setSessionTitle: setPanelSessionTitle, setPanelOpen } = usePanel();
const { t } = useTranslation();

const handleStartEditTitle = useCallback(() => {
setEditTitle(sessionTitle || 'New Conversation');
setEditTitle(sessionTitle || t('chatSession.newConversation'));
setIsEditingTitle(true);
}, [sessionTitle]);
}, [sessionTitle, t]);

const handleSaveTitle = useCallback(async () => {
const trimmed = editTitle.trim();
Expand DownExpand Up@@ -84,7 +86,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
}
setSessionId(id);
setPanelOpen(true);
const title = data.session.title || 'New Conversation';
const title = data.session.title || t('chatSession.newConversation');
setSessionTitle(title);
setPanelSessionTitle(title);
setSessionModel(data.session.model || '');
Expand All@@ -97,7 +99,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
}

loadSession();
}, [id, setWorkingDirectory, setSessionId, setPanelSessionTitle, setPanelOpen]);
}, [id, setWorkingDirectory, setSessionId, setPanelSessionTitle, setPanelOpen, t]);

useEffect(() => {
// Reset state when switching sessions
Expand All@@ -114,7 +116,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
if (cancelled) return;
if (!res.ok) {
if (res.status === 404) {
setError('Session not found');
setError(t('chatSession.sessionNotFound'));
return;
}
throw new Error('Failed to load messages');
Expand All@@ -123,9 +125,9 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
if (cancelled) return;
setMessages(data.messages);
setHasMore(data.hasMore ?? false);
} catch (err) {
} catch {
if (cancelled) return;
setError(err instanceof Error ? err.message : 'Failed to load messages');
setError(t('chatSession.failedToLoad'));
} finally {
if (!cancelled) setLoading(false);
}
Expand All@@ -134,7 +136,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
loadMessages();

return () => { cancelled = true; };
}, [id]);
}, [id, t]);

if (loading) {
return (
Expand All@@ -150,7 +152,7 @@ export default function ChatSessionPage({ params }: ChatSessionPageProps) {
<div className="text-center space-y-2">
<p className="text-destructive font-medium">{error}</p>
<Link href="/chat" className="text-sm text-muted-foreground hover:underline">
Start a new chat
{t('chatSession.startNewChat')}
</Link>
</div>
</div>
Expand Down
56 changes: 41 additions & 15 deletions src/app/chat/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,8 @@ import type { Message, SSEEvent, SessionResponse, TokenUsage, PermissionRequestE
import { MessageList } from '@/components/chat/MessageList';
import { MessageInput } from '@/components/chat/MessageInput';
import { usePanel } from '@/hooks/usePanel';
import { useTranslation } from '@/hooks/useTranslation';
import { buildHelpContent } from '@/lib/help-content';

interface ToolUseInfo {
id: string;
Expand All@@ -18,16 +20,25 @@ interface ToolResultInfo {
content: string;
}

type UserFacingError = Error & { userMessage?: string };

function makeUserFacingError(userMessage: string, technicalMessage?: string): UserFacingError {
const error = new Error(technicalMessage || userMessage) as UserFacingError;
error.userMessage = userMessage;
return error;
}

export default function NewChatPage() {
const router = useRouter();
const { setWorkingDirectory, setPanelOpen, setPendingApprovalSessionId } = usePanel();
const { setPendingApprovalSessionId } = usePanel();
const { t } = useTranslation();
const [messages, setMessages] = useState<Message[]>([]);
const [streamingContent, setStreamingContent] = useState('');
const [isStreaming, setIsStreaming] = useState(false);
const [toolUses, setToolUses] = useState<ToolUseInfo[]>([]);
const [toolResults, setToolResults] = useState<ToolResultInfo[]>([]);
const [statusText, setStatusText] = useState<string | undefined>();
const [workingDir, setWorkingDir] = useState('');
const workingDir = '';
const [mode, setMode] = useState('code');
const [currentModel, setCurrentModel] = useState('sonnet');
const [pendingPermission, setPendingPermission] = useState<PermissionRequestEvent | null>(null);
Expand DownExpand Up@@ -84,7 +95,7 @@ export default function NewChatPage() {
id: 'hint-' + Date.now(),
session_id: '',
role: 'assistant',
content: '**Please select a project directory first.** Use the folder picker in the toolbar below to choose a working directory before sending a message.',
content: `**${t('input.selectProjectFolder')}**`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand DownExpand Up@@ -119,7 +130,13 @@ export default function NewChatPage() {

if (!createRes.ok) {
const errBody = await createRes.json().catch(() => ({}));
throw new Error(errBody.error || `Failed to create session (${createRes.status})`);
const technicalMessage = typeof errBody.error === 'string'
? errBody.error
: `Failed to create session (${createRes.status})`;
throw makeUserFacingError(
t('chat.failedToCreateSession', { status: createRes.status }),
technicalMessage,
);
}

const { session }: SessionResponse = await createRes.json();
Expand DownExpand Up@@ -148,8 +165,11 @@ export default function NewChatPage() {
});

if (!response.ok) {
const err = await response.json();
throw new Error(err.error || 'Failed to send message');
const err = await response.json().catch(() => ({}));
const technicalMessage = typeof err.error === 'string'
? err.error
: `Failed to send message (${response.status})`;
throw makeUserFacingError(t('chat.failedToSend'), technicalMessage);
}

const reader = response.body?.getReader();
Expand DownExpand Up@@ -203,7 +223,7 @@ export default function NewChatPage() {
try {
const parsed = JSON.parse(event.data);
if (parsed._progress) {
setStatusText(`Running ${parsed.tool_name}... (${Math.round(parsed.elapsed_time_seconds)}s)`);
setStatusText(t('chat.running', { tool: parsed.tool_name, seconds: Math.round(parsed.elapsed_time_seconds) }));
break;
}
} catch {
Expand All@@ -219,7 +239,7 @@ export default function NewChatPage() {
try {
const statusData = JSON.parse(event.data);
if (statusData.session_id) {
setStatusText(`Connected (${statusData.model || 'claude'})`);
setStatusText(t('chat.connected', { model: statusData.model || 'claude' }));
setTimeout(() => setStatusText(undefined), 2000);
} else if (statusData.notification) {
setStatusText(statusData.message || statusData.title || undefined);
Expand DownExpand Up@@ -251,7 +271,7 @@ export default function NewChatPage() {
break;
}
case 'error': {
accumulated += '\n\n**Error:** ' + event.data;
accumulated += '\n\n**' + t('chat.error') + ':** ' + event.data;
setStreamingContent(accumulated);
break;
}
Expand DownExpand Up@@ -286,12 +306,18 @@ export default function NewChatPage() {
router.push(`/chat/${sessionId}`);
}
} else {
const errMsg = error instanceof Error ? error.message : 'Unknown error';
const errMsg =
typeof error === 'object' &&
error !== null &&
'userMessage' in error &&
typeof (error as UserFacingError).userMessage === 'string'
? (error as UserFacingError).userMessage!
: t('chat.failedToSend');
const errorMessage: Message = {
id: 'temp-error-' + Date.now(),
session_id: '',
role: 'assistant',
content: `**Error:** ${errMsg}`,
content: `**${t('chat.error')}:** ${errMsg}`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -310,7 +336,7 @@ export default function NewChatPage() {
abortControllerRef.current = null;
}
},
[isStreaming, router, workingDir, mode, currentModel, setPendingApprovalSessionId]
[isStreaming, router, workingDir, mode, currentModel, setPendingApprovalSessionId, t]
);

const handleCommand = useCallback((command: string) => {
Expand All@@ -320,7 +346,7 @@ export default function NewChatPage() {
id: 'cmd-' + Date.now(),
session_id: '',
role: 'assistant',
content: `## Available Commands\n\n- **/help** - Show this help message\n- **/clear** - Clear conversation history\n- **/compact** - Compress conversation context\n- **/cost** - Show token usage statistics\n- **/doctor** - Check system health\n- **/init** - Initialize CLAUDE.md\n- **/review** - Start code review\n- **/terminal-setup** - Configure terminal\n\n**Tips:**\n- Type \`@\` to mention files\n- Use Shift+Enter for new line\n- Select a project folder to enable file operations`,
content: buildHelpContent(t),
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -335,7 +361,7 @@ export default function NewChatPage() {
id: 'cmd-' + Date.now(),
session_id: '',
role: 'assistant',
content: `## Token Usage\n\nToken usage tracking is available after sending messages. Check the token count displayed at the bottom of each assistant response.`,
content: `${t('chat.tokenUsageTitle')}\n\n${t('chat.noTokenUsage')}`,
created_at: new Date().toISOString(),
token_usage: null,
};
Expand All@@ -345,7 +371,7 @@ export default function NewChatPage() {
default:
sendFirstMessage(command);
}
}, [sendFirstMessage]);
}, [sendFirstMessage, t]);

return (
<div className="flex h-full min-h-0 flex-col">
Expand Down
8 changes: 5 additions & 3 deletions src/app/extensions/page.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@

import { Suspense, useState } from "react";
import { useSearchParams } from "next/navigation";
import { useTranslation } from "@/hooks/useTranslation";
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { HugeiconsIcon } from "@hugeicons/react";
import { Loading02Icon } from "@hugeicons/core-free-icons";
Expand All@@ -28,15 +29,16 @@ function ExtensionsPageInner() {
const searchParams = useSearchParams();
const initialTab = (searchParams.get("tab") as ExtTab) || "skills";
const [tab, setTab] = useState<ExtTab>(initialTab);
const { t } = useTranslation();

return (
<div className="flex h-full flex-col">
<div className="px-6 pt-4 pb-0">
<h1 className="text-xl font-semibold mb-3">Extensions</h1>
<h1 className="text-xl font-semibold mb-3">{t('extensions.title')}</h1>
<Tabs value={tab} onValueChange={(v) => setTab(v as ExtTab)}>
<TabsList>
<TabsTrigger value="skills">Skills</TabsTrigger>
<TabsTrigger value="mcp">MCP Servers</TabsTrigger>
<TabsTrigger value="skills">{t('extensions.skills')}</TabsTrigger>
<TabsTrigger value="mcp">{t('extensions.mcpServers')}</TabsTrigger>
</TabsList>
</Tabs>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/app/layout.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";
import { ThemeProvider } from "@/components/layout/ThemeProvider";
import { I18nProvider } from "@/components/layout/I18nProvider";
import { AppShell } from "@/components/layout/AppShell";

const geistSans = Geist({
Expand DownExpand Up@@ -30,7 +31,9 @@ export default function RootLayout({
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
<ThemeProvider>
<AppShell>{children}</AppShell>
<I18nProvider>
<AppShell>{children}</AppShell>
</I18nProvider>
</ThemeProvider>
</body>
</html>
Expand Down
27 changes: 16 additions & 11 deletions src/components/ai-elements/tool-actions-group.tsx
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@ import {
} from "@hugeicons/core-free-icons";
import { ChevronRightIcon } from 'lucide-react';
import { cn } from '@/lib/utils';
import { useTranslation } from '@/hooks/useTranslation';

// ---------------------------------------------------------------------------
// Types
Expand DownExpand Up@@ -194,15 +195,14 @@ function getRunningDescription(tools: ToolAction[]): string {
export function ToolActionsGroup({
tools,
isStreaming = false,
streamingToolOutput: _streamingToolOutput,
}: ToolActionsGroupProps) {
const hasRunningTool = tools.some((t) => t.result === undefined);
const { t } = useTranslation();

// Track whether user has manually toggled and their chosen state
const [userExpandedState, setUserExpandedState] = useState<boolean | null>(null);

// Derived: if user has toggled, use their choice; otherwise auto-expand based on streaming state
const expanded = userExpandedState !== null ? userExpandedState : (hasRunningTool || isStreaming);
const autoExpanded = hasRunningTool || isStreaming;
const [userToggled, setUserToggled] = useState(false);
const [manualExpanded, setManualExpanded] = useState(false);
const expanded = userToggled ? manualExpanded : autoExpanded;

if (tools.length === 0) return null;

Expand All@@ -211,15 +211,20 @@ export function ToolActionsGroup({
const runningDesc = getRunningDescription(tools);

const handleToggle = () => {
setUserExpandedState((prev) => prev !== null ? !prev : !expanded);
if (!userToggled) {
setUserToggled(true);
setManualExpanded(!autoExpanded);
return;
}

setManualExpanded((prev) => !prev);
};

// Build summary text parts
const summaryParts: string[] = [];
if (runningCount > 0) summaryParts.push(`${runningCount} running`);
if (doneCount > 0) summaryParts.push(`${doneCount} completed`);
if (runningCount === 0 && isStreaming) summaryParts.push('generating response');
if (summaryParts.length === 0) summaryParts.push(`${tools.length} actions`);
if (runningCount > 0) summaryParts.push(`${runningCount} ${t('toolActions.running')}`);
if (doneCount > 0) summaryParts.push(`${doneCount} ${t('toolActions.completed')}`);
if (summaryParts.length === 0) summaryParts.push(`${tools.length} ${t('toolActions.actions')}`);

return (
<div className="w-[min(100%,48rem)]">
Expand Down
Loading