Files
orca/tests/e2e/folder-workspace-palette-wake.spec.ts
Jinjing deb6a71b29 Show folder workspaces in the Cmd+J jump palette (#28175)
* Show folder workspaces in the Cmd+J jump palette

Cmd+J only listed git worktrees, so folder workspaces could not be found or opened from it. The palette now includes folder workspaces alongside git worktrees and renames the section from "Worktrees" to "Workspaces" to match.

- Folder rows are searchable by name, comment, and attached GitHub item, and follow the sidebar's host scope.
- A blocked activation (for example, a folder path that no longer exists) keeps the palette open and shows only the path error, instead of closing or showing a second generic error.
- Folder path-status caching and sidebar reveal are keyed by execution host, so folders with the same id on different hosts no longer share cache entries or reveal the wrong group.

* Consolidate runtime target imports in folder-path-status

`getRuntimeTargetHostId` now comes from the same module as `runtimeTargetForOwnerEnvironment`, so both are imported from `runtime/runtime-client-target` instead of splitting them across two modules.

* Wake sleeping folder workspaces from Cmd+J

Picking a sleeping folder workspace from the jump palette did not restart its terminal or restore its Files explorer view. Folder and git worktree activation now share one code path in workspace-activation.ts, so both wake the same way.

- Wake a sleeping folder the same way as a worktree: bump the tab generation and tag the pending spawn when no PTY is live, including when the workspace is already selected.
- Restore the remembered right-sidebar explorer view for folders.
- Skip the GitHub PR refresh for folder workspaces, which have no PR.
- Clear unread only on the folder entry whose execution host matches the activation.

* Reveal folder workspaces on their catalog owner host

Cmd+J activation revealed folder workspaces against the focused runtime
server's host, so a folder owned by a local or SSH project could be
revealed under an unrelated server. The reveal host now comes from the
folder workspace's catalog owner, and an explicit caller host still wins.

Add a regression test covering local and SSH owners while another
runtime environment is focused.

* Keep shared workspace activation in the existing layout writer
2026-10-13 09:41:52 -07:00

105 lines
4.4 KiB
TypeScript

import { mkdtempSync, realpathSync, rmSync } from 'node:fs'
import os from 'node:os'
import path from 'node:path'
import { expect, test } from './helpers/orca-app'
import { waitForSessionReady } from './helpers/store'
import {
execInTerminal,
expectTerminalAccessibilityText,
waitForActivePanePtyId,
waitForActiveTerminalManager
} from './helpers/terminal'
test.use({ seedTestRepo: false })
for (const selection of ['workspace', 'tab'] as const) {
test(`Cmd+J ${selection} selection wakes a sleeping folder and restores Files mode`, async ({
orcaPage,
electronApp,
registerPostElectronShutdownCleanup
}, testInfo) => {
const folderPath = realpathSync(mkdtempSync(path.join(os.tmpdir(), 'orca-folder-wake-')))
registerPostElectronShutdownCleanup(async () =>
rmSync(folderPath, { recursive: true, force: true })
)
await waitForSessionReady(orcaPage)
const folders = await orcaPage.evaluate(async (folderPath) => {
const store = window.__store!
await store.getState().updateSettingsOrThrow({ defaultTuiAgent: 'blank' })
const group = await window.api.projectGroups.create({
name: 'Folder wake regression',
parentPath: folderPath,
createdFrom: 'folder-scan'
})
await store.getState().fetchProjectGroups({ runtimeEnvironmentId: null, throwOnError: true })
const target = await store
.getState()
.createFolderWorkspace(
{ projectGroupId: group.id, name: 'Sleeping research', folderPath },
{ runtimeEnvironmentId: null }
)
const other = await store
.getState()
.createFolderWorkspace(
{ projectGroupId: group.id, name: 'Other research', folderPath },
{ runtimeEnvironmentId: null }
)
if (!target || !other) {
throw new Error('Could not create folder workspaces')
}
return { target: target.id, other: other.id }
}, folderPath)
const openPalette = async (): Promise<void> => {
// Native menu accelerators need desktop focus; drive the same palette through CDP.
await orcaPage.evaluate(() => window.__store!.getState().openModal('worktree-palette'))
}
const palette = orcaPage.getByRole('dialog', { name: 'Jump to...' })
await openPalette()
await palette.getByRole('combobox').fill('Sleeping research')
await palette.getByRole('combobox').press('Enter')
await expect(palette).toHaveCount(0)
await waitForActiveTerminalManager(orcaPage)
await waitForActivePanePtyId(orcaPage)
const tabId = await orcaPage.evaluate(() => {
const state = window.__store!.getState()
const tabId = state.activeTabId
if (!tabId) {
throw new Error('Folder terminal is missing')
}
state.setTabCustomTitle(tabId, 'Wake marker terminal')
state.showRightSidebarFiles()
return tabId
})
await expect(orcaPage.getByRole('textbox', { name: 'Find files', exact: true })).toBeVisible()
await openPalette()
await palette.getByRole('combobox').fill('Other research')
await palette.getByRole('combobox').press('Enter')
await expect(palette).toHaveCount(0)
await orcaPage.evaluate(async (targetId) => {
const state = window.__store!.getState()
state.showRightSidebarSearch()
await state.shutdownWorktreeTerminals(`folder:${targetId}`, { keepIdentifiers: true })
}, folders.target)
await expect(orcaPage.getByRole('textbox', { name: 'Find files', exact: true })).toBeHidden()
await openPalette()
const query = selection === 'workspace' ? 'Sleeping research' : 'Wake marker terminal'
await palette.getByRole('combobox').fill(query)
const row = palette.locator('[cmdk-item][data-selected="true"]')
await expect(row).toContainText(query)
await palette.getByRole('combobox').press('Enter')
await expect(palette).toHaveCount(0)
await expect(orcaPage.getByRole('textbox', { name: 'Find files', exact: true })).toBeVisible()
await waitForActiveTerminalManager(orcaPage)
const ptyId = await waitForActivePanePtyId(orcaPage)
await execInTerminal(orcaPage, ptyId, 'echo FOLDER_WAKE_OK')
await expectTerminalAccessibilityText(orcaPage, tabId, 'FOLDER_WAKE_OK')
await orcaPage.screenshot({ path: testInfo.outputPath(`folder-${selection}-wake.png`) })
expect(
await electronApp.evaluate(({ BrowserWindow }) =>
BrowserWindow.getAllWindows().every((window) => !window.isVisible())
)
).toBe(true)
})
}