mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
fix(host): create folders with the entered name untrimmed
Same contract as the path editor: trim only rejects an all-whitespace draft, and the Host receives the original spelling — the backend accepts any non-blank single segment verbatim, so trimming here would create and select a different sibling.
This commit is contained in:
@@ -211,8 +211,11 @@ export function DirectoryBrowser({ open, listDirectory, createDirectory, onOpen,
|
||||
const confirmCreate = (): void => {
|
||||
/* v8 ignore next -- reentry fence: the nested dialog only renders with a target and disables while creating. */
|
||||
if (targetPath === null || folderDraft === null || creatingFolder) return
|
||||
const name = folderDraft.trim()
|
||||
if (name === '') return
|
||||
// Trim only rejects an all-whitespace draft; the Host gets the original
|
||||
// spelling — the backend accepts any non-blank single segment verbatim,
|
||||
// and trimming here would create (and select) a different sibling.
|
||||
const name = folderDraft
|
||||
if (name.trim() === '') return
|
||||
setCreatingFolder(true)
|
||||
setCreateError(null)
|
||||
const generation = openGeneration.current
|
||||
|
||||
@@ -542,6 +542,17 @@ describe('DirectoryBrowser', () => {
|
||||
expect(screen.getByText('Documents')).toBeTruthy()
|
||||
})
|
||||
|
||||
it('passes the folder name to the Host untrimmed (trim only gates blank drafts)', async () => {
|
||||
const b = mount()
|
||||
await waitFor(() => { expect(screen.getByRole('listitem')).toBeTruthy() })
|
||||
fireEvent.click(screen.getByRole('button', { name: 'browser.newFolder' }))
|
||||
const input = screen.getByLabelText('browser.folderName')
|
||||
fireEvent.change(input, { target: { value: 'project ' } })
|
||||
fireEvent.keyDown(input, { key: 'Enter' })
|
||||
// A trailing space may be the wanted spelling; trimming would create a sibling.
|
||||
await waitFor(() => { expect(b.createDirectory).toHaveBeenCalledWith(HOME, 'project ') })
|
||||
})
|
||||
|
||||
it('creates a folder through the nested dialog and lands with it selected', async () => {
|
||||
const b = mount()
|
||||
await waitFor(() => { expect(screen.getByRole('listitem')).toBeTruthy() })
|
||||
|
||||
Reference in New Issue
Block a user