diff --git a/backend/package.json b/backend/package.json index 4219eda2..3815229e 100644 --- a/backend/package.json +++ b/backend/package.json @@ -7,6 +7,7 @@ "dev": "bun --watch src/index.ts", "start": "bun src/index.ts", "build": "bun build src/index.ts --outdir=dist --target=bun", + "typecheck": "tsc --noEmit", "test": "vitest", "test:ui": "vitest --ui", "test:watch": "vitest --watch", diff --git a/backend/src/services/files.ts b/backend/src/services/files.ts index 28a34b86..da6cfe6d 100644 --- a/backend/src/services/files.ts +++ b/backend/src/services/files.ts @@ -14,7 +14,7 @@ import { listDirectory } from './file-operations' import { getReposPath, FILE_LIMITS } from '@opencode-manager/shared/config/env' -import { ALLOWED_MIME_TYPES } from '@opencode-manager/shared' +import { ALLOWED_MIME_TYPES, type AllowedMimeType } from '@opencode-manager/shared' import type { ChunkedFileInfo, PatchOperation } from '@opencode-manager/shared' const SHARED_WORKSPACE_BASE = getReposPath() @@ -144,7 +144,7 @@ export async function uploadFile(userPath: string, file: File, relativePath?: st throw new Error('File too large') } - const mimeType = file.type || getMimeType(file.name) + const mimeType = (file.type || getMimeType(file.name)) as AllowedMimeType if (!ALLOWED_MIME_TYPES.includes(mimeType) && !mimeType.startsWith('text/')) { throw new Error('File type not allowed') } @@ -246,10 +246,10 @@ function validatePath(userPath: string): string { return resolved } -function getMimeType(filePath: string): string { +function getMimeType(filePath: string): AllowedMimeType { const ext = path.extname(filePath).toLowerCase() - const mimeTypes: Record = { + const mimeTypes: Record = { '.txt': 'text/plain', '.html': 'text/html', '.css': 'text/css', diff --git a/backend/src/services/git-operations.ts b/backend/src/services/git-operations.ts index a356c493..9447167c 100644 --- a/backend/src/services/git-operations.ts +++ b/backend/src/services/git-operations.ts @@ -4,6 +4,7 @@ import { getErrorMessage } from '../utils/error-utils' import { SettingsService } from './settings' import type { Database } from 'bun:sqlite' import path from 'path' +import fs from 'fs/promises' import { createGitEnv, createNoPromptGitEnv } from '../utils/git-auth' async function hasCommits(repoPath: string): Promise { @@ -140,6 +141,37 @@ function parsePorcelainV2(output: string): { branch: string; ahead: number; behi return { branch, ahead, behind, files } } +async function expandUntrackedDirectory(repoPath: string, dirPath: string): Promise { + const cleanDirPath = dirPath.endsWith('/') ? dirPath.slice(0, -1) : dirPath + const fullDirPath = path.join(repoPath, cleanDirPath) + const files: GitFileStatus[] = [] + + async function walkDir(currentPath: string, relativePath: string): Promise { + try { + const entries = await fs.readdir(currentPath, { withFileTypes: true }) + for (const entry of entries) { + const entryRelPath = relativePath ? `${relativePath}/${entry.name}` : entry.name + const entryFullPath = path.join(currentPath, entry.name) + + if (entry.isDirectory()) { + await walkDir(entryFullPath, entryRelPath) + } else { + files.push({ + path: `${cleanDirPath}/${entryRelPath}`, + status: 'untracked', + staged: false + }) + } + } + } catch { + // Ignore errors reading directory + } + } + + await walkDir(fullDirPath, '') + return files +} + export async function getGitStatus(repoPath: string, database?: Database): Promise { try { const fullPath = path.resolve(repoPath) @@ -147,12 +179,26 @@ export async function getGitStatus(repoPath: string, database?: Database): Promi const output = await executeCommand(['git', '-C', fullPath, 'status', '--porcelain=v2', '--branch'], { env }) const { branch, ahead, behind, files } = parsePorcelainV2(output) + const expandedFiles: GitFileStatus[] = [] + for (const file of files) { + if (file.status === 'untracked' && file.path.endsWith('/')) { + const dirFiles = await expandUntrackedDirectory(fullPath, file.path) + if (dirFiles.length > 0) { + expandedFiles.push(...dirFiles) + } else { + expandedFiles.push(file) + } + } else { + expandedFiles.push(file) + } + } + return { branch, ahead, behind, - files, - hasChanges: files.length > 0 + files: expandedFiles, + hasChanges: expandedFiles.length > 0 } } catch (error: unknown) { logger.error(`Failed to get git status for ${repoPath}:`, error) diff --git a/backend/test/utils/git-auth.test.ts b/backend/test/utils/git-auth.test.ts index 02a96742..9ad4d60a 100644 --- a/backend/test/utils/git-auth.test.ts +++ b/backend/test/utils/git-auth.test.ts @@ -22,8 +22,8 @@ describe('fetchGitHubUserInfo', () => { { email: 'verified@email.com', primary: true, verified: true } ]) } - global.fetch = vi.fn() - .mockResolvedValueOnce(userResponse) + global.fetch = vi.fn() as any; + (global.fetch as any).mockResolvedValueOnce(userResponse) .mockResolvedValueOnce(emailsResponse) const result = await fetchGitHubUserInfo('test_token') @@ -43,8 +43,8 @@ describe('fetchGitHubUserInfo', () => { }) } const emailsResponse = { ok: false } - global.fetch = vi.fn() - .mockResolvedValueOnce(userResponse) + global.fetch = vi.fn() as any; + (global.fetch as any).mockResolvedValueOnce(userResponse) .mockResolvedValueOnce(emailsResponse) const result = await fetchGitHubUserInfo('test_token') @@ -65,8 +65,8 @@ describe('fetchGitHubUserInfo', () => { ok: true, json: vi.fn().mockResolvedValue([]) } - global.fetch = vi.fn() - .mockResolvedValueOnce(userResponse) + global.fetch = vi.fn() as any; + (global.fetch as any).mockResolvedValueOnce(userResponse) .mockResolvedValueOnce(emailsResponse) const result = await fetchGitHubUserInfo('test_token') @@ -89,8 +89,8 @@ describe('fetchGitHubUserInfo', () => { { email: 'unverified@email.com', primary: false, verified: false } ]) } - global.fetch = vi.fn() - .mockResolvedValueOnce(userResponse) + global.fetch = vi.fn() as any; + (global.fetch as any).mockResolvedValueOnce(userResponse) .mockResolvedValueOnce(emailsResponse) const result = await fetchGitHubUserInfo('test_token') @@ -100,7 +100,8 @@ describe('fetchGitHubUserInfo', () => { it('should return null when user API fails', async () => { const userResponse = { ok: false } - global.fetch = vi.fn().mockResolvedValueOnce(userResponse) + global.fetch = vi.fn() as any; + (global.fetch as any).mockResolvedValueOnce(userResponse) const result = await fetchGitHubUserInfo('invalid_token') @@ -116,7 +117,8 @@ describe('fetchGitHubUserInfo', () => { id: null }) } - global.fetch = vi.fn().mockResolvedValueOnce(userResponse) + global.fetch = vi.fn() as any; + (global.fetch as any).mockResolvedValueOnce(userResponse) const result = await fetchGitHubUserInfo('test_token') @@ -132,7 +134,8 @@ describe('fetchGitHubUserInfo', () => { id: 123456 }) } - global.fetch = vi.fn().mockResolvedValueOnce(userResponse) + global.fetch = vi.fn() as any; + (global.fetch as any).mockResolvedValueOnce(userResponse) const result = await fetchGitHubUserInfo('test_token') @@ -149,8 +152,8 @@ describe('fetchGitHubUserInfo', () => { }) } const emailsResponse = { ok: false } - global.fetch = vi.fn() - .mockResolvedValueOnce(userResponse) + global.fetch = vi.fn() as any; + (global.fetch as any).mockResolvedValueOnce(userResponse) .mockResolvedValueOnce(emailsResponse) const result = await fetchGitHubUserInfo('test_token') @@ -160,7 +163,8 @@ describe('fetchGitHubUserInfo', () => { }) it('should handle network errors gracefully', async () => { - global.fetch = vi.fn().mockRejectedValue(new Error('Network error')) + global.fetch = vi.fn() as any; + (global.fetch as any).mockRejectedValue(new Error('Network error')) const result = await fetchGitHubUserInfo('test_token') @@ -182,8 +186,8 @@ describe('fetchGitHubUserInfo', () => { { email: 'verified@email.com', primary: true, verified: true } ]) } - global.fetch = vi.fn() - .mockResolvedValueOnce(userResponse) + global.fetch = vi.fn() as any; + (global.fetch as any).mockResolvedValueOnce(userResponse) .mockResolvedValueOnce(emailsResponse) await fetchGitHubUserInfo('test_token') @@ -250,7 +254,7 @@ describe('findGitHubCredential', () => { describe('resolveGitIdentity', () => { beforeEach(() => { vi.clearAllMocks() - global.fetch = vi.fn() + global.fetch = vi.fn() as any; }) it('should return manual identity when both name and email provided', async () => { @@ -287,8 +291,8 @@ describe('resolveGitIdentity', () => { ]) } - global.fetch = vi.fn() - .mockResolvedValueOnce(userResponse) + global.fetch = vi.fn() as any; + (global.fetch as any).mockResolvedValueOnce(userResponse) .mockResolvedValueOnce(emailsResponse) const result = await resolveGitIdentity(manual, credentials) @@ -320,8 +324,8 @@ describe('resolveGitIdentity', () => { ]) } - global.fetch = vi.fn() - .mockResolvedValueOnce(userResponse) + global.fetch = vi.fn() as any; + (global.fetch as any).mockResolvedValueOnce(userResponse) .mockResolvedValueOnce(emailsResponse) const result = await resolveGitIdentity(manual, credentials) @@ -353,8 +357,8 @@ describe('resolveGitIdentity', () => { ]) } - global.fetch = vi.fn() - .mockResolvedValueOnce(userResponse) + global.fetch = vi.fn() as any; + (global.fetch as any).mockResolvedValueOnce(userResponse) .mockResolvedValueOnce(emailsResponse) const result = await resolveGitIdentity(manual, credentials) @@ -371,7 +375,8 @@ describe('resolveGitIdentity', () => { { name: 'github', host: 'https://github.com/', token: 'invalid-token' }, ] - global.fetch = vi.fn().mockResolvedValueOnce({ ok: false }) + global.fetch = vi.fn() as any; + (global.fetch as any).mockResolvedValueOnce({ ok: false }) const result = await resolveGitIdentity(manual, credentials) @@ -397,7 +402,8 @@ describe('resolveGitIdentity', () => { { name: 'github', host: 'https://github.com/', token: 'invalid-token' }, ] - global.fetch = vi.fn().mockResolvedValueOnce({ ok: false }) + global.fetch = vi.fn() as any; + (global.fetch as any).mockResolvedValueOnce({ ok: false }) const result = await resolveGitIdentity(manual, credentials) diff --git a/frontend/package.json b/frontend/package.json index 3ca57cc8..00bd7b57 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -5,6 +5,7 @@ "scripts": { "dev": "vite", "build": "tsc -b && vite build", + "typecheck": "tsc --noEmit", "lint": "eslint .", "preview": "vite preview", "test": "vitest" diff --git a/frontend/src/components/file-browser/FileDiffView.tsx b/frontend/src/components/file-browser/FileDiffView.tsx index 8badbddc..60665006 100644 --- a/frontend/src/components/file-browser/FileDiffView.tsx +++ b/frontend/src/components/file-browser/FileDiffView.tsx @@ -1,6 +1,7 @@ import { useFileDiff } from '@/api/git' import { Loader2, FileText, FilePlus, FileX, FileEdit, File, Plus, Minus, ArrowLeft, ExternalLink } from 'lucide-react' import { Button } from '@/components/ui/button' +import { CopyButton } from '@/components/ui/copy-button' import { cn } from '@/lib/utils' import type { GitFileStatusType } from '@/types/git' @@ -60,6 +61,8 @@ const statusConfig: Record void }) { if (line.type === 'header') { return ( @@ -198,6 +201,7 @@ export function FileDiffView({ repoId, filePath, onBack, onOpenFile, isMobile = -{diffData.deletions} )} + {diffData.diff && } diff --git a/frontend/src/components/file-browser/GitChangesPanel.tsx b/frontend/src/components/file-browser/GitChangesPanel.tsx index f3f1bfa0..0dc619d6 100644 --- a/frontend/src/components/file-browser/GitChangesPanel.tsx +++ b/frontend/src/components/file-browser/GitChangesPanel.tsx @@ -1,6 +1,6 @@ -import { useState } from 'react' +import { useState, useMemo } from 'react' import { useGitStatus } from '@/api/git' -import { Loader2, FileText, FilePlus, FileX, FileEdit, File, ChevronRight, ArrowUp, ArrowDown } from 'lucide-react' +import { Loader2, FileText, FilePlus, FileX, FileEdit, File, ChevronRight, ChevronDown, ArrowUp, ArrowDown, Folder, FolderOpen } from 'lucide-react' import { cn } from '@/lib/utils' import type { GitFileStatus, GitFileStatusType } from '@/types/git' @@ -10,6 +10,16 @@ interface GitChangesPanelProps { selectedFile?: string } +interface GitTreeNode { + name: string + path: string + isDirectory: boolean + children: GitTreeNode[] + file?: GitFileStatus + fileCount: number + statusCounts: Partial> +} + const statusConfig: Record = { modified: { icon: FileEdit, color: 'text-yellow-500', label: 'Modified' }, added: { icon: FilePlus, color: 'text-green-500', label: 'Added' }, @@ -19,31 +29,201 @@ const statusConfig: Record void }) { +function buildTree(files: GitFileStatus[]): GitTreeNode[] { + const root: GitTreeNode[] = [] + const nodeMap = new Map() + + for (const file of files) { + const isDirectoryPath = file.path.endsWith('/') + const cleanPath = isDirectoryPath ? file.path.slice(0, -1) : file.path + const parts = cleanPath.split('/').filter(p => p) + + if (parts.length === 0) continue + + let currentPath = '' + let currentLevel = root + + for (let i = 0; i < parts.length; i++) { + const part = parts[i] + const isLast = i === parts.length - 1 + currentPath = currentPath ? `${currentPath}/${part}` : part + + let node = nodeMap.get(currentPath) + if (!node) { + const isDir = !isLast || isDirectoryPath + node = { + name: part, + path: currentPath, + isDirectory: isDir, + children: [], + file: (isLast && !isDirectoryPath) ? file : undefined, + fileCount: 0, + statusCounts: isDirectoryPath && isLast ? { [file.status]: 1 } : {}, + } + nodeMap.set(currentPath, node) + currentLevel.push(node) + } else if (isLast && isDirectoryPath) { + node.statusCounts[file.status] = (node.statusCounts[file.status] || 0) + 1 + } + + if (isLast && !isDirectoryPath) { + node.file = file + node.isDirectory = false + } + + currentLevel = node.children + } + } + + function aggregateCounts(node: GitTreeNode): void { + if (node.isDirectory) { + const existingCounts = { ...node.statusCounts } + node.fileCount = 0 + node.statusCounts = {} + + if (node.children.length === 0) { + node.statusCounts = existingCounts + node.fileCount = Object.values(existingCounts).reduce((a, b) => a + (b || 0), 0) || 1 + } else { + for (const child of node.children) { + aggregateCounts(child) + node.fileCount += child.isDirectory ? child.fileCount : 1 + for (const [status, count] of Object.entries(child.statusCounts)) { + node.statusCounts[status as GitFileStatusType] = + (node.statusCounts[status as GitFileStatusType] || 0) + (count as number) + } + if (child.file) { + node.statusCounts[child.file.status] = + (node.statusCounts[child.file.status] || 0) + 1 + } + } + } + } + } + + function sortNodes(nodes: GitTreeNode[]): GitTreeNode[] { + return nodes.sort((a, b) => { + if (a.isDirectory && !b.isDirectory) return -1 + if (!a.isDirectory && b.isDirectory) return 1 + return a.name.localeCompare(b.name) + }).map(node => ({ + ...node, + children: sortNodes(node.children) + })) + } + + for (const node of root) { + aggregateCounts(node) + } + + return sortNodes(root) +} + +function filterTree(nodes: GitTreeNode[], filter: GitFileStatusType | 'all'): GitTreeNode[] { + if (filter === 'all') return nodes + + return nodes + .map(node => { + if (node.isDirectory) { + const filteredChildren = filterTree(node.children, filter) + if (filteredChildren.length === 0) return null + return { ...node, children: filteredChildren } + } + return node.file?.status === filter ? node : null + }) + .filter((node): node is GitTreeNode => node !== null) +} + +interface GitTreeNodeItemProps { + node: GitTreeNode + level: number + selectedFile?: string + expandedPaths: Set + onToggle: (path: string) => void + onSelect: (path: string) => void +} + +function GitTreeNodeItem({ node, level, selectedFile, expandedPaths, onToggle, onSelect }: GitTreeNodeItemProps) { + const isExpanded = expandedPaths.has(node.path) + const isSelected = selectedFile === node.path + + if (node.isDirectory) { + const statusEntries = Object.entries(node.statusCounts) as [GitFileStatusType, number][] + const dominantStatus = statusEntries.length > 0 + ? statusEntries.reduce((a, b) => a[1] > b[1] ? a : b)[0] + : null + + return ( +
+ + {isExpanded && ( +
+ {node.children.map(child => ( + + ))} +
+ )} +
+ ) + } + + const file = node.file! const config = statusConfig[file.status] const Icon = config.icon - const fileName = file.path.split('/').pop() || file.path - const dirPath = file.path.includes('/') ? file.path.substring(0, file.path.lastIndexOf('/')) : '' return ( +
diff --git a/frontend/src/components/message/MessagePart.tsx b/frontend/src/components/message/MessagePart.tsx index f1d77fac..05227111 100644 --- a/frontend/src/components/message/MessagePart.tsx +++ b/frontend/src/components/message/MessagePart.tsx @@ -145,7 +145,8 @@ export const MessagePart = memo(function MessagePart({ part, role, allParts, par ) case 'step-finish': { const isFree = part.cost === 0 - const costText = isMobile && isFree ? null : ${part.cost.toFixed(4)} • {part.tokens.input + part.tokens.output} tokens + const totalTokens = part.tokens.input + part.tokens.output + (part.tokens.cache?.read || 0) + const costText = isMobile && isFree ? null : ${part.cost.toFixed(4)} • {totalTokens} tokens return (
{costText} diff --git a/frontend/src/components/message/TextPart.tsx b/frontend/src/components/message/TextPart.tsx index ea0a9a3e..ddefbd79 100644 --- a/frontend/src/components/message/TextPart.tsx +++ b/frontend/src/components/message/TextPart.tsx @@ -4,7 +4,8 @@ import remarkGfm from 'remark-gfm' import rehypeHighlight from 'rehype-highlight' import rehypeRaw from 'rehype-raw' import mermaid from 'mermaid' -import { Copy, Check, Maximize2, X, AlertCircle } from 'lucide-react' +import { Maximize2, X, AlertCircle } from 'lucide-react' +import { CopyButton } from '@/components/ui/copy-button' import type { components } from '@/api/opencode-types' import { useTheme } from '@/hooks/useTheme' import 'highlight.js/styles/github-dark.css' @@ -23,7 +24,6 @@ function MermaidBlock({ code }: MermaidBlockProps) { const [svg, setSvg] = useState(null) const [error, setError] = useState(null) const [isExpanded, setIsExpanded] = useState(false) - const [copied, setCopied] = useState(false) const theme = useTheme() const uniqueId = useId().replace(/:/g, '-') const renderAttempt = React.useRef(0) @@ -71,16 +71,6 @@ function MermaidBlock({ code }: MermaidBlockProps) { renderDiagram() }, [renderDiagram, theme]) - const handleCopy = async () => { - try { - await navigator.clipboard.writeText(code) - setCopied(true) - setTimeout(() => setCopied(false), 2000) - } catch (err) { - console.error('Failed to copy:', err) - } - } - if (error) { return (
@@ -94,13 +84,7 @@ function MermaidBlock({ code }: MermaidBlockProps) { {code}
- +
) } @@ -128,13 +112,7 @@ function MermaidBlock({ code }: MermaidBlockProps) { > - +
@@ -172,8 +150,6 @@ interface CodeBlockProps { } function CodeBlock({ children, className, ...props }: CodeBlockProps) { - const [copied, setCopied] = React.useState(false) - const extractTextContent = (node: React.ReactNode): string => { if (typeof node === 'string') return node if (typeof node === 'number') return node.toString() @@ -188,29 +164,13 @@ function CodeBlock({ children, className, ...props }: CodeBlockProps) { } const codeContent = extractTextContent(children) - - const handleCopyCode = async () => { - try { - await navigator.clipboard.writeText(codeContent) - setCopied(true) - setTimeout(() => setCopied(false), 2000) - } catch (error) { - console.error('Failed to copy code:', error) - } - } return (
         {children}
       
- +
) } diff --git a/frontend/src/components/message/ToolCallPart.tsx b/frontend/src/components/message/ToolCallPart.tsx index 65e23e21..0d48f708 100644 --- a/frontend/src/components/message/ToolCallPart.tsx +++ b/frontend/src/components/message/ToolCallPart.tsx @@ -247,11 +247,12 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal )} -
 navigator.clipboard.writeText(output)}
-             title="Click to copy output">
-          {output}
-        
+
+
+            {output}
+          
+ +
) } @@ -387,11 +388,14 @@ export function ToolCallPart({ part, onFileClick, onChildSessionClick }: ToolCal )}
Output:
-
 part.state.status === 'completed' && navigator.clipboard.writeText(part.state.output)}
-                     title="Click to copy output">
-                  {part.state.status === 'completed' ? part.state.output : ''}
-                
+
+
+                    {part.state.status === 'completed' ? part.state.output : ''}
+                  
+ {part.state.status === 'completed' && part.state.output && ( + + )} +
{part.state.time && (
diff --git a/frontend/src/components/ui/copy-button.tsx b/frontend/src/components/ui/copy-button.tsx index efd4afcf..01ef862e 100644 --- a/frontend/src/components/ui/copy-button.tsx +++ b/frontend/src/components/ui/copy-button.tsx @@ -1,17 +1,32 @@ -import { Copy } from 'lucide-react' +import { useState } from 'react' +import { Copy, Check } from 'lucide-react' +import { cn } from '@/lib/utils' interface CopyButtonProps { content: string - title: string + title?: string className?: string + iconSize?: 'sm' | 'md' + variant?: 'default' | 'ghost' } -export function CopyButton({ content, title, className = "" }: CopyButtonProps) { +export function CopyButton({ + content, + title = 'Copy', + className = '', + iconSize = 'md', + variant = 'default' +}: CopyButtonProps) { + const [copied, setCopied] = useState(false) + const handleCopy = async () => { + if (!content.trim()) return try { await navigator.clipboard.writeText(content) - } catch (error) { - console.error('Failed to copy content:', error) + setCopied(true) + setTimeout(() => setCopied(false), 2000) + } catch { + // Clipboard access denied or not supported } } @@ -19,13 +34,22 @@ export function CopyButton({ content, title, className = "" }: CopyButtonProps) return null } + const sizeClasses = iconSize === 'sm' ? 'w-3.5 h-3.5' : 'w-4 h-4' + const variantClasses = variant === 'ghost' + ? 'p-1 hover:bg-accent rounded' + : 'p-1.5 rounded bg-card hover:bg-card-hover text-muted-foreground hover:text-foreground' + return ( ) } diff --git a/frontend/src/hooks/useContextUsage.ts b/frontend/src/hooks/useContextUsage.ts index 08461e5f..78a70b27 100644 --- a/frontend/src/hooks/useContextUsage.ts +++ b/frontend/src/hooks/useContextUsage.ts @@ -58,7 +58,7 @@ export const useContextUsage = (opcodeUrl: string | null | undefined, sessionID: let latestAssistantMessage = assistantMessages[assistantMessages.length - 1] if (latestAssistantMessage?.info.role === 'assistant') { - const tokens = latestAssistantMessage.info.tokens.input + latestAssistantMessage.info.tokens.output + latestAssistantMessage.info.tokens.reasoning + const tokens = latestAssistantMessage.info.tokens.input + latestAssistantMessage.info.tokens.output + latestAssistantMessage.info.tokens.reasoning + (latestAssistantMessage.info.tokens.cache?.read || 0) if (tokens === 0 && assistantMessages.length > 1) { latestAssistantMessage = assistantMessages[assistantMessages.length - 2] } @@ -88,7 +88,7 @@ export const useContextUsage = (opcodeUrl: string | null | undefined, sessionID: let totalTokens = 0 if (latestAssistantMessage?.info.role === 'assistant') { - totalTokens = latestAssistantMessage.info.tokens.input + latestAssistantMessage.info.tokens.output + latestAssistantMessage.info.tokens.reasoning + totalTokens = latestAssistantMessage.info.tokens.input + latestAssistantMessage.info.tokens.output + latestAssistantMessage.info.tokens.reasoning + (latestAssistantMessage.info.tokens.cache?.read || 0) } const usagePercentage = contextLimit ? (totalTokens / contextLimit) * 100 : null diff --git a/package.json b/package.json index 39be813e..77d20436 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,9 @@ "build": "pnpm run build:backend && pnpm run build:frontend", "build:backend": "pnpm --filter backend build", "build:frontend": "pnpm --filter frontend build", + "typecheck": "pnpm run typecheck:frontend && pnpm run typecheck:backend", + "typecheck:frontend": "pnpm --filter frontend typecheck", + "typecheck:backend": "pnpm --filter backend typecheck", "test": "pnpm run test:backend", "test:backend": "pnpm --filter backend test", "lint": "pnpm run lint:frontend && pnpm run lint:backend",