mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
feat(frontend): mobile-friendly config editor with find bar and unsaved-changes guard (#326)
* feat(frontend): mobile-friendly config editor with find bar and unsaved-changes guard * refactor: remove retry-clone flow and share destructive-confirm dialog Backend drops POST /:id/retry-clone and the supporting retryCloneRepo service and claimRepoForRetry query; failed clones now delete the repo row rather than lingering in error state. Frontend extracts ConfirmDestructiveDialog shared by Delete/Discard/UnsavedChanges dialogs, memoizes CodeEditor rows, fixes scroll jump while typing away from the active match, and aligns the responsive breakpoint to 768px.
This commit is contained in:
1 parent
f8e361c0b8
commit
a73ac19bbc
29 files changed
+2032
-356
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect, vi, beforeEach, beforeAll } from 'vitest'
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import { render, screen, waitFor, fireEvent } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { OpenCodeConfigManager } from './OpenCodeConfigManager'
|
||||
@@ -176,4 +176,46 @@ describe('OpenCodeConfigManager', () => {
|
||||
|
||||
expect(screen.queryByText('Restart OpenCode Server?')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('anchors the AGENTS.md card to the settings dialog scrollport', async () => {
|
||||
renderWithQuery(<OpenCodeConfigManager hideHealthStatus />)
|
||||
const header = await screen.findByRole('button', { name: /Global Agent Instructions/i })
|
||||
const card = header.parentElement
|
||||
expect(card?.className).toContain('overflow-clip')
|
||||
expect(card?.className).not.toContain('overflow-hidden')
|
||||
})
|
||||
|
||||
it('keeps the editor mounted while the post-save config refresh is in flight', async () => {
|
||||
const configWithRaw: OpenCodeConfig = {
|
||||
...defaultConfig,
|
||||
rawContent: '{\n "theme": "system"\n}',
|
||||
}
|
||||
mockGetOpenCodeConfigs.mockResolvedValueOnce({ configs: [configWithRaw] })
|
||||
let resolveRefresh!: () => void
|
||||
mockGetOpenCodeConfigs.mockReturnValueOnce(
|
||||
new Promise<{ configs: OpenCodeConfig[] }>((resolve) => {
|
||||
resolveRefresh = () => resolve({ configs: [configWithRaw] })
|
||||
}),
|
||||
)
|
||||
mockUpdateOpenCodeConfig.mockResolvedValue(configWithRaw)
|
||||
|
||||
const user = userEvent.setup()
|
||||
const { container } = renderWithQuery(<OpenCodeConfigManager hideHealthStatus />)
|
||||
|
||||
await screen.findByText('GPT-4o')
|
||||
const editIcon = container.querySelector('.lucide-square-pen') as SVGElement
|
||||
const editButton = editIcon.closest('button') as HTMLButtonElement
|
||||
await user.click(editButton)
|
||||
|
||||
const textarea = await screen.findByLabelText('Config content') as HTMLTextAreaElement
|
||||
fireEvent.change(textarea, { target: { value: configWithRaw.rawContent! + ' ' } })
|
||||
await user.click(screen.getByRole('button', { name: 'Update' }))
|
||||
|
||||
await waitFor(() => expect(mockUpdateOpenCodeConfig).toHaveBeenCalledTimes(1))
|
||||
expect(screen.getByText('Edit Config: default')).toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: 'Update' })).toBeDisabled()
|
||||
|
||||
resolveRefresh()
|
||||
await waitFor(() => expect(screen.queryByText('Edit Config: default')).not.toBeInTheDocument())
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user