@kortix/ui 0.16.3 → 0.16.5
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/_vendor/kortix-shared.js +1 -4
- package/dist/customize/sections/view/review-center-connected.js +64 -71
- package/dist/customize/sections/view/secret-delivery.d.ts +11 -20
- package/dist/customize/sections/view/secret-delivery.js +20 -29
- package/dist/customize/sections/view/secrets-view.js +9 -24
- package/dist/customize/settings/rail-copy-context.d.ts +2 -0
- package/dist/customize/settings/rail-copy-context.js +2 -0
- package/dist/customize/settings/tabs/chrome-connections-tab.js +1 -1
- package/dist/files/renderers/show-content-renderer.js +3 -1
- package/dist/i18n/en.d.ts +130 -22
- package/dist/i18n/en.js +142 -34
- package/dist/i18n/ui-catalog/product-catalog-translation-keys.generated.js +2 -0
- package/dist/internal/auth/auth-card-shell.d.ts +24 -3
- package/dist/internal/auth/auth-card-shell.js +15 -8
- package/dist/internal/auth/auth-primitives.d.ts +15 -2
- package/dist/internal/auth/auth-primitives.js +22 -5
- package/dist/internal/chrome/chrome-connect.d.ts +3 -5
- package/dist/internal/chrome/chrome-connect.js +7 -10
- package/dist/internal/chrome/extension.d.ts +1 -8
- package/dist/internal/chrome/extension.js +1 -8
- package/dist/internal/chrome/use-chrome-offered.d.ts +6 -12
- package/dist/internal/chrome/use-chrome-offered.js +13 -15
- package/dist/internal/components/agent-mark.d.ts +2 -1
- package/dist/internal/components/agent-mark.js +14 -3
- package/dist/internal/hooks/use-review-session-summary.d.ts +1 -1
- package/dist/internal/hooks/use-review-session-summary.js +1 -1
- package/dist/internal/layout/project-nav-row.d.ts +3 -1
- package/dist/internal/layout/project-nav-row.js +2 -2
- package/dist/internal/layout/project-page-header.js +5 -4
- package/dist/internal/stores/user-preferences-store.d.ts +17 -0
- package/dist/internal/stores/user-preferences-store.js +5 -0
- package/dist/markdown/setup-links/secret-intake-form.d.ts +4 -1
- package/dist/markdown/setup-links/secret-intake-form.js +60 -16
- package/dist/markdown/setup-links/setup-link-button.js +6 -1
- package/dist/primitives/color-picker.d.ts +19 -0
- package/dist/primitives/color-picker.js +27 -0
- package/dist/primitives/faded-scroll-area.js +4 -0
- package/dist/primitives/glyph-picker.d.ts +11 -0
- package/dist/primitives/glyph-picker.js +10 -6
- package/dist/primitives/gradient-wallpaper-gl.d.ts +61 -0
- package/dist/primitives/gradient-wallpaper-gl.js +446 -0
- package/dist/primitives/gradient-wallpaper.d.ts +20 -0
- package/dist/primitives/gradient-wallpaper.js +242 -0
- package/dist/primitives/resizable.d.ts +1 -1
- package/dist/session/agents/agent-hover-card.d.ts +26 -0
- package/dist/session/agents/agent-hover-card.js +70 -0
- package/dist/session/agents/agent-strip.js +33 -7
- package/dist/session/agents/agent-surface.d.ts +26 -1
- package/dist/session/agents/agent-surface.js +57 -6
- package/dist/session/agents/held-messages.js +2 -2
- package/dist/session/agents/subagent-dialog-content.js +2 -2
- package/dist/session/composer/ComposerCard.js +4 -4
- package/dist/session/composer/composer-toolbar.d.ts +8 -1
- package/dist/session/composer/composer-toolbar.js +2 -2
- package/dist/session/composer/dictation/dictation-control.d.ts +10 -0
- package/dist/session/composer/dictation/dictation-control.js +28 -0
- package/dist/session/composer/dictation/dictation-state.d.ts +26 -0
- package/dist/session/composer/dictation/dictation-state.js +71 -0
- package/dist/session/composer/dictation/recorder.d.ts +30 -0
- package/dist/session/composer/dictation/recorder.js +129 -0
- package/dist/session/composer/dictation/use-composer-dictation.d.ts +25 -0
- package/dist/session/composer/dictation/use-composer-dictation.js +218 -0
- package/dist/session/composer/queued-prompt-list.js +5 -1
- package/dist/session/panel/easy/apps-card.js +3 -10
- package/dist/session/panel/easy/background-tasks-card.d.ts +23 -0
- package/dist/session/panel/easy/background-tasks-card.js +119 -0
- package/dist/session/panel/easy/change-requests-card.js +1 -1
- package/dist/session/panel/easy/changes-card.js +4 -6
- package/dist/session/panel/easy/context-card.js +8 -9
- package/dist/session/panel/easy/context-meter.d.ts +2 -0
- package/dist/session/panel/easy/context-meter.js +18 -4
- package/dist/session/panel/easy/detail-view.js +7 -4
- package/dist/session/panel/easy/easy-panel-logic.d.ts +4 -15
- package/dist/session/panel/easy/easy-panel-logic.js +4 -17
- package/dist/session/panel/easy/easy-panel.js +5 -4
- package/dist/session/panel/easy/outputs-card.d.ts +1 -13
- package/dist/session/panel/easy/outputs-card.js +14 -40
- package/dist/session/panel/easy/panel-card.d.ts +13 -40
- package/dist/session/panel/easy/panel-card.js +17 -55
- package/dist/session/panel/easy/plan-card.js +4 -7
- package/dist/session/panel/model-switch-event.d.ts +2 -2
- package/dist/session/panel/model-switch-event.js +13 -9
- package/dist/session/panel/session-panel-provider.d.ts +2 -1
- package/dist/session/panel/session-panel-provider.js +3 -3
- package/dist/session/panel/shared/collect-tool-parts.js +2 -2
- package/dist/session/panel/shared/derive-panels.js +14 -1
- package/dist/session/panel/shared/use-panel-handoffs.d.ts +0 -1
- package/dist/session/panel/shared/use-panel-handoffs.js +26 -17
- package/dist/session/thread/chat-minimap.js +7 -1
- package/dist/session/thread/session-body.js +1 -1
- package/dist/session/thread/session-chat.js +59 -15
- package/dist/session/tool/shared/infrastructure-contexts.d.ts +7 -0
- package/dist/session/tool/shared/infrastructure-contexts.js +9 -0
- package/dist/session/tool/shared/infrastructure-row-header.js +4 -1
- package/dist/session/tool/shared/infrastructure-rows.js +19 -19
- package/dist/session/tool/show-group-renderer.d.ts +5 -5
- package/dist/session/tool/show-group-renderer.js +7 -4
- package/dist/session/tool/tool-part-renderer.js +25 -9
- package/dist/session/tool/tool-renderers.d.ts +1 -1
- package/dist/session/tool/tool-renderers.js +1 -1
- package/dist/session/tool/tools/bash-tool.js +3 -2
- package/dist/session/tool/tools/codemode-tool.d.ts +15 -0
- package/dist/session/tool/tools/codemode-tool.js +54 -2
- package/dist/session/tool/tools/kortix-action-tool.d.ts +1 -0
- package/dist/session/tool/tools/kortix-action-tool.js +19 -8
- package/dist/session/tool/tools/multi-agent-tool-bodies.d.ts +8 -1
- package/dist/session/tool/tools/multi-agent-tool-bodies.js +76 -10
- package/dist/session/tool/tools/task-tool.js +17 -5
- package/dist/session/turn/peer-message-row.d.ts +3 -0
- package/dist/session/turn/peer-message-row.js +8 -2
- package/dist/session/turn/subagent-notice-row.js +5 -3
- package/dist/styles.css +1 -1
- package/dist/test-utils/intl.d.ts +130 -22
- package/dist/theme/index.d.ts +2 -1
- package/dist/theme/index.js +2 -1
- package/dist/theme/wallpaper-gradients.d.ts +106 -0
- package/dist/theme/wallpaper-gradients.js +347 -0
- package/dist/theme/wallpapers.d.ts +23 -3
- package/dist/theme/wallpapers.js +53 -29
- package/dist/workspace/admin/project-admin-dashboard.js +1 -1
- package/dist/workspace/layout/project-home.js +1 -1
- package/dist/workspace/new/use-create-workspace.d.ts +5 -3
- package/dist/workspace/new/use-create-workspace.js +1 -1
- package/dist/workspace/projects/modal/project-icon-field.d.ts +3 -1
- package/dist/workspace/projects/modal/project-icon-field.js +3 -3
- package/dist/workspace/review/review-center.d.ts +9 -1
- package/dist/workspace/review/review-center.js +107 -14
- package/dist/workspace/review/review-detail.d.ts +19 -0
- package/dist/workspace/review/review-detail.js +18 -3
- package/dist/workspace/review/review-swipe-deck.d.ts +27 -0
- package/dist/workspace/review/review-swipe-deck.js +304 -0
- package/dist/workspace/review/review-swipe.d.ts +17 -0
- package/dist/workspace/review/review-swipe.js +10 -0
- package/dist/workspace/session-spaces/space-picker.js +3 -3
- package/dist/workspace/setup/setup-banner-snooze.d.ts +10 -0
- package/dist/workspace/setup/setup-banner-snooze.js +44 -0
- package/dist/workspace/setup/setup-banner.js +19 -36
- package/dist/workspace/setup/setup-steps.d.ts +0 -5
- package/dist/workspace/setup/setup-steps.js +0 -7
- package/dist/workspace/setup/workspace-setup-modal.d.ts +39 -0
- package/dist/workspace/setup/workspace-setup-modal.js +202 -0
- package/dist/workspace/sidebar/footer/project-review-nav.d.ts +13 -0
- package/dist/workspace/sidebar/footer/project-review-nav.js +29 -0
- package/dist/workspace/sidebar/project-nav-items.d.ts +3 -1
- package/dist/workspace/sidebar/project-nav-items.js +24 -5
- package/dist/workspace/sidebar/project-session-list.js +2 -1
- package/dist/workspace/sidebar/project-sidebar.js +6 -5
- package/dist/workspace/sidebar/project-spaces-nav.js +3 -10
- package/dist/workspace/sidebar/sidebar-more-group.js +1 -1
- package/package.json +14 -10
- package/skills/kortix-ui/SKILL.md +1 -1
- package/skills/kortix-ui/references/modules.md +3 -1
- package/dist/primitives/toast-clearance.d.ts +0 -36
- package/dist/primitives/toast-clearance.js +0 -94
- package/dist/workspace/setup/workspace-setup-page.d.ts +0 -10
- package/dist/workspace/setup/workspace-setup-page.js +0 -91
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { ApiError, getDictationInfo, transcribeDictation } from '@kortix/sdk';
|
|
3
|
+
import { useQuery } from '@tanstack/react-query';
|
|
4
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { useTranslations } from '../../../i18n/index.js';
|
|
6
|
+
import { isDesktop } from '../../../internal/lib/desktop-detect.js';
|
|
7
|
+
import { useUpgradeDialogStore } from '../../../internal/stores/upgrade-dialog-store.js';
|
|
8
|
+
import { errorToast, infoToast } from '../../../primitives/toast.js';
|
|
9
|
+
import { DICTATION_BARS, dictationInsert, pushLevel } from './dictation-state.js';
|
|
10
|
+
import { DictationRecorder, MicrophoneError } from './recorder.js';
|
|
11
|
+
/** A new meter bar every 60 ms: 24 bars hold the last ~1.4 s. */
|
|
12
|
+
const BAR_INTERVAL_MS = 60;
|
|
13
|
+
const DEFAULT_MAX_SECONDS = 600;
|
|
14
|
+
/**
|
|
15
|
+
* The composer's dictation, or null where it is not offered: no project, no
|
|
16
|
+
* microphone API, or a server without managed models (`available: false`).
|
|
17
|
+
* One recording at a time; the words land at the caret.
|
|
18
|
+
*/
|
|
19
|
+
export function useComposerDictation({ projectId, editorRef, }) {
|
|
20
|
+
const t = useTranslations('dictation');
|
|
21
|
+
const openUpgradeDialog = useUpgradeDialogStore((s) => s.openUpgradeDialog);
|
|
22
|
+
const supported = typeof window !== 'undefined' && DictationRecorder.supported();
|
|
23
|
+
const info = useQuery({
|
|
24
|
+
queryKey: ['dictation-info', projectId],
|
|
25
|
+
queryFn: () => getDictationInfo(projectId),
|
|
26
|
+
enabled: !!projectId && supported,
|
|
27
|
+
staleTime: 10 * 60_000,
|
|
28
|
+
retry: false,
|
|
29
|
+
});
|
|
30
|
+
const [phase, setPhase] = useState('idle');
|
|
31
|
+
const [levels, setLevels] = useState([]);
|
|
32
|
+
const [elapsedMs, setElapsedMs] = useState(0);
|
|
33
|
+
const recorderRef = useRef(null);
|
|
34
|
+
const uploadRef = useRef(null);
|
|
35
|
+
const frameRef = useRef(null);
|
|
36
|
+
const phaseRef = useRef('idle');
|
|
37
|
+
const maxSeconds = info.data?.max_seconds ?? DEFAULT_MAX_SECONDS;
|
|
38
|
+
const finishRef = useRef(() => { });
|
|
39
|
+
const uploadFnRef = useRef(async () => { });
|
|
40
|
+
const enter = useCallback((next) => {
|
|
41
|
+
phaseRef.current = next;
|
|
42
|
+
setPhase(next);
|
|
43
|
+
}, []);
|
|
44
|
+
const stopMeter = useCallback(() => {
|
|
45
|
+
if (frameRef.current !== null)
|
|
46
|
+
cancelAnimationFrame(frameRef.current);
|
|
47
|
+
frameRef.current = null;
|
|
48
|
+
}, []);
|
|
49
|
+
const insert = useCallback((text) => {
|
|
50
|
+
const editor = editorRef.current;
|
|
51
|
+
if (!editor)
|
|
52
|
+
return;
|
|
53
|
+
const state = editor.getEditingState();
|
|
54
|
+
const from = state?.selection.from ?? 0;
|
|
55
|
+
const before = state && from > 0 ? state.doc.textBetween(from - 1, from, '\n', ' ') : '';
|
|
56
|
+
const words = dictationInsert(before, text);
|
|
57
|
+
if (!words)
|
|
58
|
+
return;
|
|
59
|
+
editor.insertAtCursor(words);
|
|
60
|
+
editor.getElement()?.focus();
|
|
61
|
+
}, [editorRef]);
|
|
62
|
+
const upload = useCallback(async (clip) => {
|
|
63
|
+
if (!projectId)
|
|
64
|
+
return;
|
|
65
|
+
const controller = new AbortController();
|
|
66
|
+
uploadRef.current = controller;
|
|
67
|
+
enter('transcribing');
|
|
68
|
+
try {
|
|
69
|
+
const result = await transcribeDictation(projectId, clip, {
|
|
70
|
+
surface: isDesktop() ? 'desktop' : 'web',
|
|
71
|
+
signal: controller.signal,
|
|
72
|
+
});
|
|
73
|
+
if (controller.signal.aborted)
|
|
74
|
+
return;
|
|
75
|
+
if (result.text)
|
|
76
|
+
insert(result.text);
|
|
77
|
+
else
|
|
78
|
+
infoToast(t('nothingHeard'));
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (controller.signal.aborted)
|
|
82
|
+
return;
|
|
83
|
+
const code = error instanceof ApiError ? error.code : undefined;
|
|
84
|
+
const status = error instanceof ApiError ? error.status : undefined;
|
|
85
|
+
const retry = [{ label: t('retry'), onClick: () => void uploadFnRef.current(clip) }];
|
|
86
|
+
if (status === 402 && code !== 'budget_exceeded') {
|
|
87
|
+
const accountId = error.data?.account_id;
|
|
88
|
+
openUpgradeDialog({ reason: 'insufficient_credits', ...(accountId ? { accountId } : {}) });
|
|
89
|
+
}
|
|
90
|
+
else if (code === 'budget_exceeded') {
|
|
91
|
+
errorToast(error instanceof Error ? error.message : t('failed'));
|
|
92
|
+
}
|
|
93
|
+
else if (code === 'dictation_unavailable') {
|
|
94
|
+
errorToast(t('unavailable'));
|
|
95
|
+
void info.refetch();
|
|
96
|
+
}
|
|
97
|
+
else if (status === 429 || code === 'dictation_busy') {
|
|
98
|
+
errorToast(t('busy'), { actions: retry });
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
errorToast(t('failed'), { actions: retry });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
finally {
|
|
105
|
+
if (uploadRef.current === controller) {
|
|
106
|
+
uploadRef.current = null;
|
|
107
|
+
enter('idle');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, [projectId, enter, insert, t, openUpgradeDialog, info]);
|
|
111
|
+
const finish = useCallback(() => {
|
|
112
|
+
const recorder = recorderRef.current;
|
|
113
|
+
if (!recorder || phaseRef.current !== 'recording')
|
|
114
|
+
return;
|
|
115
|
+
recorderRef.current = null;
|
|
116
|
+
stopMeter();
|
|
117
|
+
enter('transcribing');
|
|
118
|
+
void recorder.stop().then((clip) => {
|
|
119
|
+
if (phaseRef.current !== 'transcribing')
|
|
120
|
+
return;
|
|
121
|
+
if (clip.size === 0) {
|
|
122
|
+
enter('idle');
|
|
123
|
+
infoToast(t('nothingHeard'));
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
void upload(clip);
|
|
127
|
+
});
|
|
128
|
+
}, [enter, stopMeter, upload, t]);
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
finishRef.current = finish;
|
|
131
|
+
uploadFnRef.current = upload;
|
|
132
|
+
}, [finish, upload]);
|
|
133
|
+
const cancel = useCallback(() => {
|
|
134
|
+
stopMeter();
|
|
135
|
+
recorderRef.current?.cancel();
|
|
136
|
+
recorderRef.current = null;
|
|
137
|
+
uploadRef.current?.abort();
|
|
138
|
+
uploadRef.current = null;
|
|
139
|
+
enter('idle');
|
|
140
|
+
}, [enter, stopMeter]);
|
|
141
|
+
const start = useCallback(() => {
|
|
142
|
+
if (phaseRef.current !== 'idle' || !projectId)
|
|
143
|
+
return;
|
|
144
|
+
const recorder = new DictationRecorder();
|
|
145
|
+
recorderRef.current = recorder;
|
|
146
|
+
enter('starting');
|
|
147
|
+
setLevels([]);
|
|
148
|
+
setElapsedMs(0);
|
|
149
|
+
recorder
|
|
150
|
+
.start()
|
|
151
|
+
.then(() => {
|
|
152
|
+
if (recorderRef.current !== recorder)
|
|
153
|
+
return recorder.cancel();
|
|
154
|
+
enter('recording');
|
|
155
|
+
const startedAt = performance.now();
|
|
156
|
+
let lastBar = 0;
|
|
157
|
+
let bars = [];
|
|
158
|
+
const tick = (now) => {
|
|
159
|
+
if (recorderRef.current !== recorder)
|
|
160
|
+
return;
|
|
161
|
+
const elapsed = now - startedAt;
|
|
162
|
+
if (now - lastBar >= BAR_INTERVAL_MS) {
|
|
163
|
+
lastBar = now;
|
|
164
|
+
bars = pushLevel(bars, recorder.level(), DICTATION_BARS);
|
|
165
|
+
setLevels(bars);
|
|
166
|
+
setElapsedMs(elapsed);
|
|
167
|
+
}
|
|
168
|
+
if (elapsed >= maxSeconds * 1000) {
|
|
169
|
+
infoToast(t('limitReached', { minutes: Math.round(maxSeconds / 60) }));
|
|
170
|
+
finishRef.current();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
frameRef.current = requestAnimationFrame(tick);
|
|
174
|
+
};
|
|
175
|
+
frameRef.current = requestAnimationFrame(tick);
|
|
176
|
+
})
|
|
177
|
+
.catch((error) => {
|
|
178
|
+
recorderRef.current = null;
|
|
179
|
+
enter('idle');
|
|
180
|
+
const problem = error instanceof MicrophoneError ? error.problem : 'unsupported';
|
|
181
|
+
errorToast(problem === 'denied'
|
|
182
|
+
? t(isDesktop() ? 'micDeniedDesktop' : 'micDenied')
|
|
183
|
+
: problem === 'missing'
|
|
184
|
+
? t('micMissing')
|
|
185
|
+
: problem === 'busy'
|
|
186
|
+
? t('micBusy')
|
|
187
|
+
: t('micUnsupported'));
|
|
188
|
+
});
|
|
189
|
+
}, [projectId, enter, maxSeconds, t]);
|
|
190
|
+
// Escape drops the take while one runs, before the composer reads Escape as Stop.
|
|
191
|
+
useEffect(() => {
|
|
192
|
+
if (phase === 'idle')
|
|
193
|
+
return;
|
|
194
|
+
const onKey = (event) => {
|
|
195
|
+
if (event.key !== 'Escape')
|
|
196
|
+
return;
|
|
197
|
+
event.preventDefault();
|
|
198
|
+
event.stopPropagation();
|
|
199
|
+
cancel();
|
|
200
|
+
};
|
|
201
|
+
window.addEventListener('keydown', onKey, true);
|
|
202
|
+
return () => window.removeEventListener('keydown', onKey, true);
|
|
203
|
+
}, [phase, cancel]);
|
|
204
|
+
// A composer that unmounts mid-take releases the microphone.
|
|
205
|
+
useEffect(() => () => cancel(), [cancel]);
|
|
206
|
+
if (!supported || !projectId || !info.data?.available)
|
|
207
|
+
return null;
|
|
208
|
+
return {
|
|
209
|
+
phase,
|
|
210
|
+
levels,
|
|
211
|
+
elapsedMs,
|
|
212
|
+
maxSeconds,
|
|
213
|
+
creditsPerMinute: info.data.credits_per_minute,
|
|
214
|
+
start,
|
|
215
|
+
finish,
|
|
216
|
+
cancel,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
@@ -4,6 +4,7 @@ import { Button } from '../../primitives/button.js';
|
|
|
4
4
|
import Loading from '../../primitives/loading.js';
|
|
5
5
|
import { CountBadge } from '../../primitives/count-badge.js';
|
|
6
6
|
import { parseNoticeBatch } from '../turn/subagent-notice.js';
|
|
7
|
+
import { STALE_RUNTIME_DELIVERY_ERROR } from '../../_vendor/kortix-shared.js';
|
|
7
8
|
import { useTranslations } from '../../i18n/index.js';
|
|
8
9
|
import { cn } from '../../lib/utils.js';
|
|
9
10
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '../../primitives/dropdown-menu.js';
|
|
@@ -127,7 +128,10 @@ export function QueuedPromptList({ rows, heldCount, resumePending = false, onRes
|
|
|
127
128
|
!failed &&
|
|
128
129
|
(row.steer || row.steerFallback) && (_jsx("p", { className: "text-muted-foreground text-xs", "data-queued-delivery": true, children: row.steerFallback
|
|
129
130
|
? t(STEER_FALLBACK_KEY[row.steerFallback])
|
|
130
|
-
: t('steerNextStep') })), failed && (_jsxs("p", { className: "
|
|
131
|
+
: t('steerNextStep') })), failed && (_jsxs("p", { className: "flex flex-wrap items-baseline gap-x-2 text-xs", role: "status", title: row.lastError, children: [_jsxs("span", { className: "text-kortix-red", children: [copy.raw('textcd5f943d5863'), row.lastError
|
|
132
|
+
? ` · ${row.lastError === STALE_RUNTIME_DELIVERY_ERROR ? t('queuedDisconnected') : row.lastError}`
|
|
133
|
+
: ''] }), row.lastError !== STALE_RUNTIME_DELIVERY_ERROR &&
|
|
134
|
+
actions.some((action) => action.key === 'retry') && (_jsx("button", { type: "button", onClick: actions.find((action) => action.key === 'retry').run, className: "text-foreground hover:text-foreground/80 cursor-pointer font-medium underline-offset-2 hover:underline focus-visible:underline", children: actionLabel.retry }))] }))] }), actions.length > 0 && (_jsxs(DropdownMenu, { modal: false, children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { type: "button", variant: "ghost", size: "icon-xs", "data-queued-actions": true, "aria-label": t('queuedActions'), className: cn('text-muted-foreground hover:text-foreground shrink-0', !failed &&
|
|
131
135
|
'opacity-0 group-focus-within/queued:opacity-100 group-hover/queued:opacity-100 data-[state=open]:opacity-100 pointer-coarse:opacity-100'), children: _jsx(DotsThreeIcon, { className: "size-3.5" }) }) }), _jsx(DropdownMenuContent, { align: "end", className: "w-44", children: actions.map((action) => (_jsxs(Fragment, { children: [action.key === 'remove' && actions.length > 1 && (_jsx(DropdownMenuSeparator, {})), _jsxs(DropdownMenuItem, { variant: action.key === 'remove' ? 'destructive' : 'default', onSelect: action.run, className: "gap-2", children: [ACTION_ICON[action.key], actionLabel[action.key]] })] }, action.key))) })] }))] })) }, row.id));
|
|
132
136
|
}) }))] }));
|
|
133
137
|
}
|
|
@@ -24,7 +24,7 @@ import { cn } from '../../../lib/utils.js';
|
|
|
24
24
|
import { parseLocalhostUrl } from '@kortix/sdk';
|
|
25
25
|
import { useRuntimeConnectionStore } from '@kortix/sdk/react';
|
|
26
26
|
import { useSyncExternalStore } from 'react';
|
|
27
|
-
import { PanelCard } from './panel-card.js';
|
|
27
|
+
import { PANEL_ROW, PANEL_ROW_ICON, PanelCard } from './panel-card.js';
|
|
28
28
|
function portOf(url) {
|
|
29
29
|
return parseLocalhostUrl(url ?? '')?.port ?? 0;
|
|
30
30
|
}
|
|
@@ -48,15 +48,8 @@ export function AppsCard({ apps, onOpenApp, }) {
|
|
|
48
48
|
// was static markup before this — a stopped sandbox kept "live" dots pulsing
|
|
49
49
|
// over dead servers, which is the panel lying (W8).
|
|
50
50
|
const sandboxAlive = useSyncExternalStore(useRuntimeConnectionStore.subscribe, getSandboxAliveSnapshot, getSandboxAliveSnapshot);
|
|
51
|
-
return (_jsx(PanelCard, { title: tI18nComplete.raw('text324b134f57c7'),
|
|
52
|
-
// The payoff: if the agent got something running, that is the single most
|
|
53
|
-
// interesting fact in the panel. It should not take a click to learn it.
|
|
54
|
-
defaultExpanded: apps.length > 0, emptyText: tI18nComplete.raw('texte0687cb3046c'), contentClassName: "pb-2", children: _jsx("ul", { className: "flex flex-col gap-0", children: apps.map((app) => {
|
|
51
|
+
return (_jsx(PanelCard, { title: tI18nComplete.raw('text324b134f57c7'), isEmpty: apps.length === 0, emptyText: tI18nComplete.raw('texte0687cb3046c'), children: _jsx("ul", { className: "flex flex-col gap-0", children: apps.map((app) => {
|
|
55
52
|
const port = portOf(app.url);
|
|
56
|
-
return (_jsx("li", { children: _jsxs("button", { type: "button", onClick: () => onOpenApp(app), className:
|
|
57
|
-
// Full-width row: the brand's full-width press value (0.998),
|
|
58
|
-
// shared with the Outputs and Context rows. The background
|
|
59
|
-
// change carries the press; the scale only confirms it.
|
|
60
|
-
'transition-[background-color,transform] active:scale-[0.998]'), children: [_jsx("span", { className: "flex size-7 shrink-0 items-center justify-center", "aria-hidden": true, children: _jsxs("span", { className: "relative flex size-2", children: [sandboxAlive && (_jsx("span", { className: "bg-kortix-green absolute inline-flex size-2 animate-ping rounded-full opacity-60 motion-reduce:animate-none" })), _jsx("span", { className: cn('relative inline-flex size-2 rounded-full', sandboxAlive ? 'bg-kortix-green' : 'bg-muted-foreground/40') })] }) }), _jsx("span", { className: "text-foreground min-w-0 flex-1 truncate text-sm", children: app.name }), !sandboxAlive && (_jsx("span", { className: "text-muted-foreground shrink-0 text-xs", children: tI18nComplete.raw('text8322e87d2458') })), sandboxAlive && port > 0 && (_jsxs("span", { className: "text-muted-foreground shrink-0 text-xs tabular-nums", children: [":", port] }))] }) }, app.url));
|
|
53
|
+
return (_jsx("li", { className: "flex", children: _jsxs("button", { type: "button", onClick: () => onOpenApp(app), className: PANEL_ROW, children: [_jsx("span", { className: PANEL_ROW_ICON, "aria-hidden": true, children: _jsxs("span", { className: "relative flex size-2", children: [sandboxAlive && (_jsx("span", { className: "bg-kortix-green absolute inline-flex size-2 animate-ping rounded-full opacity-60 motion-reduce:animate-none" })), _jsx("span", { className: cn('relative inline-flex size-2 rounded-full', sandboxAlive ? 'bg-kortix-green' : 'bg-muted-foreground/40') })] }) }), _jsx("span", { className: "text-foreground min-w-0 flex-1 truncate", children: app.name }), !sandboxAlive && (_jsx("span", { className: "text-muted-foreground shrink-0 text-xs", children: tI18nComplete.raw('text8322e87d2458') })), sandboxAlive && port > 0 && (_jsxs("span", { className: "text-muted-foreground shrink-0 text-xs tabular-nums", children: [":", port] }))] }) }, app.url));
|
|
61
54
|
}) }) }));
|
|
62
55
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type AgentRow } from '../../agents/agent-model.js';
|
|
2
|
+
import type { Detail } from './detail-view.js';
|
|
3
|
+
/** A finished agent: the agents line calls both of these "done". */
|
|
4
|
+
export declare function isFinishedAgent(row: Pick<AgentRow, 'state'>): boolean;
|
|
5
|
+
export declare function BackgroundTasksCard({ projectId, sessionId, live, onOpenDetail, }: {
|
|
6
|
+
projectId: string | undefined;
|
|
7
|
+
sessionId: string | undefined;
|
|
8
|
+
/** The session works now: the lists poll every 5 s instead of every 30 s. */
|
|
9
|
+
live: boolean;
|
|
10
|
+
/** Opens the full list in the detail panel. */
|
|
11
|
+
onOpenDetail: (detail: Detail) => void;
|
|
12
|
+
}): import("react").JSX.Element | null;
|
|
13
|
+
/**
|
|
14
|
+
* Every background task of the session, live: a Running group, then a
|
|
15
|
+
* collapsible Finished group. One card per agent: its mark and name (the card
|
|
16
|
+
* opens it), its task below, the time on the right — elapsed while it works,
|
|
17
|
+
* the clock time it finished once done — and Stop while it runs.
|
|
18
|
+
*/
|
|
19
|
+
export declare function BackgroundTasksDetail({ projectId, sessionId, live, }: {
|
|
20
|
+
projectId: string | undefined;
|
|
21
|
+
sessionId: string | undefined;
|
|
22
|
+
live: boolean;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
/**
|
|
4
|
+
* Background tasks — the agents this session started that work beside it: its
|
|
5
|
+
* subagents and, with `agent_teams`, its teammates.
|
|
6
|
+
*
|
|
7
|
+
* The section lists the agents still running (or waiting on you, or failed):
|
|
8
|
+
* the agent's mark, its name and task, how long it has worked, and a stop
|
|
9
|
+
* button. A done agent leaves the list; one last row, "N finished", opens the
|
|
10
|
+
* whole set in the detail panel.
|
|
11
|
+
*
|
|
12
|
+
* The detail (`BackgroundTasksDetail`) reads the agents line itself, so its
|
|
13
|
+
* timers tick and Stop works while it is open: a Running group, then a
|
|
14
|
+
* collapsible Finished group, one card per agent. A card opens that agent's
|
|
15
|
+
* session.
|
|
16
|
+
*
|
|
17
|
+
* The data is the composer's agents line (`useAgentsLine`): the same lists, the
|
|
18
|
+
* same polling. Nothing renders while the session started no agent.
|
|
19
|
+
*/
|
|
20
|
+
import { CaretDownIcon, CaretRightIcon, SquareIcon } from '@phosphor-icons/react';
|
|
21
|
+
import { useEffect, useState } from 'react';
|
|
22
|
+
import { useTranslations } from '../../../i18n/index.js';
|
|
23
|
+
import { cn } from '../../../lib/utils.js';
|
|
24
|
+
import { Button } from '../../../primitives/button.js';
|
|
25
|
+
import { Disclosure, DisclosureContent, DisclosureTrigger } from '../../../primitives/disclosure.js';
|
|
26
|
+
import Hint from '../../../primitives/hint.js';
|
|
27
|
+
import Loading from '../../../primitives/loading.js';
|
|
28
|
+
import { useKortixComputerStore } from '../../../internal/stores/kortix-computer-store.js';
|
|
29
|
+
import { SolidCheckIcon } from '../../../internal/icons/solid-check-icon.js';
|
|
30
|
+
import { AgentMarkGlyph } from '../../../internal/components/agent-mark.js';
|
|
31
|
+
import { agentSlug } from '../../agents/agent-surface.js';
|
|
32
|
+
import { shortElapsed } from '../../agents/agent-model.js';
|
|
33
|
+
import { useAgentsLine } from '../../agents/agent-strip.js';
|
|
34
|
+
import { PANEL_ROW, PANEL_ROW_ICON, PanelCard } from './panel-card.js';
|
|
35
|
+
/** A finished agent: the agents line calls both of these "done". */
|
|
36
|
+
export function isFinishedAgent(row) {
|
|
37
|
+
return row.state === 'completed' || row.state === 'idle';
|
|
38
|
+
}
|
|
39
|
+
/** Running first (oldest start first), then the rest by newest activity. */
|
|
40
|
+
function splitRows(rows) {
|
|
41
|
+
const finished = rows.filter(isFinishedAgent).sort((a, b) => b.activityMs - a.activityMs);
|
|
42
|
+
const active = rows.filter((row) => !isFinishedAgent(row));
|
|
43
|
+
return { finished, active };
|
|
44
|
+
}
|
|
45
|
+
/** Now, ticking once a second while something runs: the elapsed times read live. */
|
|
46
|
+
function useNow(ticking) {
|
|
47
|
+
const [now, setNow] = useState(() => Date.now());
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (!ticking)
|
|
50
|
+
return;
|
|
51
|
+
const id = setInterval(() => setNow(Date.now()), 1000);
|
|
52
|
+
return () => clearInterval(id);
|
|
53
|
+
}, [ticking]);
|
|
54
|
+
return now;
|
|
55
|
+
}
|
|
56
|
+
function elapsedOf(row, now) {
|
|
57
|
+
return row.state === 'working' && row.workingSinceMs !== null ? shortElapsed(now - row.workingSinceMs) : null;
|
|
58
|
+
}
|
|
59
|
+
function clockOf(ms) {
|
|
60
|
+
return ms ? new Date(ms).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' }) : null;
|
|
61
|
+
}
|
|
62
|
+
function useOpenAgent() {
|
|
63
|
+
const focusAgent = useKortixComputerStore((s) => s.focusAgent);
|
|
64
|
+
return (row) => focusAgent({ sessionId: row.sessionId, title: row.handle, handle: row.handle, task: row.line ?? undefined });
|
|
65
|
+
}
|
|
66
|
+
/** The agent's pixel mark in a row's leading slot. */
|
|
67
|
+
function Mark({ handle }) {
|
|
68
|
+
return _jsx(AgentMarkGlyph, { slug: agentSlug(handle), size: 14, trim: true });
|
|
69
|
+
}
|
|
70
|
+
/** Stop for a running agent: a filled square, a spinner while it stops. */
|
|
71
|
+
function StopButton({ row, stopping, onStop }) {
|
|
72
|
+
const t = useTranslations('multiAgent.strip');
|
|
73
|
+
if (stopping) {
|
|
74
|
+
return (_jsx("span", { className: "flex size-6 shrink-0 items-center justify-center", children: _jsx(Loading, { className: "text-muted-foreground size-3" }) }));
|
|
75
|
+
}
|
|
76
|
+
if (row.state !== 'working' && row.state !== 'needs_input')
|
|
77
|
+
return null;
|
|
78
|
+
return (_jsx(Hint, { label: t('stopHint'), side: "left", children: _jsx(Button, { type: "button", variant: "ghost", size: "icon-xs", "aria-label": t('stopAgent', { name: row.handle }), onClick: (event) => {
|
|
79
|
+
event.stopPropagation();
|
|
80
|
+
onStop(row);
|
|
81
|
+
}, className: "text-foreground shrink-0", children: _jsx(SquareIcon, { weight: "fill", className: "size-3" }) }) }));
|
|
82
|
+
}
|
|
83
|
+
export function BackgroundTasksCard({ projectId, sessionId, live, onOpenDetail, }) {
|
|
84
|
+
const t = useTranslations('sessionUi.panel');
|
|
85
|
+
const line = useAgentsLine(projectId, sessionId, { live });
|
|
86
|
+
const openAgent = useOpenAgent();
|
|
87
|
+
const rows = [...line.agents, ...line.team];
|
|
88
|
+
const { finished, active } = splitRows(rows);
|
|
89
|
+
const now = useNow(active.some((row) => row.state === 'working'));
|
|
90
|
+
if (!line.ready || rows.length === 0)
|
|
91
|
+
return null;
|
|
92
|
+
const openAll = () => onOpenDetail({
|
|
93
|
+
key: 'background-tasks',
|
|
94
|
+
title: t('backgroundTasks'),
|
|
95
|
+
body: _jsx(BackgroundTasksDetail, { projectId: projectId, sessionId: sessionId, live: live }),
|
|
96
|
+
});
|
|
97
|
+
return (_jsx(PanelCard, { title: t('backgroundTasks'), isEmpty: false, children: _jsxs("ul", { className: "flex flex-col", children: [active.map((row) => {
|
|
98
|
+
const elapsed = elapsedOf(row, now);
|
|
99
|
+
return (_jsxs("li", { className: "mx-1 flex items-center rounded-md transition-colors duration-(--duration-fast) hover:bg-hover", children: [_jsxs("button", { type: "button", onClick: () => openAgent(row), className: "flex h-8 min-w-0 flex-1 cursor-pointer items-center gap-3 px-2 text-left text-sm", children: [_jsx("span", { className: PANEL_ROW_ICON, children: _jsx(Mark, { handle: row.handle }) }), _jsx("span", { className: "text-foreground min-w-0 truncate", children: row.handle }), row.line && _jsx("span", { className: "text-muted-foreground min-w-0 flex-1 truncate", children: row.line }), elapsed && _jsx("span", { className: "text-muted-foreground ml-auto shrink-0 text-xs tabular-nums", children: elapsed })] }), _jsx("span", { className: "flex shrink-0 pr-1", children: _jsx(StopButton, { row: row, stopping: line.stopping.has(row.sessionId), onStop: line.stop }) })] }, row.sessionId));
|
|
100
|
+
}), finished.length > 0 && (_jsx("li", { className: "flex", children: _jsxs("button", { type: "button", onClick: openAll, className: cn(PANEL_ROW, 'text-muted-foreground hover:text-foreground cursor-pointer'), children: [_jsx("span", { className: PANEL_ROW_ICON, children: _jsx(SolidCheckIcon, { className: "size-3.5!" }) }), _jsx("span", { className: "truncate", children: t('finishedCount', { count: finished.length }) })] }) }))] }) }));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Every background task of the session, live: a Running group, then a
|
|
104
|
+
* collapsible Finished group. One card per agent: its mark and name (the card
|
|
105
|
+
* opens it), its task below, the time on the right — elapsed while it works,
|
|
106
|
+
* the clock time it finished once done — and Stop while it runs.
|
|
107
|
+
*/
|
|
108
|
+
export function BackgroundTasksDetail({ projectId, sessionId, live, }) {
|
|
109
|
+
const t = useTranslations('sessionUi.panel');
|
|
110
|
+
const line = useAgentsLine(projectId, sessionId, { live });
|
|
111
|
+
const openAgent = useOpenAgent();
|
|
112
|
+
const { finished, active } = splitRows([...line.agents, ...line.team]);
|
|
113
|
+
const now = useNow(active.some((row) => row.state === 'working'));
|
|
114
|
+
const [finishedOpen, setFinishedOpen] = useState(true);
|
|
115
|
+
return (_jsxs("div", { className: "flex flex-col gap-6", children: [active.length > 0 && (_jsxs("section", { className: "flex flex-col gap-2", children: [_jsxs("h3", { className: "text-muted-foreground flex gap-1.5 px-1 text-sm", children: [t('running'), _jsx("span", { className: "tabular-nums", children: active.length })] }), active.map((row) => (_jsx(TaskCard, { row: row, time: elapsedOf(row, now), onOpen: openAgent, action: _jsx(StopButton, { row: row, stopping: line.stopping.has(row.sessionId), onStop: line.stop }) }, row.sessionId)))] })), finished.length > 0 && (_jsxs(Disclosure, { open: finishedOpen, onOpenChange: setFinishedOpen, children: [_jsx(DisclosureTrigger, { children: _jsxs("div", { className: "text-muted-foreground hover:text-foreground flex w-fit cursor-pointer items-center gap-1.5 px-1 text-sm transition-colors", children: [_jsx(CaretDownIcon, { className: cn('size-3.5 transition-transform motion-reduce:transition-none', !finishedOpen && '-rotate-90') }), t('finished'), _jsx("span", { className: "tabular-nums", children: finished.length })] }) }), _jsx(DisclosureContent, { contentClassName: "flex flex-col gap-2 pt-2", children: finished.map((row) => (_jsx(TaskCard, { row: row, time: clockOf(row.activityMs), onOpen: openAgent }, row.sessionId))) })] }))] }));
|
|
116
|
+
}
|
|
117
|
+
function TaskCard({ row, time, onOpen, action, }) {
|
|
118
|
+
return (_jsxs("div", { className: "bg-popover border-border hover:bg-hover flex items-start gap-2 rounded-md border pr-2 transition-colors duration-(--duration-fast)", children: [_jsxs("button", { type: "button", onClick: () => onOpen(row), className: "flex min-w-0 flex-1 cursor-pointer items-start gap-3 py-2.5 pl-3 text-left text-sm", children: [_jsx("span", { className: "flex h-[1lh] w-4 shrink-0 items-center justify-center", children: _jsx(Mark, { handle: row.handle }) }), _jsxs("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [_jsxs("span", { className: "flex min-w-0 items-center gap-1", children: [_jsx("span", { className: "text-foreground truncate", children: row.handle }), _jsx(CaretRightIcon, { className: "text-muted-foreground size-3.5 shrink-0" })] }), row.line && _jsx("span", { className: "text-muted-foreground line-clamp-2", children: row.line })] }), time && _jsx("span", { className: "text-muted-foreground flex h-[1lh] shrink-0 items-center text-xs tabular-nums", children: time })] }), action && _jsx("span", { className: "mt-2.5 flex h-[1lh] shrink-0 items-center text-sm", children: action })] }));
|
|
119
|
+
}
|
|
@@ -13,5 +13,5 @@ export function ChangeRequestsCard({ requests, onOpen, onJump, jumping = false }
|
|
|
13
13
|
const locale = useLocale();
|
|
14
14
|
if (requests.length === 0)
|
|
15
15
|
return null;
|
|
16
|
-
return (_jsx(PanelCard, { title: t('title'),
|
|
16
|
+
return (_jsx(PanelCard, { title: t('title'), isEmpty: false, fill: true, contentClassName: "min-h-0 overflow-y-auto pb-3", children: _jsx("ul", { children: [...requests].sort((a, b) => Date.parse(b.created_at) - Date.parse(a.created_at)).map((cr) => (_jsxs("li", { className: "hover:bg-hover mx-1 flex items-center gap-1 rounded-md pr-1 transition-colors", children: [_jsxs("button", { type: "button", "data-cr-id": cr.cr_id, onClick: () => onOpen(cr.cr_id), className: "flex min-w-0 flex-1 flex-col gap-1 py-2 pl-2 text-left", children: [_jsxs("span", { className: "flex w-full min-w-0 items-baseline gap-2", children: [_jsxs("span", { className: "text-muted-foreground shrink-0 text-xs tabular-nums", children: ["#", cr.number] }), _jsx("span", { className: "text-foreground truncate text-sm", children: cr.title })] }), _jsxs("span", { className: "flex flex-wrap items-center gap-2", children: [cr.status === 'open' ? _jsx(Badge, { variant: "secondary", size: "sm", children: t('open') }) : _jsx(ChangeRequestStatusBadge, { cr: cr }), _jsx("time", { dateTime: cr.created_at, className: "text-muted-foreground text-xs", children: relativeTime(cr.created_at, locale) })] })] }), _jsx(Hint, { label: t('jump', { number: cr.number }), children: _jsx(Button, { variant: "ghost", size: "icon", disabled: jumping, "aria-label": t('jump', { number: cr.number }), onClick: () => onJump(cr.cr_id), children: _jsx(ArrowBendUpLeftIcon, { className: "size-3.5 shrink-0" }) }) })] }, cr.cr_id))) }) }));
|
|
17
17
|
}
|
|
@@ -14,12 +14,10 @@ import { ArrowRightIcon, FileTextIcon } from '@phosphor-icons/react';
|
|
|
14
14
|
import { useTranslations } from '../../../i18n/index.js';
|
|
15
15
|
import { SessionDiffViewer } from '../session-diff-viewer.js';
|
|
16
16
|
import { CHANGE_STATUS_META, useSessionChanges } from '../session-changes-shared.js';
|
|
17
|
-
import { CountBadge } from '../../../primitives/count-badge.js';
|
|
18
17
|
import { STATUS_DOT } from '../../../primitives/status.js';
|
|
19
18
|
import { useLocalizedUiCatalog } from '../../../i18n/ui-catalog/use-localized-ui-catalog.js';
|
|
20
19
|
import { cn } from '../../../lib/utils.js';
|
|
21
|
-
import {
|
|
22
|
-
import { PanelCard } from './panel-card.js';
|
|
20
|
+
import { PANEL_ROW, PANEL_ROW_ICON, PanelCard } from './panel-card.js';
|
|
23
21
|
import { getFileIcon } from '../../../files/project/components/file-icon.js';
|
|
24
22
|
/** Rows shown before the fold; the fold opens the full comparison. */
|
|
25
23
|
const VISIBLE_ROWS = 5;
|
|
@@ -50,11 +48,11 @@ export function ChangesSection({ files, onOpenDetail, onOpenAll, }) {
|
|
|
50
48
|
body: _jsx(SessionDiffViewer, { filePath: file }),
|
|
51
49
|
});
|
|
52
50
|
};
|
|
53
|
-
return (_jsxs(PanelCard, { title: t.raw('textbbd4b6a86bc6'),
|
|
51
|
+
return (_jsxs(PanelCard, { title: t.raw('textbbd4b6a86bc6'), isEmpty: false, children: [_jsx("ul", { children: visible.map((f) => {
|
|
54
52
|
const { name, dir } = splitPath(f.file);
|
|
55
53
|
// Added / Edited / Removed, as the full comparison shows it: a line
|
|
56
54
|
// count alone cannot tell a deleted file from an edit that removed lines.
|
|
57
55
|
const status = f.status ? statusMeta[f.status] : undefined;
|
|
58
|
-
return (_jsx("li", { children: _jsxs("button", { type: "button", title: status ? `${status.label}: ${f.file}` : f.file, onClick: () => openFile(f.file), className:
|
|
59
|
-
}) }), hidden > 0 && (_jsxs("button", { type: "button", onClick: onOpenAll, className:
|
|
56
|
+
return (_jsx("li", { className: "flex", children: _jsxs("button", { type: "button", title: status ? `${status.label}: ${f.file}` : f.file, onClick: () => openFile(f.file), className: PANEL_ROW, children: [_jsx("span", { className: PANEL_ROW_ICON, children: getFileIcon(name, { variant: 'monochrome' }) }), status && (_jsx("span", { "data-status": f.status, className: cn('size-1.5 shrink-0 rounded-full', STATUS_DOT[status.tone]), "aria-label": status.label, role: "img" })), _jsxs("span", { className: "min-w-0 flex-1 truncate", children: [_jsx("span", { className: "text-foreground", children: name }), dir && _jsx("span", { className: "text-muted-foreground ml-1.5 text-xs", children: dir })] }), (f.additions > 0 || f.deletions > 0) && (_jsxs("span", { className: "flex shrink-0 gap-1.5 text-xs tabular-nums", children: [f.additions > 0 && _jsxs("span", { className: "text-kortix-green", children: ["+", f.additions] }), f.deletions > 0 && _jsxs("span", { className: "text-kortix-red", children: ["\u2212", f.deletions] })] }))] }) }, f.file));
|
|
57
|
+
}) }), hidden > 0 && (_jsx("div", { className: "flex", children: _jsxs("button", { type: "button", onClick: onOpenAll, className: cn(PANEL_ROW, 'text-muted-foreground hover:text-foreground'), children: [_jsx("span", { className: PANEL_ROW_ICON, children: _jsx(ArrowRightIcon, { className: "size-3.5!" }) }), _jsx("span", { className: "flex-1 truncate", children: t.raw('text6a47708f4e14') }), _jsx("span", { className: "tabular-nums", children: hidden })] }) }))] }));
|
|
60
58
|
}
|
|
@@ -35,13 +35,14 @@ import { FaviconAvatar } from '../../../primitives/favicon-avatar.js';
|
|
|
35
35
|
import { getFileIcon } from '../../../files/project/components/file-icon.js';
|
|
36
36
|
import { ContextMeter } from './context-meter.js';
|
|
37
37
|
import { cn } from '../../../lib/utils.js';
|
|
38
|
-
import { FileTextIcon as FileText, GlobeIcon as Globe, PlusIcon as Plus, } from '@phosphor-icons/react';
|
|
38
|
+
import { CaretRightIcon, ChatsTeardropIcon, FileTextIcon as FileText, GlobeIcon as Globe, PlusIcon as Plus, } from '@phosphor-icons/react';
|
|
39
39
|
import { familyForTool, narrateFailedStep, narrateStep } from '@kortix/sdk';
|
|
40
40
|
import { safeHttpUrl } from '../../../_vendor/kortix-shared.js';
|
|
41
41
|
import { ToolParts } from './detail-view.js';
|
|
42
|
-
import {
|
|
42
|
+
import { multiAgentTool } from '../../tool/tools/kortix-tool-card.js';
|
|
43
|
+
import { PANEL_ROW, PANEL_ROW_ICON, PanelCard } from './panel-card.js';
|
|
44
|
+
import { STATUS_DOT } from '../../../primitives/status.js';
|
|
43
45
|
import { StepIcon } from './step-icon.js';
|
|
44
|
-
import { CaretRightSolidIcon } from '../../../icons/caret-right-solid.js';
|
|
45
46
|
export function ContextCard({ files, web, tools, sessionId, onOpenDetail, onOpenFile, onAddContext, usage, }) {
|
|
46
47
|
const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
|
|
47
48
|
const groups = [];
|
|
@@ -87,15 +88,13 @@ export function ContextCard({ files, web, tools, sessionId, onOpenDetail, onOpen
|
|
|
87
88
|
id: tool.callID,
|
|
88
89
|
label: tool.label,
|
|
89
90
|
count: tool.calls?.length ?? 1,
|
|
90
|
-
|
|
91
|
+
failed,
|
|
92
|
+
// A message to another agent is a conversation, not a settings change: its own glyph.
|
|
93
|
+
icon: multiAgentTool(tool.calls?.[0]?.name ?? '') === 'send_message' ? (_jsx(ChatsTeardropIcon, { className: cn('size-4 shrink-0', failed ? 'text-kortix-red' : 'text-foreground') })) : (_jsx(StepIcon, { family: family, status: failed ? 'error' : 'done', tone: "foreground" })),
|
|
91
94
|
body: _jsx(ToolParts, { calls: tool.calls ?? [], sessionId: sessionId, summary: summary }),
|
|
92
95
|
});
|
|
93
96
|
}
|
|
94
|
-
return (_jsxs(PanelCard, { title: tI18nComplete.raw('texta6e600a10fed'), isEmpty: groups.length === 0 && !usage, emptyText: tI18nComplete.raw('textc63adab9bd56'), emptyActions: _jsxs(Button, { variant: "outline", size: "sm", className: "gap-1.5", onClick: onAddContext, children: [_jsx(Plus, { className: "size-3.5" }), tI18nComplete.raw('text0f01d14cacf0')] }),
|
|
95
|
-
// No header count on purpose: the meter states how full the window is,
|
|
96
|
-
// and each row carries its own number (web sources, files read, calls
|
|
97
|
-
// per tool). Rows carry their own `px-4` and fill the width on hover.
|
|
98
|
-
contentClassName: "pb-2", defaultExpanded: files.length + web.length + tools.length > 0 || !!usage, children: [usage && _jsx(ContextMeter, { usage: usage }), _jsx("ul", { className: cn('flex flex-col gap-0', usage && groups.length > 0 && 'mt-2'), children: groups.map((g) => (_jsx("li", { className: "flex items-center", children: _jsxs("button", { type: "button", onClick: () => onOpenDetail({ key: g.id, title: g.label, icon: g.icon, body: g.body }), className: "hover:bg-accent flex h-8 w-full cursor-pointer items-center gap-2.5 px-4 text-left transition-[background-color,transform] active:scale-[0.998]", children: [_jsx("span", { className: "flex size-4 shrink-0 items-center justify-center", children: g.icon }), _jsx("span", { className: "text-foreground min-w-0 flex-1 truncate text-sm", children: g.label }), _jsx("span", { className: "text-muted-foreground text-sm tabular-nums", children: g.count }), _jsx(CaretRightSolidIcon, { className: "text-muted-foreground size-3.5 shrink-0" })] }) }, g.id))) })] }));
|
|
97
|
+
return (_jsxs(PanelCard, { title: tI18nComplete.raw('texta6e600a10fed'), isEmpty: groups.length === 0 && !usage, emptyText: tI18nComplete.raw('textc63adab9bd56'), emptyActions: _jsxs(Button, { variant: "outline", size: "sm", className: "gap-1.5", onClick: onAddContext, children: [_jsx(Plus, { className: "size-3.5" }), tI18nComplete.raw('text0f01d14cacf0')] }), children: [usage && _jsx(ContextMeter, { usage: usage }), _jsx("ul", { className: cn('flex flex-col', usage && groups.length > 0 && 'mt-2'), children: groups.map((g) => (_jsx("li", { className: "flex", children: _jsxs("button", { type: "button", onClick: () => onOpenDetail({ key: g.id, title: g.label, icon: g.icon, body: g.body }), className: cn(PANEL_ROW, 'text-muted-foreground hover:text-foreground cursor-pointer'), children: [_jsx("span", { className: PANEL_ROW_ICON, children: _jsx(CaretRightIcon, { className: "size-3.5!" }) }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: g.label }), g.failed && (_jsx("span", { className: cn('size-1.5 shrink-0 rounded-full', STATUS_DOT.destructive), "aria-hidden": true })), _jsx("span", { className: "tabular-nums", children: g.count })] }) }, g.id))) })] }));
|
|
99
98
|
}
|
|
100
99
|
const ROW = cn('flex min-h-12 w-full items-center gap-3 rounded-md px-2.5 py-2 text-left', 'bg-muted/40 transition-colors');
|
|
101
100
|
/**
|
|
@@ -13,6 +13,8 @@ export declare function findModelKey(models: {
|
|
|
13
13
|
} | null;
|
|
14
14
|
/** The live session's context usage, or null outside a session panel / before the first reply. */
|
|
15
15
|
export declare function useSessionContextUsage(): ContextUsage | null;
|
|
16
|
+
/** Offer Compact once the window is nearly full (the composer ring's warning tone, 70%). */
|
|
17
|
+
export declare function offersCompact(usage: Pick<ContextUsage, 'limit' | 'tone'>, supported: boolean): boolean;
|
|
16
18
|
export declare function ContextMeter({ usage }: {
|
|
17
19
|
usage: ContextUsage;
|
|
18
20
|
}): import("react").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
/**
|
|
4
4
|
* The Context section's usage meter: how full the model's context window is,
|
|
5
5
|
* and what fills it.
|
|
@@ -15,8 +15,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
15
15
|
* 70%, red from 85%, `contextTone`), so the two never disagree.
|
|
16
16
|
*/
|
|
17
17
|
import { flattenModels } from '@kortix/sdk';
|
|
18
|
-
import { useProjectSession, useRuntimeProviders, useSessionLogThread, useSessionModelUsage, } from '@kortix/sdk/react';
|
|
19
|
-
import { useMemo } from 'react';
|
|
18
|
+
import { useProjectSession, useRuntimeProviders, useRuntimeSupports, useSessionLogThread, useSessionModelUsage, } from '@kortix/sdk/react';
|
|
19
|
+
import { useMemo, useState } from 'react';
|
|
20
|
+
import { Button } from '../../../primitives/button.js';
|
|
21
|
+
import { CompactModal } from '../../header/compact-modal.js';
|
|
20
22
|
import { useTranslations } from '../../../i18n/index.js';
|
|
21
23
|
import { cn } from '../../../lib/utils.js';
|
|
22
24
|
import { STATUS_DOT } from '../../../primitives/status.js';
|
|
@@ -53,8 +55,16 @@ export function useSessionContextUsage() {
|
|
|
53
55
|
return usage.breakdown.total > 0 ? usage : null;
|
|
54
56
|
}, [panel, messages, models, modelKey]);
|
|
55
57
|
}
|
|
58
|
+
/** Offer Compact once the window is nearly full (the composer ring's warning tone, 70%). */
|
|
59
|
+
export function offersCompact(usage, supported) {
|
|
60
|
+
return supported && usage.limit != null && (usage.tone === 'warning' || usage.tone === 'destructive');
|
|
61
|
+
}
|
|
56
62
|
export function ContextMeter({ usage }) {
|
|
57
63
|
const t = useTranslations('hardcodedUi.i18nComplete');
|
|
64
|
+
const tProgress = useTranslations('hardcodedUi.featuresSessionComposerTokenProgress');
|
|
65
|
+
const runtimeSessionId = useOptionalSessionPanel()?.sessionId;
|
|
66
|
+
const compact = offersCompact(usage, useRuntimeSupports('session.compact')) && Boolean(runtimeSessionId);
|
|
67
|
+
const [compactOpen, setCompactOpen] = useState(false);
|
|
58
68
|
const { breakdown, limit } = usage;
|
|
59
69
|
// The bar's scale: the window when known, else the tokens themselves.
|
|
60
70
|
const scale = limit ?? breakdown.total;
|
|
@@ -69,5 +79,9 @@ export function ContextMeter({ usage }) {
|
|
|
69
79
|
{ key: 'input', label: t.raw('text36ecb4f86691'), value: breakdown.input, swatch: 'bg-kortix-purple' },
|
|
70
80
|
{ key: 'output', label: t.raw('textb2439bcb8dee'), value: breakdown.output, swatch: 'bg-kortix-green' },
|
|
71
81
|
].filter((p) => p.value > 0);
|
|
72
|
-
return (_jsxs("div", { className: "
|
|
82
|
+
return (_jsxs("div", { className: "flex flex-col", children: [_jsxs("div", { className: "flex items-center justify-between gap-2 px-3 text-sm tabular-nums", children: [_jsxs("span", { className: "text-foreground flex items-center gap-1.5", children: [limit && usage.tone !== 'info' && (_jsx("span", { className: cn('size-1.5 rounded-full', STATUS_DOT[usage.tone]), "aria-hidden": true })), limit ? `${usage.percent}% ${t.raw('textf83916135509')}` : formatContextCount(breakdown.total)] }), limit && (_jsxs("span", { className: "text-muted-foreground", children: [formatContextCount(breakdown.total), " / ", formatContextCount(limit)] }))] }), _jsx("div", { className: "bg-muted mx-3 mt-2 flex h-1 gap-px overflow-hidden rounded-full", "aria-hidden": true, children: parts.map((p) => (_jsx("span", { className: p.swatch, style: { width: `${share(p.value) * 100}%` } }, p.key))) }), _jsxs("dl", { className: "mt-2 flex flex-col", children: [parts.map((p) => (_jsx(MeterRow, { swatch: p.swatch, label: p.label, value: p.value, percent: limit ? pct(p.value) : null }, p.key))), free != null && (_jsx(MeterRow, { className: "mt-2", swatch: "bg-muted ring-1 ring-border ring-inset", label: t.raw('text64cd989efc14'), value: free, percent: pct(free) }))] }), compact && runtimeSessionId && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex items-center justify-between gap-2 px-3 pt-3", children: [_jsx("span", { className: "text-muted-foreground text-sm tabular-nums", children: tProgress('remainingCount', { remaining: formatContextCount(free ?? 0) }) }), _jsx(Button, { variant: "secondary", size: "sm", onClick: () => setCompactOpen(true), children: t.raw('textee1ca259e05b') })] }), _jsx(CompactModal, { sessionId: runtimeSessionId, open: compactOpen, onOpenChange: setCompactOpen })] }))] }));
|
|
83
|
+
}
|
|
84
|
+
/** One legend row: swatch, label, tokens, share. Columns line up down the list. */
|
|
85
|
+
function MeterRow({ swatch, label, value, percent, className, }) {
|
|
86
|
+
return (_jsxs("div", { className: cn('mx-1 flex h-7 items-center gap-3 px-2 text-sm tabular-nums', className), children: [_jsx("span", { className: "flex w-5 shrink-0 items-center justify-center", "aria-hidden": true, children: _jsx("span", { className: cn('size-2.5 rounded-xs', swatch) }) }), _jsx("dt", { className: "text-muted-foreground min-w-0 flex-1 truncate", children: label }), _jsx("dd", { className: "text-muted-foreground text-right", children: formatContextCount(value) }), percent && _jsx("dd", { className: "text-foreground w-14 text-right", children: percent })] }));
|
|
73
87
|
}
|