Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1.1 KB
Raw Blame
import { useActions, useValues } from 'kea'
import { Suspense } from 'react'

import { useShortcut } from 'lib/components/Shortcuts/useShortcut'
import { lazyWithRetry } from 'lib/utils/retryImport'

import { terminalDockLogic } from './terminalDockLogic'

const TerminalPanel = lazyWithRetry(() =>
    import('./TerminalPanel').then(({ TerminalPanel }) => ({ default: TerminalPanel }))
)

export function TerminalDock(): JSX.Element | null {
    const { hasOpened, terminalEnabled } = useValues(terminalDockLogic)
    const { toggleTerminal } = useActions(terminalDockLogic)
    useShortcut({
        name: 'toggle-terminal',
        disabled: !terminalEnabled,
        keybind: [
            ['ctrl', '`'],
            ['ctrl', 'shift', '~'],
            ['command', '`'],
            ['command', 'shift', '~'],
        ],
        intent: 'Toggle terminal',
        interaction: 'function',
        callback: toggleTerminal,
        priority: 10,
    })
    return hasOpened ? (
        <Suspense fallback={null}>
            <TerminalPanel />
        </Suspense>
    ) : null
}