mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 21:04:23 +01:00
feat(frontend): give the composer its own strip and let voice mode skip reading replies
This commit is contained in:
1 parent
5f4cf63f8b
commit
6904cfbc58
15 files changed
+341
-55
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { useState, useRef, useEffect, useMemo, useImperativeHandle, forwardRef, memo, useCallback, type KeyboardEvent } from 'react'
|
||||
import { useState, useRef, useEffect, useMemo, useImperativeHandle, forwardRef, memo, useCallback, type KeyboardEvent, type ReactNode } from 'react'
|
||||
import { z } from 'zod'
|
||||
import { useSendPrompt, useInterruptSession, useSendShell, useAgents, useSkills } from '@/hooks/useOpenCode'
|
||||
import { useCommands } from '@/hooks/useCommands'
|
||||
@@ -88,19 +88,19 @@ const KEYBAR_KEYS: Array<{ id: KeybarKey, symbol: string, label: string }> = [
|
||||
const COMPOSER_MODE_STYLES = {
|
||||
command: {
|
||||
label: 'COMMAND',
|
||||
frame: 'border-primary/70 ring-1 ring-primary/40 shadow-lg shadow-primary/20',
|
||||
frame: 'ring-1 ring-primary/40 shadow-lg shadow-primary/20',
|
||||
badge: 'bg-primary text-primary-foreground',
|
||||
key: 'bg-primary text-primary-foreground border-primary',
|
||||
},
|
||||
mention: {
|
||||
label: 'MENTION',
|
||||
frame: 'border-success/70 ring-1 ring-success/40 shadow-lg shadow-success/20',
|
||||
frame: 'ring-1 ring-success/40 shadow-lg shadow-success/20',
|
||||
badge: 'bg-success text-success-foreground',
|
||||
key: 'bg-success text-success-foreground border-success',
|
||||
},
|
||||
bash: {
|
||||
label: 'BASH',
|
||||
frame: 'border-warning/70 ring-1 ring-warning/40 shadow-lg shadow-warning/20',
|
||||
frame: 'ring-1 ring-warning/40 shadow-lg shadow-warning/20',
|
||||
badge: 'bg-warning text-warning-foreground',
|
||||
key: 'bg-warning text-warning-foreground border-warning',
|
||||
},
|
||||
@@ -132,6 +132,7 @@ interface PromptInputProps {
|
||||
commandActions: PageCommandActions
|
||||
onPromptChange?: (hasContent: boolean) => void
|
||||
voiceConversation?: VoiceConversationFactory
|
||||
trailingAction?: ReactNode
|
||||
}
|
||||
|
||||
export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(function PromptInput({
|
||||
@@ -145,7 +146,8 @@ export const PromptInput = memo(forwardRef<PromptInputHandle, PromptInputProps>(
|
||||
onScrollToBottom,
|
||||
commandActions,
|
||||
onPromptChange,
|
||||
voiceConversation
|
||||
voiceConversation,
|
||||
trailingAction
|
||||
}, ref) {
|
||||
const [restoredDraft] = useState(() => useComposerDraftStore.getState().getDraft(sessionID))
|
||||
const [prompt, setPrompt] = useState(restoredDraft.prompt)
|
||||
@@ -1175,7 +1177,7 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
|
||||
}}
|
||||
className={isMobile
|
||||
? 'min-h-11 min-w-11 px-0 rounded-lg transition-all duration-150 flex items-center justify-center border bg-muted hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground border-border active:bg-muted-foreground/30 active:scale-95'
|
||||
: 'p-2 rounded-lg transition-all duration-200 active:scale-95 hover:scale-105 shadow-md border flex items-center justify-center bg-muted hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground border-border'}
|
||||
: 'size-10 shrink-0 rounded-lg transition-all duration-200 active:scale-95 hover:scale-105 shadow-md border flex items-center justify-center bg-muted hover:bg-muted-foreground/20 text-muted-foreground hover:text-foreground border-border'}
|
||||
>
|
||||
<Mic className={isMobile ? 'w-6 h-6' : 'w-5 h-5'} />
|
||||
</button>
|
||||
@@ -1240,7 +1242,7 @@ if (isIOS && isSecureContext && navigator.clipboard && navigator.clipboard.read)
|
||||
: ''
|
||||
|
||||
return (
|
||||
<div className={`relative isolate border-t md:border border-border dark:border-border/30 rounded-t-xl md:rounded-xl p-2 pb-7 md:p-3 md:mb-3 w-full before:pointer-events-none before:absolute before:-inset-px before:-z-10 before:rounded-t-xl md:before:rounded-xl before:bg-background md:before:bg-background/95 before:backdrop-blur-md before:content-[''] ${hasPendingPermissionForSession ? 'border-highlight/50 ring-1 ring-highlight/30' : composerModeStyle?.frame ?? ''} ${isTakeoverOpen ? 'z-[60]' : ''}`}>
|
||||
<div className={`relative isolate rounded-t-xl md:rounded-xl p-2 pb-7 md:p-3 md:mb-3 w-full ${hasPendingPermissionForSession ? 'ring-1 ring-highlight/30' : composerModeStyle?.frame ?? ''} ${isTakeoverOpen ? 'z-[60]' : ''}`}>
|
||||
<div role="status" aria-live="polite" className="sr-only">
|
||||
{sessionActivityAnnouncement}
|
||||
</div>
|
||||
@@ -1308,7 +1310,7 @@ return (
|
||||
? "Enter bash command..."
|
||||
: "Send a message..."
|
||||
}
|
||||
className={`flex-1 min-w-0 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] ${
|
||||
className={`flex-1 min-w-0 bg-muted/50 pl-2 md:pl-3 pr-3 py-2.5 md:py-2 text-[16px] text-foreground placeholder-muted-foreground focus:outline-none focus:bg-muted/70 resize-none min-h-11 md:min-h-[40px] max-h-[120px] disabled:opacity-50 disabled:cursor-not-allowed md:text-sm rounded-lg [field-sizing:content] ${
|
||||
isBashMode
|
||||
? 'border-warning/50 bg-warning/5 focus:bg-warning/10'
|
||||
: isDragging ? 'border-info/50 border-dashed bg-info/5' : ''
|
||||
@@ -1347,6 +1349,14 @@ return (
|
||||
onChange={handleFileInputChange}
|
||||
/>
|
||||
{showVoiceMic && !hasPromptContent && !showStopButton && renderVoiceMic()}
|
||||
{trailingAction !== undefined && (
|
||||
<div
|
||||
data-testid="composer-trailing-slot"
|
||||
className="flex h-11 w-11 shrink-0 items-center justify-center md:h-10 md:w-10 @min-[86rem]/composer:absolute @min-[86rem]/composer:bottom-0 @min-[86rem]/composer:left-full @min-[86rem]/composer:ml-4 @min-[86rem]/composer:h-10 @min-[86rem]/composer:w-10"
|
||||
>
|
||||
{trailingAction}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{imageAttachments.length > 0 && (
|
||||
|
||||
Reference in new issue
Block a user