@kabmo-labs/kabmo 0.13.0 → 0.14.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/dist/client/index.html +1 -1
- package/dist/client/index.js +319 -319
- package/dist/client/static/js/{index-vzb1qz51.js → index-nfsg1jpt.js} +779 -779
- package/dist/client/static/js/index-tsgy3gd1.css +1 -0
- package/package.json +1 -1
- package/src/client/components/common/batch-selection/BatchActionBar.test.ts +42 -5
- package/src/client/components/common/batch-selection/BatchActionBar.tsx +57 -14
- package/src/client/components/common/code-surface/extensions.ts +7 -1
- package/src/client/components/common/code-surface/fold-placeholder.ts +43 -0
- package/src/client/components/common/session-row/StatusSlot.tsx +133 -0
- package/src/client/components/common/session-row/TrailingSlot.tsx +84 -0
- package/src/client/components/common/session-row/index.tsx +205 -0
- package/src/client/components/common/session-row/session-row.test.tsx +144 -0
- package/src/client/components/layout/session-sidebar/ClassicView.tsx +121 -0
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +99 -112
- package/src/client/components/layout/session-sidebar/Toolbar.tsx +2 -2
- package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +149 -0
- package/src/client/components/layout/session-sidebar/modern/FilterChips.tsx +150 -0
- package/src/client/components/layout/session-sidebar/modern/SearchField.tsx +75 -0
- package/src/client/components/layout/session-sidebar/modern/Skeleton.tsx +55 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +184 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +333 -0
- package/src/client/components/layout/session-sidebar/modern/index.tsx +147 -0
- package/src/client/components/layout/session-sidebar/variant-props.ts +73 -0
- package/src/client/components/mobile/SessionSidebar.tsx +137 -146
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +140 -0
- package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +3 -3
- package/src/client/components/mobile/mobile-session-sidebar/use-drawer.ts +104 -0
- package/src/client/components/settings/Modal.tsx +5 -27
- package/src/client/components/settings/Sidebar.tsx +1 -1
- package/src/client/components/settings/apply-side-effects.test.ts +102 -0
- package/src/client/components/settings/apply-side-effects.ts +90 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +11 -1
- package/src/client/components/settings/categories/ChatSettings.test.tsx +121 -0
- package/src/client/components/settings/categories/ChatSettings.tsx +80 -15
- package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +157 -0
- package/src/client/components/settings/categories/chat-settings/ComposerStyleSection.tsx +177 -0
- package/src/client/components/settings/categories/chat-settings/LayoutSection.tsx +1 -1
- package/src/client/components/settings/categories/chat-settings/SidebarList.tsx +73 -0
- package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +144 -0
- package/src/client/components/settings/categories/chat-settings/groups.test.ts +42 -0
- package/src/client/components/settings/categories/chat-settings/groups.ts +81 -0
- package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +1 -68
- package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +7 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +14 -5
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +90 -41
- package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +13 -6
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +108 -67
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.test.ts +28 -8
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +48 -4
- package/src/client/components/workspace/chat-timeline/TurnRail.tsx +64 -0
- package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +158 -0
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerNotice.tsx +50 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +178 -0
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +102 -122
- package/src/client/components/workspace/chat-timeline/chat-input/props.ts +7 -0
- package/src/client/components/workspace/chat-timeline/chat-input/styles/index.tsx +111 -0
- package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +181 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/approval-gate.test.tsx +31 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/index.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/plugin-renderers.ts +6 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +98 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolCardShell.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/status-glyph.tsx +56 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/toggle-label.ts +19 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +132 -0
- package/src/client/components/workspace/chat-timeline/{ToolCallCard.plugin.test.ts → tool-renderers/styles/Card.plugin.test.ts} +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +60 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +89 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +72 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +84 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/props.ts +22 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +153 -0
- package/src/client/components/workspace/diff-panel/folding.ts +6 -1
- package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +86 -12
- package/src/client/components/workspace/model-dropdown/Item.tsx +56 -19
- package/src/client/components/workspace/model-dropdown/Panel.tsx +21 -13
- package/src/client/components/workspace/model-dropdown/Section.test.tsx +114 -4
- package/src/client/components/workspace/model-dropdown/Section.tsx +21 -9
- package/src/client/components/workspace/model-dropdown/groups.test.ts +164 -1
- package/src/client/components/workspace/model-dropdown/groups.ts +94 -17
- package/src/client/components/workspace/model-dropdown/index.tsx +27 -19
- package/src/client/data/settings/omp-schema.json +151 -6
- package/src/client/hooks/chat/composer/style.ts +66 -0
- package/src/client/hooks/chat/timeline/tool-render-mode.ts +65 -0
- package/src/client/hooks/settings/providers/login.ts +11 -2
- package/src/client/hooks/ui/window-event.ts +20 -4
- package/src/client/hooks/workspace/batch-archive-run.ts +47 -0
- package/src/client/hooks/workspace/batch-archive.test.ts +59 -0
- package/src/client/hooks/workspace/batch-archive.ts +78 -0
- package/src/client/hooks/workspace/sidebar-batch.ts +95 -0
- package/src/client/hooks/workspace/sidebar-style.ts +66 -0
- package/src/client/tailwind.css +111 -0
- package/src/server/index.ts +10 -134
- package/src/server/lib/lifecycle/after-listen.ts +178 -0
- package/src/server/lib/lifecycle/rejection-guard.test.ts +79 -0
- package/src/server/lib/lifecycle/rejection-guard.ts +74 -0
- package/src/server/lib/lifecycle/tls.test.ts +7 -7
- package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +131 -0
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +46 -0
- package/src/server/lib/omp/rpc/frame-fold.test.ts +1 -100
- package/src/server/lib/omp/rpc/frame-fold.ts +13 -0
- package/src/server/lib/plugins/background.server.ts +17 -1
- package/src/server/lib/plugins/background.test.ts +33 -0
- package/src/server/routes/sessions/batch-archive.test.ts +113 -0
- package/src/server/routes/sessions/batch-archive.ts +80 -0
- package/src/server/routes/sessions/index.ts +4 -0
- package/src/shared/lib/chat/composer/style.test.ts +126 -0
- package/src/shared/lib/chat/composer/style.ts +171 -0
- package/src/shared/lib/chat/composer/tui-only.test.ts +3 -0
- package/src/shared/lib/chat/composer/tui-only.ts +5 -0
- package/src/shared/lib/chat/timeline/block-chrome.ts +129 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.test.ts +51 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.ts +74 -0
- package/src/shared/lib/chat/timeline/trace-groups.test.ts +120 -0
- package/src/shared/lib/chat/timeline/trace-groups.ts +68 -0
- package/src/shared/lib/settings/defaults.ts +6 -0
- package/src/shared/lib/workspace/session-focus.test.ts +93 -0
- package/src/shared/lib/workspace/session-focus.ts +71 -0
- package/src/shared/lib/workspace/sidebar-filter-row.test.ts +73 -0
- package/src/shared/lib/workspace/sidebar-filter-row.ts +86 -0
- package/src/shared/lib/workspace/sidebar-style.test.ts +58 -0
- package/src/shared/lib/workspace/sidebar-style.ts +86 -0
- package/src/shared/types/omp/agent.ts +6 -0
- package/src/shared/types/settings/state.ts +31 -0
- package/dist/client/static/js/index-68w8h33q.css +0 -1
- package/src/client/components/workspace/chat-timeline/ToolCallCard.tsx +0 -194
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
|
|
2
2
|
import type { ClipboardEvent, SetStateAction } from 'preact/compat';
|
|
3
|
-
import { AlertTriangle, X } from 'lucide-preact';
|
|
4
3
|
import type { Attachment } from '@/shared/types';
|
|
5
|
-
import { ComposerToolbar } from '@/client/components/workspace/chat-timeline/chat-input/Toolbar';
|
|
6
|
-
import { VoiceNotice } from '@/client/components/workspace/chat-timeline/chat-input/VoiceNotice';
|
|
7
|
-
import { ComposerTextarea } from '@/client/components/common/ComposerTextarea';
|
|
8
|
-
import { usePublishComposerState } from '@/client/hooks/chat/composer/publish-state';
|
|
9
4
|
import { useModelSelection } from '@/client/hooks/chat/composer/model-selection';
|
|
10
|
-
import { AttachmentToolbar } from '@/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar';
|
|
11
5
|
import { NO_PENDING_PICK } from '@/client/hooks/chat/timeline/deferred-model';
|
|
12
6
|
import { CHAT_COMPOSER_MAX_LINES, useAutoGrow } from '@/client/hooks/chat/composer/auto-grow';
|
|
13
7
|
import { useVoiceInput } from '@/client/hooks/chat/composer/voice-input';
|
|
14
8
|
import { primeFileReads } from '@/client/hooks/chat/composer/file-reads';
|
|
15
9
|
import { useComposerPipeline } from '@/client/hooks/chat/composer/pipeline';
|
|
10
|
+
import { usePublishComposerState } from '@/client/hooks/chat/composer/publish-state';
|
|
16
11
|
import { DropOverlay } from '@/client/components/workspace/chat-timeline/chat-input/DropOverlay';
|
|
17
12
|
import { GoalSurfaces } from '@/client/components/workspace/chat-timeline/chat-input/GoalSurfaces';
|
|
13
|
+
import { ComposerFrame } from '@/client/components/workspace/chat-timeline/chat-input/styles/index';
|
|
14
|
+
import { composerRows } from '@/client/components/workspace/chat-timeline/chat-input/ComposerRows';
|
|
18
15
|
import { normalizeGoalBudget } from '@/shared/lib/omp/mode/budget';
|
|
19
16
|
import { readKabmoSetting } from '@/shared/lib/settings/client';
|
|
20
17
|
import { useKeyboardInset } from '@/client/hooks/ui/keyboard-inset';
|
|
21
18
|
import { composerExpansion } from '@/client/components/workspace/chat-timeline/chat-input/expansion';
|
|
22
19
|
import { useComposerCompact } from '@/client/hooks/chat/composer/compact';
|
|
20
|
+
import { useComposerStyle } from '@/client/hooks/chat/composer/style';
|
|
21
|
+
import { composerStyleLayout } from '@/shared/lib/chat/composer/style';
|
|
23
22
|
import type { ChatInputProps } from '@/client/components/workspace/chat-timeline/chat-input/props';
|
|
24
23
|
|
|
25
24
|
export function ChatInput({
|
|
@@ -55,9 +54,9 @@ export function ChatInput({
|
|
|
55
54
|
deferredComposerPickRef = NO_PENDING_PICK,
|
|
56
55
|
chatRunning,
|
|
57
56
|
expandable = false,
|
|
57
|
+
hero = false,
|
|
58
58
|
shrinkWhileReading = false,
|
|
59
59
|
}: ChatInputProps) {
|
|
60
|
-
const [internalAttachments, setInternalAttachments] = useState<Attachment[]>([]);
|
|
61
60
|
// The Goal modal is owned here, not by the toolbar: the button is a toggle,
|
|
62
61
|
// and the modal it opens needs the same `modes` slice the toolbar got.
|
|
63
62
|
const [goalModalOpen, setGoalModalOpen] = useState(false);
|
|
@@ -80,20 +79,18 @@ export function ChatInput({
|
|
|
80
79
|
onThinkingLevelChange,
|
|
81
80
|
});
|
|
82
81
|
|
|
82
|
+
// Attachments: owned here when nobody else needs to read them (the New Chat
|
|
83
|
+
// modal), forwarded through the caller's setter when a dock does. The
|
|
84
|
+
// forward has to stay a state setter: evaluating a functional update here
|
|
85
|
+
// against the closed-over value would resurrect stale state (the async
|
|
86
|
+
// FileReader callback wiping the just-added image).
|
|
87
|
+
const [internalAttachments, setInternalAttachments] = useState<Attachment[]>([]);
|
|
83
88
|
const attachments = externalAttachments !== undefined ? externalAttachments : internalAttachments;
|
|
84
89
|
const setAttachments = (updater: SetStateAction<Attachment[]>) => {
|
|
85
|
-
if (onAttachmentsChange)
|
|
86
|
-
|
|
87
|
-
// so functional updates stay functional. Evaluating them here against
|
|
88
|
-
// the closure `attachments` would resurrect stale state (e.g. the async
|
|
89
|
-
// FileReader callback wiping the just-added image).
|
|
90
|
-
onAttachmentsChange(updater);
|
|
91
|
-
} else {
|
|
92
|
-
setInternalAttachments(updater);
|
|
93
|
-
}
|
|
90
|
+
if (onAttachmentsChange) onAttachmentsChange(updater);
|
|
91
|
+
else setInternalAttachments(updater);
|
|
94
92
|
};
|
|
95
93
|
|
|
96
|
-
|
|
97
94
|
const handlePaste = (e: ClipboardEvent<HTMLTextAreaElement>) => {
|
|
98
95
|
const clipboard = e.clipboardData;
|
|
99
96
|
if (!clipboard) return;
|
|
@@ -158,6 +155,20 @@ export function ChatInput({
|
|
|
158
155
|
});
|
|
159
156
|
const layout = composerExpansion({ variant, expanded, isDragging, keyboardInset });
|
|
160
157
|
|
|
158
|
+
// The style only reorders rows and re-frames the card; every control below is
|
|
159
|
+
// rendered in every style. `hero` is the empty-chat state `stage` reacts to —
|
|
160
|
+
// the composer cannot see the transcript, so the caller says so, and the
|
|
161
|
+
// default (false) keeps the docked shape for a caller that does not care.
|
|
162
|
+
const style = useComposerStyle();
|
|
163
|
+
const styleLayout = composerStyleLayout({ style, hero });
|
|
164
|
+
// Position FIRST: `cardPositionClass` must not be cancelled by a later
|
|
165
|
+
// position utility (Tailwind resolves those by emission order regardless of
|
|
166
|
+
// class order, which is why `expansion.ts` keeps position in its own field).
|
|
167
|
+
// The style contributes NO class here — its pixels are `[data-composer-style]`
|
|
168
|
+
// rules in `tailwind.css`, because `rounded-md` beside `rounded-xl` lost.
|
|
169
|
+
const cardClass = `${layout.cardPositionClass} ${layout.cardClass} ${layout.cardLayoutClass}`;
|
|
170
|
+
const textareaClass = layout.textareaClass;
|
|
171
|
+
|
|
161
172
|
// Growth: a modal composer states its own px bounds, the chat's docked one
|
|
162
173
|
// grows to `CHAT_COMPOSER_MAX_LINES` lines. Either way it is measured only
|
|
163
174
|
// while the layout does NOT own the height — a stretched composer is `h-full`
|
|
@@ -202,10 +213,13 @@ export function ChatInput({
|
|
|
202
213
|
});
|
|
203
214
|
|
|
204
215
|
return (
|
|
205
|
-
<
|
|
206
|
-
|
|
207
|
-
|
|
216
|
+
<ComposerFrame
|
|
217
|
+
layout={styleLayout}
|
|
218
|
+
cardClass={cardClass}
|
|
208
219
|
style={layout.style}
|
|
220
|
+
className={className}
|
|
221
|
+
cardRef={cardRef}
|
|
222
|
+
expanded={expanded}
|
|
209
223
|
// focusin/focusout BUBBLE, unlike focus/blur: the card has to learn that
|
|
210
224
|
// the textarea inside it was focused, and a capture-phase `onFocus` on
|
|
211
225
|
// this element is not the same question (it fires for the card's own
|
|
@@ -228,110 +242,76 @@ export function ChatInput({
|
|
|
228
242
|
// Press-time, not click-time — see `useComposerCompact` for why a click
|
|
229
243
|
// never arrives in the compact state.
|
|
230
244
|
onPointerDown={onCardPointerDown}
|
|
231
|
-
{
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
{/* Goal mode strip describes the turn the next message will join. */}
|
|
236
|
-
<GoalSurfaces
|
|
237
|
-
modes={modes}
|
|
238
|
-
running={chatRunning ?? isGenerating}
|
|
239
|
-
open={goalModalOpen}
|
|
240
|
-
defaultBudget={normalizeGoalBudget(readKabmoSetting<number>('goalDefaultBudget', appSettings))}
|
|
241
|
-
onOpen={() => setGoalModalOpen(true)}
|
|
242
|
-
onClose={() => setGoalModalOpen(false)}
|
|
243
|
-
/>
|
|
244
|
-
|
|
245
|
-
<AttachmentToolbar
|
|
246
|
-
attachments={attachments}
|
|
247
|
-
onFilesSelected={(files) => acceptFiles(files)}
|
|
248
|
-
onRemove={removeAttachment}
|
|
249
|
-
// The phone hosts the mode toggles here; the desktop keeps them in the
|
|
250
|
-
// bottom toolbar, which has room. `showAccess` gates both hosts.
|
|
251
|
-
modes={isMobile && showAccess ? modes : undefined}
|
|
252
|
-
onOpenGoal={() => setGoalModalOpen(true)}
|
|
253
|
-
// Only the chat's own composer stretches; a caller that owns its size
|
|
254
|
-
// (the New Chat modal) gets no control and cannot be stretched.
|
|
255
|
-
expanded={expandable ? expanded : undefined}
|
|
256
|
-
onToggleExpand={expandable ? () => setExpanded((prev) => !prev) : undefined}
|
|
257
|
-
compact={compact}
|
|
258
|
-
onExpandComposer={reopen}
|
|
259
|
-
/>
|
|
260
|
-
|
|
261
|
-
{/* Refused plan/goal command notice. */}
|
|
262
|
-
{(notice || modes?.error) && (
|
|
263
|
-
<div className="flex items-start gap-1.5 bg-error/5 px-3 py-1.5 text-[11px] text-error">
|
|
264
|
-
<AlertTriangle size={11} className="mt-0.5 shrink-0" />
|
|
265
|
-
<span className="min-w-0 flex-1 break-words">{notice || modes?.error}</span>
|
|
266
|
-
<button
|
|
267
|
-
type="button"
|
|
268
|
-
onClick={() => (notice ? dismissNotice() : modes?.clearError())}
|
|
269
|
-
className="shrink-0 text-error/60 hover:text-error transition-colors"
|
|
270
|
-
title="Dismiss"
|
|
271
|
-
>
|
|
272
|
-
<X size={11} />
|
|
273
|
-
</button>
|
|
274
|
-
</div>
|
|
275
|
-
)}
|
|
276
|
-
|
|
277
|
-
{/* Textarea. Not rendered at all while compact: the phone gives the
|
|
278
|
-
transcript its height back by removing the box, not by shrinking it,
|
|
279
|
-
and `AttachmentToolbar` then carries the "Type here" target that
|
|
280
|
-
brings it back. Rendering it at `h-0` would keep a focusable element
|
|
281
|
-
with no pixels, which is exactly the trap the `inert` rules elsewhere
|
|
282
|
-
exist to avoid. */}
|
|
283
|
-
{!compact && (
|
|
284
|
-
<ComposerTextarea
|
|
285
|
-
value={value}
|
|
286
|
-
onChange={onChange}
|
|
287
|
-
onSend={submit}
|
|
288
|
-
disabled={disabled}
|
|
289
|
-
appSettings={appSettings}
|
|
290
|
-
rootPath={rootPath}
|
|
291
|
-
enablePicker={enablePicker}
|
|
292
|
-
placement={layout.pickerPlacement}
|
|
293
|
-
wrapperClassName={layout.wrapperClass}
|
|
294
|
-
placeholder={placeholder ?? (disabled ? "Please select a workspace above to start prompting..." : "@ for files/agents; / for commands and skills (Paste images/files here)")}
|
|
295
|
-
className={`w-full bg-transparent border-none focus:outline-none resize-none text-ink placeholder-ink/40 disabled:opacity-50 disabled:cursor-not-allowed ${layout.textareaClass}`}
|
|
296
|
-
onPaste={handlePaste}
|
|
297
|
-
variant={variant}
|
|
298
|
-
textareaRef={growRef}
|
|
299
|
-
onReady={onTextareaReady}
|
|
300
|
-
/>
|
|
301
|
-
)}
|
|
302
|
-
{/* Dictation progress / failure, above the toolbar that owns the mic. */}
|
|
303
|
-
<VoiceNotice status={voiceStatus} error={displayedVoiceError} />
|
|
245
|
+
dropProps={dropProps}
|
|
246
|
+
header={
|
|
247
|
+
<>
|
|
248
|
+
<DropOverlay visible={isDragging} />
|
|
304
249
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
250
|
+
{/* Goal mode strip describes the turn the next message will join. It
|
|
251
|
+
is card chrome, not a row: it stays above the rows in every style. */}
|
|
252
|
+
<GoalSurfaces
|
|
253
|
+
modes={modes}
|
|
254
|
+
running={chatRunning ?? isGenerating}
|
|
255
|
+
open={goalModalOpen}
|
|
256
|
+
defaultBudget={normalizeGoalBudget(readKabmoSetting<number>('goalDefaultBudget', appSettings))}
|
|
257
|
+
onOpen={() => setGoalModalOpen(true)}
|
|
258
|
+
onClose={() => setGoalModalOpen(false)}
|
|
259
|
+
/>
|
|
260
|
+
</>
|
|
261
|
+
}
|
|
262
|
+
rows={composerRows({
|
|
263
|
+
textareaClass,
|
|
264
|
+
wrapperClass: layout.wrapperClass,
|
|
265
|
+
pickerPlacement: layout.pickerPlacement,
|
|
266
|
+
attachments,
|
|
267
|
+
onFilesSelected: (files) => acceptFiles(files),
|
|
268
|
+
onRemoveAttachment: removeAttachment,
|
|
269
|
+
modes,
|
|
270
|
+
onOpenGoal: () => setGoalModalOpen(true),
|
|
271
|
+
expanded,
|
|
272
|
+
onToggleExpand: expandable ? () => setExpanded((prev) => !prev) : undefined,
|
|
273
|
+
compact,
|
|
274
|
+
onExpandComposer: reopen,
|
|
275
|
+
notice,
|
|
276
|
+
dismissNotice,
|
|
277
|
+
value,
|
|
278
|
+
onChange,
|
|
279
|
+
submit,
|
|
280
|
+
sendDisabled: disabled || (!value.trim() && attachments.length === 0),
|
|
281
|
+
disabled,
|
|
282
|
+
appSettings,
|
|
283
|
+
rootPath,
|
|
284
|
+
enablePicker,
|
|
285
|
+
placeholder: placeholder ?? (disabled ? "Please select a workspace above to start prompting..." : "@ for files/agents; / for commands and skills (Paste images/files here)"),
|
|
286
|
+
onPaste: handlePaste,
|
|
287
|
+
variant,
|
|
288
|
+
textareaRef: growRef,
|
|
289
|
+
onTextareaReady,
|
|
290
|
+
voiceStatus,
|
|
291
|
+
voiceError: displayedVoiceError,
|
|
292
|
+
isMobile,
|
|
293
|
+
selectedModel,
|
|
294
|
+
onSelectModel: (model) => {
|
|
310
295
|
setSelectedModel(model);
|
|
311
296
|
onModelChange?.(model.provider, model.id);
|
|
312
|
-
}
|
|
313
|
-
thinkingLevels
|
|
314
|
-
currentThinking
|
|
315
|
-
onSelectThinking
|
|
316
|
-
onThinkingLevelChange
|
|
317
|
-
isGenerating
|
|
318
|
-
chatRunning
|
|
319
|
-
onStop
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
voiceBusy={voiceBusy}
|
|
332
|
-
onVoiceToggle={handleVoiceToggle}
|
|
333
|
-
text={value}
|
|
334
|
-
/>
|
|
335
|
-
</div>
|
|
297
|
+
},
|
|
298
|
+
thinkingLevels,
|
|
299
|
+
currentThinking,
|
|
300
|
+
onSelectThinking: selectThinking,
|
|
301
|
+
onThinkingLevelChange,
|
|
302
|
+
isGenerating,
|
|
303
|
+
chatRunning,
|
|
304
|
+
onStop,
|
|
305
|
+
accessMode,
|
|
306
|
+
onSelectAccess: onAccessModeChange,
|
|
307
|
+
showModel,
|
|
308
|
+
showThinking,
|
|
309
|
+
showAccess,
|
|
310
|
+
voiceSupported,
|
|
311
|
+
voiceListening,
|
|
312
|
+
voiceBusy,
|
|
313
|
+
onVoiceToggle: handleVoiceToggle,
|
|
314
|
+
})}
|
|
315
|
+
/>
|
|
336
316
|
);
|
|
337
317
|
}
|
|
@@ -98,6 +98,13 @@ export interface ChatInputProps {
|
|
|
98
98
|
* form lives inside a panel that is already sized to the answers beside it.
|
|
99
99
|
*/
|
|
100
100
|
expandable?: boolean;
|
|
101
|
+
/**
|
|
102
|
+
* The chat has no messages yet. Only the `stage` composer style reads it:
|
|
103
|
+
* an empty session draws a taller draft so the first prompt is not written
|
|
104
|
+
* into a 68px slot in the middle of a blank screen. Every other style — and
|
|
105
|
+
* every caller that omits it — draws the docked shape.
|
|
106
|
+
*/
|
|
107
|
+
hero?: boolean;
|
|
101
108
|
/**
|
|
102
109
|
* The reader has scrolled back through the transcript. On a phone with an
|
|
103
110
|
* empty draft the composer then gives its height back to the conversation
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The composer card's FRAME, as one component.
|
|
8
|
+
*
|
|
9
|
+
* Every style renders the same five rows — attachments, notice, draft, voice,
|
|
10
|
+
* toolbar — and the only thing that differs is their order
|
|
11
|
+
* (`composerStyleLayout().rows`). Rendering that order here, rather than with a
|
|
12
|
+
* second copy of the JSX per style, is what makes "no control can go missing"
|
|
13
|
+
* structural instead of a review checklist: a row absent from `rows` is a row
|
|
14
|
+
* this file never renders, and the table is asserted to contain all five.
|
|
15
|
+
*
|
|
16
|
+
* The card's POSITION and stretch semantics are not decided here: they come
|
|
17
|
+
* from `composerExpansion`, which already owns the two layout answers (phone
|
|
18
|
+
* takes the viewport, desktop grows in place), the keyboard inset and the
|
|
19
|
+
* popup placement. This file adds the style's own attributes and keeps the two
|
|
20
|
+
* surfaces that describe the CARD — the goal strip and the drag overlay — above
|
|
21
|
+
* every row, because they do not belong to a line of it.
|
|
22
|
+
*
|
|
23
|
+
* **The style's pixels are CSS, not classes** (`[data-composer-style]` in
|
|
24
|
+
* `tailwind.css`): two utilities of the same property resolve by emission
|
|
25
|
+
* order, so a style writing `rounded-md` beside the frame's `rounded-xl`
|
|
26
|
+
* rendered 12px (measured). The attributes below are the whole handshake.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
import { Fragment } from 'preact';
|
|
30
|
+
import type { ComponentChildren } from 'preact';
|
|
31
|
+
import type { CSSProperties, RefObject } from 'preact/compat';
|
|
32
|
+
import type { FileDropProps } from '@/client/hooks/chat/composer/file-drop';
|
|
33
|
+
import type { ComposerRow, ComposerStyleLayout } from '@/shared/lib/chat/composer/style';
|
|
34
|
+
|
|
35
|
+
export interface ComposerFrameProps {
|
|
36
|
+
layout: ComposerStyleLayout;
|
|
37
|
+
/** Position, frame, radius, elevation — resolved by `composerExpansion`. */
|
|
38
|
+
cardClass: string;
|
|
39
|
+
/** The keyboard inset / safe-area padding, when the layout states one. */
|
|
40
|
+
style?: CSSProperties;
|
|
41
|
+
/** Extra classes from the caller (`ChatInput.className`). */
|
|
42
|
+
className?: string;
|
|
43
|
+
/** The card element: the compact hook, the keyboard inset and focus read it. */
|
|
44
|
+
cardRef: RefObject<HTMLDivElement>;
|
|
45
|
+
/**
|
|
46
|
+
* The card currently fills the viewport (the phone's stretched composer).
|
|
47
|
+
* Written as an attribute because a style's radius is plain CSS and would
|
|
48
|
+
* otherwise beat the expansion frame's `rounded-none` — measured: a stretched
|
|
49
|
+
* `glass` card kept a 20px radius over a `fixed inset-0` surface, showing the
|
|
50
|
+
* canvas at its corners.
|
|
51
|
+
*/
|
|
52
|
+
expanded?: boolean;
|
|
53
|
+
/** Preact maps these to the bubble-phase events (`onFocusIn`/`onFocusOut`). */
|
|
54
|
+
onFocusIn: () => void;
|
|
55
|
+
onFocusOut: () => void;
|
|
56
|
+
onPointerDown: (event: PointerEvent) => void;
|
|
57
|
+
dropProps: FileDropProps;
|
|
58
|
+
/** Goal strip, drag overlay — above every row, in every style. */
|
|
59
|
+
header?: ComponentChildren;
|
|
60
|
+
rows: Record<ComposerRow, ComponentChildren>;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function ComposerFrame({
|
|
64
|
+
layout,
|
|
65
|
+
cardClass,
|
|
66
|
+
style,
|
|
67
|
+
className = '',
|
|
68
|
+
cardRef,
|
|
69
|
+
expanded = false,
|
|
70
|
+
onFocusIn,
|
|
71
|
+
onFocusOut,
|
|
72
|
+
onPointerDown,
|
|
73
|
+
dropProps,
|
|
74
|
+
header,
|
|
75
|
+
rows,
|
|
76
|
+
}: ComposerFrameProps) {
|
|
77
|
+
return (
|
|
78
|
+
<div
|
|
79
|
+
ref={cardRef}
|
|
80
|
+
data-composer-style={layout.attributeValue}
|
|
81
|
+
data-composer-hero={layout.hero ? 'true' : undefined}
|
|
82
|
+
data-composer-expanded={expanded ? 'true' : undefined}
|
|
83
|
+
// NO position utility here: `cardClass` carries `cardPositionClass`, and
|
|
84
|
+
// Tailwind's position utilities are ordered `static, fixed, absolute,
|
|
85
|
+
// relative, sticky` — a `relative` written in this base list would WIN
|
|
86
|
+
// over the `fixed inset-0` a stretched phone composer adds (measured in
|
|
87
|
+
// `expansion.ts`).
|
|
88
|
+
className={`@container transition-colors flex flex-col ${cardClass} ${className}`}
|
|
89
|
+
style={style}
|
|
90
|
+
onFocusIn={onFocusIn}
|
|
91
|
+
onFocusOut={onFocusOut}
|
|
92
|
+
onPointerDown={onPointerDown}
|
|
93
|
+
{...dropProps}
|
|
94
|
+
>
|
|
95
|
+
{header}
|
|
96
|
+
{layout.promptGlyph && (
|
|
97
|
+
// The console style's prompt glyph: decoration that names the surface,
|
|
98
|
+
// so it is inert to the pointer and hidden from the accessibility tree.
|
|
99
|
+
<span
|
|
100
|
+
aria-hidden="true"
|
|
101
|
+
className="pointer-events-none absolute -top-5 left-2 font-mono text-[11px] text-ink/35"
|
|
102
|
+
>
|
|
103
|
+
omp ›
|
|
104
|
+
</span>
|
|
105
|
+
)}
|
|
106
|
+
{layout.rows.map((row) => (
|
|
107
|
+
<Fragment key={row}>{rows[row]}</Fragment>
|
|
108
|
+
))}
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The composer's four styles, rendered.
|
|
8
|
+
*
|
|
9
|
+
* The contract these pin is not cosmetic: **a style may reorder the card's rows
|
|
10
|
+
* and change its frame, and may never remove a control.** The worst case of a
|
|
11
|
+
* violation is the access-mode selector — the one control that decides whether
|
|
12
|
+
* a turn may write to disk — silently missing from a card the user is about to
|
|
13
|
+
* send from.
|
|
14
|
+
*
|
|
15
|
+
* The style reaches the composer through the primed settings snapshot
|
|
16
|
+
* (`readKabmoSetting('composerStyle')`), which is what `main.tsx` does at boot,
|
|
17
|
+
* so priming is also the honest way to mount it here.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
21
|
+
import { Window } from 'happy-dom';
|
|
22
|
+
import { h, render } from 'preact';
|
|
23
|
+
import { act } from 'preact/test-utils';
|
|
24
|
+
import { ChatInput } from '@/client/components/workspace/chat-timeline/chat-input';
|
|
25
|
+
import { primeKabmoSettings } from '@/shared/lib/settings/client';
|
|
26
|
+
import { delay } from '@/client/hooks/chat/composer/file-reads';
|
|
27
|
+
import { restoreRealtime, silenceRealtime } from '@/test-support/silent-socket';
|
|
28
|
+
import { COMPOSER_STYLES, type ComposerStyle } from '@/shared/lib/chat/composer/style';
|
|
29
|
+
|
|
30
|
+
const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'HTMLInputElement', 'HTMLTextAreaElement', 'Event', 'MouseEvent', 'KeyboardEvent', 'FocusEvent'] as const;
|
|
31
|
+
const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
|
|
32
|
+
|
|
33
|
+
beforeAll(() => {
|
|
34
|
+
const win = new Window({ url: 'http://localhost' });
|
|
35
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
36
|
+
for (const key of DOM_GLOBALS) {
|
|
37
|
+
if (!(key in nativeGlobals)) nativeGlobals[key] = target[key];
|
|
38
|
+
target[key] = (win as unknown as Record<string, unknown>)[key];
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
afterAll(() => {
|
|
43
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
44
|
+
for (const key of DOM_GLOBALS) {
|
|
45
|
+
if (nativeGlobals[key] === undefined) delete target[key];
|
|
46
|
+
else target[key] = nativeGlobals[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
let container: HTMLElement | null = null;
|
|
51
|
+
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
silenceRealtime();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
afterEach(async () => {
|
|
57
|
+
// Unmount, then drain while this window still exists — see `compact.test.tsx`
|
|
58
|
+
// for why the order is load-bearing (the model picker keeps a realtime
|
|
59
|
+
// subscription and a reconnect timer).
|
|
60
|
+
const host = container;
|
|
61
|
+
if (host) {
|
|
62
|
+
await act(async () => { render(null, host); });
|
|
63
|
+
host.remove();
|
|
64
|
+
}
|
|
65
|
+
container = null;
|
|
66
|
+
restoreRealtime();
|
|
67
|
+
await delay(50);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
async function mount(style: ComposerStyle): Promise<HTMLElement> {
|
|
71
|
+
primeKabmoSettings({ kabmo_settings: { composerStyle: style } });
|
|
72
|
+
const host = document.createElement('div');
|
|
73
|
+
document.body.appendChild(host);
|
|
74
|
+
container = host;
|
|
75
|
+
|
|
76
|
+
await act(async () => {
|
|
77
|
+
render(
|
|
78
|
+
h(ChatInput, {
|
|
79
|
+
value: '',
|
|
80
|
+
onChange: () => {},
|
|
81
|
+
onSend: () => {},
|
|
82
|
+
isGenerating: false,
|
|
83
|
+
composerModelRef: { current: null },
|
|
84
|
+
variant: 'desktop',
|
|
85
|
+
sessionId: 'composer-style-test',
|
|
86
|
+
expandable: true,
|
|
87
|
+
accessMode: 'always-ask',
|
|
88
|
+
onAccessModeChange: () => {},
|
|
89
|
+
modes: {
|
|
90
|
+
plan: false,
|
|
91
|
+
goal: false,
|
|
92
|
+
goalOpen: false,
|
|
93
|
+
goalRecord: null,
|
|
94
|
+
goalContinuation: null,
|
|
95
|
+
goalEvaluating: false,
|
|
96
|
+
pending: false,
|
|
97
|
+
planAvailable: true,
|
|
98
|
+
error: null,
|
|
99
|
+
clearError: () => {},
|
|
100
|
+
onTogglePlan: () => {},
|
|
101
|
+
onGoalAction: () => {},
|
|
102
|
+
},
|
|
103
|
+
}),
|
|
104
|
+
host,
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
await act(async () => { await delay(20); });
|
|
108
|
+
return host;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
describe('composer styles', () => {
|
|
112
|
+
for (const style of COMPOSER_STYLES) {
|
|
113
|
+
test(`${style} renders every control`, async () => {
|
|
114
|
+
const host = await mount(style);
|
|
115
|
+
|
|
116
|
+
// The card carries the style, so CSS can key its pixels off it.
|
|
117
|
+
const card = host.querySelector('[data-composer-style]');
|
|
118
|
+
expect(card?.getAttribute('data-composer-style')).toBe(style);
|
|
119
|
+
|
|
120
|
+
// Draft.
|
|
121
|
+
expect(host.querySelector('[data-testid="composer-input"]')).not.toBeNull();
|
|
122
|
+
// Attach + its file input.
|
|
123
|
+
expect(host.querySelector('button[title="Attach file or image"]')).not.toBeNull();
|
|
124
|
+
expect(host.querySelector('input[type="file"]')).not.toBeNull();
|
|
125
|
+
// The stretch control.
|
|
126
|
+
expect(host.querySelector('button[aria-label="Maximize composer"]')).not.toBeNull();
|
|
127
|
+
// Plan and Goal: `aria-label` carries the mode, so it survives a narrow
|
|
128
|
+
// card whose labels are hidden by the container query.
|
|
129
|
+
expect(host.querySelector('button[aria-label="Enter plan mode"]')).not.toBeNull();
|
|
130
|
+
expect(host.querySelector('button[aria-label="Set a goal"]')).not.toBeNull();
|
|
131
|
+
// Send. The VOICE button is not asserted: `useVoiceInput` reports support
|
|
132
|
+
// from `navigator.mediaDevices`, which happy-dom does not implement, so its
|
|
133
|
+
// absence here says nothing about a style. It is gated on capability
|
|
134
|
+
// inside the toolbar, identically for every style.
|
|
135
|
+
expect(host.querySelector('button[aria-label="Send message"]')).not.toBeNull();
|
|
136
|
+
// The access selector is a menu, not a labelled button, so it is found by
|
|
137
|
+
// its own trigger text — the value the composer was handed.
|
|
138
|
+
expect(host.textContent ?? '').toContain('Always ask');
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
test('the calm and console styles put the draft above the attachment row', async () => {
|
|
143
|
+
for (const style of ['calm', 'console'] as const) {
|
|
144
|
+
const host = await mount(style);
|
|
145
|
+
const card = host.querySelector('[data-composer-style]');
|
|
146
|
+
const children = Array.from(card?.children ?? []);
|
|
147
|
+
const draftIndex = children.findIndex((el) => el.querySelector('[data-testid="composer-input"]'));
|
|
148
|
+
const attachIndex = children.findIndex((el) => el.className.includes('composer-attach-row'));
|
|
149
|
+
expect(draftIndex).toBeGreaterThanOrEqual(0);
|
|
150
|
+
expect(attachIndex).toBeGreaterThanOrEqual(0);
|
|
151
|
+
expect(draftIndex).toBeLessThan(attachIndex);
|
|
152
|
+
|
|
153
|
+
await act(async () => { render(null, host); });
|
|
154
|
+
host.remove();
|
|
155
|
+
container = null;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test('classic keeps the attachment row first', async () => {
|
|
160
|
+
const host = await mount('classic');
|
|
161
|
+
const card = host.querySelector('[data-composer-style]');
|
|
162
|
+
const children = Array.from(card?.children ?? []);
|
|
163
|
+
const attachIndex = children.findIndex((el) => el.className.includes('composer-attach-row'));
|
|
164
|
+
const draftIndex = children.findIndex((el) => el.querySelector('[data-testid="composer-input"]'));
|
|
165
|
+
expect(attachIndex).toBe(0);
|
|
166
|
+
expect(attachIndex).toBeLessThan(draftIndex);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
test('the console style is the only one that draws the prompt glyph', async () => {
|
|
170
|
+
for (const style of COMPOSER_STYLES) {
|
|
171
|
+
const host = await mount(style);
|
|
172
|
+
const glyphs = Array.from(host.querySelectorAll('span[aria-hidden="true"]'))
|
|
173
|
+
.filter((el) => (el.textContent ?? '').includes('omp ›'));
|
|
174
|
+
expect(glyphs.length).toBe(style === 'console' ? 1 : 0);
|
|
175
|
+
|
|
176
|
+
await act(async () => { render(null, host); });
|
|
177
|
+
host.remove();
|
|
178
|
+
container = null;
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
});
|
|
@@ -306,6 +306,9 @@ export function ChatTimeline({ className = '', appSettings = {}, onSessionTitle,
|
|
|
306
306
|
// transcript, so a phone composer may give its height back.
|
|
307
307
|
// `composerExpansion` ignores it on a desktop.
|
|
308
308
|
shrinkWhileReading={readingBack}
|
|
309
|
+
// No turns yet: the `stage` composer style draws its wider,
|
|
310
|
+
// taller card only here.
|
|
311
|
+
hero={localMessages.length === 0 && !timelineRunning}
|
|
309
312
|
/>
|
|
310
313
|
)}
|
|
311
314
|
</>
|
package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx
CHANGED
|
@@ -84,6 +84,7 @@ export function FrameControl({ frame, multi, selected, onAnswer, onToggle, onRes
|
|
|
84
84
|
) : (
|
|
85
85
|
<input
|
|
86
86
|
autoFocus
|
|
87
|
+
type={frame.secret === true ? 'password' : 'text'}
|
|
87
88
|
value={text}
|
|
88
89
|
placeholder={frame.placeholder || 'Type your answer…'}
|
|
89
90
|
onChange={(event) => setText(event.currentTarget.value)}
|
|
@@ -143,3 +143,34 @@ describe('the gate\'s answer', () => {
|
|
|
143
143
|
expect(sent).toEqual([{ value: 'Approve' }]);
|
|
144
144
|
});
|
|
145
145
|
});
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* omp 18.14.0 added `secret` to an `input` dialog (`ctx.ui.input({ secret:
|
|
149
|
+
* true })`) and forwards it on the frame. A client that ignores it draws the
|
|
150
|
+
* password in clear text on screen.
|
|
151
|
+
*
|
|
152
|
+
* The frame shape is upstream's: `InputUiRequest` gained `"secret": boolean`,
|
|
153
|
+
* validated as an optional member — measured against 18.14.0's
|
|
154
|
+
* `rpc-wire.schema.json`, where it is the only change to that definition.
|
|
155
|
+
*/
|
|
156
|
+
describe('a secret input dialog', () => {
|
|
157
|
+
const SECRET_INPUT: ExtensionUiDialogRequest = {
|
|
158
|
+
type: 'extension_ui_request',
|
|
159
|
+
id: 'i1',
|
|
160
|
+
method: 'input',
|
|
161
|
+
title: 'Paste the API key',
|
|
162
|
+
placeholder: 'sk-…',
|
|
163
|
+
secret: true,
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
test('masks what the user types', () => {
|
|
167
|
+
draw(SECRET_INPUT);
|
|
168
|
+
const field = container.querySelector('input');
|
|
169
|
+
expect(field?.getAttribute('type')).toBe('password');
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test('a plain input stays readable', () => {
|
|
173
|
+
draw({ ...SECRET_INPUT, id: 'i2', secret: undefined });
|
|
174
|
+
expect(container.querySelector('input')?.getAttribute('type')).toBe('text');
|
|
175
|
+
});
|
|
176
|
+
});
|
package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx
CHANGED
|
@@ -218,7 +218,7 @@ export function ExtensionDialog({ request, onRespond }: ExtensionDialogProps) {
|
|
|
218
218
|
</div>
|
|
219
219
|
<input
|
|
220
220
|
ref={inputRef}
|
|
221
|
-
type=
|
|
221
|
+
type={request.secret === true ? 'password' : 'text'}
|
|
222
222
|
value={value}
|
|
223
223
|
placeholder={request.placeholder || 'Type your response...'}
|
|
224
224
|
onChange={(e) => setValue(e.currentTarget.value)}
|