@kabmo-labs/kabmo 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +164 -164
- package/dist/client/static/js/index-32rpkj6b.css +1 -0
- package/dist/client/static/js/{index-95b3n20k.js → index-e3qh2yps.js} +668 -668
- package/package.json +1 -1
- package/src/client/components/common/Toast.test.tsx +28 -2
- package/src/client/components/common/Toast.tsx +21 -9
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +2 -1
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +2 -1
- package/src/client/components/layout/session-sidebar/SessionList.tsx +2 -1
- package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +3 -2
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +2 -1
- package/src/client/components/layout/session-sidebar/modern/RevealRow.tsx +56 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +10 -28
- package/src/client/components/layout/session-sidebar/modern/reveal-row.test.tsx +104 -0
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -1
- package/src/client/components/layout/session-sidebar/variant-props.ts +2 -1
- package/src/client/components/mobile/SessionSidebar.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/List.tsx +2 -1
- package/src/client/components/settings/Modal.tsx +1 -1
- package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
- package/src/client/components/settings/categories/usage-settings/LimitsSection.tsx +39 -19
- package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +1 -0
- package/src/client/components/settings/categories/usage-settings/limit-groups.test.ts +94 -0
- package/src/client/components/settings/categories/usage-settings/limit-groups.ts +118 -0
- package/src/client/components/settings/categories/usage-settings/limits-section.test.tsx +118 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +58 -54
- package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +11 -1
- package/src/client/components/workspace/chat-timeline/PendingTranscript.tsx +130 -0
- package/src/client/components/workspace/chat-timeline/fork-preview.test.tsx +141 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +6 -1
- package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +2 -1
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +5 -4
- package/src/client/components/workspace/git-panel/index.tsx +2 -2
- package/src/client/components/workspace/terminal-panel/RealtimeTerminalView.tsx +8 -5
- package/src/client/components/workspace/terminal-panel/index.tsx +3 -0
- package/src/client/hooks/chat/omp/session-list.tsx +5 -0
- package/src/client/hooks/chat/omp/sidebar-reload.test.ts +85 -0
- package/src/client/hooks/chat/omp/sidebar-reload.ts +30 -0
- package/src/client/hooks/chat/timeline/fork-preview.test.ts +148 -0
- package/src/client/hooks/chat/timeline/fork-preview.ts +104 -0
- package/src/client/hooks/chat/timeline/fork-send.test.ts +139 -0
- package/src/client/hooks/chat/timeline/pending-branch.ts +9 -0
- package/src/client/hooks/chat/timeline/pending-dispatch.ts +49 -0
- package/src/client/hooks/chat/timeline/stop-with-queue.ts +1 -1
- package/src/client/hooks/chat/waiting/cancel.ts +2 -1
- package/src/client/hooks/chat/waiting/dispatch.ts +5 -4
- package/src/client/hooks/chat/waiting/held.ts +2 -1
- package/src/client/hooks/settings/providers/actions.ts +3 -2
- package/src/client/hooks/settings/providers/messages.ts +9 -7
- package/src/client/hooks/settings/providers/model-actions.ts +2 -1
- package/src/client/hooks/ui/editor-error-toast.ts +2 -1
- package/src/client/hooks/workspace/batch-archive.test.ts +2 -2
- package/src/client/hooks/workspace/batch-archive.ts +4 -2
- package/src/client/hooks/workspace/git-action-outcome.ts +4 -3
- package/src/client/hooks/workspace/navbar-session-actions.ts +2 -1
- package/src/client/hooks/workspace/session-actions.test.ts +2 -1
- package/src/client/hooks/workspace/session-actions.ts +2 -1
- package/src/client/hooks/workspace/terminal/connection.test.ts +63 -0
- package/src/client/hooks/workspace/terminal/connection.ts +47 -0
- package/src/client/hooks/workspace/terminal/index.ts +35 -4
- package/src/client/hooks/workspace/workspace-folder-actions.ts +2 -1
- package/src/server/lib/usage/report.server.ts +57 -0
- package/src/shared/lib/chat/timeline/fork-preview.test.ts +62 -0
- package/src/shared/lib/chat/timeline/fork-preview.ts +36 -0
- package/src/shared/lib/ui/toast-duration.test.ts +25 -1
- package/src/shared/lib/ui/toast-duration.ts +22 -4
- package/src/shared/lib/workspace/session-state/store.ts +4 -0
- package/dist/client/static/js/index-p2yw9ywf.css +0 -1
package/package.json
CHANGED
|
@@ -18,8 +18,10 @@
|
|
|
18
18
|
* - **Two live toasts were painted in the same place.** Each card used to be its
|
|
19
19
|
* own `fixed bottom-4 right-4` portal; the stack is one column, so a second
|
|
20
20
|
* card pushes the first up instead of covering it.
|
|
21
|
-
* - **An error drew a check mark.** The tone picks
|
|
22
|
-
* region — `alert` for a failure.
|
|
21
|
+
* - **An error drew a check mark.** The tone picks the icon, its tint, the
|
|
22
|
+
* card's border and the live region — `alert` for a failure. A third tone
|
|
23
|
+
* (`warning`) covers the partial outcomes, so an operation that stopped on a
|
|
24
|
+
* conflict cannot be painted as either a success or a failure.
|
|
23
25
|
*/
|
|
24
26
|
|
|
25
27
|
import { afterAll, afterEach, beforeAll, describe, expect, jest, test } from 'bun:test';
|
|
@@ -244,6 +246,30 @@ describe('Toast', () => {
|
|
|
244
246
|
expect(dismissed).toEqual([11]);
|
|
245
247
|
});
|
|
246
248
|
|
|
249
|
+
test('each tone draws its own glyph and tint', async () => {
|
|
250
|
+
const cases = [
|
|
251
|
+
{ type: 'success' as const, tint: 'text-success-text' },
|
|
252
|
+
{ type: 'warning' as const, tint: 'text-warning-text' },
|
|
253
|
+
{ type: 'error' as const, tint: 'text-error-text' },
|
|
254
|
+
];
|
|
255
|
+
|
|
256
|
+
for (const { type, tint } of cases) {
|
|
257
|
+
if (container) render(null, container);
|
|
258
|
+
document.body.replaceChildren();
|
|
259
|
+
mount(
|
|
260
|
+
h(Toast, {
|
|
261
|
+
toast: { id: 12, message: 'Tone check', type, duration: 3000 },
|
|
262
|
+
onDismiss: () => {},
|
|
263
|
+
}),
|
|
264
|
+
);
|
|
265
|
+
await settle();
|
|
266
|
+
|
|
267
|
+
expect(card().getAttribute('data-tone')).toBe(type);
|
|
268
|
+
const glyph = card().querySelector('svg');
|
|
269
|
+
expect(glyph?.getAttribute('class')).toContain(tint);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
247
273
|
test('a failure is an alert, a confirmation is a status', async () => {
|
|
248
274
|
mountCard(3000);
|
|
249
275
|
expect(card().getAttribute('role')).toBe('status');
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
|
|
2
|
-
import { AlertCircle, CheckCircle2, X } from 'lucide-preact';
|
|
2
|
+
import { AlertCircle, AlertTriangle, CheckCircle2, X, type LucideIcon } from 'lucide-preact';
|
|
3
3
|
import { TOAST_EXIT_MS } from '@/shared/lib/ui/toast-duration';
|
|
4
4
|
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* What each tone looks like.
|
|
8
|
+
*
|
|
9
|
+
* The tone owns ALL three signals — the icon, its colour and the card's border —
|
|
10
|
+
* so a success cannot draw an alert, and the tint is never decided at a call
|
|
11
|
+
* site. `text-*-text` (not the raw fill token) is the contrast-solved half of
|
|
12
|
+
* the palette: the raw signal colours drop under 2:1 on the light themes.
|
|
13
|
+
*/
|
|
14
|
+
const TONES: Record<ToastTone, { Icon: LucideIcon; icon: string; border: string }> = {
|
|
15
|
+
success: { Icon: CheckCircle2, icon: 'text-success-text', border: 'border-success/35' },
|
|
16
|
+
warning: { Icon: AlertTriangle, icon: 'text-warning-text', border: 'border-warning/40' },
|
|
17
|
+
error: { Icon: AlertCircle, icon: 'text-error-text', border: 'border-error/40' },
|
|
18
|
+
};
|
|
19
|
+
|
|
6
20
|
export interface ToastData {
|
|
7
21
|
id: number;
|
|
8
22
|
message: string;
|
|
@@ -90,11 +104,13 @@ export function Toast({ toast, onDismiss }: ToastProps) {
|
|
|
90
104
|
const hold = useCallback(() => setPaused(true), []);
|
|
91
105
|
const release = useCallback(() => setPaused(false), []);
|
|
92
106
|
|
|
107
|
+
const tone = TONES[toast.type];
|
|
93
108
|
const isError = toast.type === 'error';
|
|
94
109
|
return (
|
|
95
110
|
<div
|
|
96
111
|
role={isError ? 'alert' : 'status'}
|
|
97
112
|
aria-live={isError ? 'assertive' : 'polite'}
|
|
113
|
+
data-tone={toast.type}
|
|
98
114
|
onPointerEnter={hold}
|
|
99
115
|
onPointerLeave={release}
|
|
100
116
|
onFocus={hold}
|
|
@@ -106,16 +122,12 @@ export function Toast({ toast, onDismiss }: ToastProps) {
|
|
|
106
122
|
if (next instanceof Node && event.currentTarget.contains(next)) return;
|
|
107
123
|
release();
|
|
108
124
|
}}
|
|
109
|
-
className={`pointer-events-auto flex items-start gap-2 rounded-lg border bg-paper px-3.5 py-2.5 text-xs font-sans shadow-xl transition-all ${
|
|
110
|
-
|
|
111
|
-
}
|
|
125
|
+
className={`pointer-events-auto flex items-start gap-2 rounded-lg border bg-paper px-3.5 py-2.5 text-xs font-sans shadow-xl transition-all ${tone.border} ${
|
|
126
|
+
entered && !leaving ? 'opacity-100 translate-y-0' : 'opacity-0 translate-y-2'
|
|
127
|
+
}`}
|
|
112
128
|
style={{ transitionDuration: `${TOAST_EXIT_MS}ms` }}
|
|
113
129
|
>
|
|
114
|
-
{
|
|
115
|
-
<AlertCircle size={15} className="mt-px text-error flex-shrink-0" />
|
|
116
|
-
) : (
|
|
117
|
-
<CheckCircle2 size={15} className="mt-0.5 text-success flex-shrink-0" />
|
|
118
|
-
)}
|
|
130
|
+
<tone.Icon size={15} className={`mt-px flex-shrink-0 ${tone.icon}`} aria-hidden="true" />
|
|
119
131
|
<span className="min-w-0 flex-1 whitespace-pre-line break-words leading-relaxed text-ink">
|
|
120
132
|
{toast.message}
|
|
121
133
|
</span>
|
|
@@ -51,6 +51,7 @@ import { useToasts } from '@/client/hooks/ui/toasts';
|
|
|
51
51
|
import { useUpdates } from '@/client/hooks/ui/updates';
|
|
52
52
|
import { UPDATE_REQUEST_EVENT } from '@/shared/lib/updates/popup-state';
|
|
53
53
|
import { MAX_LEFT_PANEL_WIDTH } from '@/shared/lib/workspace/sidebar-width';
|
|
54
|
+
import { updateOutcomeTone } from '@/shared/lib/ui/toast-duration';
|
|
54
55
|
import type { AgentStreamStatus } from '@/shared/lib/chat/omp/status';
|
|
55
56
|
|
|
56
57
|
interface LeftColumnProps {
|
|
@@ -102,7 +103,7 @@ export function LeftColumn({
|
|
|
102
103
|
setInfoOpen(true);
|
|
103
104
|
void updates.apply('kabmo').then((result) => {
|
|
104
105
|
if (!result) return;
|
|
105
|
-
pushToast(result.message, result
|
|
106
|
+
pushToast(result.message, updateOutcomeTone(result));
|
|
106
107
|
});
|
|
107
108
|
});
|
|
108
109
|
|
|
@@ -6,6 +6,7 @@ import { useShowMore } from '@/client/hooks/ui/show-more';
|
|
|
6
6
|
import { useWorkspaceFolderActions } from '@/client/hooks/workspace/workspace-folder-actions';
|
|
7
7
|
import { useSessionDelete } from '@/client/hooks/workspace/session-delete';
|
|
8
8
|
import { SessionDeleteModal } from '@/client/components/common/session-delete-modal';
|
|
9
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
9
10
|
import { SessionItem, SESSION_ITEM_BRANCH_STYLE } from '@/client/components/layout/session-sidebar/SessionItem';
|
|
10
11
|
import { CategoryHeader } from '@/client/components/layout/session-sidebar/CategoryHeader';
|
|
11
12
|
import { SessionBranch, branchControlFor } from '@/client/components/common/session-branch';
|
|
@@ -43,7 +44,7 @@ export function Category({
|
|
|
43
44
|
forceExpanded?: boolean;
|
|
44
45
|
showArchived?: boolean;
|
|
45
46
|
sessionStatus?: Record<string, 'stream' | 'finish' | 'abort'>;
|
|
46
|
-
onToast?: (message: string, type?:
|
|
47
|
+
onToast?: (message: string, type?: ToastTone) => void;
|
|
47
48
|
/** Present only while a batch selection is active; absent is the normal list. */
|
|
48
49
|
batch?: BatchBinding;
|
|
49
50
|
/** Start a session selection scoped to this workspace, from its `⋯` menu. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Category } from '@/client/components/layout/session-sidebar/CategoryItem';
|
|
2
2
|
import type { BatchBinding } from '@/client/components/common/batch-selection/types';
|
|
3
3
|
import type { WorkspaceFolderData } from '@/shared/types';
|
|
4
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
4
5
|
|
|
5
6
|
interface SessionSidebarSessionListProps {
|
|
6
7
|
folders: WorkspaceFolderData[];
|
|
@@ -13,7 +14,7 @@ interface SessionSidebarSessionListProps {
|
|
|
13
14
|
/** Start a chat in a worktree made from this folder. */
|
|
14
15
|
onNewWorktreeSession?: (folderId: number, worktreePath: string) => void;
|
|
15
16
|
/** Surfaces a refused folder action (the reveal endpoint's own reason). */
|
|
16
|
-
onToast?: (message: string, type?:
|
|
17
|
+
onToast?: (message: string, type?: ToastTone) => void;
|
|
17
18
|
/** Present only while a batch selection is active. */
|
|
18
19
|
batch?: BatchBinding;
|
|
19
20
|
onStartSessionSelection?: (folderId: number) => void;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { AlertCircle, Check, Download, Loader2, RefreshCw, Sparkles } from 'lucide-preact';
|
|
2
2
|
import type { UpdateTarget, UpdateTargetInfo } from '@/shared/types/updates';
|
|
3
|
+
import { updateOutcomeTone, type ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
3
4
|
import type { UseUpdatesResult } from '@/client/hooks/ui/updates';
|
|
4
5
|
import { UpdateLog } from '@/client/components/common/UpdateLog';
|
|
5
6
|
import { UPDATE_POPUP_OPEN_EVENT } from '@/shared/lib/updates/popup-state';
|
|
6
7
|
|
|
7
8
|
interface UpdateSectionProps {
|
|
8
9
|
updates: UseUpdatesResult;
|
|
9
|
-
onToast?: (message: string, type?:
|
|
10
|
+
onToast?: (message: string, type?: ToastTone) => void;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
interface UpdateRowProps {
|
|
@@ -70,7 +71,7 @@ export function UpdateSection({ updates, onToast }: UpdateSectionProps) {
|
|
|
70
71
|
|
|
71
72
|
// `manual` means the environment cannot self-update and the message is the
|
|
72
73
|
// command to run — action required, not a success.
|
|
73
|
-
onToast(result.message, result
|
|
74
|
+
onToast(result.message, updateOutcomeTone(result));
|
|
74
75
|
};
|
|
75
76
|
|
|
76
77
|
const showResult = Boolean(updates.info && !updates.checking && !updates.error);
|
|
@@ -3,6 +3,7 @@ import { createPortal } from 'preact/compat';
|
|
|
3
3
|
import { Heart, X } from 'lucide-preact';
|
|
4
4
|
import packageJson from '@/../package.json';
|
|
5
5
|
import type { UseUpdatesResult } from '@/client/hooks/ui/updates';
|
|
6
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
6
7
|
import { BrandWordmark } from '@/client/components/common/brand-wordmark';
|
|
7
8
|
import { NotesDialog } from '@/client/components/layout/session-sidebar/about-modal/NotesDialog';
|
|
8
9
|
import { SocialLinks } from '@/client/components/layout/session-sidebar/about-modal/SocialLinks';
|
|
@@ -24,7 +25,7 @@ export interface AboutModalProps {
|
|
|
24
25
|
isOpen: boolean;
|
|
25
26
|
onClose: () => void;
|
|
26
27
|
updates: UseUpdatesResult;
|
|
27
|
-
onToast?: (message: string, type?:
|
|
28
|
+
onToast?: (message: string, type?: ToastTone) => void;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProps) {
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `modern` sidebar's reveal / collapse row, below a workspace's sessions.
|
|
8
|
+
*
|
|
9
|
+
* Split out of `WorkspaceSection.tsx` so that file stays under the repo's
|
|
10
|
+
* per-file ceiling, the same way `mobile-session-sidebar/RevealRow.tsx` was
|
|
11
|
+
* split out of `Item.tsx`. The window itself is the folder hook's
|
|
12
|
+
* (`useShowMore`), so this file owns only the markup.
|
|
13
|
+
*
|
|
14
|
+
* Reveal and collapse are two controls, not one toggle: the list is truncated
|
|
15
|
+
* for height, so after a partial reveal the user needs to keep going AND to
|
|
16
|
+
* start over, which is what two controls say and one alternating control
|
|
17
|
+
* cannot.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { ChevronDown, ChevronUp } from 'lucide-preact';
|
|
21
|
+
|
|
22
|
+
interface Props {
|
|
23
|
+
hiddenCount: number;
|
|
24
|
+
canShowLess: boolean;
|
|
25
|
+
onShowMore: () => void;
|
|
26
|
+
onShowLess: () => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function WorkspaceRevealRow({ hiddenCount, canShowLess, onShowMore, onShowLess }: Props) {
|
|
30
|
+
if (hiddenCount <= 0 && !canShowLess) return null;
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div className="flex items-center gap-1 pl-6">
|
|
34
|
+
{hiddenCount > 0 && (
|
|
35
|
+
<button
|
|
36
|
+
type="button"
|
|
37
|
+
onClick={onShowMore}
|
|
38
|
+
className="min-w-0 truncate rounded-md px-1 py-1 text-[11px] text-ink/45 transition-colors cursor-pointer hover:bg-ink/[0.04] hover:text-ink/80"
|
|
39
|
+
>
|
|
40
|
+
<ChevronDown size={11} className="mr-1 inline align-[-2px]" />
|
|
41
|
+
{hiddenCount} more
|
|
42
|
+
</button>
|
|
43
|
+
)}
|
|
44
|
+
{canShowLess && (
|
|
45
|
+
<button
|
|
46
|
+
type="button"
|
|
47
|
+
onClick={onShowLess}
|
|
48
|
+
className="ml-auto shrink-0 rounded-md px-1 py-1 text-[11px] text-ink/45 transition-colors cursor-pointer hover:bg-ink/[0.04] hover:text-ink/80"
|
|
49
|
+
>
|
|
50
|
+
<ChevronUp size={11} className="mr-1 inline align-[-2px]" />
|
|
51
|
+
Less
|
|
52
|
+
</button>
|
|
53
|
+
)}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
import { useEffect, useState } from 'preact/hooks';
|
|
28
|
-
import { ChevronDown, ChevronUp } from 'lucide-preact';
|
|
29
28
|
import { useSearchParams } from '@/client/lib/router/search-params';
|
|
30
29
|
import { useFetcher } from '@/client/lib/router/fetcher';
|
|
31
30
|
import { useShowMore } from '@/client/hooks/ui/show-more';
|
|
32
31
|
import { useWorkspaceFolderActions } from '@/client/hooks/workspace/workspace-folder-actions';
|
|
33
32
|
import { useSessionDelete } from '@/client/hooks/workspace/session-delete';
|
|
34
33
|
import { useExpandedSessions } from '@/client/hooks/workspace/expanded-sessions';
|
|
34
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
35
35
|
import { useSidebarData } from '@/client/hooks/chat/omp/session-list';
|
|
36
36
|
import { SessionRow, sessionRowBranchStyle, type SessionRowDensity } from '@/client/components/common/session-row';
|
|
37
37
|
import { SessionBranch, branchControlFor } from '@/client/components/common/session-branch';
|
|
@@ -41,6 +41,7 @@ import { SessionDeleteModal } from '@/client/components/common/session-delete-mo
|
|
|
41
41
|
import { WorkspaceOptionsMenu } from '@/client/components/common/workspace-options-menu';
|
|
42
42
|
import { NewWorktreeModal } from '@/client/components/workspace/worktree-modal/index';
|
|
43
43
|
import { WorkspaceHeader } from '@/client/components/layout/session-sidebar/modern/WorkspaceHeader';
|
|
44
|
+
import { WorkspaceRevealRow } from '@/client/components/layout/session-sidebar/modern/RevealRow';
|
|
44
45
|
import { folderBatchState } from '@/client/components/common/batch-selection/folder-state';
|
|
45
46
|
import { relativeTimeAgo } from '@/shared/lib/workspace/relative-time';
|
|
46
47
|
import { isPendingSessionId } from '@/shared/lib/omp/session/default-title';
|
|
@@ -61,7 +62,7 @@ export interface WorkspaceSectionProps {
|
|
|
61
62
|
onSelectSession: (id: number | string) => void;
|
|
62
63
|
onNewSessionForFolder: (folderId: number) => void;
|
|
63
64
|
onNewWorktreeSession?: (folderId: number, worktreePath: string) => void;
|
|
64
|
-
onToast: (message: string, type?:
|
|
65
|
+
onToast: (message: string, type?: ToastTone) => void;
|
|
65
66
|
onStartSessionSelection?: (folderId: number) => void;
|
|
66
67
|
onCancelWait?: (waitId: string) => void;
|
|
67
68
|
}
|
|
@@ -288,32 +289,13 @@ export function WorkspaceSection({
|
|
|
288
289
|
);
|
|
289
290
|
})}
|
|
290
291
|
|
|
291
|
-
{
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
{
|
|
297
|
-
|
|
298
|
-
type="button"
|
|
299
|
-
onClick={showMore}
|
|
300
|
-
className="min-w-0 truncate rounded-md px-1 py-1 text-[11px] text-ink/45 transition-colors cursor-pointer hover:bg-ink/[0.04] hover:text-ink/80"
|
|
301
|
-
>
|
|
302
|
-
<ChevronDown size={11} className="mr-1 inline align-[-2px]" />
|
|
303
|
-
{hiddenCount} more
|
|
304
|
-
</button>
|
|
305
|
-
)}
|
|
306
|
-
{canShowLess && (
|
|
307
|
-
<button
|
|
308
|
-
type="button"
|
|
309
|
-
onClick={showLess}
|
|
310
|
-
className="ml-auto shrink-0 rounded-md px-1 py-1 text-[11px] text-ink/45 transition-colors cursor-pointer hover:bg-ink/[0.04] hover:text-ink/80"
|
|
311
|
-
>
|
|
312
|
-
<ChevronUp size={11} className="mr-1 inline align-[-2px]" />
|
|
313
|
-
Less
|
|
314
|
-
</button>
|
|
315
|
-
)}
|
|
316
|
-
</div>
|
|
292
|
+
{!forceExpanded && !sessionCheckboxes && (
|
|
293
|
+
<WorkspaceRevealRow
|
|
294
|
+
hiddenCount={hiddenCount}
|
|
295
|
+
canShowLess={canShowLess}
|
|
296
|
+
onShowMore={showMore}
|
|
297
|
+
onShowLess={showLess}
|
|
298
|
+
/>
|
|
317
299
|
)}
|
|
318
300
|
|
|
319
301
|
{offered.length === 0 && (
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `modern` sidebar's reveal row.
|
|
8
|
+
*
|
|
9
|
+
* Two controls, never one toggle: the window is truncated for height, so a
|
|
10
|
+
* partial reveal must leave both "N more" and "Less" reachable. A single
|
|
11
|
+
* alternating control strands the user after the first reveal — the bug this
|
|
12
|
+
* row exists to prevent.
|
|
13
|
+
*
|
|
14
|
+
* Rendered with `h()` against happy-dom, following
|
|
15
|
+
* `modern/workspace-header.test.tsx`.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
19
|
+
import { Window } from 'happy-dom';
|
|
20
|
+
import { h, render } from 'preact';
|
|
21
|
+
|
|
22
|
+
import { WorkspaceRevealRow } from '@/client/components/layout/session-sidebar/modern/RevealRow';
|
|
23
|
+
|
|
24
|
+
const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event', 'MouseEvent'] as const;
|
|
25
|
+
const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
|
|
26
|
+
|
|
27
|
+
let container: HTMLElement;
|
|
28
|
+
|
|
29
|
+
beforeAll(() => {
|
|
30
|
+
const win = new Window({ url: 'http://localhost' });
|
|
31
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
32
|
+
for (const key of DOM_GLOBALS) {
|
|
33
|
+
if (!(key in nativeGlobals)) nativeGlobals[key] = target[key];
|
|
34
|
+
target[key] = (win as unknown as Record<string, unknown>)[key];
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
afterAll(() => {
|
|
39
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
40
|
+
for (const key of DOM_GLOBALS) {
|
|
41
|
+
if (nativeGlobals[key] === undefined) delete target[key];
|
|
42
|
+
else target[key] = nativeGlobals[key];
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
afterEach(() => {
|
|
47
|
+
if (container) render(null, container);
|
|
48
|
+
container?.remove();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
function mount(props: { hiddenCount: number; canShowLess: boolean; onShowMore?: () => void; onShowLess?: () => void }) {
|
|
52
|
+
if (container) {
|
|
53
|
+
render(null, container);
|
|
54
|
+
container.remove();
|
|
55
|
+
}
|
|
56
|
+
container = document.createElement('div');
|
|
57
|
+
document.body.appendChild(container);
|
|
58
|
+
render(
|
|
59
|
+
h(WorkspaceRevealRow, {
|
|
60
|
+
onShowMore: () => {},
|
|
61
|
+
onShowLess: () => {},
|
|
62
|
+
...props,
|
|
63
|
+
}),
|
|
64
|
+
container,
|
|
65
|
+
);
|
|
66
|
+
return container.firstElementChild as HTMLElement | null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const buttons = () => Array.from(container.querySelectorAll('button'));
|
|
70
|
+
|
|
71
|
+
describe('modern workspace reveal row', () => {
|
|
72
|
+
test('it renders nothing when every row is already visible', () => {
|
|
73
|
+
expect(mount({ hiddenCount: 0, canShowLess: false })).toBeNull();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test('it names the hidden row count on the reveal control', () => {
|
|
77
|
+
mount({ hiddenCount: 4, canShowLess: false });
|
|
78
|
+
expect(buttons()).toHaveLength(1);
|
|
79
|
+
expect(buttons()[0]!.textContent).toContain('4 more');
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('a partial reveal keeps both controls on screen', () => {
|
|
83
|
+
mount({ hiddenCount: 2, canShowLess: true });
|
|
84
|
+
const labels = buttons().map((button) => button.textContent);
|
|
85
|
+
expect(labels).toHaveLength(2);
|
|
86
|
+
expect(labels[0]).toContain('2 more');
|
|
87
|
+
expect(labels[1]).toContain('Less');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('each control calls its own handler', () => {
|
|
91
|
+
const calls: string[] = [];
|
|
92
|
+
mount({
|
|
93
|
+
hiddenCount: 1,
|
|
94
|
+
canShowLess: true,
|
|
95
|
+
onShowMore: () => calls.push('more'),
|
|
96
|
+
onShowLess: () => calls.push('less'),
|
|
97
|
+
});
|
|
98
|
+
const [more, less] = buttons();
|
|
99
|
+
more!.click();
|
|
100
|
+
expect(calls).toEqual(['more']);
|
|
101
|
+
less!.click();
|
|
102
|
+
expect(calls).toEqual(['more', 'less']);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -25,6 +25,7 @@ import { TaskForm } from '@/client/components/layout/session-sidebar/scheduler-m
|
|
|
25
25
|
import { TaskList } from '@/client/components/layout/session-sidebar/scheduler-modal/TaskList';
|
|
26
26
|
import { useScheduleFolders } from '@/client/components/layout/session-sidebar/scheduler-modal/folders';
|
|
27
27
|
import type { ScheduledTask } from '@/shared/types/schedule';
|
|
28
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
28
29
|
|
|
29
30
|
export interface SchedulerModalProps {
|
|
30
31
|
isOpen: boolean;
|
|
@@ -32,7 +33,7 @@ export interface SchedulerModalProps {
|
|
|
32
33
|
/** Session the composer is on, offered as "resume this conversation". */
|
|
33
34
|
activeSessionId?: string | null;
|
|
34
35
|
/** Surfaces a failure outside the modal (the sidebar's toast stack). */
|
|
35
|
-
onToast?: (message: string, type?:
|
|
36
|
+
onToast?: (message: string, type?: ToastTone) => void;
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
/** The editor's shape: a draft plus the id it edits, or null when creating. */
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
import type { SessionSortOption, WorkspaceFolderData } from '@/shared/types';
|
|
23
23
|
import type { BatchBinding } from '@/client/components/common/batch-selection/types';
|
|
24
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
24
25
|
|
|
25
26
|
export type SessionStatusMap = Record<string, 'stream' | 'finish' | 'abort'>;
|
|
26
27
|
|
|
@@ -67,7 +68,7 @@ export interface SessionSidebarVariantProps {
|
|
|
67
68
|
/** Start a chat in a worktree made from this folder. */
|
|
68
69
|
onNewWorktreeSession?: (folderId: number, worktreePath: string) => void;
|
|
69
70
|
/** Reports a refused folder action (the reveal endpoint's own reason). */
|
|
70
|
-
onToast: (message: string, type?:
|
|
71
|
+
onToast: (message: string, type?: ToastTone) => void;
|
|
71
72
|
onCancelWait?: (waitId: string) => void;
|
|
72
73
|
|
|
73
74
|
/** The active batch mode, or undefined when the list is not selecting. */
|
|
@@ -11,6 +11,7 @@ import { useWaitingDispatch } from '@/client/hooks/chat/waiting/dispatch';
|
|
|
11
11
|
import { useUpdates } from '@/client/hooks/ui/updates';
|
|
12
12
|
import { useSidebarStyle } from '@/client/hooks/workspace/sidebar-style';
|
|
13
13
|
import { UPDATE_REQUEST_EVENT } from '@/shared/lib/updates/popup-state';
|
|
14
|
+
import { updateOutcomeTone } from '@/shared/lib/ui/toast-duration';
|
|
14
15
|
import { useScheduledTaskCount } from '@/client/hooks/workspace/scheduled-tasks';
|
|
15
16
|
import { phoneLeftStripVisible } from '@/shared/lib/workspace/mobile-dock';
|
|
16
17
|
import { MobileDockBody, MobileDockStrip } from '@/client/components/mobile/mobile-session-sidebar/Dock';
|
|
@@ -123,7 +124,7 @@ export function MobileSessionSidebar({
|
|
|
123
124
|
setAboutOpen(true);
|
|
124
125
|
void updates.apply('kabmo').then((result) => {
|
|
125
126
|
if (!result) return;
|
|
126
|
-
pushToast(result.message, result
|
|
127
|
+
pushToast(result.message, updateOutcomeTone(result));
|
|
127
128
|
});
|
|
128
129
|
});
|
|
129
130
|
|
|
@@ -20,6 +20,7 @@ import { MobileSessionListSkeleton } from '@/client/components/mobile/mobile-ses
|
|
|
20
20
|
import { SessionListNotice } from '@/client/components/layout/session-sidebar/SessionListNotice';
|
|
21
21
|
import type { BatchBinding } from '@/client/components/common/batch-selection/types';
|
|
22
22
|
import type { SessionSortOption, WorkspaceFolderData } from '@/shared/types';
|
|
23
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
23
24
|
|
|
24
25
|
export interface ClassicDrawerProps {
|
|
25
26
|
folders: WorkspaceFolderData[];
|
|
@@ -54,7 +55,7 @@ export interface ClassicDrawerProps {
|
|
|
54
55
|
onNewSessionForFolder: (folderId: number) => void;
|
|
55
56
|
onNewWorktreeSession?: (folderId: number, worktreePath: string) => void;
|
|
56
57
|
onToggleFolder: (folderId: number) => void;
|
|
57
|
-
onToast: (message: string, type?:
|
|
58
|
+
onToast: (message: string, type?: ToastTone) => void;
|
|
58
59
|
onStartSessionSelection: (folderId: number) => void;
|
|
59
60
|
onCancelWait?: (waitId: string) => void;
|
|
60
61
|
}
|
|
@@ -4,6 +4,7 @@ import { useSearchParams } from '@/client/lib/router/search-params';
|
|
|
4
4
|
import { MobileSessionRow, MOBILE_BRANCH_STYLE } from '@/client/components/mobile/mobile-session-sidebar/SessionRow';
|
|
5
5
|
import { SessionBranch, branchControlFor } from '@/client/components/common/session-branch';
|
|
6
6
|
import type { BranchControl } from '@/client/components/common/session-branch';
|
|
7
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
7
8
|
import { buildSessionTree } from '@/client/lib/session-tree';
|
|
8
9
|
import { useWorktreeDialog } from '@/client/components/mobile/mobile-session-sidebar/WorktreeDialog';
|
|
9
10
|
import { useShowMore } from '@/client/hooks/ui/show-more';
|
|
@@ -33,7 +34,7 @@ interface MobileSessionCategoryProps {
|
|
|
33
34
|
onToggleExpand: () => void;
|
|
34
35
|
showArchived?: boolean;
|
|
35
36
|
sessionStatus?: Record<string, 'stream' | 'finish' | 'abort'>;
|
|
36
|
-
onToast?: (message: string, type?:
|
|
37
|
+
onToast?: (message: string, type?: ToastTone) => void;
|
|
37
38
|
/** Present only while a batch selection is active; absent is the normal list. */
|
|
38
39
|
batch?: BatchBinding;
|
|
39
40
|
/** Start a session selection scoped to this workspace, from its `⋯` menu. */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MobileSessionCategory } from '@/client/components/mobile/mobile-session-sidebar/Item';
|
|
2
2
|
import type { BatchBinding } from '@/client/components/common/batch-selection/types';
|
|
3
3
|
import type { WorkspaceFolderData } from '@/shared/types';
|
|
4
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
4
5
|
|
|
5
6
|
interface MobileSessionListProps {
|
|
6
7
|
folders: WorkspaceFolderData[];
|
|
@@ -14,7 +15,7 @@ interface MobileSessionListProps {
|
|
|
14
15
|
onNewWorktreeSession?: (folderId: number, worktreePath: string) => void;
|
|
15
16
|
onToggleFolder: (folderId: number) => void;
|
|
16
17
|
/** Surfaces a refused folder action (the reveal endpoint's own reason). */
|
|
17
|
-
onToast?: (message: string, type?:
|
|
18
|
+
onToast?: (message: string, type?: ToastTone) => void;
|
|
18
19
|
/** Present only while a batch selection is active. */
|
|
19
20
|
batch?: BatchBinding;
|
|
20
21
|
onStartSessionSelection?: (folderId: number) => void;
|
|
@@ -25,13 +25,14 @@ import { useWorktrees } from '@/client/hooks/workspace/worktree/index';
|
|
|
25
25
|
import { removeWorktree } from '@/client/hooks/workspace/worktree/index';
|
|
26
26
|
import { WORKTREE_CARRY_SETTING, WORKTREE_DIRECTORY_SETTING } from '@/shared/lib/fs/worktree/settings-keys';
|
|
27
27
|
import { branchDeletable, removalRefusal, worktreeRowDetail } from '@/client/components/settings/categories/project-settings/worktree-row';
|
|
28
|
+
import type { ToastTone } from '@/shared/lib/ui/toast-duration';
|
|
28
29
|
|
|
29
30
|
export interface WorktreeSettingsProps {
|
|
30
31
|
/** The selected project's `project_path`; the section is inert without one. */
|
|
31
32
|
root: string | null;
|
|
32
33
|
folderId: number | null;
|
|
33
34
|
/** Report a refusal — the section never claims a removal it did not get. */
|
|
34
|
-
onReport: (message: string, tone?:
|
|
35
|
+
onReport: (message: string, tone?: ToastTone) => void;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export function WorktreeSettings({ root, folderId, onReport }: WorktreeSettingsProps) {
|