* style(B1-1): 格式化 ink/buddy/cli/context/screens/tasks/services/keybindings/state (43 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 修复了 Box.tsx 和 ScrollBox.tsx 中无效的 global.d.ts import。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-2): 格式化 commands (79 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-3): 格式化 components/messages,permissions,mcp,sandbox,shell (104 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-4): 格式化 components/PromptInput,FeedbackSurvey,tasks,agents,skills,design-system,wizard (73 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-5): 格式化 components其余 + hooks + tools (232 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(B1-6): 格式化 main/entrypoints/utils/moreright (21 files) 纯格式化:移除分号、React Compiler import、import 多行展开。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docs: 更新 README,新增 Run.ps1/TODO.md,删除 V6.md - README.md: 大幅重写,更详细版本历史和配置示例 - Run.ps1: 新增 Windows 启动脚本 - TODO.md: 新增包完成清单 - V6.md: 删除(架构重构规划已不适用) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: 修复以前的问题 * fix: 修复 login 面板的问题 --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
109 lines
2.9 KiB
TypeScript
109 lines
2.9 KiB
TypeScript
import React, { useEffect } from 'react'
|
|
import {
|
|
type AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
|
|
logEvent,
|
|
} from 'src/services/analytics/index.js'
|
|
import type { TeleportRemoteResponse } from 'src/utils/conversationRecovery.js'
|
|
import type { CodeSession } from 'src/utils/teleport/api.js'
|
|
import {
|
|
type TeleportSource,
|
|
useTeleportResume,
|
|
} from '../hooks/useTeleportResume.js'
|
|
import { Box, Text } from '../ink.js'
|
|
import { useKeybinding } from '../keybindings/useKeybinding.js'
|
|
import { ResumeTask } from './ResumeTask.js'
|
|
import { Spinner } from './Spinner.js'
|
|
|
|
interface TeleportResumeWrapperProps {
|
|
onComplete: (result: TeleportRemoteResponse) => void
|
|
onCancel: () => void
|
|
onError?: (error: string, formattedMessage?: string) => void
|
|
isEmbedded?: boolean
|
|
source: TeleportSource
|
|
}
|
|
|
|
/**
|
|
* Wrapper component that manages the full teleport resume flow,
|
|
* including session selection, loading state, and error handling
|
|
*/
|
|
export function TeleportResumeWrapper({
|
|
onComplete,
|
|
onCancel,
|
|
onError,
|
|
isEmbedded = false,
|
|
source,
|
|
}: TeleportResumeWrapperProps): React.ReactNode {
|
|
const { resumeSession, isResuming, error, selectedSession } =
|
|
useTeleportResume(source)
|
|
|
|
// Log when teleport flow starts (for funnel tracking)
|
|
useEffect(() => {
|
|
logEvent('tengu_teleport_started', {
|
|
source:
|
|
source as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS,
|
|
})
|
|
}, [source])
|
|
|
|
const handleSelect = async (session: CodeSession) => {
|
|
const result = await resumeSession(session)
|
|
if (result) {
|
|
onComplete(result)
|
|
} else if (error) {
|
|
// If there's an error handler provided, use it
|
|
if (onError) {
|
|
onError(error.message, error.formattedMessage)
|
|
}
|
|
// Otherwise the error will be displayed in the UI
|
|
}
|
|
}
|
|
|
|
const handleCancel = () => {
|
|
logEvent('tengu_teleport_cancelled', {})
|
|
onCancel()
|
|
}
|
|
|
|
// Allow Esc to dismiss the error state
|
|
useKeybinding('app:interrupt', handleCancel, {
|
|
context: 'Global',
|
|
isActive: !!error && !onError,
|
|
})
|
|
|
|
// Show loading spinner when resuming
|
|
if (isResuming && selectedSession) {
|
|
return (
|
|
<Box flexDirection="column" padding={1}>
|
|
<Box flexDirection="row">
|
|
<Spinner />
|
|
<Text bold>Resuming session…</Text>
|
|
</Box>
|
|
<Text dimColor>Loading "{selectedSession.title}"…</Text>
|
|
</Box>
|
|
)
|
|
}
|
|
|
|
// Show error if there was a problem resuming
|
|
if (error && !onError) {
|
|
return (
|
|
<Box flexDirection="column" padding={1}>
|
|
<Text bold color="error">
|
|
Failed to resume session
|
|
</Text>
|
|
<Text dimColor>{error.message}</Text>
|
|
<Box marginTop={1}>
|
|
<Text dimColor>
|
|
Press <Text bold>Esc</Text> to cancel
|
|
</Text>
|
|
</Box>
|
|
</Box>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<ResumeTask
|
|
onSelect={handleSelect}
|
|
onCancel={handleCancel}
|
|
isEmbedded={isEmbedded}
|
|
/>
|
|
)
|
|
}
|