diff --git a/frontend/src/components/message/PromptInput.command.test.tsx b/frontend/src/components/message/PromptInput.command.test.tsx index 3c49ba58..122ef04f 100644 --- a/frontend/src/components/message/PromptInput.command.test.tsx +++ b/frontend/src/components/message/PromptInput.command.test.tsx @@ -3,7 +3,6 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' import { render, screen, fireEvent, act, waitFor } from '@testing-library/react' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { PromptInput, type PromptInputHandle } from './PromptInput' -import { useUIState } from '@/stores/uiStateStore' import { BUILTIN_COMMANDS } from '@/lib/builtinCommands' import { createCommandActionsMock, stubMatchMedia } from '@/test/test-utils' @@ -209,8 +208,6 @@ describe('PromptInput command submission', () => { mocks.useSendErrorStore.mockImplementation((selector: (state: unknown) => unknown) => selector({ errors: {} })) suggestionProps.isOpen = false suggestionProps.selectedIndex = 0 - useUIState.getState().clearPendingPromptCommand() - useUIState.getState().clearPendingPromptFile() }) afterEach(() => { @@ -269,13 +266,13 @@ describe('PromptInput command submission', () => { }) it('sends parsed command attachments and offsets to runCommand without injecting the selected agent', async () => { + mocks.useFileSearch.mockReturnValue({ files: ['src/App.tsx'] }) const { container } = renderComponent() - act(() => { - useUIState.getState().selectPromptFile('src/App.tsx') - }) - const input = await screen.findByPlaceholderText('Send a message...') + fireEvent.change(input, { target: { value: '@App' } }) + await waitFor(() => expect(suggestionProps.isOpen).toBe(true)) + fireEvent.keyDown(input, { key: 'Enter' }) await waitFor(() => expect(input).toHaveValue('@App.tsx ')) await attachImage(container) diff --git a/frontend/src/components/message/PromptInput.goal.test.tsx b/frontend/src/components/message/PromptInput.goal.test.tsx index 6268cdb5..9c9c3d1d 100644 --- a/frontend/src/components/message/PromptInput.goal.test.tsx +++ b/frontend/src/components/message/PromptInput.goal.test.tsx @@ -2,7 +2,6 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' import { render, screen, fireEvent, waitFor, act } from '@testing-library/react' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { PromptInput } from './PromptInput' -import { useUIState } from '@/stores/uiStateStore' import { createCommandActionsMock, stubMatchMedia } from '@/test/test-utils' const mocks = vi.hoisted(() => ({ @@ -194,8 +193,6 @@ describe('PromptInput goal mode', () => { mocks.useUserBash.mockImplementation((selector: (state: unknown) => unknown) => selector({ addUserBashCommand: vi.fn() })) mocks.useSessionAgentStore.mockImplementation((selector: (state: unknown) => unknown) => selector({ setAgent: mocks.setAgent })) mocks.useSendErrorStore.mockImplementation((selector: (state: unknown) => unknown) => selector({ errors: {} })) - useUIState.getState().clearPendingPromptCommand() - useUIState.getState().clearPendingPromptFile() }) afterEach(() => { diff --git a/frontend/src/components/message/PromptInput.mention.test.tsx b/frontend/src/components/message/PromptInput.mention.test.tsx index b348fd4e..22bc670a 100644 --- a/frontend/src/components/message/PromptInput.mention.test.tsx +++ b/frontend/src/components/message/PromptInput.mention.test.tsx @@ -2,7 +2,6 @@ import { describe, it, expect, vi, beforeEach } from 'vitest' import { render, screen, fireEvent, waitFor } from '@testing-library/react' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { PromptInput } from './PromptInput' -import { useUIState } from '@/stores/uiStateStore' import { createCommandActionsMock } from '@/test/test-utils' const mocks = vi.hoisted(() => ({ @@ -194,8 +193,6 @@ describe('PromptInput agent mention submission', () => { mocks.useSessionAgentStore.mockImplementation((selector: (state: unknown) => unknown) => selector({ setAgent: vi.fn() })) suggestionProps.isOpen = false suggestionProps.selectedIndex = 0 - useUIState.getState().clearPendingPromptCommand() - useUIState.getState().clearPendingPromptFile() }) it('sends an @agent mention as an attachment without switching the session agent', async () => { diff --git a/frontend/src/components/message/PromptInput.stt.test.tsx b/frontend/src/components/message/PromptInput.stt.test.tsx index 7db04e55..b7a786f3 100644 --- a/frontend/src/components/message/PromptInput.stt.test.tsx +++ b/frontend/src/components/message/PromptInput.stt.test.tsx @@ -2,7 +2,6 @@ import { describe, it, expect, vi, beforeEach } from 'vitest' import { render, screen, fireEvent, act, waitFor } from '@testing-library/react' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { PromptInput } from './PromptInput' -import { useUIState } from '@/stores/uiStateStore' import { createCommandActionsMock } from '@/test/test-utils' const createTestQueryClient = () => new QueryClient({ @@ -211,8 +210,6 @@ describe('PromptInput STT Gesture Tests', () => { mocks.useUserBash.mockImplementation((selector) => selector({ addUserBashCommand: vi.fn() })) mocks.useSessionAgentStore.mockImplementation((selector) => selector({ setAgent: mockSetAgent })) mocks.useSendErrorStore.mockImplementation((selector) => selector({ errors: {} })) - useUIState.getState().clearPendingPromptCommand() - useUIState.getState().clearPendingPromptFile() }) const renderComponent = (sttOverrides: Partial = {}) => { @@ -421,33 +418,6 @@ describe('PromptInput STT Gesture Tests', () => { expect(screen.getAllByTitle('Stop').length).toBeGreaterThan(0) }) - it('inserts a command selected from the mobile drawer', async () => { - renderComponent() - - act(() => { - useUIState.getState().selectPromptCommand({ - name: 'help', - description: 'Show help', - }) - }) - - await waitFor(() => { - expect(screen.getByPlaceholderText('Send a message...')).toHaveValue('/help ') - }) - }) - - it('inserts a file selected from the mobile drawer', async () => { - renderComponent() - - act(() => { - useUIState.getState().selectPromptFile('src/App.tsx') - }) - - await waitFor(() => { - expect(screen.getByPlaceholderText('Send a message...')).toHaveValue('@App.tsx ') - }) - }) - it('quick tap starts recording through click only', async () => { mockStartRecording.mockResolvedValue(true) diff --git a/frontend/src/components/message/PromptInput.tsx b/frontend/src/components/message/PromptInput.tsx index a914e01b..441211a4 100644 --- a/frontend/src/components/message/PromptInput.tsx +++ b/frontend/src/components/message/PromptInput.tsx @@ -10,7 +10,6 @@ import { useSTT } from '@/hooks/useSTT' import { useUserBash } from '@/stores/userBashStore' import { useSessionAgentStore } from '@/stores/sessionAgentStore' -import { useUIState } from '@/stores/uiStateStore' import { useSendErrorStore } from '@/stores/sendErrorStore' import { useRecentCommandsStore } from '@/stores/recentCommandsStore' import { useTouchTapSelect } from '@/hooks/useTouchTapSelect' @@ -166,10 +165,6 @@ export const PromptInput = memo(forwardRef( const promptRef = useRef(prompt) const attachedFilesRef = useRef(attachedFiles) const imageAttachmentsRef = useRef(imageAttachments) - const pendingPromptCommand = useUIState((state) => state.pendingPromptCommand) - const pendingPromptFile = useUIState((state) => state.pendingPromptFile) - const clearPendingPromptCommand = useUIState((state) => state.clearPendingPromptCommand) - const clearPendingPromptFile = useUIState((state) => state.clearPendingPromptFile) const { isRecording, @@ -582,16 +577,10 @@ export const PromptInput = memo(forwardRef( handleSubmitRef.current() }, [prompt]) - useEffect(() => { - if (!pendingPromptCommand) return - handleCommandSelect(pendingPromptCommand.command) - clearPendingPromptCommand() - }, [pendingPromptCommand, handleCommandSelect, clearPendingPromptCommand]) - - const insertFileMention = useCallback((filePath: string, range: { start: number, end: number } | null = mentionRange) => { + const insertFileMention = useCallback((filePath: string, range: { start: number, end: number }) => { const filename = getFilename(filePath) - const beforeMention = range ? prompt.slice(0, range.start) : `${prompt}${prompt.trim() ? ' ' : ''}` - const afterMention = range ? prompt.slice(range.end) : '' + const beforeMention = prompt.slice(0, range.start) + const afterMention = prompt.slice(range.end) const newPrompt = beforeMention + '@' + filename + ' ' + afterMention setPrompt(newPrompt) @@ -612,13 +601,7 @@ export const PromptInput = memo(forwardRef( }) focusPromptAt(beforeMention.length + filename.length + 2) - }, [directory, mentionRange, prompt, focusPromptAt]) - - useEffect(() => { - if (!pendingPromptFile) return - insertFileMention(pendingPromptFile.path, null) - clearPendingPromptFile() - }, [pendingPromptFile, insertFileMention, clearPendingPromptFile]) + }, [directory, prompt, focusPromptAt]) const handleMentionSelect = (item: MentionItem) => { if (!mentionRange || !textareaRef.current) return diff --git a/frontend/src/components/navigation/MoreDrawer.test.tsx b/frontend/src/components/navigation/MoreDrawer.test.tsx index ebfd892b..83d085d9 100644 --- a/frontend/src/components/navigation/MoreDrawer.test.tsx +++ b/frontend/src/components/navigation/MoreDrawer.test.tsx @@ -1,29 +1,17 @@ -import { render, screen, fireEvent } from '@testing-library/react' +import { render, screen, fireEvent, within } from '@testing-library/react' import { beforeEach, describe, it, expect, vi } from 'vitest' import { MemoryRouter, Route, Routes, useNavigate } from 'react-router-dom' import { QueryClient, QueryClientProvider } from '@tanstack/react-query' import { MoreDrawer } from './MoreDrawer' import { useAuth } from '@/hooks/useAuth' import { useServerHealth } from '@/hooks/useServerHealth' -import { useCommands } from '@/hooks/useCommands' -import { useUIState } from '@/stores/uiStateStore' import { getRepo } from '@/api/repos' vi.mock('@/hooks/useAuth') vi.mock('@/hooks/useServerHealth') -vi.mock('@/hooks/useCommands') vi.mock('@/api/repos', () => ({ getRepo: vi.fn(), })) -vi.mock('@/components/file-browser/FileBrowserSheet', () => ({ - FileBrowserSheet: ({ isOpen, basePath, onFileSelect }: { isOpen: boolean; basePath: string; onFileSelect: (file: { path: string }) => void }) => ( - isOpen ? ( -
- -
- ) : null - ), -})) vi.mock('react-router-dom', async () => { const actual = await vi.importActual('react-router-dom') return { @@ -102,17 +90,6 @@ describe('MoreDrawer', () => { beforeEach(() => { vi.clearAllMocks() vi.mocked(useNavigate).mockReturnValue(vi.fn()) - vi.mocked(useCommands).mockReturnValue({ - commands: [{ name: 'help', description: 'Show help' }], - recentNames: [], - loading: false, - error: null, - searchCommands: vi.fn(), - findCommand: vi.fn(), - }) - useUIState.getState().clearPendingPromptCommand() - useUIState.getState().clearPendingPromptFile() - useUIState.getState().setActivePromptFileBasePath(null) vi.mocked(getRepo).mockResolvedValue({ id: 1, localPath: 'wrong-repo', @@ -192,33 +169,27 @@ describe('MoreDrawer', () => { expect(screen.queryByText('OpenCode')).not.toBeInTheDocument() }) - it('shows session commands and selects a command', () => { + it('leaves commands and file mentions to the prompt input', () => { mockAuth() mockServerHealth() - const handleClose = vi.fn() - renderMoreDrawer({ initialEntry: '/repos/1/sessions/session-1', routePath: '/repos/:id/sessions/:sessionId', onClose: handleClose }) + renderMoreDrawer({ initialEntry: '/repos/1/sessions/session-1', routePath: '/repos/:id/sessions/:sessionId' }) - fireEvent.click(screen.getByText('Commands')) - expect(screen.queryByText('/help')).not.toBeInTheDocument() - fireEvent.click(screen.getByText('help')) - - expect(useUIState.getState().pendingPromptCommand?.command.name).toBe('help') - expect(handleClose).toHaveBeenCalled() + expect(screen.queryByText('Commands')).not.toBeInTheDocument() + expect(screen.queryByText('Mention File')).not.toBeInTheDocument() }) - it('opens file browser and selects a file mention', () => { + it('groups session items into workspace and project sections', () => { mockAuth() mockServerHealth() - const handleClose = vi.fn() - useUIState.getState().setActivePromptFileBasePath('repo') - renderMoreDrawer({ initialEntry: '/repos/1/sessions/session-1', routePath: '/repos/:id/sessions/:sessionId', onClose: handleClose }) + renderMoreDrawer({ initialEntry: '/repos/1/sessions/session-1', routePath: '/repos/:id/sessions/:sessionId' }) - fireEvent.click(screen.getByText('Mention File')) - expect(screen.getByTestId('mention-file-browser')).toHaveAttribute('data-base-path', 'repo') - fireEvent.click(screen.getByText('App.tsx')) + const sectionLabels = (name: string) => + within(screen.getByRole('region', { name })).getAllByRole('button').map((button) => button.textContent) - expect(useUIState.getState().pendingPromptFile?.path).toBe('src/App.tsx') - expect(handleClose).toHaveBeenCalled() + expect(sectionLabels('Workspace')).toEqual(['Files', 'Source Control', 'Terminal', 'Walkthrough', 'Preview']) + expect(sectionLabels('Project')).toEqual(['MCP', 'Skills', 'Reset Permissions', 'Schedules', 'Actions']) + expect(screen.getAllByText('Settings')).toHaveLength(1) + expect(screen.getAllByText('Logout')).toHaveLength(1) }) it('shows Assistant instead of the source repo on assistant routes', () => { diff --git a/frontend/src/components/navigation/MoreDrawer.tsx b/frontend/src/components/navigation/MoreDrawer.tsx index 70433cf4..965fdb76 100644 --- a/frontend/src/components/navigation/MoreDrawer.tsx +++ b/frontend/src/components/navigation/MoreDrawer.tsx @@ -1,21 +1,17 @@ import { useNavigate, useLocation, useParams } from 'react-router-dom' -import { useState, useRef, useEffect } from 'react' -import { ChevronDown, ChevronRight, Command as CommandIcon, FileText, FolderGit2, X, GitBranch } from 'lucide-react' +import { useRef, useEffect, type ReactNode } from 'react' +import { ChevronRight, FolderGit2, X, GitBranch, type LucideIcon } from 'lucide-react' import { useAuth } from '@/hooks/useAuth' import { useServerHealth } from '@/hooks/useServerHealth' -import { useCommands } from '@/hooks/useCommands' import { useUrlParams } from '@/hooks/useUrlParams' -import { useUIState } from '@/stores/uiStateStore' import { useQuery } from '@tanstack/react-query' import { getRepo } from '@/api/repos' import { useRefreshOnOpen } from '@/hooks/useRefreshOnOpen' import { SideDrawer, SideDrawerContent } from '@/components/ui/side-drawer' -import { FileBrowserSheet } from '@/components/file-browser/FileBrowserSheet' -import { buildMoreItems, buildNavModel, isSessionDetailPath } from './moreDrawerItems' +import { buildMoreItems, buildNavModel, isSessionDetailPath, type MoreDrawerItem } from './moreDrawerItems' import { useSwipeBack } from '@/hooks/useMobile' -import { getRepoDisplayName } from '@/lib/utils' +import { cn, getRepoDisplayName } from '@/lib/utils' import { getPathWithReturnTo, isAssistantPath } from '@/lib/navigation' -import type { CommandInfo } from '@opencode-manager/shared/opencode' import { useMobileTabBar } from '@/hooks/useMobileTabBar' interface MoreDrawerProps { @@ -23,13 +19,54 @@ interface MoreDrawerProps { onClose: () => void } +const ACCOUNT_ITEM_KEYS: ReadonlySet = new Set(['settings', 'logout']) + +const ITEM_GROUPS: ReadonlyArray<{ label: string; keys: ReadonlySet }> = [ + { label: 'Workspace', keys: new Set(['files', 'source-control', 'terminal', 'preview', 'walkthrough']) }, + { label: 'Project', keys: new Set(['mcp', 'skills', 'actions', 'schedules', 'all-schedules', 'reset-permissions']) }, +] + +function MenuSection({ label, children }: { label?: string; children: ReactNode }) { + return ( +
+ {label && ( +

{label}

+ )} + {children} +
+ ) +} + +interface MenuRowProps { + icon: LucideIcon + label: string + onClick: () => void + danger?: boolean + trailing?: boolean +} + +function MenuRow({ icon: Icon, label, onClick, danger, trailing }: MenuRowProps) { + return ( + + ) +} + export function MoreDrawer({ isOpen, onClose }: MoreDrawerProps) { const navigate = useNavigate() const location = useLocation() const { id } = useParams<{ id: string }>() const repoId = id ? Number(id) : null - const [commandsOpen, setCommandsOpen] = useState(false) - const [mentionFileBrowserOpen, setMentionFileBrowserOpen] = useState(false) const swipeRef = useRef(null) const { bind } = useSwipeBack(onClose, { enabled: isOpen, suspendsRouteSwipe: true }) const { searchParams, updateParams } = useUrlParams() @@ -38,10 +75,6 @@ export function MoreDrawer({ isOpen, onClose }: MoreDrawerProps) { const isSessionDetail = isSessionDetailPath(location.pathname) const isAssistantRoute = isAssistantPath(location.pathname) const isAssistantSession = isSessionDetail && searchParams.get('assistant') === '1' - const { commands } = useCommands({ enabled: isSessionDetail }) - const activePromptFileBasePath = useUIState((state) => state.activePromptFileBasePath) - const selectPromptCommand = useUIState((state) => state.selectPromptCommand) - const selectPromptFile = useUIState((state) => state.selectPromptFile) const { open: openMobileSheet } = useMobileTabBar() useEffect(() => { @@ -80,7 +113,15 @@ export function MoreDrawer({ isOpen, onClose }: MoreDrawerProps) { } } - const handleItemClick = (item: ReturnType[0]) => { + const handleItemClick = (item: MoreDrawerItem) => { + if (item.key === 'settings') { + handleSettingsClick() + return + } + if (item.key === 'logout') { + void handleLogoutClick() + return + } if (item.to) { const to = item.key === 'schedules' ? getPathWithReturnTo(item.to, `${location.pathname}${location.search}`) @@ -94,30 +135,10 @@ export function MoreDrawer({ isOpen, onClose }: MoreDrawerProps) { } } - const handleCommandClick = (command: CommandInfo) => { - selectPromptCommand(command) - onClose() - } - - const getPromptFilePath = (path: string) => { - if (!activePromptFileBasePath) return path - - const normalizedPath = path.replace(/^\.\//, '') - const normalizedBasePath = activePromptFileBasePath.replace(/^\.\//, '').replace(/\/+$/, '') - const basePrefix = `${normalizedBasePath}/` - - return normalizedPath.startsWith(basePrefix) - ? normalizedPath.slice(basePrefix.length) - : normalizedPath - } - - const handleFileClick = (path: string) => { - selectPromptFile(getPromptFilePath(path)) - setMentionFileBrowserOpen(false) - onClose() - } - const items = buildMoreItems(location.pathname) + const itemsInGroup = (keys: ReadonlySet) => items.filter((item) => keys.has(item.key)) + const groupedKeys = new Set([...ACCOUNT_ITEM_KEYS, ...ITEM_GROUPS.flatMap(({ keys }) => [...keys])]) + const navigationItems = items.filter((item) => !groupedKeys.has(item.key)) const assistantCta = isSessionDetail && !isAssistantSession ? buildNavModel(location.pathname).primary.find((cta) => cta.key === 'assistant') : undefined @@ -161,97 +182,44 @@ export function MoreDrawer({ isOpen, onClose }: MoreDrawerProps) { )} - - {isSessionDetail && ( -
- - {assistantCta?.to && ( - - )} - - {commandsOpen && ( -
- {commands.map((command) => ( - - ))} -
- )} - -
- )} - {items.map((item) => ( + + + {isSessionDetail && ( + openMobileSheet('repos')} trailing /> + )} + {assistantCta?.to && ( + navigate(assistantCta.to!)} /> + )} + {navigationItems.map((item) => ( + handleItemClick(item)} /> + ))} + + {ITEM_GROUPS.map(({ label, keys }) => { + const groupItems = itemsInGroup(keys) + if (groupItems.length === 0) return null + return ( + + {groupItems.map((item) => ( + handleItemClick(item)} /> + ))} + + ) + })} + +
+ {itemsInGroup(ACCOUNT_ITEM_KEYS).map((item) => ( ))} - +
- setMentionFileBrowserOpen(false)} - basePath={activePromptFileBasePath ?? ''} - onFileSelect={(file) => handleFileClick(file.path)} - /> ) } diff --git a/frontend/src/pages/SessionDetail.tsx b/frontend/src/pages/SessionDetail.tsx index a007870c..954918ce 100644 --- a/frontend/src/pages/SessionDetail.tsx +++ b/frontend/src/pages/SessionDetail.tsx @@ -272,7 +272,6 @@ export function SessionDetail() { const { modelRef } = useModelSelection(sessionDirectory, modelSelectionSession); const setSessionStatus = useSessionStatus((state) => state.setStatus); const isEditingMessage = useUIState((state) => state.isEditingMessage); - const setActivePromptFileBasePath = useUIState((state) => state.setActivePromptFileBasePath); const { isEnabled: ttsEnabled } = useTTS(); const { syncForSession: syncPermissionsForSession } = usePermissions(); const { getForSession: getFormForSession, reply: replyToForm, cancel: cancelForm, syncForSession: syncFormsForSession } = useForms(); @@ -292,14 +291,6 @@ export function SessionDetail() { const isStreamingResponse = hasIncompleteMessages && isSessionActive; const workspaceBasePath = repo?.localPath; - useEffect(() => { - setActivePromptFileBasePath(sessionDirectory ? workspaceBasePath ?? null : null) - - return () => { - setActivePromptFileBasePath(null) - } - }, [sessionDirectory, setActivePromptFileBasePath, workspaceBasePath]) - useAutoPlayLastResponse({ sessionId: sessionId ?? '', lastAssistantMessage, diff --git a/frontend/src/pages/__tests__/SessionDetail.commands.test.tsx b/frontend/src/pages/__tests__/SessionDetail.commands.test.tsx index 3950cb99..2f772ede 100644 --- a/frontend/src/pages/__tests__/SessionDetail.commands.test.tsx +++ b/frontend/src/pages/__tests__/SessionDetail.commands.test.tsx @@ -147,7 +147,7 @@ vi.mock('@/hooks/useAutoPlayLastResponse', () => ({ vi.mock('@/stores/uiStateStore', () => ({ useUIState: vi.fn((selector?: (state: Record) => unknown) => typeof selector === 'function' - ? selector({ isEditingMessage: false, setActivePromptFileBasePath: vi.fn() }) + ? selector({ isEditingMessage: false }) : false ), })) diff --git a/frontend/src/pages/__tests__/SessionDetail.form-prompt.test.tsx b/frontend/src/pages/__tests__/SessionDetail.form-prompt.test.tsx index 46d539ab..6926575d 100644 --- a/frontend/src/pages/__tests__/SessionDetail.form-prompt.test.tsx +++ b/frontend/src/pages/__tests__/SessionDetail.form-prompt.test.tsx @@ -107,7 +107,7 @@ vi.mock('@/hooks/useAutoPlayLastResponse', () => ({ vi.mock('@/stores/uiStateStore', () => ({ useUIState: vi.fn((selector?: (state: Record) => unknown) => typeof selector === 'function' - ? selector({ isEditingMessage: false, setActivePromptFileBasePath: vi.fn() }) + ? selector({ isEditingMessage: false }) : false ), })) diff --git a/frontend/src/pages/__tests__/SessionDetail.scroll-floating.test.tsx b/frontend/src/pages/__tests__/SessionDetail.scroll-floating.test.tsx index b586ef39..761323a7 100644 --- a/frontend/src/pages/__tests__/SessionDetail.scroll-floating.test.tsx +++ b/frontend/src/pages/__tests__/SessionDetail.scroll-floating.test.tsx @@ -102,7 +102,7 @@ vi.mock('@/hooks/useAutoPlayLastResponse', () => ({ vi.mock('@/stores/uiStateStore', () => ({ useUIState: vi.fn((selector?: (state: Record) => unknown) => typeof selector === 'function' - ? selector({ isEditingMessage: mocks.uiState.isEditingMessage, setActivePromptFileBasePath: vi.fn() }) + ? selector({ isEditingMessage: mocks.uiState.isEditingMessage }) : false ), })) diff --git a/frontend/src/stores/uiStateStore.ts b/frontend/src/stores/uiStateStore.ts index 73328ca3..30e4e255 100644 --- a/frontend/src/stores/uiStateStore.ts +++ b/frontend/src/stores/uiStateStore.ts @@ -1,28 +1,11 @@ import { create } from 'zustand' -import type { CommandInfo } from '@opencode-manager/shared/opencode' interface UIStateStore { isEditingMessage: boolean - activePromptFileBasePath: string | null - pendingPromptCommand: { id: number; command: CommandInfo } | null - pendingPromptFile: { id: number; path: string } | null setIsEditingMessage: (isEditing: boolean) => void - setActivePromptFileBasePath: (basePath: string | null) => void - selectPromptCommand: (command: CommandInfo) => void - clearPendingPromptCommand: () => void - selectPromptFile: (path: string) => void - clearPendingPromptFile: () => void } export const useUIState = create((set) => ({ isEditingMessage: false, - activePromptFileBasePath: null, - pendingPromptCommand: null, - pendingPromptFile: null, setIsEditingMessage: (isEditing: boolean) => set({ isEditingMessage: isEditing }), - setActivePromptFileBasePath: (basePath: string | null) => set({ activePromptFileBasePath: basePath }), - selectPromptCommand: (command: CommandInfo) => set({ pendingPromptCommand: { id: Date.now(), command } }), - clearPendingPromptCommand: () => set({ pendingPromptCommand: null }), - selectPromptFile: (path: string) => set({ pendingPromptFile: { id: Date.now(), path } }), - clearPendingPromptFile: () => set({ pendingPromptFile: null }), }))