Merge main into feature/TTS and resolve conflicts

This commit is contained in:
Chris Scott committed 2025-12-15 14:50:04 -05:00
commit 67cb729ca7
19 files changed
+963 -524

No files matched your search

+20 -64
View File
@@ -15,15 +15,11 @@ import { CommandSuggestions } from '@/components/command/CommandSuggestions'
import { MentionSuggestions, type MentionItem } from './MentionSuggestions'
import { SessionStatusIndicator } from '@/components/ui/session-status-indicator'
import { detectMentionTrigger, parsePromptToParts, getFilename, filterAgentsByQuery } from '@/lib/promptParser'
import { getModel, formatModelName } from '@/api/providers'
import type { components } from '@/api/opencode-types'
import type { MessageWithParts, FileInfo } from '@/api/types'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'
type CommandType = components['schemas']['Command']
@@ -55,7 +51,7 @@ export function PromptInput({
onExportSession
}: PromptInputProps) {
const [prompt, setPrompt] = useState('')
const [modelName, setModelName] = useState<string>('')
const [isBashMode, setIsBashMode] = useState(false)
const [showSuggestions, setShowSuggestions] = useState(false)
const [suggestionQuery, setSuggestionQuery] = useState('')
@@ -452,33 +448,16 @@ export function PromptInput({
const modeColor = currentMode === 'plan' ? 'text-yellow-600 dark:text-yellow-500' : 'text-green-600 dark:text-green-500'
const modeBg = currentMode === 'plan' ? 'bg-yellow-500/10 border-yellow-500/30' : 'bg-green-500/10 border-green-500/30'
const { model: selectedModel, modelString } = useModelSelection(opcodeUrl, directory)
const { modelString } = useModelSelection(opcodeUrl, directory)
const currentModel = modelString || ''
const isMobile = useMobile()
const sessionStatus = useSessionStatusForSession(sessionID)
const showStopButton = hasActiveStream && (sessionStatus.type === 'busy' || sessionStatus.type === 'retry')
const hideSecondaryButtons = isMobile && hasActiveStream
useEffect(() => {
const loadModelName = async () => {
if (selectedModel) {
try {
const model = await getModel(selectedModel.providerID, selectedModel.modelID)
if (model) {
setModelName(formatModelName(model))
} else {
setModelName(currentModel)
}
} catch {
setModelName(currentModel)
}
} else {
setModelName('No model selected')
}
}
loadModelName()
}, [selectedModel, currentModel])
useEffect(() => {
if (textareaRef.current && !disabled) {
@@ -490,11 +469,7 @@ export function PromptInput({
return (
<div className="relative backdrop-blur-md bg-background opacity-95 border border-border dark:border-white/30 rounded-xl p-2 md:p-3 md:mx-4 mb-4 md:mb-1 w-[94%] md:max-w-4xl">
{hasActiveStream && (
<div className="pb-1">
<SessionStatusIndicator sessionID={sessionID} />
</div>
)}
<textarea
ref={textareaRef}
@@ -527,40 +502,21 @@ export function PromptInput({
>
{isBashMode ? 'BASH' : currentMode.toUpperCase()}
</button>
{!hideSecondaryButtons && (
<button
onClick={onShowModelsDialog}
className="px-2 py-1 rounded-md text-xs font-medium border bg-muted border-border text-muted-foreground hover:bg-muted-foreground/10 transition-colors cursor-pointer max-w-[120px] md:max-w-[180px] truncate"
>
{modelName.length > 12 ? modelName.substring(0, 10) + '...' : modelName || 'Select model'}
</button>
)}
{!hideSecondaryButtons && (
<DropdownMenu>
<DropdownMenuTrigger asChild>
{hasActiveStream ? (
<div className="px-2 py-1 rounded-md text-xs font-medium border bg-muted border-border text-muted-foreground max-w-[120px] md:max-w-[180px] truncate">
<SessionStatusIndicator sessionID={sessionID} />
</div>
) : (
!hideSecondaryButtons && (
<button
className="w-6 h-6 rounded-full border-2 border-foreground text-foreground hover:bg-foreground hover:text-background transition-colors flex items-center justify-center text-sm font-medium flex-shrink-0"
title="Help"
onClick={onShowModelsDialog}
className="px-2 py-1 rounded-md text-xs font-medium border bg-muted border-border text-muted-foreground hover:bg-muted-foreground/10 transition-colors cursor-pointer max-w-[120px] md:max-w-[180px] truncate"
>
?
{currentModel.length > 12 ? currentModel.substring(0, 10) + '...' : currentModel || 'Select model'}
</button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-64">
<DropdownMenuItem disabled className="text-xs text-muted-foreground font-medium">
Keyboard Shortcuts
</DropdownMenuItem>
<DropdownMenuItem disabled className="text-xs text-muted-foreground">
<span className="font-mono">Cmd/Ctrl+Enter</span> - Send message
</DropdownMenuItem>
<DropdownMenuItem disabled className="text-xs text-muted-foreground">
<span className="font-mono">@</span> - Mention files or agents
</DropdownMenuItem>
<DropdownMenuItem disabled className="text-xs text-muted-foreground">
<span className="font-mono">!</span> - Bash command mode
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)}
)
)}
</div>
<div className="flex items-center gap-1.5 md:gap-2 flex-shrink-0">
<button
@@ -1,6 +1,6 @@
import { useState } from "react";
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { createRepo } from "@/api/repos";
import { createRepo, createBranch } from "@/api/repos";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import {
@@ -15,24 +15,32 @@ interface AddBranchWorkspaceDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
repoUrl: string;
repoId: number;
}
export function AddBranchWorkspaceDialog({
open,
onOpenChange,
repoUrl,
repoId,
}: AddBranchWorkspaceDialogProps) {
const [branch, setBranch] = useState("");
const [useWorktree, setUseWorktree] = useState(true);
const [useWorktree, setUseWorktree] = useState(false);
const queryClient = useQueryClient();
const mutation = useMutation({
mutationFn: () =>
createRepo(repoUrl, undefined, branch || undefined, undefined, useWorktree),
mutationFn: () => {
if (useWorktree) {
return createRepo(repoUrl, undefined, branch || undefined, undefined, true)
}
return createBranch(repoId, branch)
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ["repos"] });
queryClient.invalidateQueries({ queryKey: ["branches", repoId] });
queryClient.invalidateQueries({ queryKey: ["repo", repoId] });
setBranch("");
setUseWorktree(true);
setUseWorktree(false);
onOpenChange(false);
},
});
@@ -54,10 +62,10 @@ export function AddBranchWorkspaceDialog({
<DialogContent className="max-w-[90%] sm:max-w-[500px] bg-[#141414] border-[#2a2a2a]">
<DialogHeader>
<DialogTitle className="text-xl bg-gradient-to-r from-white to-gray-300 bg-clip-text text-transparent">
Add Branch Workspace
Add Branch
</DialogTitle>
<p className="text-sm text-zinc-400 mt-1">
Create a new workspace for{" "}
Create a new branch for{" "}
{repoUrl.split("/").pop()?.replace(".git", "")}
</p>
</DialogHeader>
@@ -99,8 +107,8 @@ export function AddBranchWorkspaceDialog({
</div>
<p className="text-xs text-zinc-500">
{useWorktree
? "Creates a git worktree - shares git history with base repo (recommended, faster)"
: "Creates a full clone - independent copy of the repository (slower, more disk space)"}
? "Creates a separate workspace directory - allows working on multiple branches simultaneously"
: "Creates a local branch in the current repository"}
</p>
</div>
@@ -112,12 +120,12 @@ export function AddBranchWorkspaceDialog({
{mutation.isPending ? (
<>
<Loader2 className="w-4 h-4 mr-2 animate-spin" />
{useWorktree ? "Creating worktree..." : "Cloning..."}
{useWorktree ? "Creating worktree..." : "Creating branch..."}
</>
) : useWorktree ? (
"Create Worktree"
) : (
"Clone Branch"
"Create Branch"
)}
</Button>
{mutation.isError && (
+83 -47
View File
@@ -9,10 +9,11 @@ import {
} from "@/components/ui/dropdown-menu";
import { GitBranch, Check, Plus, GitCommit, Loader2 } from "lucide-react";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { listBranches, switchBranch } from "@/api/repos";
import { listBranches, switchBranch, GitAuthError } from "@/api/repos";
import { useGitStatus } from "@/api/git";
import { AddBranchWorkspaceDialog } from "@/components/repo/AddBranchWorkspaceDialog";
import { GitChangesSheet } from "@/components/file-browser/GitChangesSheet";
import { showToast } from "@/lib/toast";
interface BranchSwitcherProps {
repoId: number;
@@ -45,16 +46,22 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, rep
const switchBranchMutation = useMutation({
mutationFn: (branch: string) => switchBranch(repoId, branch),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ["repo", repoId] });
onSuccess: (updatedRepo) => {
queryClient.setQueryData(["repo", repoId], updatedRepo);
queryClient.invalidateQueries({ queryKey: ["branches", repoId] });
queryClient.invalidateQueries({ queryKey: ["repos"] });
},
onError: (error) => {
if (error instanceof GitAuthError) {
showToast.error('Authentication failed. Please update your Git token in Settings or run "gh auth login".');
} else {
showToast.error(error.message || 'Failed to switch branch');
}
},
});
if (isWorktree) {
return null;
}
const isCurrentBranchInList = branches?.all?.includes(currentBranch) ?? false;
const showLoading = switchBranchMutation.isPending || (branchesLoading && !isCurrentBranchInList);
return (
<>
@@ -66,7 +73,7 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, rep
disabled={switchBranchMutation.isPending}
className={`h-6 px-1 sm:px-2 text-[10px] sm:text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 hover:bg-accent gap-1 border border-blue-500/20 ${iconOnly ? 'w-6' : ''} ${className || ""}`}
>
{switchBranchMutation.isPending ? (
{showLoading ? (
<Loader2 className="w-3 h-3 animate-spin" />
) : (
<GitBranch className="w-3 h-3" />
@@ -75,58 +82,86 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, rep
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent sideOffset={0} align="end" className="bg-card border-border min-w-[200px]">
{branchesLoading ? (
<DropdownMenuItem disabled className="text-muted-foreground">
Loading branches...
</DropdownMenuItem>
) : branches?.local && branches.local.length > 0 ? (
branches.local.map((branch: string) => (
<DropdownMenuItem
key={branch}
onClick={() => switchBranchMutation.mutate(branch)}
disabled={switchBranchMutation.isPending}
className="text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer"
>
{isWorktree ? (
<>
<DropdownMenuItem disabled className="text-muted-foreground">
<div className="flex items-center gap-2 w-full">
<GitBranch className="w-3 h-3" />
<span className="flex-1">{branch}</span>
{branch === currentBranch && <Check className="w-3 h-3 text-green-500" />}
<span className="flex-1">Worktree: {currentBranch}</span>
</div>
</DropdownMenuItem>
))
) : (
<DropdownMenuItem disabled className="text-muted-foreground">
No branches available
</DropdownMenuItem>
)}
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => setGitChangesOpen(true)}
className="text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer"
>
<div className="flex items-center gap-2 w-full">
<GitCommit className="w-3 h-3" />
<span className="flex-1">View Changes</span>
{gitStatus?.hasChanges && (
<span className="text-xs text-yellow-500">
{gitStatus.files.length}
</span>
)}
</div>
</DropdownMenuItem>
{!isWorktree && repoUrl && (
<>
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => setAddBranchOpen(true)}
onClick={() => setGitChangesOpen(true)}
className="text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer"
>
<div className="flex items-center gap-2 w-full">
<Plus className="w-3 h-3" />
<span className="flex-1">Add Branch</span>
<GitCommit className="w-3 h-3" />
<span className="flex-1">View Changes</span>
{gitStatus?.hasChanges && (
<span className="text-xs text-yellow-500">
{gitStatus.files.length}
</span>
)}
</div>
</DropdownMenuItem>
</>
) : (
<>
{branchesLoading ? (
<DropdownMenuItem disabled className="text-muted-foreground">
Loading branches...
</DropdownMenuItem>
) : branches?.all && branches.all.length > 0 ? (
branches.all.map((branch: string) => (
<DropdownMenuItem
key={branch}
onClick={() => switchBranchMutation.mutate(branch)}
disabled={switchBranchMutation.isPending}
className="text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer"
>
<div className="flex items-center gap-2 w-full">
<GitBranch className="w-3 h-3" />
<span className="flex-1">{branch}</span>
{branch === currentBranch && <Check className="w-3 h-3 text-green-500" />}
</div>
</DropdownMenuItem>
))
) : (
<DropdownMenuItem disabled className="text-muted-foreground">
No branches available
</DropdownMenuItem>
)}
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => setGitChangesOpen(true)}
className="text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer"
>
<div className="flex items-center gap-2 w-full">
<GitCommit className="w-3 h-3" />
<span className="flex-1">View Changes</span>
{gitStatus?.hasChanges && (
<span className="text-xs text-yellow-500">
{gitStatus.files.length}
</span>
)}
</div>
</DropdownMenuItem>
{repoUrl && (
<>
<DropdownMenuSeparator />
<DropdownMenuItem
onClick={() => setAddBranchOpen(true)}
className="text-muted-foreground hover:text-foreground hover:bg-accent cursor-pointer"
>
<div className="flex items-center gap-2 w-full">
<Plus className="w-3 h-3" />
<span className="flex-1">Add Branch</span>
</div>
</DropdownMenuItem>
</>
)}
</>
)}
</DropdownMenuContent>
</DropdownMenu>
@@ -136,6 +171,7 @@ export function BranchSwitcher({ repoId, currentBranch, isWorktree, repoUrl, rep
open={addBranchOpen}
onOpenChange={setAddBranchOpen}
repoUrl={repoUrl}
repoId={repoId}
/>
)}
+10 -12
View File
@@ -83,7 +83,7 @@ export function RepoCard({
<Badge
className="text-xs px-2.5 py-0.5 bg-purple-600/20 text-purple-600 dark:text-purple-400 border-purple-600/40"
>
worktree
{branchToDisplay || "main"}
</Badge>
)}
{repo.cloneStatus === "cloning" && (
@@ -120,17 +120,15 @@ export function RepoCard({
Open
</Button>
{!repo.isWorktree && (
<BranchSwitcher
repoId={repo.id}
currentBranch={branchToDisplay || ""}
isWorktree={repo.isWorktree}
repoUrl={repo.repoUrl}
repoLocalPath={repo.localPath}
iconOnly={true}
className="h-10 sm:h-9 w-10"
/>
)}
<BranchSwitcher
repoId={repo.id}
currentBranch={branchToDisplay || ""}
isWorktree={repo.isWorktree}
repoUrl={repo.repoUrl}
repoLocalPath={repo.localPath}
iconOnly={true}
className="h-10 sm:h-9 w-10"
/>
<Button
size="sm"
@@ -140,7 +140,7 @@ export function PermissionRequestDialog({
return (
<Dialog open={true} onOpenChange={() => {}}>
<DialogContent hideCloseButton className="sm:max-w-md">
<DialogContent hideCloseButton className="max-w-[calc(100vw-2rem)] sm:max-w-md">
<DialogHeader>
<DialogTitle className="flex items-center gap-2">
Permission Request
@@ -163,16 +163,16 @@ export function PermissionRequestDialog({
</div>
{details.primary && (
<div className="bg-muted/50 border rounded-md p-3 max-h-32 overflow-y-auto">
<pre className="text-sm font-mono whitespace-pre-wrap break-all">
<div className="bg-muted/50 border rounded-md p-3 max-h-32 overflow-x-auto overflow-y-auto">
<pre className="text-sm font-mono whitespace-pre-wrap break-words max-w-full">
{details.primary}
</pre>
</div>
)}
{details.secondary && (
<div className="bg-muted/30 border rounded-md p-3 max-h-24 overflow-y-auto">
<pre className="text-xs font-mono whitespace-pre-wrap break-all text-muted-foreground">
<div className="bg-muted/30 border rounded-md p-3 max-h-24 overflow-x-auto overflow-y-auto">
<pre className="text-xs font-mono whitespace-pre-wrap break-words max-w-full text-muted-foreground">
{details.secondary}
</pre>
</div>
@@ -189,13 +189,13 @@ export function PermissionRequestDialog({
)}
</div>
<DialogFooter className="flex-row gap-2 sm:justify-between">
<DialogFooter className="flex-col-reverse gap-2 sm:flex-row sm:justify-between">
<Button
variant="outline"
onClick={() => handleResponse('reject')}
disabled={isLoading}
className={cn(
"flex-1",
"w-full sm:flex-1",
loadingAction === 'reject' && "opacity-70"
)}
>
@@ -206,7 +206,7 @@ export function PermissionRequestDialog({
onClick={() => handleResponse('once')}
disabled={isLoading}
className={cn(
"flex-1",
"w-full sm:flex-1",
loadingAction === 'once' && "opacity-70"
)}
>
@@ -217,7 +217,7 @@ export function PermissionRequestDialog({
onClick={() => handleResponse('always')}
disabled={isLoading}
className={cn(
"flex-1",
"w-full sm:flex-1",
loadingAction === 'always' && "opacity-70"
)}
>
@@ -5,7 +5,7 @@ import { z } from 'zod'
import { useSettings } from '@/hooks/useSettings'
import { useTTS } from '@/hooks/useTTS'
import { useTTSModels, useTTSVoices, useTTSDiscovery } from '@/api/tts'
import { Loader2, Volume2, Square, CheckCircle, XCircle, RefreshCw } from 'lucide-react'
import { Loader2, Volume2, Square, XCircle, RefreshCw } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { Switch } from '@/components/ui/switch'
@@ -49,7 +49,6 @@ export function TTSSettings() {
const { preferences, isLoading, updateSettings, isUpdating } = useSettings()
const { speak, stop, isPlaying, isLoading: isTTSLoading, error: ttsError } = useTTS()
const { refreshAll } = useTTSDiscovery()
const [testStatus, setTestStatus] = useState<'idle' | 'success' | 'error'>('idle')
const [isRefreshingDiscovery, setIsRefreshingDiscovery] = useState(false)
const form = useForm<TTSFormValues>({
@@ -124,20 +123,12 @@ export function TTSSettings() {
updateSettings({ tts: data })
}
const handleTest = async () => {
setTestStatus('idle')
try {
await speak(TEST_PHRASE)
setTestStatus('success')
setTimeout(() => setTestStatus('idle'), 3000)
} catch {
setTestStatus('error')
}
const handleTest = () => {
speak(TEST_PHRASE)
}
const handleStopTest = () => {
stop()
setTestStatus('idle')
}
if (isLoading) {
@@ -392,12 +383,6 @@ export function TTSSettings() {
Click "Refresh" to discover available voices, or check your API key and endpoint URL.
</p>
)}
{testStatus === 'success' && (
<p className="text-sm text-green-500 flex items-center gap-1">
<CheckCircle className="h-4 w-4" />
TTS is working
</p>
)}
</div>
<Button
type="button"