mirror of
https://github.com/stablyai/orca.git
synced 2026-10-15 08:03:08 +00:00
Route floating workspace markdown through template picker
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { FLOATING_TERMINAL_WORKTREE_ID } from '../../../shared/constants'
|
||||
import type { BrowserTab, TerminalTab } from '../../../shared/types'
|
||||
import { createUntitledMarkdownFile } from './create-untitled-markdown'
|
||||
import { createUntitledMarkdownFileWithTemplateSelection } from './create-untitled-markdown'
|
||||
import { getConnectionId } from './connection-context'
|
||||
import { detectLanguage } from './language-detect'
|
||||
import type { AppState } from '@/store/types'
|
||||
@@ -84,12 +84,15 @@ export async function createFloatingWorkspaceMarkdownTab(
|
||||
if (!floatingMarkdownDirectory) {
|
||||
return
|
||||
}
|
||||
const fileInfo = await createUntitledMarkdownFile(
|
||||
const fileInfo = await createUntitledMarkdownFileWithTemplateSelection(
|
||||
floatingMarkdownDirectory,
|
||||
FLOATING_TERMINAL_WORKTREE_ID,
|
||||
getConnectionId(FLOATING_TERMINAL_WORKTREE_ID) ?? undefined,
|
||||
{ activeRuntimeEnvironmentId: null }
|
||||
)
|
||||
if (!fileInfo) {
|
||||
return
|
||||
}
|
||||
store.openFile(
|
||||
{
|
||||
...fileInfo,
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
const activateWebRuntimeSessionTabMock = vi.hoisted(() => vi.fn())
|
||||
const createWebRuntimeSessionBrowserTabMock = vi.hoisted(() => vi.fn())
|
||||
const createWebRuntimeSessionTerminalMock = vi.hoisted(() => vi.fn())
|
||||
const createUntitledMarkdownFileMock = vi.hoisted(() => vi.fn())
|
||||
const createUntitledMarkdownFileWithTemplateSelectionMock = vi.hoisted(() => vi.fn())
|
||||
const focusTerminalTabSurfaceMock = vi.hoisted(() => vi.fn())
|
||||
const isWebRuntimeSessionActiveMock = vi.hoisted(() => vi.fn())
|
||||
|
||||
@@ -33,7 +33,8 @@ vi.mock('@/runtime/web-runtime-session', () => ({
|
||||
}))
|
||||
|
||||
vi.mock('./create-untitled-markdown', () => ({
|
||||
createUntitledMarkdownFile: createUntitledMarkdownFileMock
|
||||
createUntitledMarkdownFileWithTemplateSelection:
|
||||
createUntitledMarkdownFileWithTemplateSelectionMock
|
||||
}))
|
||||
|
||||
vi.mock('./connection-context', () => ({
|
||||
@@ -423,7 +424,7 @@ describe('createFloatingWorkspaceBrowserTab', () => {
|
||||
|
||||
describe('createFloatingWorkspaceMarkdownTab', () => {
|
||||
beforeEach(() => {
|
||||
createUntitledMarkdownFileMock.mockReset()
|
||||
createUntitledMarkdownFileWithTemplateSelectionMock.mockReset()
|
||||
})
|
||||
|
||||
it('creates floating markdown tabs without activating the main workspace', async () => {
|
||||
@@ -439,11 +440,11 @@ describe('createFloatingWorkspaceMarkdownTab', () => {
|
||||
activeGroupIdByWorktree: { [FLOATING_TERMINAL_WORKTREE_ID]: 'floating-group' },
|
||||
openFile: vi.fn()
|
||||
}
|
||||
createUntitledMarkdownFileMock.mockResolvedValue(fileInfo)
|
||||
createUntitledMarkdownFileWithTemplateSelectionMock.mockResolvedValue(fileInfo)
|
||||
|
||||
await createFloatingWorkspaceMarkdownTab(store as never, '/tmp/orca/floating-workspace')
|
||||
|
||||
expect(createUntitledMarkdownFileMock).toHaveBeenCalledWith(
|
||||
expect(createUntitledMarkdownFileWithTemplateSelectionMock).toHaveBeenCalledWith(
|
||||
'/tmp/orca/floating-workspace',
|
||||
FLOATING_TERMINAL_WORKTREE_ID,
|
||||
undefined,
|
||||
@@ -455,6 +456,24 @@ describe('createFloatingWorkspaceMarkdownTab', () => {
|
||||
suppressActiveRuntimeFallback: true
|
||||
})
|
||||
})
|
||||
|
||||
it('does not open a floating markdown tab when template selection is cancelled', async () => {
|
||||
const store = {
|
||||
activeGroupIdByWorktree: { [FLOATING_TERMINAL_WORKTREE_ID]: 'floating-group' },
|
||||
openFile: vi.fn()
|
||||
}
|
||||
createUntitledMarkdownFileWithTemplateSelectionMock.mockResolvedValue(null)
|
||||
|
||||
await createFloatingWorkspaceMarkdownTab(store as never, '/tmp/orca/floating-workspace')
|
||||
|
||||
expect(createUntitledMarkdownFileWithTemplateSelectionMock).toHaveBeenCalledWith(
|
||||
'/tmp/orca/floating-workspace',
|
||||
FLOATING_TERMINAL_WORKTREE_ID,
|
||||
undefined,
|
||||
{ activeRuntimeEnvironmentId: null }
|
||||
)
|
||||
expect(store.openFile).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
describe('switchFloatingWorkspaceTab', () => {
|
||||
|
||||
Reference in New Issue
Block a user