mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
fix: follow up prompt preservation changes (#292)
* fix: remove unused disabled prop, throttle SW update checks, precache icon * fix: retract transient send error and restored prompt once server confirms send When a long-running prompt request drops (gateway timeout or network error) while the agent is actually working, the send error banner and the restored prompt text were left in place. Tag send errors as 'network' and clear them when the server confirms session activity (message.updated / session.idle), also clearing the restored input text. Genuine server-reported session errors (kind 'session') are preserved. * style: restyle ErrorBanner with neutral card fill and destructive accent bar Replace the all-red destructive Alert variant (transparent background, full red text) with a neutral card-filled banner, a left destructive accent bar, red icon, foreground title, and muted body/detail text. Improves the send-error and git-error banners on the dark theme.
This commit is contained in:
1 parent
71ba7371bc
commit
8d93f2f1f9
11 files changed
+215
-31
No files matched your search
@@ -17,7 +17,6 @@ interface AgentQuickSelectProps {
|
||||
currentAgent: string
|
||||
onAgentChange: (agent: string) => void
|
||||
isBashMode?: boolean
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
interface AgentInfo {
|
||||
@@ -55,7 +54,6 @@ export function AgentQuickSelect({
|
||||
currentAgent,
|
||||
onAgentChange,
|
||||
isBashMode = false,
|
||||
disabled = false,
|
||||
}: AgentQuickSelectProps) {
|
||||
const { data: agents = [] } = useAgents(opcodeUrl, directory)
|
||||
|
||||
@@ -79,7 +77,6 @@ export function AgentQuickSelect({
|
||||
const buttonContent = (
|
||||
<button
|
||||
data-toggle-mode
|
||||
disabled={disabled}
|
||||
style={styleVars as React.CSSProperties}
|
||||
className="px-2 md:px-3.5 py-1 h-[36px] rounded-lg text-sm font-medium border min-w-[56px] max-w-[80px] md:max-w-[100px] flex-shrink-0 flex items-center justify-center transition-all duration-200 active:scale-95 hover:scale-105 shadow-md text-[var(--agent-color-light)] dark:text-[var(--agent-color-dark)] bg-[var(--agent-bg-light)] dark:bg-[var(--agent-bg-dark)] border-[var(--agent-border-light)] dark:border-[var(--agent-border-dark)] hover:bg-[var(--agent-bg-hover-light)] dark:hover:bg-[var(--agent-bg-hover-dark)] hover:border-[var(--agent-border-hover-light)] dark:hover:border-[var(--agent-border-hover-dark)] shadow-[var(--agent-shadow-light)] dark:shadow-[var(--agent-shadow-dark)] hover:shadow-[var(--agent-shadow-hover-light)] dark:hover:shadow-[var(--agent-shadow-hover-dark)]"
|
||||
>
|
||||
@@ -89,7 +86,7 @@ export function AgentQuickSelect({
|
||||
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild disabled={disabled}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
{buttonContent}
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="start" className="w-64">
|
||||
|
||||
@@ -139,7 +139,6 @@ describe('PromptInput STT Gesture Tests', () => {
|
||||
directory: '/test',
|
||||
sessionID: 'test-session',
|
||||
repoId: 1,
|
||||
disabled: false,
|
||||
showScrollButton: false,
|
||||
isSessionActive: false,
|
||||
isStreamingResponse: false,
|
||||
@@ -367,6 +366,43 @@ describe('PromptInput STT Gesture Tests', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it('clears the restored prompt when the send error resolves', async () => {
|
||||
const queryClient = createTestQueryClient()
|
||||
mocks.useSendErrorStore.mockImplementation((selector) => selector({
|
||||
errors: {
|
||||
'test-session': {
|
||||
sessionID: 'test-session',
|
||||
title: 'Connection Failed',
|
||||
message: 'Could not connect.',
|
||||
failedPrompt: 'recovered prompt',
|
||||
kind: 'network',
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
const { rerender } = render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<PromptInput {...defaultProps} />
|
||||
</QueryClientProvider>,
|
||||
)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByPlaceholderText('Send a message...')).toHaveValue('recovered prompt')
|
||||
})
|
||||
|
||||
mocks.useSendErrorStore.mockImplementation((selector) => selector({ errors: {} }))
|
||||
|
||||
rerender(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<PromptInput {...defaultProps} />
|
||||
</QueryClientProvider>,
|
||||
)
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByPlaceholderText('Send a message...')).toHaveValue('')
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps stop available while active with prompt content', async () => {
|
||||
render(
|
||||
<QueryClientProvider client={createTestQueryClient()}>
|
||||
|
||||
@@ -65,7 +65,6 @@ interface PromptInputProps {
|
||||
opcodeUrl: string
|
||||
directory?: string
|
||||
sessionID: string
|
||||
disabled?: boolean
|
||||
showScrollButton?: boolean
|
||||
isSessionActive?: boolean
|
||||
isStreamingResponse?: boolean
|
||||
@@ -81,7 +80,6 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
|
||||
opcodeUrl,
|
||||
directory,
|
||||
sessionID,
|
||||
disabled,
|
||||
showScrollButton,
|
||||
isSessionActive = false,
|
||||
isStreamingResponse = false,
|
||||
@@ -241,11 +239,20 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
|
||||
const restoredFailedPromptRef = useRef<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (!failedPrompt || restoredFailedPromptRef.current === failedPrompt) return
|
||||
restoredFailedPromptRef.current = failedPrompt
|
||||
if (promptRef.current) return
|
||||
setPrompt(failedPrompt)
|
||||
textareaRef.current?.focus()
|
||||
if (failedPrompt) {
|
||||
if (restoredFailedPromptRef.current === failedPrompt) return
|
||||
restoredFailedPromptRef.current = failedPrompt
|
||||
if (promptRef.current) return
|
||||
setPrompt(failedPrompt)
|
||||
textareaRef.current?.focus()
|
||||
return
|
||||
}
|
||||
if (restoredFailedPromptRef.current !== null) {
|
||||
if (promptRef.current === restoredFailedPromptRef.current) {
|
||||
setPrompt('')
|
||||
}
|
||||
restoredFailedPromptRef.current = null
|
||||
}
|
||||
}, [failedPrompt])
|
||||
|
||||
const mentionItems = useMemo((): MentionItem[] => {
|
||||
@@ -275,7 +282,6 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
|
||||
const addUserBashCommand = useUserBash((s) => s.addUserBashCommand)
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (disabled) return
|
||||
if (!prompt.trim() && imageAttachments.length === 0) return
|
||||
|
||||
pendingVoiceAutoSubmitRef.current = false
|
||||
@@ -572,7 +578,7 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
|
||||
}
|
||||
|
||||
const handleVoicePointerDown = (event: ReactPointerEvent<HTMLDivElement>) => {
|
||||
if ((event.pointerType === 'mouse' && event.button !== 0) || disabled || isProcessing || !isRecording) {
|
||||
if ((event.pointerType === 'mouse' && event.button !== 0) || isProcessing || !isRecording) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1196,7 +1202,7 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleVoiceClick}
|
||||
disabled={disabled || isProcessing}
|
||||
disabled={isProcessing}
|
||||
className={buttonClassName}
|
||||
title={voiceButtonTitle}
|
||||
>
|
||||
@@ -1245,7 +1251,6 @@ return (
|
||||
{showStopButton && (
|
||||
<button
|
||||
onClick={handleStop}
|
||||
disabled={disabled}
|
||||
className="border fixed bottom-19 right-0 md:hidden z-50 p-3 rounded-xl transition-all duration-200 active:scale-95 hover:scale-105 bg-gradient-to-br from-red-600 to-red-700 hover:from-red-500 hover:to-red-600 text-destructive-foreground border border-red-500/60 shadow-lg shadow-red-500/30"
|
||||
title="Stop"
|
||||
>
|
||||
@@ -1267,7 +1272,6 @@ return (
|
||||
? "Enter bash command..."
|
||||
: "Send a message..."
|
||||
}
|
||||
disabled={disabled}
|
||||
className={`w-full bg-muted/50 pl-2 md:pl-3 pr-3 py-2 text-[16px] text-foreground placeholder-muted-foreground focus:outline-none focus:bg-muted/70 resize-none min-h-[40px] max-h-[120px] disabled:opacity-50 disabled:cursor-not-allowed md:text-sm rounded-lg [field-sizing:content] ${
|
||||
isBashMode
|
||||
? 'border-purple-500/50 bg-purple-500/5 focus:bg-purple-500/10'
|
||||
@@ -1324,7 +1328,6 @@ return (
|
||||
currentAgent={currentMode}
|
||||
onAgentChange={handleAgentChange}
|
||||
isBashMode={isBashMode}
|
||||
disabled={disabled}
|
||||
/>
|
||||
{isSessionActive ? (
|
||||
<div className="px-2.5 py-1.5 md:px-3 md:py-2 rounded-lg text-xs md:text-sm font-medium text-muted-foreground max-w-[120px] md:max-w-[180px]">
|
||||
@@ -1363,7 +1366,6 @@ return (
|
||||
{showStopButton && (
|
||||
<button
|
||||
onClick={handleStop}
|
||||
disabled={disabled}
|
||||
className="hidden md:block p-1.5 px-5 md:p-2 md:px-6 rounded-lg transition-all duration-200 active:scale-95 hover:scale-105 bg-gradient-to-br from-red-600 to-red-700 hover:from-red-500 hover:to-red-600 text-destructive-foreground border border-red-500/60 hover:border-red-400 shadow-md shadow-red-500/30 hover:shadow-red-500/40 ring-1 ring-red-500/20 hover:ring-red-500/30"
|
||||
title="Stop"
|
||||
>
|
||||
@@ -1394,7 +1396,7 @@ return (
|
||||
<button
|
||||
data-submit-prompt
|
||||
onClick={hasPendingPermissionForSession ? () => setShowDialog(true) : handleSubmit}
|
||||
disabled={hasPendingPermissionForSession ? false : ((!prompt.trim() && imageAttachments.length === 0) || disabled || (isPromptSubmitPending && !isStreamingResponse))}
|
||||
disabled={hasPendingPermissionForSession ? false : ((!prompt.trim() && imageAttachments.length === 0) || (isPromptSubmitPending && !isStreamingResponse))}
|
||||
className={`px-4 md:px-5 py-1.5 md:py-2 rounded-lg text-sm font-medium transition-colors dark:border flex-shrink-0 min-w-[52px] ${
|
||||
hasPendingPermissionForSession
|
||||
? 'bg-orange-500 hover:bg-orange-600 border-orange-400 text-primary-foreground ring-orange-500/20'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Alert, AlertTitle, AlertDescription } from '@/components/ui/alert'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { AlertCircle, X } from 'lucide-react'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
export interface ErrorBannerProps {
|
||||
title?: string
|
||||
@@ -12,21 +13,21 @@ export interface ErrorBannerProps {
|
||||
|
||||
export function ErrorBanner({ title, summary, detail, onDismiss, className }: ErrorBannerProps) {
|
||||
return (
|
||||
<Alert variant="destructive" className={className}>
|
||||
<Alert className={cn('bg-card border-border border-l-[3px] border-l-destructive', className)}>
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="flex items-start gap-2">
|
||||
<AlertCircle className="h-4 w-4 mt-0.5 flex-shrink-0" />
|
||||
<AlertCircle className="h-4 w-4 mt-0.5 flex-shrink-0 text-red-400" />
|
||||
<div className="flex-1 min-w-0">
|
||||
{title && (
|
||||
<AlertTitle className="mb-1 font-medium leading-none tracking-tight">{title}</AlertTitle>
|
||||
<AlertTitle className="mb-1 font-medium leading-none tracking-tight text-foreground">{title}</AlertTitle>
|
||||
)}
|
||||
<AlertDescription className="text-sm">{summary}</AlertDescription>
|
||||
<AlertDescription className="text-sm text-muted-foreground">{summary}</AlertDescription>
|
||||
</div>
|
||||
{onDismiss && (
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-7 w-7 p-0 flex-shrink-0"
|
||||
className="h-7 w-7 p-0 flex-shrink-0 text-muted-foreground"
|
||||
onClick={onDismiss}
|
||||
>
|
||||
<X className="w-3.5 h-3.5" />
|
||||
@@ -34,7 +35,7 @@ export function ErrorBanner({ title, summary, detail, onDismiss, className }: Er
|
||||
)}
|
||||
</div>
|
||||
{detail && (
|
||||
<pre className="p-2 rounded border bg-destructive/5 border-destructive/20 text-xs font-mono overflow-auto max-h-32">
|
||||
<pre className="p-2 rounded border bg-background border-border text-xs font-mono text-muted-foreground overflow-auto max-h-32">
|
||||
{detail}
|
||||
</pre>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user