mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 08:02:28 +00:00
69 lines
2.2 KiB
TypeScript
69 lines
2.2 KiB
TypeScript
import { useCallback, useMemo, useRef, type KeyboardEvent } from 'react'
|
|
import { track } from '@/lib/telemetry'
|
|
import { OnboardingInlineCommandTerminal } from './OnboardingInlineCommandTerminal'
|
|
import {
|
|
onboardingFeatureSetupTelemetrySelection,
|
|
type OnboardingFeatureSetupSelection
|
|
} from './onboarding-feature-setup'
|
|
|
|
type FeatureSetupInlineTerminalProps = {
|
|
command: string
|
|
selection: OnboardingFeatureSetupSelection
|
|
}
|
|
|
|
export function FeatureSetupInlineTerminal({
|
|
command,
|
|
selection
|
|
}: FeatureSetupInlineTerminalProps): React.JSX.Element {
|
|
const terminalOpenedTrackedRef = useRef(false)
|
|
const terminalInteractedTrackedRef = useRef(false)
|
|
|
|
const selectionTelemetry = useMemo(
|
|
() => onboardingFeatureSetupTelemetrySelection(selection),
|
|
[selection]
|
|
)
|
|
|
|
const trackTerminalOpened = useCallback(() => {
|
|
if (terminalOpenedTrackedRef.current) {
|
|
return
|
|
}
|
|
terminalOpenedTrackedRef.current = true
|
|
track('onboarding_feature_setup_terminal_opened', selectionTelemetry)
|
|
}, [selectionTelemetry])
|
|
|
|
const trackTerminalInteraction = useCallback(
|
|
(method: 'keyboard' | 'pointer', event?: KeyboardEvent<HTMLElement>) => {
|
|
if (terminalInteractedTrackedRef.current) {
|
|
return
|
|
}
|
|
const isMac = navigator.userAgent.includes('Mac')
|
|
const isContinueShortcut = event?.key === 'Enter' && (isMac ? event.metaKey : event.ctrlKey)
|
|
if (isContinueShortcut) {
|
|
return
|
|
}
|
|
// Why: auto-insert focuses the terminal programmatically; only count
|
|
// direct terminal activity, not the global continue shortcut.
|
|
terminalInteractedTrackedRef.current = true
|
|
track('onboarding_feature_setup_terminal_interacted', {
|
|
...selectionTelemetry,
|
|
method
|
|
})
|
|
},
|
|
[selectionTelemetry]
|
|
)
|
|
|
|
return (
|
|
<OnboardingInlineCommandTerminal
|
|
command={command}
|
|
title="Skill setup"
|
|
ariaLabel="Skill setup command"
|
|
description="Press Enter to run the command and confirm npx if asked. You can also set this up later in Settings."
|
|
terminalHeightPx={180}
|
|
terminalTopMarginPx={16}
|
|
autoScrollIntoView={false}
|
|
onOpened={trackTerminalOpened}
|
|
onInteracted={trackTerminalInteraction}
|
|
/>
|
|
)
|
|
}
|