fix: expose terminal visual layout and copyable handles (#5845)
Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
formatAutomationShow,
|
||||
formatComputerAction,
|
||||
formatGetAppState,
|
||||
formatTerminalList,
|
||||
formatTerminalRead,
|
||||
formatWorktreeList,
|
||||
printResult
|
||||
@@ -195,6 +196,135 @@ describe('formatAutomationShow', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('formatTerminalList', () => {
|
||||
it('prints visual split groups and nested terminal panes', () => {
|
||||
const output = formatTerminalList({
|
||||
terminals: [
|
||||
{
|
||||
handle: 'term_left',
|
||||
ptyId: 'pty-left',
|
||||
worktreeId: 'wt-1',
|
||||
worktreePath: '/repo',
|
||||
branch: 'main',
|
||||
tabId: 'tab-left',
|
||||
leafId: 'leaf-left',
|
||||
title: 'Left',
|
||||
connected: true,
|
||||
writable: true,
|
||||
lastOutputAt: null,
|
||||
preview: ''
|
||||
},
|
||||
{
|
||||
handle: 'term_top',
|
||||
ptyId: 'pty-top',
|
||||
worktreeId: 'wt-1',
|
||||
worktreePath: '/repo',
|
||||
branch: 'main',
|
||||
tabId: 'tab-right',
|
||||
leafId: 'leaf-top',
|
||||
title: 'Right top',
|
||||
connected: true,
|
||||
writable: true,
|
||||
lastOutputAt: null,
|
||||
preview: ''
|
||||
},
|
||||
{
|
||||
handle: 'term_bottom',
|
||||
ptyId: 'pty-bottom',
|
||||
worktreeId: 'wt-1',
|
||||
worktreePath: '/repo',
|
||||
branch: 'main',
|
||||
tabId: 'tab-right',
|
||||
leafId: 'leaf-bottom',
|
||||
title: 'Right bottom',
|
||||
connected: true,
|
||||
writable: true,
|
||||
lastOutputAt: null,
|
||||
preview: ''
|
||||
}
|
||||
],
|
||||
totalCount: 3,
|
||||
truncated: false,
|
||||
visualLayouts: [
|
||||
{
|
||||
worktreeId: 'wt-1',
|
||||
worktreePath: '/repo',
|
||||
root: {
|
||||
type: 'split',
|
||||
direction: 'horizontal',
|
||||
first: {
|
||||
type: 'group',
|
||||
groupId: 'group-left',
|
||||
activeTabId: 'tab-left',
|
||||
tabs: [
|
||||
{
|
||||
tabId: 'tab-left',
|
||||
title: 'Left',
|
||||
activeLeafId: 'leaf-left',
|
||||
panes: {
|
||||
type: 'terminal',
|
||||
handle: 'term_left',
|
||||
tabId: 'tab-left',
|
||||
leafId: 'leaf-left',
|
||||
title: 'Left',
|
||||
connected: true,
|
||||
active: true
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
second: {
|
||||
type: 'group',
|
||||
groupId: 'group-right',
|
||||
activeTabId: 'tab-right',
|
||||
tabs: [
|
||||
{
|
||||
tabId: 'tab-right',
|
||||
title: 'Right',
|
||||
activeLeafId: 'leaf-bottom',
|
||||
panes: {
|
||||
type: 'pane-split',
|
||||
direction: 'vertical',
|
||||
first: {
|
||||
type: 'terminal',
|
||||
handle: 'term_top',
|
||||
tabId: 'tab-right',
|
||||
leafId: 'leaf-top',
|
||||
title: 'Right top',
|
||||
connected: true,
|
||||
active: false
|
||||
},
|
||||
second: {
|
||||
type: 'terminal',
|
||||
handle: 'term_bottom',
|
||||
tabId: 'tab-right',
|
||||
leafId: 'leaf-bottom',
|
||||
title: 'Right bottom',
|
||||
connected: true,
|
||||
active: true
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
} as never)
|
||||
|
||||
expect(output).toContain('visual layout:')
|
||||
expect(output).toContain('/repo')
|
||||
expect(output).toContain('split horizontal')
|
||||
expect(output).toContain('group group-left')
|
||||
expect(output).toContain('tab tab-left Left')
|
||||
expect(output).toContain('* term_left Left tab=tab-left leaf=leaf-left')
|
||||
expect(output).toContain('group group-right')
|
||||
expect(output).toContain('pane split vertical')
|
||||
expect(output).toContain(' term_top Right top tab=tab-right leaf=leaf-top')
|
||||
expect(output).toContain('* term_bottom Right bottom tab=tab-right leaf=leaf-bottom')
|
||||
})
|
||||
})
|
||||
|
||||
describe('formatTerminalRead', () => {
|
||||
it('warns limited cursor reads to continue with the next cursor', () => {
|
||||
const output = formatTerminalRead({
|
||||
|
||||
Reference in New Issue
Block a user