@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,304 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ArrowBendUpLeftIcon, ArrowCounterClockwiseIcon, ArrowsOutSimpleIcon, CheckIcon, WarningIcon, XIcon, } from '@phosphor-icons/react';
|
|
4
|
+
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
5
|
+
import { useTranslations } from '../../i18n/index.js';
|
|
6
|
+
import { cn } from '../../internal/lib/utils.js';
|
|
7
|
+
import { approvalIdentity } from '../../markdown/setup-links/approval-decision.js';
|
|
8
|
+
import { ConnectorAppMark } from '../../markdown/setup-links/connector-handshake.js';
|
|
9
|
+
import { Button } from '../../primitives/button.js';
|
|
10
|
+
import { EmptyState } from '../../primitives/empty-state.js';
|
|
11
|
+
import { undoToast } from '../../primitives/toast.js';
|
|
12
|
+
import { reviewApprovalDetails } from './approval-modal.js';
|
|
13
|
+
import { OutputBody } from './review-detail.js';
|
|
14
|
+
import { formatItemAge } from './review-actions.js';
|
|
15
|
+
import { ROW_TILE, reviewKindLabel } from './review-meta.js';
|
|
16
|
+
import { reviewSwipeVerdicts } from './review-swipe.js';
|
|
17
|
+
/** How long a verdict waits for Undo before it is sent. */
|
|
18
|
+
const UNDO_MS = 5_000;
|
|
19
|
+
/** How far a card moves before a release decides it. */
|
|
20
|
+
const SWIPE_PX = 110;
|
|
21
|
+
/** A pointer that moves less than this is a click, not a drag. */
|
|
22
|
+
const CLICK_SLOP_PX = 6;
|
|
23
|
+
/** The fly-off after a decision. */
|
|
24
|
+
const EXIT_MS = 220;
|
|
25
|
+
/** The cards drawn under the top one. */
|
|
26
|
+
const STACK_DEPTH = 2;
|
|
27
|
+
const EASE_OUT = 'cubic-bezier(0.23, 1, 0.32, 1)';
|
|
28
|
+
export function ReviewSwipeDeck({ items, allows, onDecide, onOpen, paused }) {
|
|
29
|
+
const t = useTranslations('hardcodedUi.reviewDeck');
|
|
30
|
+
const [skipped, setSkipped] = useState([]);
|
|
31
|
+
const [staged, setStaged] = useState(() => new Map());
|
|
32
|
+
const [leaving, setLeaving] = useState(null);
|
|
33
|
+
// The card whose "what should change?" box is open (a left swipe on a
|
|
34
|
+
// change or an output), and its text.
|
|
35
|
+
const [asking, setAsking] = useState(null);
|
|
36
|
+
const [note, setNote] = useState('');
|
|
37
|
+
const rootRef = useRef(null);
|
|
38
|
+
const stagedRef = useRef(staged);
|
|
39
|
+
stagedRef.current = staged;
|
|
40
|
+
const onDecideRef = useRef(onDecide);
|
|
41
|
+
onDecideRef.current = onDecide;
|
|
42
|
+
// A verdict accepted while its card still flies off: registered at once,
|
|
43
|
+
// so leaving the page mid-animation still sends it.
|
|
44
|
+
const flyingRef = useRef(null);
|
|
45
|
+
// The deck takes focus when it shows, so its keys work at once.
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
if (!paused)
|
|
48
|
+
rootRef.current?.focus({ preventScroll: true });
|
|
49
|
+
}, [paused]);
|
|
50
|
+
// Leaving the page sends what waits: Undo is a short grace, not a draft.
|
|
51
|
+
useEffect(() => () => {
|
|
52
|
+
const flying = flyingRef.current;
|
|
53
|
+
if (flying) {
|
|
54
|
+
clearTimeout(flying.timer);
|
|
55
|
+
onDecideRef.current(flying.item, flying.verdict, flying.feedback);
|
|
56
|
+
}
|
|
57
|
+
for (const entry of stagedRef.current.values()) {
|
|
58
|
+
clearTimeout(entry.timer);
|
|
59
|
+
onDecideRef.current(entry.item, entry.verdict, entry.feedback);
|
|
60
|
+
}
|
|
61
|
+
}, []);
|
|
62
|
+
// Skipped cards go to the back, in the order they were skipped.
|
|
63
|
+
const deck = useMemo(() => {
|
|
64
|
+
const open = items.filter((item) => !staged.has(item.id));
|
|
65
|
+
const rank = (id) => skipped.indexOf(id);
|
|
66
|
+
return [...open].sort((a, b) => rank(a.id) - rank(b.id));
|
|
67
|
+
}, [items, staged, skipped]);
|
|
68
|
+
const top = deck[0] ?? null;
|
|
69
|
+
const swipe = top ? reviewSwipeVerdicts(top.kind) : null;
|
|
70
|
+
const yes = top && swipe?.right && allows(top, swipe.right) ? swipe.right : null;
|
|
71
|
+
const no = top && swipe?.left && allows(top, swipe.left) ? swipe.left : null;
|
|
72
|
+
const verdictLabel = useCallback((item, verdict) => {
|
|
73
|
+
if (verdict === 'changes')
|
|
74
|
+
return t('sendBack');
|
|
75
|
+
if (item.kind === 'change')
|
|
76
|
+
return verdict === 'approve' ? t('merge') : t('close');
|
|
77
|
+
if (item.kind === 'approval')
|
|
78
|
+
return verdict === 'approve' ? t('approve') : t('deny');
|
|
79
|
+
return verdict === 'approve' ? t('approve') : t('dismiss');
|
|
80
|
+
}, [t]);
|
|
81
|
+
const stage = useCallback((item, verdict, feedback) => {
|
|
82
|
+
const timer = setTimeout(() => {
|
|
83
|
+
setStaged((prev) => {
|
|
84
|
+
const next = new Map(prev);
|
|
85
|
+
next.delete(item.id);
|
|
86
|
+
return next;
|
|
87
|
+
});
|
|
88
|
+
onDecideRef.current(item, verdict, feedback);
|
|
89
|
+
}, UNDO_MS);
|
|
90
|
+
setStaged((prev) => new Map(prev).set(item.id, { item, verdict, feedback, timer }));
|
|
91
|
+
undoToast(t('staged', { verdict: verdictLabel(item, verdict), title: item.title }), {
|
|
92
|
+
duration: UNDO_MS,
|
|
93
|
+
undoLabel: t('undo'),
|
|
94
|
+
onUndo: () => {
|
|
95
|
+
const entry = stagedRef.current.get(item.id);
|
|
96
|
+
if (!entry)
|
|
97
|
+
return;
|
|
98
|
+
clearTimeout(entry.timer);
|
|
99
|
+
setStaged((prev) => {
|
|
100
|
+
const next = new Map(prev);
|
|
101
|
+
next.delete(item.id);
|
|
102
|
+
return next;
|
|
103
|
+
});
|
|
104
|
+
// The card comes back on top.
|
|
105
|
+
setSkipped((prev) => prev.filter((id) => id !== item.id));
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
}, [t, verdictLabel]);
|
|
109
|
+
/** The card flies off; its verdict is registered now and staged once it is gone. */
|
|
110
|
+
const fly = useCallback((item, dir, verdict, feedback) => {
|
|
111
|
+
setLeaving({ id: item.id, dir });
|
|
112
|
+
const timer = setTimeout(() => {
|
|
113
|
+
flyingRef.current = null;
|
|
114
|
+
setLeaving(null);
|
|
115
|
+
stage(item, verdict, feedback);
|
|
116
|
+
}, EXIT_MS);
|
|
117
|
+
flyingRef.current = { item, verdict, feedback, timer };
|
|
118
|
+
}, [stage]);
|
|
119
|
+
const decide = useCallback((dir) => {
|
|
120
|
+
if (!top || leaving)
|
|
121
|
+
return;
|
|
122
|
+
const verdict = dir === 'right' ? yes : no;
|
|
123
|
+
if (!verdict)
|
|
124
|
+
return;
|
|
125
|
+
// Sending back needs the words: the card stays and asks what should change.
|
|
126
|
+
if (verdict === 'changes') {
|
|
127
|
+
setAsking(top.id);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
fly(top, dir, verdict);
|
|
131
|
+
}, [top, leaving, yes, no, fly]);
|
|
132
|
+
// A note belongs to its card: a new top card starts with an empty box.
|
|
133
|
+
const topId = top?.id;
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
setAsking(null);
|
|
136
|
+
setNote('');
|
|
137
|
+
}, [topId]);
|
|
138
|
+
const sendBack = useCallback(() => {
|
|
139
|
+
const text = note.trim();
|
|
140
|
+
if (!top || !text)
|
|
141
|
+
return;
|
|
142
|
+
setAsking(null);
|
|
143
|
+
setNote('');
|
|
144
|
+
fly(top, 'left', 'changes', text);
|
|
145
|
+
}, [top, note, fly]);
|
|
146
|
+
const skip = useCallback(() => {
|
|
147
|
+
if (!top || deck.length < 2)
|
|
148
|
+
return;
|
|
149
|
+
setSkipped((prev) => [...prev.filter((id) => id !== top.id), top.id]);
|
|
150
|
+
}, [top, deck.length]);
|
|
151
|
+
const onKeyDown = (event) => {
|
|
152
|
+
if (paused || !top || event.metaKey || event.ctrlKey || event.altKey)
|
|
153
|
+
return;
|
|
154
|
+
// The "what should change?" box owns its keys.
|
|
155
|
+
if (asking === top.id)
|
|
156
|
+
return;
|
|
157
|
+
const key = event.key.toLowerCase();
|
|
158
|
+
if (key === 'arrowright')
|
|
159
|
+
decide('right');
|
|
160
|
+
else if (key === 'arrowleft')
|
|
161
|
+
decide('left');
|
|
162
|
+
else if (key === 's')
|
|
163
|
+
skip();
|
|
164
|
+
// Enter on a focused control (Merge, Close) is that control's click.
|
|
165
|
+
else if (key === 'enter' && event.target === event.currentTarget)
|
|
166
|
+
onOpen(top);
|
|
167
|
+
else
|
|
168
|
+
return;
|
|
169
|
+
event.preventDefault();
|
|
170
|
+
event.stopPropagation();
|
|
171
|
+
};
|
|
172
|
+
if (!top) {
|
|
173
|
+
return (_jsx("div", { className: "flex flex-1 items-center justify-center p-6", children: _jsx(EmptyState, { title: t('emptyTitle'), description: t('emptyDescription') }) }));
|
|
174
|
+
}
|
|
175
|
+
const below = deck.slice(1, 1 + STACK_DEPTH);
|
|
176
|
+
// Why a verdict control is off: a decision is answered from its options;
|
|
177
|
+
// anything else, this viewer may not give that verdict.
|
|
178
|
+
const offReason = top.kind === 'decision' ? t('needsChoice') : t('noVerdict');
|
|
179
|
+
return (_jsx("div", { ref: rootRef,
|
|
180
|
+
// The deck takes focus on mount so its keys work at once.
|
|
181
|
+
tabIndex: -1, onKeyDown: onKeyDown, "aria-label": t('label'), role: "region",
|
|
182
|
+
// The card fills the inbox's height, as a dating app's card fills the
|
|
183
|
+
// screen; the whole review scrolls inside it.
|
|
184
|
+
className: "mx-auto flex min-h-96 w-full max-w-xl flex-1 flex-col px-3 pt-2 pb-3 outline-none", children: _jsxs("div", { className: "relative min-h-0 flex-1", children: [below
|
|
185
|
+
.map((item, index) => (_jsx("div", { "aria-hidden": true, className: "bg-card border-border absolute inset-0 rounded-2xl border", style: {
|
|
186
|
+
transform: `translateY(${(index + 1) * 8}px) scale(${1 - (index + 1) * 0.03})`,
|
|
187
|
+
opacity: 1 - (index + 1) * 0.35,
|
|
188
|
+
transition: `transform 220ms ${EASE_OUT}, opacity 220ms ${EASE_OUT}`,
|
|
189
|
+
} }, item.id)))
|
|
190
|
+
.reverse(), _jsx(SwipeCard, { item: top, leaving: leaving?.id === top.id ? leaving.dir : null, canRight: !!yes, canLeft: !!no, leftTone: no === 'changes' ? 'orange' : 'red', onSwipe: decide, onOpen: () => onOpen(top) }, top.id), asking === top.id ? (_jsx(SendBackBox, { value: note, onChange: setNote, onCancel: () => {
|
|
191
|
+
setAsking(null);
|
|
192
|
+
setNote('');
|
|
193
|
+
}, onSend: sendBack })) : (
|
|
194
|
+
/* The actions float over the card's bottom edge, no captions: each
|
|
195
|
+
names itself to a screen reader and in its tooltip. */
|
|
196
|
+
_jsxs("div", { className: "pointer-events-none absolute inset-x-0 bottom-4 flex items-center justify-center gap-4", children: [_jsx(DeckButton, { label: t('skip'), kbd: "S", size: "sm", disabled: deck.length < 2, onClick: skip, children: _jsx(ArrowCounterClockwiseIcon, { className: "size-4" }) }), _jsx(DeckButton, { label: no ? verdictLabel(top, no) : offReason, kbd: "ArrowLeft", disabled: !no, onClick: () => decide('left'), children: no === 'changes' ? (_jsx(ArrowBendUpLeftIcon, { weight: "bold", className: "text-kortix-orange size-6" })) : (_jsx(XIcon, { weight: "bold", className: "text-kortix-red size-6" })) }), _jsx(DeckButton, { label: yes ? verdictLabel(top, yes) : offReason, kbd: "ArrowRight", disabled: !yes, onClick: () => decide('right'), children: _jsx(CheckIcon, { weight: "bold", className: "text-kortix-green size-6" }) }), _jsx(DeckButton, { label: t('open'), kbd: "Enter", size: "sm", onClick: () => onOpen(top), children: _jsx(ArrowsOutSimpleIcon, { className: "size-4" }) })] }))] }) }));
|
|
197
|
+
}
|
|
198
|
+
/** "What should change?": the note a left swipe sends back to the agent. */
|
|
199
|
+
function SendBackBox({ value, onChange, onCancel, onSend, }) {
|
|
200
|
+
const t = useTranslations('hardcodedUi.reviewDeck');
|
|
201
|
+
return (_jsxs("div", { className: "bg-background border-border absolute inset-x-3 bottom-3 z-10 flex flex-col gap-2 rounded-xl border p-3 shadow-lg", children: [_jsx("textarea", { autoFocus: true, rows: 3, value: value, "aria-label": t('whatShouldChange'), placeholder: t('whatShouldChange'), onChange: (event) => onChange(event.target.value), onKeyDown: (event) => {
|
|
202
|
+
if (event.key === 'Escape')
|
|
203
|
+
onCancel();
|
|
204
|
+
else if (event.key === 'Enter' && (event.metaKey || event.ctrlKey))
|
|
205
|
+
onSend();
|
|
206
|
+
}, className: "text-foreground placeholder:text-muted-foreground min-h-16 w-full resize-none bg-transparent text-sm outline-none" }), _jsxs("div", { className: "flex items-center justify-end gap-2", children: [_jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: onCancel, children: t('cancel') }), _jsx(Button, { type: "button", size: "sm", disabled: !value.trim(), onClick: onSend, children: t('sendToAgent') })] })] }));
|
|
207
|
+
}
|
|
208
|
+
/** One round control over the card. Its name is its tooltip and accessible name. */
|
|
209
|
+
function DeckButton({ label, kbd, size = 'lg', disabled, onClick, children, }) {
|
|
210
|
+
return (_jsx(Button, { type: "button", variant: "outline", "aria-label": label, "aria-keyshortcuts": kbd, title: label, disabled: disabled, onClick: onClick, className: cn('bg-background pointer-events-auto rounded-full p-0 shadow-md transition-transform duration-150 ease-out active:scale-95', size === 'lg' ? 'size-14' : 'size-11'), children: children }));
|
|
211
|
+
}
|
|
212
|
+
function SwipeCard({ item, leaving, canRight, canLeft, leftTone, onSwipe, onOpen, }) {
|
|
213
|
+
const [drag, setDrag] = useState(0);
|
|
214
|
+
const [dragging, setDragging] = useState(false);
|
|
215
|
+
const start = useRef(null);
|
|
216
|
+
// A side with no verdict resists: the card moves a third as far.
|
|
217
|
+
const resisted = (dx) => ((dx > 0 && !canRight) || (dx < 0 && !canLeft) ? dx / 3 : dx);
|
|
218
|
+
const onPointerDown = (event) => {
|
|
219
|
+
if (event.button !== 0 || leaving)
|
|
220
|
+
return;
|
|
221
|
+
// A control inside the card (a video's play, a file row) keeps its click.
|
|
222
|
+
if (event.target.closest('video, audio, button, a, input, textarea, [role="button"]'))
|
|
223
|
+
return;
|
|
224
|
+
start.current = { x: event.clientX, moved: false };
|
|
225
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
226
|
+
};
|
|
227
|
+
const onPointerMove = (event) => {
|
|
228
|
+
const s = start.current;
|
|
229
|
+
if (!s)
|
|
230
|
+
return;
|
|
231
|
+
const dx = event.clientX - s.x;
|
|
232
|
+
if (!s.moved && Math.abs(dx) < CLICK_SLOP_PX)
|
|
233
|
+
return;
|
|
234
|
+
s.moved = true;
|
|
235
|
+
setDragging(true);
|
|
236
|
+
setDrag(resisted(dx));
|
|
237
|
+
};
|
|
238
|
+
const onPointerUp = () => {
|
|
239
|
+
const s = start.current;
|
|
240
|
+
start.current = null;
|
|
241
|
+
setDragging(false);
|
|
242
|
+
if (!s)
|
|
243
|
+
return;
|
|
244
|
+
if (!s.moved) {
|
|
245
|
+
onOpen();
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (drag > SWIPE_PX && canRight)
|
|
249
|
+
onSwipe('right');
|
|
250
|
+
else if (drag < -SWIPE_PX && canLeft)
|
|
251
|
+
onSwipe('left');
|
|
252
|
+
setDrag(0);
|
|
253
|
+
};
|
|
254
|
+
const x = leaving ? (leaving === 'right' ? 1 : -1) * 640 : drag;
|
|
255
|
+
const progress = Math.min(1, Math.abs(drag) / SWIPE_PX);
|
|
256
|
+
const transform = `translateX(${x}px) rotate(${x / 30}deg)`;
|
|
257
|
+
return (_jsxs("article", { "data-testid": "review-swipe-card", "aria-label": item.title, className: cn('bg-card border-border absolute inset-0 flex cursor-grab touch-pan-y flex-col overflow-hidden rounded-2xl border shadow-sm select-none', dragging && 'cursor-grabbing'), style: {
|
|
258
|
+
transform,
|
|
259
|
+
opacity: leaving ? 0 : 1,
|
|
260
|
+
// No transition while the pointer drives the card: it follows the finger.
|
|
261
|
+
transition: dragging ? 'none' : `transform ${EXIT_MS}ms ${EASE_OUT}, opacity ${EXIT_MS}ms ${EASE_OUT}`,
|
|
262
|
+
}, onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: onPointerUp, onPointerCancel: () => {
|
|
263
|
+
start.current = null;
|
|
264
|
+
setDragging(false);
|
|
265
|
+
setDrag(0);
|
|
266
|
+
}, children: [_jsx("div", { className: "min-h-0 flex-1 overflow-y-auto pb-24", children: _jsx(CardBody, { item: item }) }), _jsx("div", { "aria-hidden": true, className: "from-card pointer-events-none absolute inset-x-0 bottom-0 h-28 bg-gradient-to-t to-transparent" }), _jsx("div", { "aria-hidden": true, className: "bg-kortix-green/15 pointer-events-none absolute inset-0", style: { opacity: drag > 0 && canRight ? progress : 0 } }), _jsx("div", { "aria-hidden": true, className: cn('pointer-events-none absolute inset-0', leftTone === 'orange' ? 'bg-kortix-orange/15' : 'bg-kortix-red/15'), style: { opacity: drag < 0 && canLeft ? progress : 0 } })] }));
|
|
267
|
+
}
|
|
268
|
+
function CardBody({ item }) {
|
|
269
|
+
const tI18nComplete = useTranslations('hardcodedUi.i18nComplete');
|
|
270
|
+
const t = useTranslations('hardcodedUi.reviewDeck');
|
|
271
|
+
const [age, setAge] = useState('');
|
|
272
|
+
// Relative time is client-only: it differs between server and hydration.
|
|
273
|
+
useEffect(() => setAge(formatItemAge(item.createdAt)), [item.createdAt]);
|
|
274
|
+
const connector = item.kind === 'approval' ? reviewApprovalDetails(item) : null;
|
|
275
|
+
const who = connector ? approvalIdentity(connector) : null;
|
|
276
|
+
const tile = ROW_TILE[item.kind];
|
|
277
|
+
return (_jsxs("div", { className: "flex flex-col gap-5 p-6", children: [_jsxs("div", { className: "flex items-center gap-2.5", children: [who ? (_jsx(ConnectorAppMark, { name: who.connector ?? item.title, slug: who.slug, iconUrl: who.iconUrl, size: "md" })) : (_jsx("span", { className: cn('flex size-8 shrink-0 items-center justify-center rounded-md', tile.tint), children: _jsx(tile.icon, { className: "size-4" }) })), _jsxs("div", { className: "text-muted-foreground min-w-0 flex-1 truncate text-xs", children: [reviewKindLabel(item.kind, tI18nComplete), item.kind === 'change' && item.detail.number != null ? ` #${item.detail.number}` : '', ' · ', item.agent, age ? ` · ${age}` : ''] }), item.risk === 'high' ? (_jsx(WarningIcon, { weight: "fill", "aria-label": t('highRisk'), className: "text-kortix-orange size-4 shrink-0" })) : null] }), _jsxs("div", { className: "flex flex-col gap-1.5", children: [_jsx("h3", { className: "text-foreground text-2xl leading-tight font-medium tracking-tight text-pretty", children: item.title }), item.summary ? (_jsx("p", { className: "text-muted-foreground text-base text-pretty", children: item.summary })) : null] }), _jsx(KindDetail, { item: item })] }));
|
|
278
|
+
}
|
|
279
|
+
/** What each kind adds under the title: the facts a verdict rests on. */
|
|
280
|
+
function KindDetail({ item }) {
|
|
281
|
+
const t = useTranslations('hardcodedUi.reviewDeck');
|
|
282
|
+
if (item.kind === 'change') {
|
|
283
|
+
const { additions, deletions, files } = item.detail.advanced;
|
|
284
|
+
const conflicts = item.detail.conflicts?.length ?? 0;
|
|
285
|
+
return (_jsxs("div", { className: "flex flex-col gap-3", children: [item.detail.whatChanged.length > 0 ? (_jsx("ul", { className: "text-foreground flex flex-col gap-1 text-sm", children: item.detail.whatChanged.slice(0, 3).map((line) => (_jsxs("li", { className: "flex gap-2", children: [_jsx("span", { "aria-hidden": true, className: "text-muted-foreground", children: "\u00B7" }), _jsx("span", { children: line })] }, line))) })) : null, files.length > 0 || additions > 0 || deletions > 0 || conflicts > 0 ? (_jsxs("div", { className: "border-border flex items-center gap-3 border-t pt-3 text-xs tabular-nums", children: [_jsx("span", { className: "text-muted-foreground", children: t('files', { count: files.length }) }), _jsxs("span", { className: "text-kortix-green", children: ["+", additions] }), _jsxs("span", { className: "text-kortix-red", children: ["\u2212", deletions] }), conflicts > 0 ? (_jsxs("span", { className: "text-muted-foreground ml-auto flex items-center gap-1", children: [_jsx(WarningIcon, { weight: "fill", className: "text-kortix-orange size-3.5" }), t('conflicts', { count: conflicts })] })) : null] })) : null] }));
|
|
286
|
+
}
|
|
287
|
+
if (item.kind === 'approval') {
|
|
288
|
+
const call = item.detail.actions[0];
|
|
289
|
+
if (!call)
|
|
290
|
+
return null;
|
|
291
|
+
const args = call.argsPreview.slice(0, 4);
|
|
292
|
+
return (_jsxs("div", { className: "flex flex-col gap-3", children: [call.consequence ? _jsx("p", { className: "text-foreground text-sm", children: call.consequence }) : null, args.length > 0 ? (_jsx("dl", { className: "bg-muted/50 grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 rounded-lg p-3 font-mono text-xs", children: args.map((arg) => (_jsxs("div", { className: "contents", children: [_jsx("dt", { className: "text-muted-foreground", children: arg.key }), _jsx("dd", { className: "text-foreground truncate", children: arg.value })] }, arg.key))) })) : null] }));
|
|
293
|
+
}
|
|
294
|
+
if (item.kind === 'output') {
|
|
295
|
+
// What the agent made, drawn as in the detail: the video, image or text
|
|
296
|
+
// is the card's face. The note often repeats the summary: say it once.
|
|
297
|
+
const shown = item.detail.note === item.summary ? { ...item, detail: { ...item.detail, note: '' } } : item;
|
|
298
|
+
return (_jsx("div", { className: "flex flex-col gap-4", children: _jsx(OutputBody, { item: shown }) }));
|
|
299
|
+
}
|
|
300
|
+
if (item.kind === 'decision') {
|
|
301
|
+
return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx("p", { className: "text-foreground text-sm font-medium", children: item.detail.question }), _jsx("ul", { className: "flex flex-col gap-1", children: item.detail.options.slice(0, 4).map((option) => (_jsx("li", { className: "border-border text-foreground truncate rounded-md border px-2.5 py-1.5 text-sm", children: option.label }, option.id))) })] }));
|
|
302
|
+
}
|
|
303
|
+
return item.detail.note && item.detail.note !== item.summary ? (_jsxs("p", { className: "text-foreground text-sm", children: [item.detail.note, _jsxs("span", { className: "text-muted-foreground", children: [" \u00B7 ", t('items', { count: item.detail.children.length })] })] })) : null;
|
|
304
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which verdict each swipe gives on a review item, in the card deck of the
|
|
3
|
+
* Review page. Right is the item's yes, left its no. A decision needs a
|
|
4
|
+
* chosen option, so it takes no swipe: its card opens the detail.
|
|
5
|
+
*
|
|
6
|
+
* - change, output: right approves (a change merges), left sends it back:
|
|
7
|
+
* the person writes what should change and the agent gets it (`changes`).
|
|
8
|
+
* Closing a change stays in its detail.
|
|
9
|
+
* - approval: right approves, left denies.
|
|
10
|
+
* - batch: right approves, left dismisses.
|
|
11
|
+
*/
|
|
12
|
+
import type { ReviewItemKind, ReviewVerdict } from '@kortix/sdk';
|
|
13
|
+
export interface ReviewSwipeVerdicts {
|
|
14
|
+
right: ReviewVerdict | null;
|
|
15
|
+
left: ReviewVerdict | null;
|
|
16
|
+
}
|
|
17
|
+
export declare function reviewSwipeVerdicts(kind: ReviewItemKind): ReviewSwipeVerdicts;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const SWIPE_VERDICTS = {
|
|
2
|
+
change: { right: 'approve', left: 'changes' },
|
|
3
|
+
approval: { right: 'approve', left: 'reject' },
|
|
4
|
+
output: { right: 'approve', left: 'changes' },
|
|
5
|
+
batch: { right: 'approve', left: 'dismiss' },
|
|
6
|
+
decision: { right: null, left: null },
|
|
7
|
+
};
|
|
8
|
+
export function reviewSwipeVerdicts(kind) {
|
|
9
|
+
return SWIPE_VERDICTS[kind];
|
|
10
|
+
}
|
|
@@ -8,7 +8,7 @@ import { cn } from '../../lib/utils.js';
|
|
|
8
8
|
import { Button } from '../../primitives/button.js';
|
|
9
9
|
import { CommandGroup, CommandInput, CommandItem, CommandList, CommandPopover, CommandPopoverContent, CommandPopoverTrigger, CommandSeparator, } from '../../primitives/command.js';
|
|
10
10
|
import { SpaceFormModal } from './space-form-modal.js';
|
|
11
|
-
import {
|
|
11
|
+
import { SpaceIconBare } from './space-icon.js';
|
|
12
12
|
/** Spaces on screen before the popover shows its search field (it stays mounted for the arrow keys). */
|
|
13
13
|
const SEARCH_THRESHOLD = 8;
|
|
14
14
|
/**
|
|
@@ -34,8 +34,8 @@ export function SpacePicker({ projectId, value, onChange, }) {
|
|
|
34
34
|
setOpen(false);
|
|
35
35
|
setSearch('');
|
|
36
36
|
};
|
|
37
|
-
const row = (space) => (_jsxs(CommandItem, { value: `space-${space.group_id}`, className: "gap-2", onSelect: () => pick(space.group_id), children: [_jsx(
|
|
38
|
-
return (_jsxs(_Fragment, { children: [_jsxs(CommandPopover, { open: open, onOpenChange: setOpen, children: [_jsx(CommandPopoverTrigger, { children: _jsxs(Button, { type: "button", variant: "ghost", size: "sm", "aria-label": picked ? `${t('picker')}: ${picked.name}` : t('picker'), className: cn('rounded-lg hit-area-y-3', picked ? 'text-foreground' : 'text-muted-foreground'), children: [picked ? _jsx(
|
|
37
|
+
const row = (space) => (_jsxs(CommandItem, { value: `space-${space.group_id}`, className: "gap-2", onSelect: () => pick(space.group_id), children: [_jsx(SpaceIconBare, { space: space }), _jsx("span", { className: "min-w-0 flex-1 truncate first-letter:uppercase", children: space.name }), space.group_id === value ? _jsx(CheckIcon, { className: "text-foreground size-4 shrink-0" }) : null] }, space.group_id));
|
|
38
|
+
return (_jsxs(_Fragment, { children: [_jsxs(CommandPopover, { open: open, onOpenChange: setOpen, children: [_jsx(CommandPopoverTrigger, { children: _jsxs(Button, { type: "button", variant: "ghost", size: "sm", "aria-label": picked ? `${t('picker')}: ${picked.name}` : t('picker'), className: cn('rounded-lg hit-area-y-3', picked ? 'text-foreground' : 'text-muted-foreground'), children: [picked ? _jsx(SpaceIconBare, { space: picked }) : _jsx(StackIcon, { className: "size-4 shrink-0" }), _jsx("span", { className: "max-w-[140px] truncate first-letter:uppercase", children: picked ? picked.name : t('picker') }), _jsx(CaretDownIcon, { className: cn('size-3 transition-transform duration-moderate ease-out', open && 'rotate-180') })] }) }), _jsxs(CommandPopoverContent, { side: "top", align: "start", sideOffset: 8, className: "w-[min(300px,calc(100vw-1.5rem))]", children: [_jsx("div", { className: spaces.length > SEARCH_THRESHOLD ? undefined : 'sr-only', children: _jsx(CommandInput, { compact: true, placeholder: t('pickerSearch'), value: search, onValueChange: setSearch }) }), _jsx(CommandList, { className: "max-h-[320px]", children: _jsxs(CommandGroup, { forceMount: true, className: "[&_[cmdk-group-items]]:flex [&_[cmdk-group-items]]:flex-col [&_[cmdk-group-items]]:gap-px", children: [query ? null : (_jsxs(CommandItem, { value: "space-none", className: "gap-2", onSelect: () => pick(null), children: [_jsx(StackIcon, { className: "text-muted-foreground size-4 shrink-0" }), _jsx("span", { className: "text-muted-foreground min-w-0 flex-1 truncate", children: t('pickerNone') }), value === null ? _jsx(CheckIcon, { className: "text-foreground size-4 shrink-0" }) : null] })), shown.map(row), query && shown.length === 0 ? (_jsx("div", { className: "text-muted-foreground py-6 text-center text-xs", children: t('pickerEmpty') })) : null, _jsx(CommandSeparator, { className: "my-1" }), _jsxs(CommandItem, { value: "space-new", className: "gap-2", onSelect: () => {
|
|
39
39
|
setOpen(false);
|
|
40
40
|
setCreating(true);
|
|
41
41
|
}, children: [_jsx(PlusIcon, { className: "size-4 shrink-0" }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: t('newSpace') })] })] }) })] })] }), _jsx(SpaceFormModal, { projectId: projectId, space: null, open: creating, onOpenChange: setCreating, onSaved: (space) => onChange(space.group_id) })] }));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Later" in the setup modal snoozes the home banner for this long. The banner
|
|
3
|
+
* has no dismiss of its own: the one way to quiet it is the modal it opens.
|
|
4
|
+
* It comes back after the snooze while a step is still open.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SETUP_BANNER_SNOOZE_MS: number;
|
|
7
|
+
/** Hide the banner of this workspace, in this browser, for `SETUP_BANNER_SNOOZE_MS`. */
|
|
8
|
+
export declare function snoozeSetupBanner(projectId: string, now?: number): void;
|
|
9
|
+
/** True while "Later" holds the banner of this workspace. The server renders it unsnoozed. */
|
|
10
|
+
export declare function useSetupBannerSnoozed(projectId: string): boolean;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useSyncExternalStore } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* "Later" in the setup modal snoozes the home banner for this long. The banner
|
|
5
|
+
* has no dismiss of its own: the one way to quiet it is the modal it opens.
|
|
6
|
+
* It comes back after the snooze while a step is still open.
|
|
7
|
+
*/
|
|
8
|
+
export const SETUP_BANNER_SNOOZE_MS = 24 * 60 * 60 * 1000;
|
|
9
|
+
const KEY = (projectId) => `kortix.setupBanner.snoozedUntil.${projectId}`;
|
|
10
|
+
/** Same-tab signal: `storage` events fire only in other tabs. */
|
|
11
|
+
const EVENT = 'kortix:setup-banner-snooze';
|
|
12
|
+
/** Hide the banner of this workspace, in this browser, for `SETUP_BANNER_SNOOZE_MS`. */
|
|
13
|
+
export function snoozeSetupBanner(projectId, now = Date.now()) {
|
|
14
|
+
try {
|
|
15
|
+
window.localStorage.setItem(KEY(projectId), String(now + SETUP_BANNER_SNOOZE_MS));
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// Private mode or blocked storage: the banner stays. Nothing else depends on it.
|
|
19
|
+
}
|
|
20
|
+
window.dispatchEvent(new Event(EVENT));
|
|
21
|
+
}
|
|
22
|
+
function snoozedUntil(projectId) {
|
|
23
|
+
try {
|
|
24
|
+
const raw = window.localStorage.getItem(KEY(projectId));
|
|
25
|
+
const until = raw ? Number(raw) : 0;
|
|
26
|
+
return Number.isFinite(until) ? until : 0;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function subscribe(onChange) {
|
|
33
|
+
window.addEventListener(EVENT, onChange);
|
|
34
|
+
window.addEventListener('storage', onChange);
|
|
35
|
+
return () => {
|
|
36
|
+
window.removeEventListener(EVENT, onChange);
|
|
37
|
+
window.removeEventListener('storage', onChange);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** True while "Later" holds the banner of this workspace. The server renders it unsnoozed. */
|
|
41
|
+
export function useSetupBannerSnoozed(projectId) {
|
|
42
|
+
// The snapshot is a boolean, so it stays stable between reads while the snooze holds.
|
|
43
|
+
return useSyncExternalStore(subscribe, () => snoozedUntil(projectId) > Date.now(), () => false);
|
|
44
|
+
}
|
|
@@ -1,57 +1,40 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
/**
|
|
4
|
-
* The way back to `/workspaces/<id>/setup`. The workspace home shows it
|
|
5
|
-
* the
|
|
6
|
-
* in, a required secret, Slack. It
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* The way back to `/workspaces/<id>/setup`. The workspace home shows it,
|
|
5
|
+
* floating at the bottom of the page, while the setup page has an open step
|
|
6
|
+
* the viewer can finish: a connector to sign in, a required secret, Slack. It
|
|
7
|
+
* counts the same steps as the page. It has no dismiss of its own: "Later" in
|
|
8
|
+
* the setup modal snoozes it for a day (`setup-banner-snooze.ts`), and it goes
|
|
9
|
+
* for good when every step it counts is done.
|
|
9
10
|
*/
|
|
10
11
|
import { useProjectAccountId } from '@kortix/sdk/react';
|
|
11
|
-
import { XIcon } from '@phosphor-icons/react';
|
|
12
|
-
import { useState } from 'react';
|
|
13
12
|
import { useTranslations } from '../../i18n/index.js';
|
|
14
13
|
import { cn } from '../../lib/utils.js';
|
|
15
14
|
import { PROJECT_ACTIONS } from '../../internal/lib/project-actions.js';
|
|
16
15
|
import { useProjectCan } from '../../internal/lib/use-project-can.js';
|
|
17
|
-
import { Alert, AlertActions, AlertTitle } from '../../primitives/alert.js';
|
|
18
16
|
import { Button } from '../../primitives/button.js';
|
|
19
17
|
import { UiLink as Link } from '../../providers/ui-provider.js';
|
|
20
|
-
import { openStepsFor
|
|
18
|
+
import { openStepsFor } from './setup-steps.js';
|
|
19
|
+
import { useSetupBannerSnoozed } from './setup-banner-snooze.js';
|
|
21
20
|
import { useSetupSteps } from './use-setup-steps.js';
|
|
22
|
-
|
|
23
|
-
/** The step ids that were open when the viewer dismissed the banner, or null. */
|
|
24
|
-
function readDismissed(projectId) {
|
|
25
|
-
try {
|
|
26
|
-
const raw = window.localStorage.getItem(DISMISS_KEY(projectId));
|
|
27
|
-
const ids = raw ? JSON.parse(raw) : null;
|
|
28
|
-
return Array.isArray(ids) ? ids.filter((id) => typeof id === 'string') : null;
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
21
|
+
import { StepLogoStack, useStepCopy } from './workspace-setup-modal.js';
|
|
34
22
|
export function SetupBanner({ projectId, className }) {
|
|
35
23
|
const t = useTranslations('workspaceSetup');
|
|
24
|
+
const copy = useStepCopy();
|
|
36
25
|
const accountId = useProjectAccountId(projectId);
|
|
37
26
|
const canConnect = useProjectCan(projectId, PROJECT_ACTIONS.PROJECT_CONNECTOR_WRITE, { accountId }).allowed === true;
|
|
38
27
|
const canSetSecrets = useProjectCan(projectId, PROJECT_ACTIONS.PROJECT_SECRET_WRITE).allowed === true;
|
|
39
28
|
const { steps } = useSetupSteps(projectId, { enabled: canConnect || canSetSecrets });
|
|
40
29
|
const open = openStepsFor(steps, { connect: canConnect, setSecrets: canSetSecrets });
|
|
41
|
-
const
|
|
42
|
-
if (open.length === 0 ||
|
|
30
|
+
const snoozed = useSetupBannerSnoozed(projectId);
|
|
31
|
+
if (open.length === 0 || snoozed)
|
|
43
32
|
return null;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
setDismissed(ids);
|
|
53
|
-
};
|
|
54
|
-
return (
|
|
55
|
-
// One line: the title centers on the button, not on the alert's first line.
|
|
56
|
-
_jsxs(Alert, { variant: "default", className: cn('items-center', className), "data-testid": "setup-banner", children: [_jsx(AlertTitle, { children: t('bannerTitle', { left: open.length }) }), _jsxs(AlertActions, { children: [_jsx(Button, { asChild: true, variant: "outline", size: "sm", children: _jsx(Link, { href: `/workspaces/${projectId}/setup`, children: t('title') }) }), _jsx(Button, { variant: "ghost", size: "icon-xs", "aria-label": t('bannerDismiss'), onClick: dismiss, children: _jsx(XIcon, { className: "size-3.5" }) })] })] }));
|
|
33
|
+
// One open step names itself ("Connect GitHub to finish setup"); more give the count.
|
|
34
|
+
const only = open.length === 1 ? open[0] : null;
|
|
35
|
+
const title = only ? t('bannerNamed', { action: copy.action(only) }) : t('bannerTitle', { left: open.length });
|
|
36
|
+
return (_jsxs("div", { role: "status", "data-testid": "setup-banner", className: cn(
|
|
37
|
+
// Floats over the home page: the light preset of the soft layered shadow
|
|
38
|
+
// (shadow.floriankiem.com `ring-sm`, the toasts' shadow), hairline included.
|
|
39
|
+
'bg-popover smooth-shadow-ring-sm flex items-center gap-3 rounded-xl py-2 pr-2 pl-3', 'animate-in fade-in-0 zoom-in-95 duration-normal ease-out motion-reduce:animate-none', className), children: [_jsx(StepLogoStack, { steps: open, ringClassName: "ring-popover" }), _jsx("p", { className: "text-foreground min-w-0 flex-1 truncate text-sm font-medium", title: open.map((step) => step.name).join(', '), children: title }), _jsx(Button, { asChild: true, size: "sm", children: _jsx(Link, { href: `/workspaces/${projectId}/setup`, children: steps.some((step) => step.done) ? t('bannerContinue') : t('bannerStart') }) })] }));
|
|
57
40
|
}
|
|
@@ -50,8 +50,3 @@ export declare function openStepsFor(steps: SetupStep[], can: {
|
|
|
50
50
|
connect: boolean;
|
|
51
51
|
setSecrets: boolean;
|
|
52
52
|
}): SetupStep[];
|
|
53
|
-
/**
|
|
54
|
-
* A dismissed banner stays hidden until a step opens that was not open when
|
|
55
|
-
* the viewer dismissed it, for example a connector a later setup added.
|
|
56
|
-
*/
|
|
57
|
-
export declare function setupBannerDismissed(open: SetupStep[], dismissedIds: readonly string[] | null): boolean;
|
|
@@ -44,10 +44,3 @@ export function setupSteps({ connectors, secrets, slack, slackName, }) {
|
|
|
44
44
|
export function openStepsFor(steps, can) {
|
|
45
45
|
return steps.filter((step) => !step.done && (step.kind === 'secret' ? can.setSecrets : can.connect));
|
|
46
46
|
}
|
|
47
|
-
/**
|
|
48
|
-
* A dismissed banner stays hidden until a step opens that was not open when
|
|
49
|
-
* the viewer dismissed it, for example a connector a later setup added.
|
|
50
|
-
*/
|
|
51
|
-
export function setupBannerDismissed(open, dismissedIds) {
|
|
52
|
-
return dismissedIds !== null && open.every((step) => dismissedIds.includes(step.id));
|
|
53
|
-
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ConnectorLogoSize } from '../../internal/connector-logo/connector-logo.js';
|
|
2
|
+
import type { SetupStep } from './setup-steps.js';
|
|
3
|
+
/**
|
|
4
|
+
* `/workspaces/<id>/setup`: every step of a workspace's setup that only a
|
|
5
|
+
* person can do, in one modal over the workspace. The route keeps its URL:
|
|
6
|
+
* the web app intercepts it (`@modal/(.)setup`) over the page it was opened
|
|
7
|
+
* from, and a direct load draws it over the workspace home. `kortix onboard`
|
|
8
|
+
* opens that URL instead of printing a link per step, and `kortix onboard
|
|
9
|
+
* --wait` continues when every row is done. A missing model never reaches
|
|
10
|
+
* this modal: the workspace shell shows "Connect a model" first (`ProjectShell`).
|
|
11
|
+
*/
|
|
12
|
+
export declare function WorkspaceSetupModal({ projectId, onClose }: {
|
|
13
|
+
projectId: string;
|
|
14
|
+
onClose: () => void;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
export declare function StepLogo({ step, size, className, }: {
|
|
17
|
+
step: SetupStep;
|
|
18
|
+
size?: ConnectorLogoSize;
|
|
19
|
+
className?: string;
|
|
20
|
+
}): import("react").JSX.Element;
|
|
21
|
+
/**
|
|
22
|
+
* Steps' logos as an overlapping stack, the rest as "+N". Every logo sits on
|
|
23
|
+
* the same 28px tile, washed with its own colour: a blurred, scaled copy of
|
|
24
|
+
* the logo at low opacity behind the mark. The logo hosts send no CORS
|
|
25
|
+
* headers, so a canvas cannot read the colour; the browser blends it instead.
|
|
26
|
+
* Each tile overlaps the one before it and is cut out of it by a ring in the
|
|
27
|
+
* surface's own fill (`ringClassName`); the "+N" tile, last, is never hidden.
|
|
28
|
+
*/
|
|
29
|
+
export declare function StepLogoStack({ steps, max, ringClassName, }: {
|
|
30
|
+
steps: SetupStep[];
|
|
31
|
+
max?: number;
|
|
32
|
+
ringClassName: string;
|
|
33
|
+
}): import("react").JSX.Element;
|
|
34
|
+
/** The words for one step: the verb that finishes it, whole or short. */
|
|
35
|
+
export declare function useStepCopy(): {
|
|
36
|
+
action: (step: SetupStep) => string;
|
|
37
|
+
/** The verb alone, for a row that already names the step. Slack keeps its own label. */
|
|
38
|
+
short: (step: SetupStep) => string | undefined;
|
|
39
|
+
};
|