@vvedantb/native-ui 0.37.2 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/dist/Avatar.jsx +22 -19
- package/dist/BottomSheetContainer.jsx +0 -6
- package/dist/BulkActionBar.jsx +0 -24
- package/dist/Button.jsx +92 -116
- package/dist/Card.jsx +56 -50
- package/dist/ColorSwatches.jsx +0 -6
- package/dist/Dialog.jsx +0 -12
- package/dist/DropdownMenu.jsx +0 -10
- package/dist/EmptyState.jsx +0 -3
- package/dist/ExpoWebRoot.jsx +0 -6
- package/dist/Field.jsx +0 -17
- package/dist/FloatingSurface.jsx +95 -80
- package/dist/FloatingTabBar.jsx +0 -23
- package/dist/IconButton.jsx +0 -1
- package/dist/LoadingState.jsx +0 -6
- package/dist/PasswordInput.jsx +0 -15
- package/dist/PillTabs.jsx +39 -36
- package/dist/SearchInput.jsx +0 -13
- package/dist/SectionLabel.jsx +0 -1
- package/dist/SharedTransition.jsx +0 -3
- package/dist/Skeleton.jsx +0 -2
- package/dist/Spinner.jsx +0 -2
- package/dist/StatusDot.jsx +0 -5
- package/dist/Switch.jsx +32 -22
- package/dist/Tabs.jsx +27 -26
- package/dist/Textarea.jsx +0 -1
- package/dist/ThemeToggle.jsx +0 -1
- package/dist/Toast.jsx +80 -91
- package/dist/UpdateChecker.jsx +0 -1
- package/dist/ai/activity-question.jsx +0 -6
- package/dist/ai/activity-step-label.js +0 -6
- package/dist/ai/activity-step-types.js +0 -4
- package/dist/ai/activity-tasks-utils.js +0 -17
- package/dist/ai/activity-timeline.js +0 -8
- package/dist/ai/attachments.jsx +0 -2
- package/dist/ai/chain-of-thought.jsx +0 -3
- package/dist/ai/chat-text.js +0 -1
- package/dist/ai/chat-thread.jsx +0 -1
- package/dist/ai/choice-question.jsx +0 -10
- package/dist/ai/code-block.jsx +0 -31
- package/dist/ai/collapsible.jsx +0 -14
- package/dist/ai/conversation-context.js +0 -3
- package/dist/ai/conversation.jsx +2 -48
- package/dist/ai/file-chip.jsx +0 -2
- package/dist/ai/icon-button.jsx +0 -8
- package/dist/ai/index.js +0 -5
- package/dist/ai/message-context-menu.jsx +0 -7
- package/dist/ai/message.jsx +0 -21
- package/dist/ai/prompt-input-menu.jsx +0 -3
- package/dist/ai/prompt-input.jsx +0 -27
- package/dist/ai/response-text.jsx +0 -6
- package/dist/ai/sources.jsx +0 -1
- package/dist/ai/suggestion.jsx +0 -1
- package/dist/ai/trace.jsx +0 -11
- package/dist/ai/unified-diff.jsx +0 -4
- package/dist/app-root/AuthGroupGate.jsx +65 -0
- package/dist/app-root/SsoCallbackScreen.jsx +97 -0
- package/dist/app-root/fonts.js +88 -0
- package/dist/app-root/index.js +3 -0
- package/dist/auth/AuthScreen.jsx +250 -77
- package/dist/auth/GoogleSignInButton.jsx +0 -3
- package/dist/auth/SecondFactorScreen.jsx +18 -14
- package/dist/auth/SignInScreen.jsx +40 -34
- package/dist/auth/authErrors.js +0 -4
- package/dist/auth/clerkCore3.js +0 -7
- package/dist/auth/index.js +0 -4
- package/dist/auth/totp.js +0 -2
- package/dist/brand/GoogleMark.jsx +0 -1
- package/dist/brand/ProviderIcon.jsx +0 -2
- package/dist/brand/index.js +0 -3
- package/dist/brand/svg.js +0 -6
- package/dist/configureTheme.js +0 -9
- package/dist/controlStyles.js +0 -14
- package/dist/crash/LastCrashDialog.jsx +56 -0
- package/dist/crash/lastCrash.js +192 -0
- package/dist/entries/ai.js +0 -3
- package/dist/entries/ambient.js +0 -2
- package/dist/entries/app-root.js +1 -0
- package/dist/entries/auth.js +0 -4
- package/dist/entries/bottom-sheet.js +0 -2
- package/dist/entries/brand.js +0 -1
- package/dist/entries/button.js +0 -1
- package/dist/entries/crash.js +2 -0
- package/dist/entries/date-time.js +0 -2
- package/dist/entries/expo-router.js +0 -3
- package/dist/entries/expo-web-root.js +0 -2
- package/dist/entries/floating.js +0 -2
- package/dist/entries/generative-ui.js +0 -4
- package/dist/entries/gesture-handler.js +0 -3
- package/dist/entries/keyboard-controller.js +0 -3
- package/dist/entries/layout.js +0 -2
- package/dist/entries/markdown.js +0 -3
- package/dist/entries/marketing.js +0 -1
- package/dist/entries/page-title.js +0 -5
- package/dist/entries/password-input.js +0 -2
- package/dist/entries/paste-input.js +0 -3
- package/dist/entries/primitives.js +0 -6
- package/dist/entries/search-input.js +0 -2
- package/dist/entries/tab-bar.js +0 -2
- package/dist/entries/theme.js +4 -2
- package/dist/entries/toast.js +0 -3
- package/dist/entries/video.js +0 -2
- package/dist/entries/webview.js +0 -2
- package/dist/examples/AiChatGallery.jsx +0 -11
- package/dist/examples/ParityGallery.jsx +0 -12
- package/dist/floating.js +0 -8
- package/dist/generative-ui/GenerativeUiPanel.jsx +0 -2
- package/dist/generative-ui/components.jsx +0 -8
- package/dist/glass.js +55 -0
- package/dist/glassBlur.jsx +0 -12
- package/dist/highlight.js +0 -26
- package/dist/index.js +4 -2
- package/dist/loadingGrid.js +0 -13
- package/dist/markdown/Markdown.jsx +0 -59
- package/dist/markdown/MarkdownTable.jsx +0 -18
- package/dist/markdown/tableText.js +0 -5
- package/dist/marketing/UpgradeToProCard.jsx +0 -5
- package/dist/marketing/pricing.js +0 -3
- package/dist/media/ImageGallery.jsx +0 -16
- package/dist/media/imageZoom.js +0 -4
- package/dist/media/zoom-image-gesture.jsx +0 -8
- package/dist/media/zoomImage.js +0 -3
- package/dist/motion.js +0 -3
- package/dist/neutralTheme.js +158 -0
- package/dist/pagerSwipe.js +0 -16
- package/dist/palette.js +0 -10
- package/dist/primitives/button.jsx +0 -5
- package/dist/primitives/icon.jsx +0 -4
- package/dist/primitives/keyboard-controller.jsx +0 -27
- package/dist/primitives/native-only-animated-view.jsx +0 -5
- package/dist/primitives/overlay.jsx +0 -2
- package/dist/primitives/pager-gesture.jsx +3 -29
- package/dist/primitives/paste-input.jsx +0 -5
- package/dist/primitives/select.jsx +0 -10
- package/dist/primitives/sheet-drag.jsx +0 -3
- package/dist/primitives/sheet-gesture.jsx +0 -8
- package/dist/primitives/swipe-row-gesture.jsx +3 -45
- package/dist/primitives/text.jsx +0 -5
- package/dist/primitives/toast-drag-gesture.jsx +4 -24
- package/dist/primitives/web-click-guard.js +0 -3
- package/dist/primitives/window-layer.jsx +0 -14
- package/dist/push.js +0 -6
- package/dist/relativeTime.js +0 -13
- package/dist/settings/MoreFromProjectV.jsx +0 -5
- package/dist/settings/ThemeModePicker.jsx +2 -9
- package/dist/settings/projectVMobileApps.js +1 -6
- package/dist/sheetDrag.js +0 -10
- package/dist/swipeRow.js +0 -15
- package/dist/tabBarRoutes.js +0 -4
- package/dist/tabIndicator.js +0 -4
- package/dist/tailwind-preset.cjs +0 -54
- package/dist/tailwind-preset.d.cts +0 -8
- package/dist/theme.jsx +29 -21
- package/dist/themeModeStore.js +62 -0
- package/dist/themeModes.js +9 -0
- package/dist/toastChrome.js +0 -6
- package/dist/toastDrag.js +0 -14
- package/dist/toastStore.js +0 -4
- package/dist/updateCheck.js +0 -7
- package/dist/video/InlineVideo.jsx +0 -2
- package/dist/webview/htmlView.js +0 -5
- package/package.json +47 -19
- package/src/ArtifactList.tsx +0 -2
- package/src/Avatar.tsx +3 -3
- package/src/Badge.tsx +0 -1
- package/src/BottomSheetContainer.tsx +0 -11
- package/src/BulkActionBar.tsx +0 -66
- package/src/Button.tsx +4 -40
- package/src/CaptureButton.tsx +0 -1
- package/src/Card.tsx +3 -15
- package/src/Checkbox.tsx +0 -2
- package/src/ColorSwatches.tsx +0 -9
- package/src/ConfirmDialog.tsx +0 -7
- package/src/DateTimeField.tsx +0 -5
- package/src/Dialog.tsx +0 -27
- package/src/DividedList.tsx +0 -1
- package/src/DropdownMenu.tsx +0 -51
- package/src/EmptyState.tsx +0 -5
- package/src/ExpoWebRoot.tsx +0 -10
- package/src/Field.tsx +0 -14
- package/src/FloatingFAB.tsx +0 -3
- package/src/FloatingSurface.tsx +11 -8
- package/src/FloatingTabBar.tsx +0 -25
- package/src/IconButton.tsx +0 -5
- package/src/Input.tsx +0 -1
- package/src/Label.tsx +0 -1
- package/src/LabeledSwitchRow.tsx +0 -2
- package/src/ListRow.tsx +0 -12
- package/src/LoadingState.tsx +0 -12
- package/src/MenuSheet.tsx +0 -2
- package/src/PageIndicator.tsx +0 -2
- package/src/PageTitle.tsx +0 -15
- package/src/Pager.tsx +0 -9
- package/src/PasswordInput.tsx +0 -24
- package/src/PillTabs.tsx +3 -11
- package/src/PinnedBotTile.tsx +0 -6
- package/src/Progress.tsx +0 -3
- package/src/ReactionRow.tsx +0 -8
- package/src/ScreenContainer.tsx +0 -4
- package/src/SearchInput.tsx +0 -25
- package/src/SectionLabel.tsx +0 -2
- package/src/Select.tsx +0 -6
- package/src/Separator.tsx +0 -2
- package/src/SharedTransition.tsx +0 -7
- package/src/Sheet.tsx +0 -3
- package/src/SheetRow.tsx +0 -12
- package/src/Skeleton.tsx +0 -10
- package/src/Spinner.tsx +0 -6
- package/src/StackPageHeader.tsx +0 -16
- package/src/StatGrid.tsx +0 -1
- package/src/StatusDot.tsx +0 -6
- package/src/SurfaceRow.tsx +0 -12
- package/src/SwipeableRow.tsx +0 -4
- package/src/Switch.tsx +3 -4
- package/src/Tabs.tsx +3 -27
- package/src/Textarea.tsx +0 -2
- package/src/ThemeToggle.tsx +0 -1
- package/src/Toast.tsx +3 -19
- package/src/UpdateChecker.tsx +0 -46
- package/src/ai/activity-question.tsx +0 -8
- package/src/ai/activity-step-detail.tsx +0 -5
- package/src/ai/activity-step-label.ts +0 -5
- package/src/ai/activity-step-types.ts +0 -24
- package/src/ai/activity-step.tsx +0 -4
- package/src/ai/activity-tasks-utils.ts +0 -13
- package/src/ai/activity-timeline.ts +0 -6
- package/src/ai/attachments.tsx +0 -13
- package/src/ai/chain-of-thought.tsx +0 -5
- package/src/ai/chat-jump-rail.tsx +0 -2
- package/src/ai/chat-text.ts +0 -1
- package/src/ai/chat-thread.tsx +0 -9
- package/src/ai/choice-question.tsx +0 -36
- package/src/ai/code-block.tsx +0 -52
- package/src/ai/collapsible.tsx +0 -12
- package/src/ai/conversation-context.ts +0 -14
- package/src/ai/conversation.tsx +0 -58
- package/src/ai/file-chip.tsx +0 -1
- package/src/ai/icon-button.tsx +0 -17
- package/src/ai/index.ts +0 -5
- package/src/ai/message-action-sheet.tsx +0 -8
- package/src/ai/message-context-menu.tsx +0 -22
- package/src/ai/message-quote.tsx +0 -4
- package/src/ai/message.tsx +0 -66
- package/src/ai/prompt-input-menu.tsx +0 -19
- package/src/ai/prompt-input.tsx +0 -97
- package/src/ai/reasoning.tsx +0 -6
- package/src/ai/reply-quote-chip.tsx +0 -5
- package/src/ai/response-text.tsx +0 -8
- package/src/ai/shimmer.tsx +0 -2
- package/src/ai/sources.tsx +0 -3
- package/src/ai/subagent-cards.tsx +0 -13
- package/src/ai/suggestion.tsx +0 -4
- package/src/ai/tool-approval-card.tsx +0 -14
- package/src/ai/trace.tsx +0 -23
- package/src/ai/unified-diff.tsx +0 -16
- package/src/ai/use-streaming-disclosure.ts +0 -4
- package/src/app-root/AuthGroupGate.tsx +38 -0
- package/src/app-root/SsoCallbackScreen.tsx +52 -0
- package/src/app-root/fonts.ts +53 -0
- package/src/app-root/index.ts +6 -0
- package/src/auth/AccountScreens.tsx +0 -16
- package/src/auth/AuthProviders.tsx +0 -13
- package/src/auth/AuthScreen.tsx +95 -6
- package/src/auth/GoogleSignInButton.tsx +0 -12
- package/src/auth/SecondFactorScreen.tsx +17 -15
- package/src/auth/SignInScreen.tsx +103 -105
- package/src/auth/authErrors.ts +0 -6
- package/src/auth/clerkCore3.ts +0 -6
- package/src/auth/index.ts +0 -4
- package/src/auth/totp.ts +0 -13
- package/src/brand/AppIcons.tsx +0 -6
- package/src/brand/AppMark.tsx +0 -5
- package/src/brand/AppWordmark.tsx +0 -7
- package/src/brand/GoogleMark.tsx +0 -4
- package/src/brand/ProviderIcon.tsx +0 -6
- package/src/brand/familyApps.ts +0 -2
- package/src/brand/index.ts +0 -3
- package/src/brand/svg.ts +0 -9
- package/src/configureTheme.ts +0 -10
- package/src/controlStyles.ts +0 -12
- package/src/crash/LastCrashDialog.tsx +36 -0
- package/src/crash/lastCrash.ts +218 -0
- package/src/entries/ai.ts +0 -3
- package/src/entries/ambient.ts +0 -2
- package/src/entries/app-root.ts +1 -0
- package/src/entries/auth.ts +0 -4
- package/src/entries/bottom-sheet.ts +0 -2
- package/src/entries/brand.ts +0 -1
- package/src/entries/button.ts +0 -1
- package/src/entries/crash.ts +13 -0
- package/src/entries/date-time.ts +0 -2
- package/src/entries/expo-router.ts +0 -3
- package/src/entries/expo-web-root.ts +0 -2
- package/src/entries/floating.ts +0 -2
- package/src/entries/generative-ui.ts +0 -4
- package/src/entries/gesture-handler.ts +0 -3
- package/src/entries/keyboard-controller.ts +0 -3
- package/src/entries/layout.ts +0 -2
- package/src/entries/markdown.ts +0 -3
- package/src/entries/marketing.ts +0 -1
- package/src/entries/page-title.ts +0 -5
- package/src/entries/password-input.ts +0 -2
- package/src/entries/paste-input.ts +0 -3
- package/src/entries/primitives.ts +0 -6
- package/src/entries/search-input.ts +0 -2
- package/src/entries/tab-bar.ts +0 -2
- package/src/entries/theme.ts +8 -2
- package/src/entries/toast.ts +0 -3
- package/src/entries/video.ts +0 -2
- package/src/entries/webview.ts +0 -2
- package/src/examples/AiChatGallery.tsx +0 -11
- package/src/examples/ParityGallery.tsx +0 -25
- package/src/floating.ts +0 -6
- package/src/generative-ui/GenerativeUiPanel.tsx +0 -15
- package/src/generative-ui/components.tsx +0 -9
- package/src/generative-ui/context.ts +0 -2
- package/src/glass.ts +31 -0
- package/src/glassBlur.tsx +0 -15
- package/src/highlight.ts +1 -21
- package/src/index.ts +7 -2
- package/src/loadingGrid.ts +0 -12
- package/src/markdown/Markdown.tsx +0 -71
- package/src/markdown/MarkdownTable.tsx +0 -23
- package/src/markdown/tableText.ts +0 -3
- package/src/marketing/PricingModal.tsx +0 -13
- package/src/marketing/UpgradeToProCard.tsx +0 -14
- package/src/marketing/pricing.ts +0 -12
- package/src/media/ImageGallery.tsx +0 -18
- package/src/media/MediaCard.tsx +0 -8
- package/src/media/imageZoom.ts +0 -4
- package/src/media/zoom-image-gesture.tsx +0 -9
- package/src/media/zoomImage.ts +0 -5
- package/src/motion.ts +0 -3
- package/src/neutralTheme.ts +127 -0
- package/src/pagerSwipe.ts +0 -13
- package/src/palette.ts +0 -10
- package/src/pressScale.ts +0 -7
- package/src/primitives/button.tsx +0 -4
- package/src/primitives/card.tsx +0 -1
- package/src/primitives/icon.tsx +0 -2
- package/src/primitives/input.tsx +0 -4
- package/src/primitives/keyboard-controller.tsx +0 -25
- package/src/primitives/keyboard-parts.tsx +0 -27
- package/src/primitives/native-only-animated-view.tsx +0 -5
- package/src/primitives/overlay.tsx +0 -25
- package/src/primitives/pager-gesture.tsx +0 -20
- package/src/primitives/paste-input.tsx +0 -4
- package/src/primitives/paste-parts.tsx +0 -1
- package/src/primitives/select.tsx +0 -18
- package/src/primitives/sheet-drag.tsx +0 -19
- package/src/primitives/sheet-gesture.tsx +0 -22
- package/src/primitives/swipe-row-gesture.tsx +0 -33
- package/src/primitives/switch.tsx +0 -4
- package/src/primitives/text.tsx +0 -4
- package/src/primitives/toast-drag-gesture.tsx +0 -13
- package/src/primitives/web-click-guard.ts +0 -2
- package/src/primitives/window-layer.tsx +0 -18
- package/src/push.ts +0 -15
- package/src/relativeTime.ts +0 -21
- package/src/router/RouterStackPageHeader.tsx +0 -1
- package/src/settings/MoreFromProjectV.tsx +0 -8
- package/src/settings/SettingsEmptyState.tsx +0 -2
- package/src/settings/SettingsSection.tsx +0 -3
- package/src/settings/SettingsToggleRow.tsx +0 -4
- package/src/settings/ThemeModePicker.tsx +2 -16
- package/src/settings/projectVMobileApps.ts +0 -8
- package/src/sheetDrag.ts +0 -9
- package/src/swipeRow.ts +0 -23
- package/src/tabBarRoutes.ts +0 -13
- package/src/tabIndicator.ts +0 -5
- package/src/tailwind-preset.cjs +0 -54
- package/src/tailwind-preset.d.cts +0 -8
- package/src/theme.tsx +11 -2
- package/src/themeModeStore.ts +85 -0
- package/src/themeModes.ts +10 -0
- package/src/toastChrome.ts +0 -6
- package/src/toastDrag.ts +0 -13
- package/src/toastStore.ts +0 -7
- package/src/updateCheck.ts +0 -15
- package/src/video/InlineVideo.tsx +0 -5
- package/src/webview/HtmlView.tsx +0 -23
- package/src/webview/HtmlView.web.tsx +0 -1
- package/src/webview/htmlView.ts +0 -5
- package/types/prism-react-renderer.d.ts +22 -0
|
@@ -810,10 +810,6 @@ function joinCommandText(verb: string, target: string): string {
|
|
|
810
810
|
return `${verb} ${target}`;
|
|
811
811
|
}
|
|
812
812
|
|
|
813
|
-
/**
|
|
814
|
-
* Past-tense phrase used when a step type is folded into a group summary line.
|
|
815
|
-
* Deliberately plural/vague — the exact call is one click away in the fold.
|
|
816
|
-
*/
|
|
817
813
|
const GROUP_PHRASES: Record<ActivityStep["type"], string> = {
|
|
818
814
|
read: "read files",
|
|
819
815
|
edit: "edited files",
|
|
@@ -841,7 +837,6 @@ function groupPhraseForStep(step: ActivityStep): string {
|
|
|
841
837
|
if (step.type !== "tool") {
|
|
842
838
|
return GROUP_PHRASES[step.type];
|
|
843
839
|
}
|
|
844
|
-
// Codex reports edits as a `file_change` tool call, not an edit step.
|
|
845
840
|
if (isFileChangeTool(step)) {
|
|
846
841
|
return GROUP_PHRASES.edit;
|
|
847
842
|
}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
// Pure step types for the activity timeline: no React, so `@vvedantb/native-ui`
|
|
2
|
-
// keeps a byte-identical copy (`src/ai/activity-step-types.ts`), with the step
|
|
3
|
-
// labels and grouping that read them.
|
|
4
|
-
|
|
5
1
|
/** One item in a todo checklist step (type "todos"). */
|
|
6
2
|
export interface ActivityTodoItem {
|
|
7
3
|
content: string;
|
|
@@ -54,43 +50,23 @@ export interface ActivityStep {
|
|
|
54
50
|
| "notice"
|
|
55
51
|
| "hook"
|
|
56
52
|
| "status"
|
|
57
|
-
/** A queued user message the agent took into this live turn (Steer). */
|
|
58
53
|
| "steer";
|
|
59
54
|
label: string;
|
|
60
55
|
detail?: string;
|
|
61
|
-
/** Full, unshortened path for file-type steps. Powers the chat File Viewer. */
|
|
62
56
|
path?: string;
|
|
63
|
-
/** `pending`: a planned step that has not started (sandbox startup stages). */
|
|
64
57
|
status: "complete" | "active" | "pending";
|
|
65
|
-
/** The tool_use id that produced this step (Claude only). */
|
|
66
58
|
toolUseId?: string;
|
|
67
|
-
/** Parent `Agent` tool_use id — set on steps that ran inside a subagent. */
|
|
68
59
|
parentToolUseId?: string;
|
|
69
|
-
/** Todo checklist snapshot (type "todos" only). */
|
|
70
60
|
todos?: ActivityTodoItem[];
|
|
71
|
-
/** Bash command (fuller than detail, capped). */
|
|
72
61
|
command?: string;
|
|
73
|
-
/** Tool result transcript (tail-capped). */
|
|
74
62
|
output?: ActivityStepOutput;
|
|
75
|
-
/** Edit before/after snippets. */
|
|
76
63
|
edits?: ActivityStepEdit[];
|
|
77
|
-
/** Codex file_change paths. */
|
|
78
64
|
files?: string[];
|
|
79
|
-
/** Write tool content head preview. */
|
|
80
65
|
contentPreview?: string;
|
|
81
|
-
/** True when the tool failed or exited non-zero. */
|
|
82
66
|
isError?: boolean;
|
|
83
|
-
/** Wall time from push → complete (ms). */
|
|
84
67
|
durationMs?: number;
|
|
85
|
-
/** AskUserQuestion prompt (type "question" only): the questions and options shown to the user. */
|
|
86
68
|
questions?: ActivityQuestion[];
|
|
87
|
-
/** AskUserQuestion answers keyed by question text. Absent when the turn ended without a structured answer. */
|
|
88
69
|
answers?: Record<string, string>;
|
|
89
|
-
/**
|
|
90
|
-
* The transcript query stripped this step's expanded-only fields (`output`,
|
|
91
|
-
* `edits`, `contentPreview`) to keep the chat subscription small. The row
|
|
92
|
-
* still opens; the body fills in once the full payload is fetched.
|
|
93
|
-
*/
|
|
94
70
|
hasHiddenDetail?: boolean;
|
|
95
71
|
}
|
|
96
72
|
|
package/src/ai/activity-step.tsx
CHANGED
|
@@ -7,13 +7,9 @@ import { AgentTraceDescription, AgentTraceIcon, AgentTraceLine, AgentTraceTitle
|
|
|
7
7
|
export type ActivityStepStatus = "running" | "complete" | "error";
|
|
8
8
|
|
|
9
9
|
export type ActivityStepProps = {
|
|
10
|
-
/** What the AI is doing, such as "Searching the web" or "Reading 3 files". */
|
|
11
10
|
label: string;
|
|
12
|
-
/** The tool's icon. Without one, the line shows the status icon only. */
|
|
13
11
|
icon?: ComponentType<IconProps>;
|
|
14
|
-
/** `running` pulses the label and shows a spinner; `complete` a check; `error` a warning in the danger colour. Default `complete`. */
|
|
15
12
|
status?: ActivityStepStatus;
|
|
16
|
-
/** Faded detail after the label, such as "Worked for 12s" (see `formatElapsed`). */
|
|
17
13
|
description?: string;
|
|
18
14
|
testID?: string;
|
|
19
15
|
};
|
|
@@ -9,11 +9,6 @@ export interface ActivityRow {
|
|
|
9
9
|
children?: ActivityRow[];
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Status-filler thinking labels emitted by older callback versions (and by
|
|
14
|
-
* prod until the current callback deploys). The response/reasoning text is
|
|
15
|
-
* shown directly, so these narration rows are pure noise — hide them.
|
|
16
|
-
*/
|
|
17
12
|
const LEGACY_NOISE_LABELS = new Set([
|
|
18
13
|
"Generating response...",
|
|
19
14
|
"Generated response",
|
|
@@ -22,10 +17,8 @@ const LEGACY_NOISE_LABELS = new Set([
|
|
|
22
17
|
"Finalizing response...",
|
|
23
18
|
]);
|
|
24
19
|
|
|
25
|
-
/** Thinking labels that mark model reasoning rather than status narration. */
|
|
26
20
|
const REASONING_LABELS = new Set(["Thinking...", "Thought"]);
|
|
27
21
|
|
|
28
|
-
/** Placeholder details older callbacks attached to reasoning-label steps. */
|
|
29
22
|
const FILLER_DETAILS = new Set([
|
|
30
23
|
"Claude is reasoning...",
|
|
31
24
|
"Codex is reasoning...",
|
|
@@ -51,7 +44,6 @@ export function normalizeStep(step: ActivityStep): ActivityStep | null {
|
|
|
51
44
|
return step;
|
|
52
45
|
}
|
|
53
46
|
|
|
54
|
-
/** Builds one row per normalized step (no consecutive-type merging). */
|
|
55
47
|
function stepsToRows(steps: ActivityStep[]): ActivityRow[] {
|
|
56
48
|
const rows: ActivityRow[] = [];
|
|
57
49
|
for (const raw of steps) {
|
|
@@ -62,10 +54,6 @@ function stepsToRows(steps: ActivityStep[]): ActivityRow[] {
|
|
|
62
54
|
return rows;
|
|
63
55
|
}
|
|
64
56
|
|
|
65
|
-
/**
|
|
66
|
-
* Row types that read as narration rather than work: they already summarise
|
|
67
|
-
* themselves, so folding them into an action group would hide their only text.
|
|
68
|
-
*/
|
|
69
57
|
const STANDALONE_TYPES = new Set<ActivityStep["type"]>([
|
|
70
58
|
"todos",
|
|
71
59
|
"notice",
|
|
@@ -95,7 +83,6 @@ export function groupActivityRows(rows: ActivityRow[]): ActivitySegment[] {
|
|
|
95
83
|
segments.push({ kind: "reasoning", step: row.step });
|
|
96
84
|
continue;
|
|
97
85
|
}
|
|
98
|
-
// Mid-turn reply text: it ends the tool run before it, like reasoning.
|
|
99
86
|
if (row.step.type === "response") {
|
|
100
87
|
segments.push({ kind: "response", step: row.step });
|
|
101
88
|
continue;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
// The folded (Codex-style) rules of the web `ActivityTasks`
|
|
2
|
-
// (`@vvedantb/ui` `activity-tasks.tsx`), as pure logic for an app that draws
|
|
3
|
-
// the rows with the `AgentTrace` parts. The row text, the grouping and the
|
|
4
|
-
// step types are byte-identical copies of the web files
|
|
5
|
-
// (`activity-step-label.ts`, `activity-tasks-utils.ts`, `activity-step-types.ts`).
|
|
6
1
|
import type { ActivityRow, ActivitySegment } from "./activity-tasks-utils";
|
|
7
2
|
import { buildActivityRows, groupActivityRows } from "./activity-tasks-utils";
|
|
8
3
|
import type { ActivityStep } from "./activity-step-types";
|
|
@@ -13,7 +8,6 @@ export const ACTIVITY_MAX_VISIBLE_BLOCKS = 8;
|
|
|
13
8
|
/** Child rows a subagent step shows before "+N more" (web `MAX_VISIBLE_CHILDREN`). */
|
|
14
9
|
export const ACTIVITY_MAX_VISIBLE_CHILDREN = 8;
|
|
15
10
|
|
|
16
|
-
/** Step types the folded layout hides: the reply text and the status thinking lines. */
|
|
17
11
|
const HIDDEN_TYPES = new Set<ActivityStep["type"]>(["thinking", "response"]);
|
|
18
12
|
|
|
19
13
|
/**
|
package/src/ai/attachments.tsx
CHANGED
|
@@ -23,14 +23,10 @@ import { ResponseText } from "./response-text";
|
|
|
23
23
|
*/
|
|
24
24
|
export type AttachmentData = {
|
|
25
25
|
id: string;
|
|
26
|
-
/** `"source-document"` for a referenced source. Default a file. */
|
|
27
26
|
type?: "file" | "source-document";
|
|
28
27
|
filename?: string;
|
|
29
|
-
/** MIME type, such as `image/png`. */
|
|
30
28
|
mediaType?: string;
|
|
31
|
-
/** A local or remote URI. An image with one shows a thumbnail. */
|
|
32
29
|
url?: string;
|
|
33
|
-
/** A source document's title. */
|
|
34
30
|
title?: string;
|
|
35
31
|
};
|
|
36
32
|
|
|
@@ -86,14 +82,8 @@ export function Attachments({ variant = "inline", className, ...props }: Attachm
|
|
|
86
82
|
|
|
87
83
|
export type AttachmentProps = {
|
|
88
84
|
data: AttachmentData;
|
|
89
|
-
/** Shows a remove button, labelled "Remove" and the attachment name. */
|
|
90
85
|
onRemove?: () => void;
|
|
91
|
-
/**
|
|
92
|
-
* Makes the chip a button, such as to open the file. The remove button stays a
|
|
93
|
-
* separate target and does not call this. Without it the chip is not pressable.
|
|
94
|
-
*/
|
|
95
86
|
onPress?: () => void;
|
|
96
|
-
/** Names the chip button, with `onPress`. Default the attachment name (`getAttachmentLabel`). */
|
|
97
87
|
accessibilityLabel?: string;
|
|
98
88
|
testID?: string;
|
|
99
89
|
};
|
|
@@ -101,7 +91,6 @@ export type AttachmentProps = {
|
|
|
101
91
|
/** The hit target of a pressable chip, in points, on each axis. */
|
|
102
92
|
export const ATTACHMENT_PRESS_TARGET = 48;
|
|
103
93
|
|
|
104
|
-
/** A remove cross of 20 in a 32 row: the slop brings it to 44. */
|
|
105
94
|
const REMOVE_SIZE = 20;
|
|
106
95
|
|
|
107
96
|
/**
|
|
@@ -175,8 +164,6 @@ export function Attachment({ data, onRemove, onPress, accessibilityLabel, testID
|
|
|
175
164
|
<Pressable
|
|
176
165
|
accessibilityRole="button"
|
|
177
166
|
accessibilityLabel={`Remove ${label}`}
|
|
178
|
-
// A pressable label sits 6 before it, and the next chip 8 past this
|
|
179
|
-
// chip's edge: the slop stops short of both, so neither steals a tap.
|
|
180
167
|
hitSlop={{ ...touchSlop(REMOVE_SIZE), left: onPress ? 3 : touchSlop(REMOVE_SIZE).left, right: 8 }}
|
|
181
168
|
onPress={onRemove}
|
|
182
169
|
className="items-center justify-center rounded-full active:opacity-70"
|
|
@@ -19,16 +19,12 @@ import {
|
|
|
19
19
|
} from "./collapsible";
|
|
20
20
|
import { ResponseText } from "./response-text";
|
|
21
21
|
|
|
22
|
-
// The web `ChainOfThought`, simplified: a fold of steps with search-result
|
|
23
|
-
// chips. `ChainOfThoughtImage` and the step enter animation are not ported.
|
|
24
|
-
|
|
25
22
|
/** Holds its open state (default closed), or takes `open` and `onOpenChange`. */
|
|
26
23
|
export function ChainOfThought({ className, ...props }: CollapsibleProps) {
|
|
27
24
|
return <Collapsible className={cn("w-full gap-4", className)} {...props} />;
|
|
28
25
|
}
|
|
29
26
|
|
|
30
27
|
export type ChainOfThoughtHeaderProps = Omit<CollapsibleTriggerProps, "children"> & {
|
|
31
|
-
/** Default "Chain of Thought". A string, as it is also the accessibility label. */
|
|
32
28
|
children?: string;
|
|
33
29
|
icon?: ComponentType<IconProps>;
|
|
34
30
|
};
|
|
@@ -71,7 +67,6 @@ export type ChainOfThoughtStepProps = ViewProps & {
|
|
|
71
67
|
icon?: ComponentType<IconProps>;
|
|
72
68
|
label: string;
|
|
73
69
|
description?: string;
|
|
74
|
-
/** `active` is the foreground, `complete` muted, `pending` muted at half opacity, as on the web. Default `complete`. */
|
|
75
70
|
status?: ChainOfThoughtStepStatus;
|
|
76
71
|
className?: string;
|
|
77
72
|
children?: ReactNode;
|
|
@@ -5,9 +5,7 @@ import { cn } from "../cn";
|
|
|
5
5
|
export type ChatJumpRailItem = { id: string; label: string };
|
|
6
6
|
|
|
7
7
|
export type ChatJumpRailProps = {
|
|
8
|
-
/** The messages to jump between, such as the user messages of a long thread. */
|
|
9
8
|
items: ChatJumpRailItem[];
|
|
10
|
-
/** Called with the `id` of the pressed item. */
|
|
11
9
|
onJump: (id: string) => void;
|
|
12
10
|
className?: string;
|
|
13
11
|
testID?: string;
|
package/src/ai/chat-text.ts
CHANGED
package/src/ai/chat-thread.tsx
CHANGED
|
@@ -19,25 +19,17 @@ export type UIMessage = {
|
|
|
19
19
|
|
|
20
20
|
export type ChatThreadProps<M extends UIMessage = UIMessage> = {
|
|
21
21
|
messages: M[];
|
|
22
|
-
/** True while a reply is on its way. Marks the last assistant message as streaming and shows `thinking`. */
|
|
23
22
|
working: boolean;
|
|
24
|
-
/** Draws one message. `isStreaming` is true for the last assistant message while `working`. */
|
|
25
23
|
renderMessage: (message: M, isStreaming: boolean) => ReactNode;
|
|
26
|
-
/** A row after the last user message while `working`, such as a `Shimmer` "Thinking". */
|
|
27
24
|
thinking?: ReactNode;
|
|
28
|
-
/** Shown in place of the list when there are no messages. */
|
|
29
25
|
emptyState?: ReactNode;
|
|
30
|
-
/** Last in the column, lifted over the keyboard. A `PromptInput`. */
|
|
31
26
|
footer: ReactNode;
|
|
32
|
-
/** Merged into the `ConversationContent` column classes (`gap-4 px-3 py-3`), such as `px-4 py-4`. */
|
|
33
27
|
contentContainerClassName?: string;
|
|
34
|
-
/** Height of anything above the thread, such as a navigation header, for the keyboard lift. Default 0. */
|
|
35
28
|
keyboardVerticalOffset?: number;
|
|
36
29
|
className?: string;
|
|
37
30
|
testID?: string;
|
|
38
31
|
};
|
|
39
32
|
|
|
40
|
-
/** Index of the last message with `role`, or -1. A loop, not `findLastIndex` (Hermes). */
|
|
41
33
|
function lastIndexOfRole(messages: UIMessage[], role: UIMessage["role"]) {
|
|
42
34
|
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
43
35
|
if (messages[index]!.role === role) return index;
|
|
@@ -71,7 +63,6 @@ export function ChatThread<M extends UIMessage = UIMessage>({
|
|
|
71
63
|
|
|
72
64
|
return (
|
|
73
65
|
<KeyboardAvoidingView testID={testID} keyboardVerticalOffset={keyboardVerticalOffset} style={styles.fill}>
|
|
74
|
-
{/* The column lifts as a whole: the parts in it add no lift of their own. */}
|
|
75
66
|
<KeyboardLiftContext.Provider value>
|
|
76
67
|
<View className={cn("flex-1", className)}>
|
|
77
68
|
<Conversation>
|
|
@@ -14,7 +14,6 @@ import { chatTextSize } from "./chat-text";
|
|
|
14
14
|
/** One question, as an agent's AskUserQuestion sends it. */
|
|
15
15
|
export type ChoiceQuestionItem = {
|
|
16
16
|
question: string;
|
|
17
|
-
/** Short tag shown as a badge beside the question. */
|
|
18
17
|
header: string;
|
|
19
18
|
multiSelect: boolean;
|
|
20
19
|
options: ReadonlyArray<{ label: string; description: string }>;
|
|
@@ -22,23 +21,11 @@ export type ChoiceQuestionItem = {
|
|
|
22
21
|
|
|
23
22
|
export type ChoiceQuestionProps = {
|
|
24
23
|
questions: ReadonlyArray<ChoiceQuestionItem>;
|
|
25
|
-
/**
|
|
26
|
-
* Question text to the picked label, or the typed "Other" answer.
|
|
27
|
-
* Multi-select joins labels with ", " (the shape AskUserQuestion reads).
|
|
28
|
-
*/
|
|
29
24
|
onSubmit: (answers: Record<string, string>) => void | Promise<void>;
|
|
30
|
-
/** Shows a spinner on the submit button and blocks input. */
|
|
31
25
|
loading?: boolean;
|
|
32
|
-
/** Default "Other...". */
|
|
33
26
|
otherLabel?: string;
|
|
34
|
-
/** Default "Type your answer...". */
|
|
35
27
|
otherPlaceholder?: string;
|
|
36
|
-
/** Inside the web dock card (`rounded-surface bg-card p-3`, scrolling past 60% of the screen). Default `true`. */
|
|
37
28
|
framed?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Back, Next and Submit label weight. Default `medium`, the `Button` label
|
|
40
|
-
* (web `font-medium`). `semibold` for apps whose web buttons are semibold, as Eva.
|
|
41
|
-
*/
|
|
42
29
|
buttonWeight?: "medium" | "semibold";
|
|
43
30
|
};
|
|
44
31
|
|
|
@@ -83,7 +70,6 @@ export function ChoiceQuestion({
|
|
|
83
70
|
const largerText = useLargerText();
|
|
84
71
|
const icon = largerText ? 18 : 15;
|
|
85
72
|
const buttonText = largerText ? "text-xl" : "text-sm";
|
|
86
|
-
// A string child draws the `Button` medium label; a semibold one is drawn here, in the variant's label colour.
|
|
87
73
|
const buttonLabel = (text: string, variant: "primary" | "ghost") =>
|
|
88
74
|
buttonWeight === "medium" ? (
|
|
89
75
|
text
|
|
@@ -128,7 +114,6 @@ export function ChoiceQuestion({
|
|
|
128
114
|
<View className="flex-row items-center justify-between" style={{ gap: 8 }}>
|
|
129
115
|
<Text
|
|
130
116
|
className="flex-1 font-instrument-sans-medium"
|
|
131
|
-
// Web `text-[15px] leading-snug` (15 / 20.625); larger text steps up to 18.
|
|
132
117
|
style={[{ fontSize: largerText ? 18 : 15, lineHeight: largerText ? 24 : 15 * 1.375 }, textStyle("foreground", scheme), typeStyle("medium")]}
|
|
133
118
|
>
|
|
134
119
|
{question.question}
|
|
@@ -175,8 +160,6 @@ export function ChoiceQuestion({
|
|
|
175
160
|
placeholder={otherPlaceholder}
|
|
176
161
|
editable={!loading}
|
|
177
162
|
autoFocus
|
|
178
|
-
// Return is the Next or Submit button. Until there is an
|
|
179
|
-
// answer it keeps the keyboard up, as the button does nothing.
|
|
180
163
|
returnKeyType={isLast ? "send" : "next"}
|
|
181
164
|
submitBehavior={isLast && hasAnswer ? "blurAndSubmit" : "submit"}
|
|
182
165
|
onSubmitEditing={next}
|
|
@@ -255,10 +238,8 @@ export function TopicBadge({ children }: { children: string }) {
|
|
|
255
238
|
);
|
|
256
239
|
}
|
|
257
240
|
|
|
258
|
-
/** The option card's `py-2 px-2.5`, which is also the slop of its press target. */
|
|
259
241
|
const CARD_PADDING = { top: 8, bottom: 8, left: 10, right: 10 };
|
|
260
242
|
|
|
261
|
-
/** A whole card is at least a 44 target: the press target inside is this much less its slop. */
|
|
262
243
|
const CARD_MIN_HEIGHT = 44;
|
|
263
244
|
|
|
264
245
|
/** The card while pressed: the kit 3% press scale, or a dim with Reduce Motion. */
|
|
@@ -267,11 +248,6 @@ export function choicePressStyle(pressed: boolean, reduceMotion: boolean) {
|
|
|
267
248
|
return reduceMotion ? { opacity: 0.8 } : { transform: [{ scale: 0.97 }] };
|
|
268
249
|
}
|
|
269
250
|
|
|
270
|
-
/**
|
|
271
|
-
* One option row (web `Card` with `bg-secondary`, `py-2 px-2.5`, radius 16): a round 24 mark
|
|
272
|
-
* (30 with larger text; letter, or a pencil for "Other"; a check on the primary fill when picked),
|
|
273
|
-
* the label and the description. Picked: a 1-wide primary ring outside, on the accent.
|
|
274
|
-
*/
|
|
275
251
|
function ChoiceRow({
|
|
276
252
|
selected,
|
|
277
253
|
disabled,
|
|
@@ -284,7 +260,6 @@ function ChoiceRow({
|
|
|
284
260
|
}: {
|
|
285
261
|
selected: boolean;
|
|
286
262
|
disabled: boolean;
|
|
287
|
-
/** A multi-select question: each row is a `checkbox`, not a `radio`. */
|
|
288
263
|
multiple: boolean;
|
|
289
264
|
mark: string;
|
|
290
265
|
label: string;
|
|
@@ -295,24 +270,18 @@ function ChoiceRow({
|
|
|
295
270
|
const scheme = useScheme();
|
|
296
271
|
const largerText = useLargerText();
|
|
297
272
|
const reduceMotion = useReduceMotion();
|
|
298
|
-
// The scale moves the whole card, which is not the Pressable (the "Other" field sits in it too).
|
|
299
273
|
const [pressed, setPressed] = useState(false);
|
|
300
274
|
const muted = tokens.color.muted[scheme];
|
|
301
275
|
const markSize = largerText ? 30 : 24;
|
|
302
276
|
const markText = largerText ? 14 : 11;
|
|
303
277
|
const glyph = largerText ? 16 : 13;
|
|
304
278
|
const small = chatTextSize("small", largerText);
|
|
305
|
-
// Web: an option label is `text-sm leading-snug font-medium`; "Other..." is
|
|
306
|
-
// plain `text-sm`, medium only once picked.
|
|
307
279
|
const plain = mark === "other" && !selected;
|
|
308
|
-
// The web label is an inline `leading-snug` span in a 16 / 24 block, so each
|
|
309
|
-
// line box is the block's 24, not 19.25: rows are 24 a line, as on the web.
|
|
310
280
|
const labelLine = largerText ? sizeStyle(small, "snug") : { ...sizeStyle(small, "snug"), lineHeight: 24 };
|
|
311
281
|
return (
|
|
312
282
|
<View
|
|
313
283
|
style={[
|
|
314
284
|
{
|
|
315
|
-
// Web `Card` (rounded-surface, 16) with `py-2 px-2.5` and no border width.
|
|
316
285
|
borderRadius: tokens.radius.lg,
|
|
317
286
|
backgroundColor: selected ? tokens.color.background[scheme] : palette.default[scheme],
|
|
318
287
|
opacity: disabled ? 0.5 : 1,
|
|
@@ -323,7 +292,6 @@ function ChoiceRow({
|
|
|
323
292
|
]}
|
|
324
293
|
>
|
|
325
294
|
{selected ? (
|
|
326
|
-
// Web `ring-1 ring-primary`: a 1 line just outside the card, so picking a row moves nothing.
|
|
327
295
|
<View
|
|
328
296
|
pointerEvents="none"
|
|
329
297
|
style={{
|
|
@@ -344,7 +312,6 @@ function ChoiceRow({
|
|
|
344
312
|
accessibilityHint={description || undefined}
|
|
345
313
|
accessibilityState={{ checked: selected, disabled }}
|
|
346
314
|
disabled={disabled}
|
|
347
|
-
// The card's own padding: a tap anywhere on the card picks it, and stops at its edge.
|
|
348
315
|
hitSlop={CARD_PADDING}
|
|
349
316
|
onPress={onPress}
|
|
350
317
|
onPressIn={() => setPressed(true)}
|
|
@@ -360,7 +327,6 @@ function ChoiceRow({
|
|
|
360
327
|
style={{
|
|
361
328
|
width: markSize,
|
|
362
329
|
height: markSize,
|
|
363
|
-
// Web `rounded-md` (radius - 2 = 14 at the default 1rem) on a 24 box: round.
|
|
364
330
|
borderRadius: markSize / 2,
|
|
365
331
|
marginTop: description ? 2 : 0,
|
|
366
332
|
alignItems: "center",
|
|
@@ -373,7 +339,6 @@ function ChoiceRow({
|
|
|
373
339
|
) : mark === "other" ? (
|
|
374
340
|
<IconPencil size={glyph} color={muted} />
|
|
375
341
|
) : (
|
|
376
|
-
// Web `text-2xs font-medium tracking-wide`, at semibold: native-ui draws no bold face.
|
|
377
342
|
<Text
|
|
378
343
|
className="font-instrument-sans-medium"
|
|
379
344
|
style={[
|
|
@@ -400,7 +365,6 @@ function ChoiceRow({
|
|
|
400
365
|
</Text>
|
|
401
366
|
)}
|
|
402
367
|
{description ? (
|
|
403
|
-
// Web `text-xs mt-0.5 leading-relaxed` (12 / 19.5).
|
|
404
368
|
<Text
|
|
405
369
|
className="font-instrument-sans"
|
|
406
370
|
style={[sizeStyle(chatTextSize("caption", largerText), "relaxed"), { color: muted, marginTop: 2 }]}
|
package/src/ai/code-block.tsx
CHANGED
|
@@ -32,20 +32,10 @@ export const CODE_BLOCK_METRICS = {
|
|
|
32
32
|
|
|
33
33
|
export type CodeBlockCopyButtonProps = {
|
|
34
34
|
code: string;
|
|
35
|
-
/**
|
|
36
|
-
* Puts `code` on the clipboard. React Native's own `Clipboard` is
|
|
37
|
-
* deprecated, and native-ui adds no clipboard package, so the app passes its
|
|
38
|
-
* own (for example `expo-clipboard`'s `setStringAsync`). A rejected promise
|
|
39
|
-
* leaves the copy icon.
|
|
40
|
-
*/
|
|
41
35
|
onCopy: (code: string) => void | Promise<void>;
|
|
42
|
-
/** Milliseconds the check shows after a copy. Default 2000, as on the web. */
|
|
43
36
|
timeout?: number;
|
|
44
|
-
/** Default "Copy code"; "Copied" while the check shows. */
|
|
45
37
|
label?: string;
|
|
46
|
-
/** Default `sm` (the web `CodeBlock` copy button); the markdown code block uses `xs`. */
|
|
47
38
|
size?: ChatIconButtonSize;
|
|
48
|
-
/** Default `"square"`. See `ChatIconButton`. */
|
|
49
39
|
slop?: ChatIconButtonProps["slop"];
|
|
50
40
|
};
|
|
51
41
|
|
|
@@ -57,7 +47,6 @@ export function CodeBlockCopyButton({ code, onCopy, timeout = 2000, label = "Cop
|
|
|
57
47
|
useEffect(() => () => clearTimeout(timer.current), []);
|
|
58
48
|
|
|
59
49
|
const copy = async () => {
|
|
60
|
-
// As the web: presses while the check shows do nothing.
|
|
61
50
|
if (copied) return;
|
|
62
51
|
try {
|
|
63
52
|
await onCopy(code);
|
|
@@ -81,39 +70,13 @@ export function CodeBlockCopyButton({ code, onCopy, timeout = 2000, label = "Cop
|
|
|
81
70
|
|
|
82
71
|
export type CodeBlockProps = {
|
|
83
72
|
code: string;
|
|
84
|
-
/**
|
|
85
|
-
* Shown in the header, and the Prism language for highlighting (`tsx`,
|
|
86
|
-
* `python`, `json`…). An unknown language draws plain text.
|
|
87
|
-
*/
|
|
88
73
|
language?: string;
|
|
89
|
-
/**
|
|
90
|
-
* Colour the code in the GitHub light and dark colours, as the web shiki
|
|
91
|
-
* block. Default `true`. Needs the optional peer `prism-react-renderer` and a
|
|
92
|
-
* `language`; without either the code is plain.
|
|
93
|
-
*/
|
|
94
74
|
highlight?: boolean;
|
|
95
|
-
/** With it, the header has a copy button. See `CodeBlockCopyButton`. */
|
|
96
75
|
onCopy?: (code: string) => void | Promise<void>;
|
|
97
|
-
/** Default `default`, the web `CodeBlock`. `markdown` is the web `MarkdownCodeBlock` (see `CodeBlock`). */
|
|
98
76
|
variant?: "default" | "markdown";
|
|
99
77
|
className?: string;
|
|
100
78
|
};
|
|
101
79
|
|
|
102
|
-
/**
|
|
103
|
-
* Code on the flat panel at radius 16, selectable, long lines scrolling
|
|
104
|
-
* sideways. With `prism-react-renderer` installed and a `language`, tokens
|
|
105
|
-
* take the GitHub colours of the scheme.
|
|
106
|
-
*
|
|
107
|
-
* `default` is the web `CodeBlock` (`ai-elements/code-block.tsx`): `text-sm`
|
|
108
|
-
* code in `p-4`, and a `px-3` header with the language and a copy button when
|
|
109
|
-
* either is given. `markdown` is the web `MarkdownCodeBlock`, which `Markdown`
|
|
110
|
-
* draws for fenced code: 13 / 20.15 code, a 32 header with `icon-xs` actions,
|
|
111
|
-
* a wrap toggle ("Wrap long lines", foreground while on) and then copy.
|
|
112
|
-
*/
|
|
113
|
-
/**
|
|
114
|
-
* Android fades the code at a side with more to scroll (there is no scroll
|
|
115
|
-
* bar), so a cut line reads as "scroll sideways". iOS ignores it.
|
|
116
|
-
*/
|
|
117
80
|
const CODE_FADING_EDGE = 24;
|
|
118
81
|
|
|
119
82
|
export function CodeBlock({ code, language, highlight = true, onCopy, variant = "default", className }: CodeBlockProps) {
|
|
@@ -142,7 +105,6 @@ export function CodeBlock({ code, language, highlight = true, onCopy, variant =
|
|
|
142
105
|
);
|
|
143
106
|
}
|
|
144
107
|
|
|
145
|
-
/** The web `MarkdownCodeBlock`: `CodeBlock` with `variant="markdown"`. A component of its own for the wrap state. */
|
|
146
108
|
function MarkdownCodeBlock({
|
|
147
109
|
code,
|
|
148
110
|
language,
|
|
@@ -164,8 +126,6 @@ function MarkdownCodeBlock({
|
|
|
164
126
|
style={largerText ? { paddingLeft: headerBox.paddingLeft, paddingRight: headerBox.paddingRight } : headerBox}
|
|
165
127
|
>
|
|
166
128
|
{parts.label}
|
|
167
|
-
{/* Web `.markdown-code-actions`: `gap-0.5`. The two sit 2 apart, so
|
|
168
|
-
each slops only above and below and on its outer side. */}
|
|
169
129
|
<View className="flex-row items-center gap-0.5">
|
|
170
130
|
<ChatIconButton
|
|
171
131
|
icon={IconTextWrap}
|
|
@@ -196,7 +156,6 @@ function MarkdownCodeBlock({
|
|
|
196
156
|
);
|
|
197
157
|
}
|
|
198
158
|
|
|
199
|
-
/** The panel style, the language label and the code text both code blocks draw. */
|
|
200
159
|
function useCodeParts(code: string, language: string | undefined, highlight: boolean, markdown: boolean) {
|
|
201
160
|
const scheme = useScheme();
|
|
202
161
|
const largerText = useLargerText();
|
|
@@ -226,10 +185,6 @@ function useCodeParts(code: string, language: string | undefined, highlight: boo
|
|
|
226
185
|
};
|
|
227
186
|
}
|
|
228
187
|
|
|
229
|
-
/**
|
|
230
|
-
* Coloured runs as nested `Text` spans, lines joined by newlines. They
|
|
231
|
-
* inherit the size and font of the code `Text` around them.
|
|
232
|
-
*/
|
|
233
188
|
function CodeRuns({ lines, scheme }: { lines: CodeToken[][]; scheme: "light" | "dark" }) {
|
|
234
189
|
return (
|
|
235
190
|
<>
|
|
@@ -247,12 +202,6 @@ function CodeRuns({ lines, scheme }: { lines: CodeToken[][]; scheme: "light" | "
|
|
|
247
202
|
);
|
|
248
203
|
}
|
|
249
204
|
|
|
250
|
-
/**
|
|
251
|
-
* The code in the web's Shiki colours: shell blocks through `shellTokens`
|
|
252
|
-
* (no peer needed), other languages through Prism, the JavaScript family
|
|
253
|
-
* recoloured where Prism and Shiki disagree (`scriptTokens`). Without
|
|
254
|
-
* `prism-react-renderer` a non-shell block is the plain code.
|
|
255
|
-
*/
|
|
256
205
|
function HighlightedCode({ code, language, scheme }: { code: string; language: string; scheme: "light" | "dark" }) {
|
|
257
206
|
const lang = language.toLowerCase();
|
|
258
207
|
const source = code.replace(/\n$/, "");
|
|
@@ -269,7 +218,6 @@ function HighlightedCode({ code, language, scheme }: { code: string; language: s
|
|
|
269
218
|
{tokens.map((line, lineIndex) => (
|
|
270
219
|
<Fragment key={lineIndex}>
|
|
271
220
|
{lineIndex > 0 ? "\n" : null}
|
|
272
|
-
{/* An empty line is one `empty` token whose content is "\n": the join above already breaks it. */}
|
|
273
221
|
{line.map((token, tokenIndex) =>
|
|
274
222
|
token.empty ? null : (
|
|
275
223
|
<Text key={tokenIndex} style={{ color: codeTokenColor(token.types, scheme) }}>
|
package/src/ai/collapsible.tsx
CHANGED
|
@@ -7,17 +7,6 @@ import { MIN_TOUCH_TARGET, touchSlop } from "../controlStyles";
|
|
|
7
7
|
import { useControllableState } from "../primitives/use-controllable-state";
|
|
8
8
|
import { useReduceMotion } from "../useReduceMotion";
|
|
9
9
|
|
|
10
|
-
// A small fold for the AI parts: native-ui has no `Collapsible`. A `Pressable`
|
|
11
|
-
// trigger and content that mounts only while open. The content appears at
|
|
12
|
-
// once: a fade would also run each time a list mounts an open fold (a chat
|
|
13
|
-
// opening, a virtualised row scrolled back). The chevron turns in 150 ms; with
|
|
14
|
-
// Reduce Motion it changes in place.
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The web chevron: `transition-transform duration-150`. The curve is the
|
|
18
|
-
* predefined `ease-out`: a `cubicBezier(...)` value in an `Animated.View`
|
|
19
|
-
* style does not typecheck against `react-native-reanimated` 4.3.
|
|
20
|
-
*/
|
|
21
10
|
const CHEVRON_TURN = {
|
|
22
11
|
transitionProperty: "transform",
|
|
23
12
|
transitionDuration: 150,
|
|
@@ -56,7 +45,6 @@ export function Collapsible({ open, defaultOpen = false, onOpenChange, ...props
|
|
|
56
45
|
);
|
|
57
46
|
}
|
|
58
47
|
|
|
59
|
-
/** A `text-sm` line with the web `py-1`: 28 high. The slop brings it to 44. */
|
|
60
48
|
const TRIGGER_ROW_HEIGHT = 28;
|
|
61
49
|
|
|
62
50
|
export type CollapsibleTriggerProps = Omit<PressableProps, "children"> & {
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { createContext, useContext, type RefObject } from "react";
|
|
2
2
|
import type { NativeScrollEvent } from "react-native";
|
|
3
3
|
|
|
4
|
-
// The `Conversation` context on its own, so a message can reach it without the
|
|
5
|
-
// thread's components (`message.tsx` sets `overlay`).
|
|
6
|
-
|
|
7
4
|
/**
|
|
8
5
|
* What the thread scrolls with: the `ScrollView` of `ConversationContent` or
|
|
9
6
|
* the `FlatList` of `ConversationList`. `scrollToEnd` goes to the newest
|
|
@@ -22,22 +19,11 @@ export type ConversationContextValue = {
|
|
|
22
19
|
isAtBottom: boolean;
|
|
23
20
|
scrollToBottom: () => void;
|
|
24
21
|
scrollRef: RefObject<ConversationScroller | null>;
|
|
25
|
-
/** `bottomInset` and `inverted`, as `isScrolledToBottom`. */
|
|
26
22
|
onScroll: (event: NativeScrollEvent, bottomInset?: number, inverted?: boolean) => void;
|
|
27
23
|
onUserScroll: () => void;
|
|
28
24
|
followContent: () => void;
|
|
29
|
-
/** The height of the `ConversationDock` under the thread, 0 without one. */
|
|
30
25
|
dockHeight: number;
|
|
31
26
|
setDockHeight: (height: number) => void;
|
|
32
|
-
/**
|
|
33
|
-
* A message's hold menu over the thread. Its window takes the focus on
|
|
34
|
-
* Android, as it opens and again as it closes, and the keyboard handler of
|
|
35
|
-
* `ConversationList` would scroll the thread to its end each time. The list
|
|
36
|
-
* ignores the keyboard from `openOverlay` until the close has settled:
|
|
37
|
-
* `closeOverlay` marks it `closing`, and `settleOverlay` ends that on the
|
|
38
|
-
* close's last keyboard event (Android), the menu's dismiss (iOS) or the
|
|
39
|
-
* reader's next drag. Android gives no dismiss callback for a `Modal`.
|
|
40
|
-
*/
|
|
41
27
|
overlay: "none" | "open" | "closing";
|
|
42
28
|
openOverlay: () => void;
|
|
43
29
|
closeOverlay: () => void;
|