mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
fix(editor): soften file reveal flash and skip new views (#36039)
This commit is contained in:
@@ -1905,7 +1905,7 @@ html.native-shell .app-layout {
|
||||
inset: 0;
|
||||
z-index: 30;
|
||||
pointer-events: none;
|
||||
background: color-mix(in srgb, var(--terminal-pane-locate) 12%, transparent);
|
||||
background: color-mix(in srgb, var(--terminal-pane-locate) 6%, transparent);
|
||||
animation: editor-reveal-flash 1.2s ease-out forwards;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,13 +44,17 @@ export function openLinkedFileInEditor(
|
||||
isCurrentRequest: () => boolean
|
||||
): EditorOpenResult | null {
|
||||
const language = detectLanguage(file.filePath)
|
||||
const existingViews = useAppStore.getState().unifiedTabsByWorktree?.[file.worktreeId] ?? []
|
||||
// Why on shown: a layout-owner build draws a new view only with main's frame.
|
||||
const reveal = (shown: EditorOpenResult | null): void => {
|
||||
if (!shown) {
|
||||
return
|
||||
}
|
||||
// Why: a link to an already-active tab otherwise changes nothing on screen.
|
||||
if (isCurrentRequest()) {
|
||||
if (
|
||||
isCurrentRequest() &&
|
||||
existingViews.some((tab) => tab.id === shown.viewStateId && tab.entityId === shown.fileId)
|
||||
) {
|
||||
flashRevealedEditorView(shown.viewStateId)
|
||||
}
|
||||
if (position.line === null) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { openRoutedHttpLink } from '@/lib/http-link-destinations'
|
||||
import * as browserLinkOpen from './terminal-file-link-browser-open'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import * as editorRevealFlash from '@/components/tab-group/editor-reveal-flash'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { activateAndRevealWorkspace } from '@/lib/worktree-activation'
|
||||
import { openDetectedFilePath } from './terminal-link-handlers'
|
||||
import { createTerminalLinkTestDoubles } from './terminal-link-handlers-test-fixtures'
|
||||
@@ -231,6 +232,35 @@ describe('terminal file links carry their source tab', () => {
|
||||
})
|
||||
|
||||
describe('terminal file link reveals target the opened view', () => {
|
||||
afterEach(() => vi.restoreAllMocks())
|
||||
|
||||
it.each([
|
||||
{ existingFileId: null, flashes: false, label: 'a newly opened file' },
|
||||
{ existingFileId: '/tmp/src/a.ts', flashes: true, label: 'an existing document view' },
|
||||
{ existingFileId: '/tmp/src/b.ts', flashes: false, label: 'a reused preview for another file' }
|
||||
])('only flashes existing documents: $label', async ({ existingFileId, flashes }) => {
|
||||
setPlatform('Macintosh')
|
||||
const flash = vi
|
||||
.spyOn(editorRevealFlash, 'flashRevealedEditorView')
|
||||
.mockImplementation(() => {})
|
||||
if (existingFileId) {
|
||||
storeState.unifiedTabsByWorktree = {
|
||||
'wt-1': [{ id: 'view:/tmp/src/a.ts', entityId: existingFileId, groupId: 'group-1' }]
|
||||
}
|
||||
}
|
||||
|
||||
openDetectedFilePath('/tmp/src/a.ts', 12, 3, deps)
|
||||
await flushAsyncWork()
|
||||
await flushDoubleRaf()
|
||||
|
||||
expect(flash).toHaveBeenCalledTimes(flashes ? 1 : 0)
|
||||
if (flashes) {
|
||||
expect(flash).toHaveBeenCalledWith('view:/tmp/src/a.ts')
|
||||
}
|
||||
expect(lastReveal()).toMatchObject({ viewStateId: 'view:/tmp/src/a.ts', line: 12, column: 3 })
|
||||
expect(lastReveal().canApply?.()).toBe(true)
|
||||
})
|
||||
|
||||
it('scopes the reveal to the returned view', async () => {
|
||||
setPlatform('Macintosh')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user