mirror of
https://github.com/stablyai/orca
synced 2026-04-21 14:17:16 +00:00
fix tui lifecyle
This commit is contained in:
parent
884d336798
commit
38e94383eb
2 changed files with 38 additions and 19 deletions
|
|
@ -173,7 +173,20 @@ function App(): React.JSX.Element {
|
|||
</div>
|
||||
<div className="flex flex-row flex-1 min-h-0 overflow-hidden">
|
||||
<Sidebar />
|
||||
{activeView === 'settings' ? <Settings /> : activeWorktreeId ? <Terminal /> : <Landing />}
|
||||
<div className="relative flex flex-1 min-w-0 min-h-0 overflow-hidden">
|
||||
{activeWorktreeId && (
|
||||
<div
|
||||
className={
|
||||
activeView === 'settings'
|
||||
? 'hidden flex-1 min-w-0 min-h-0'
|
||||
: 'flex flex-1 min-w-0 min-h-0'
|
||||
}
|
||||
>
|
||||
<Terminal />
|
||||
</div>
|
||||
)}
|
||||
{activeView === 'settings' ? <Settings /> : !activeWorktreeId ? <Landing /> : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import TerminalPane from './TerminalPane'
|
|||
|
||||
export default function Terminal(): React.JSX.Element | null {
|
||||
const activeWorktreeId = useAppStore((s) => s.activeWorktreeId)
|
||||
const activeView = useAppStore((s) => s.activeView)
|
||||
const worktreesByRepo = useAppStore((s) => s.worktreesByRepo)
|
||||
const tabsByWorktree = useAppStore((s) => s.tabsByWorktree)
|
||||
const activeTabId = useAppStore((s) => s.activeTabId)
|
||||
|
|
@ -21,19 +22,11 @@ export default function Terminal(): React.JSX.Element | null {
|
|||
const workspaceSessionReady = useAppStore((s) => s.workspaceSessionReady)
|
||||
|
||||
const tabs = activeWorktreeId ? (tabsByWorktree[activeWorktreeId] ?? []) : []
|
||||
const allWorktrees = Object.values(worktreesByRepo).flat()
|
||||
const prevTabCountRef = useRef(tabs.length)
|
||||
const tabBarRef = useRef<HTMLDivElement>(null)
|
||||
const initialTabCreationGuardRef = useRef<string | null>(null)
|
||||
|
||||
// Find the active worktree to get its path
|
||||
const activeWorktree = activeWorktreeId
|
||||
? Object.values(worktreesByRepo)
|
||||
.flat()
|
||||
.find((w) => w.id === activeWorktreeId)
|
||||
: null
|
||||
|
||||
const cwd = activeWorktree?.path
|
||||
|
||||
// Auto-create first tab when worktree activates
|
||||
useEffect(() => {
|
||||
if (!workspaceSessionReady) return
|
||||
|
|
@ -225,15 +218,28 @@ export default function Terminal(): React.JSX.Element | null {
|
|||
|
||||
{/* Terminal panes container */}
|
||||
<div className="relative flex-1 min-h-0 overflow-hidden">
|
||||
{tabs.map((tab) => (
|
||||
<TerminalPane
|
||||
key={tab.id}
|
||||
tabId={tab.id}
|
||||
cwd={cwd}
|
||||
isActive={tab.id === activeTabId}
|
||||
onPtyExit={(ptyId) => handlePtyExit(tab.id, ptyId)}
|
||||
/>
|
||||
))}
|
||||
{allWorktrees.map((worktree) => {
|
||||
const worktreeTabs = tabsByWorktree[worktree.id] ?? []
|
||||
const isVisible = activeView !== 'settings' && worktree.id === activeWorktreeId
|
||||
|
||||
return (
|
||||
<div
|
||||
key={worktree.id}
|
||||
className={isVisible ? 'absolute inset-0' : 'absolute inset-0 hidden'}
|
||||
aria-hidden={!isVisible}
|
||||
>
|
||||
{worktreeTabs.map((tab) => (
|
||||
<TerminalPane
|
||||
key={tab.id}
|
||||
tabId={tab.id}
|
||||
cwd={worktree.path}
|
||||
isActive={isVisible && tab.id === activeTabId}
|
||||
onPtyExit={(ptyId) => handlePtyExit(tab.id, ptyId)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue