@kabmo-labs/kabmo 0.13.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +319 -319
- package/dist/client/static/js/index-bnrrw242.css +1 -0
- package/dist/client/static/js/{index-vzb1qz51.js → index-w6jx0h0p.js} +780 -780
- package/marketplace/plugins/command-runner/package.json +2 -2
- package/marketplace/plugins/command-runner/src/server/ring.test.ts +41 -0
- package/marketplace/plugins/command-runner/src/server/run-types.ts +6 -0
- package/marketplace/plugins/command-runner/src/server/runner-harness.ts +69 -0
- package/marketplace/plugins/command-runner/src/server/runner-path.test.ts +127 -0
- package/marketplace/plugins/command-runner/src/server/runner.test.ts +2 -72
- package/marketplace/plugins/command-runner/src/server/runner.ts +31 -3
- package/package.json +2 -2
- package/src/client/components/common/batch-selection/BatchActionBar.test.ts +42 -5
- package/src/client/components/common/batch-selection/BatchActionBar.tsx +57 -14
- package/src/client/components/common/code-surface/extensions.ts +7 -1
- package/src/client/components/common/code-surface/fold-placeholder.ts +43 -0
- package/src/client/components/common/session-row/StatusSlot.tsx +133 -0
- package/src/client/components/common/session-row/TrailingSlot.tsx +84 -0
- package/src/client/components/common/session-row/index.tsx +215 -0
- package/src/client/components/common/session-row/session-row.test.tsx +154 -0
- package/src/client/components/layout/session-sidebar/ClassicView.tsx +121 -0
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +99 -112
- package/src/client/components/layout/session-sidebar/Toolbar.tsx +2 -2
- package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +149 -0
- package/src/client/components/layout/session-sidebar/modern/FilterChips.tsx +150 -0
- package/src/client/components/layout/session-sidebar/modern/SearchField.tsx +75 -0
- package/src/client/components/layout/session-sidebar/modern/Skeleton.tsx +56 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +193 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +333 -0
- package/src/client/components/layout/session-sidebar/modern/index.tsx +147 -0
- package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +111 -0
- package/src/client/components/layout/session-sidebar/variant-props.ts +73 -0
- package/src/client/components/mobile/SessionSidebar.tsx +137 -146
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +140 -0
- package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +3 -3
- package/src/client/components/mobile/mobile-session-sidebar/use-drawer.ts +104 -0
- package/src/client/components/settings/Modal.tsx +5 -27
- package/src/client/components/settings/Sidebar.tsx +1 -1
- package/src/client/components/settings/apply-side-effects.test.ts +102 -0
- package/src/client/components/settings/apply-side-effects.ts +90 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +11 -1
- package/src/client/components/settings/categories/ChatSettings.test.tsx +121 -0
- package/src/client/components/settings/categories/ChatSettings.tsx +80 -15
- package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +157 -0
- package/src/client/components/settings/categories/chat-settings/ComposerStyleSection.tsx +177 -0
- package/src/client/components/settings/categories/chat-settings/LayoutSection.tsx +1 -1
- package/src/client/components/settings/categories/chat-settings/SidebarList.tsx +73 -0
- package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +144 -0
- package/src/client/components/settings/categories/chat-settings/groups.test.ts +42 -0
- package/src/client/components/settings/categories/chat-settings/groups.ts +81 -0
- package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +1 -68
- package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +7 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +15 -5
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +90 -41
- package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +13 -6
- package/src/client/components/workspace/chat-timeline/ThinkingSection.test.tsx +117 -0
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +117 -75
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.test.ts +28 -8
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +48 -4
- package/src/client/components/workspace/chat-timeline/TurnRail.tsx +64 -0
- package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +178 -0
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerNotice.tsx +50 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +178 -0
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +102 -122
- package/src/client/components/workspace/chat-timeline/chat-input/props.ts +7 -0
- package/src/client/components/workspace/chat-timeline/chat-input/styles/index.tsx +111 -0
- package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +181 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/approval-gate.test.tsx +31 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/index.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/plugin-renderers.ts +6 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +98 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolCardShell.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/status-glyph.tsx +56 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/toggle-label.ts +19 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +132 -0
- package/src/client/components/workspace/chat-timeline/{ToolCallCard.plugin.test.ts → tool-renderers/styles/Card.plugin.test.ts} +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +60 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +89 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +72 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +84 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/props.ts +22 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +153 -0
- package/src/client/components/workspace/diff-panel/folding.ts +6 -1
- package/src/client/components/workspace/editor/viewers/SvgPreview.tsx +16 -2
- package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +86 -12
- package/src/client/components/workspace/model-dropdown/Item.tsx +56 -19
- package/src/client/components/workspace/model-dropdown/Panel.tsx +21 -13
- package/src/client/components/workspace/model-dropdown/Section.test.tsx +114 -4
- package/src/client/components/workspace/model-dropdown/Section.tsx +21 -9
- package/src/client/components/workspace/model-dropdown/groups.test.ts +164 -1
- package/src/client/components/workspace/model-dropdown/groups.ts +94 -17
- package/src/client/components/workspace/model-dropdown/index.tsx +27 -19
- package/src/client/data/settings/omp-schema.json +151 -6
- package/src/client/hooks/chat/composer/style.ts +66 -0
- package/src/client/hooks/chat/timeline/row-window-reveal.ts +130 -0
- package/src/client/hooks/chat/timeline/row-window.test.ts +35 -0
- package/src/client/hooks/chat/timeline/row-window.ts +59 -133
- package/src/client/hooks/chat/timeline/thinking-open.ts +67 -0
- package/src/client/hooks/chat/timeline/tool-render-mode.ts +65 -0
- package/src/client/hooks/settings/providers/login.ts +11 -2
- package/src/client/hooks/ui/window-event.ts +20 -4
- package/src/client/hooks/workspace/batch-archive-run.ts +47 -0
- package/src/client/hooks/workspace/batch-archive.test.ts +59 -0
- package/src/client/hooks/workspace/batch-archive.ts +78 -0
- package/src/client/hooks/workspace/sidebar-batch.ts +95 -0
- package/src/client/hooks/workspace/sidebar-style.ts +66 -0
- package/src/client/tailwind.css +111 -0
- package/src/server/index.ts +10 -134
- package/src/server/lib/lifecycle/after-listen.ts +178 -0
- package/src/server/lib/lifecycle/rejection-guard.test.ts +79 -0
- package/src/server/lib/lifecycle/rejection-guard.ts +74 -0
- package/src/server/lib/lifecycle/tls.test.ts +7 -7
- package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +131 -0
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +46 -0
- package/src/server/lib/omp/rpc/frame-fold.test.ts +1 -100
- package/src/server/lib/omp/rpc/frame-fold.ts +13 -0
- package/src/server/lib/plugins/background.server.ts +17 -1
- package/src/server/lib/plugins/background.test.ts +33 -0
- package/src/server/routes/sessions/batch-archive.test.ts +113 -0
- package/src/server/routes/sessions/batch-archive.ts +80 -0
- package/src/server/routes/sessions/index.ts +4 -0
- package/src/shared/lib/chat/composer/style.test.ts +126 -0
- package/src/shared/lib/chat/composer/style.ts +171 -0
- package/src/shared/lib/chat/composer/tui-only.test.ts +3 -0
- package/src/shared/lib/chat/composer/tui-only.ts +5 -0
- package/src/shared/lib/chat/timeline/block-chrome.ts +129 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.test.ts +51 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.ts +74 -0
- package/src/shared/lib/chat/timeline/trace-groups.test.ts +132 -0
- package/src/shared/lib/chat/timeline/trace-groups.ts +95 -0
- package/src/shared/lib/settings/defaults.ts +6 -0
- package/src/shared/lib/workspace/session-focus.test.ts +93 -0
- package/src/shared/lib/workspace/session-focus.ts +71 -0
- package/src/shared/lib/workspace/session-state/store.ts +5 -0
- package/src/shared/lib/workspace/sidebar-filter-row.test.ts +73 -0
- package/src/shared/lib/workspace/sidebar-filter-row.ts +86 -0
- package/src/shared/lib/workspace/sidebar-style.test.ts +58 -0
- package/src/shared/lib/workspace/sidebar-style.ts +86 -0
- package/src/shared/types/omp/agent.ts +6 -0
- package/src/shared/types/settings/state.ts +31 -0
- package/dist/client/static/js/index-68w8h33q.css +0 -1
- package/src/client/components/workspace/chat-timeline/ToolCallCard.tsx +0 -194
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
} from '@codemirror/view';
|
|
49
49
|
import { highlightSelectionMatches } from '@codemirror/search';
|
|
50
50
|
import { history } from '@codemirror/commands';
|
|
51
|
-
import { bracketMatching, foldGutter, indentUnit } from '@codemirror/language';
|
|
51
|
+
import { bracketMatching, codeFolding, foldGutter, indentUnit } from '@codemirror/language';
|
|
52
52
|
|
|
53
53
|
import { commentSyntaxFor } from '@/shared/lib/code/editor/comment-syntax';
|
|
54
54
|
import type { EditorCommand } from '@/shared/lib/code/editor/keymap';
|
|
@@ -56,6 +56,7 @@ import { bracketGuide } from '@/client/components/common/code-surface/bracket-gu
|
|
|
56
56
|
import { indentDataExtension, indentExtensions } from '@/client/components/common/code-surface/indent';
|
|
57
57
|
import { typingExtensions, type EditorTypingOptions } from '@/client/components/common/code-surface/typing';
|
|
58
58
|
import { indentFoldService } from '@/client/components/common/code-surface/fold';
|
|
59
|
+
import { foldPlaceholderDom } from '@/client/components/common/code-surface/fold-placeholder';
|
|
59
60
|
import { indentGuides } from '@/client/components/common/code-surface/indent-guide';
|
|
60
61
|
import { findMarksField } from '@/client/components/common/code-surface/marks';
|
|
61
62
|
import { surfaceKeymap } from '@/client/components/common/code-surface/keymap';
|
|
@@ -288,6 +289,11 @@ export function surfaceExtensions({
|
|
|
288
289
|
// dropped silently — verified: no placeholder, no error.
|
|
289
290
|
indentFoldService,
|
|
290
291
|
foldGutter(),
|
|
292
|
+
// `foldGutter()` brings `codeFolding()` with its package placeholder, which
|
|
293
|
+
// WebKit loses to the editor's own mouse selection — see
|
|
294
|
+
// `fold-placeholder.ts` for the measurement. A later config wins in
|
|
295
|
+
// `combineConfig`, so this one replaces the package default.
|
|
296
|
+
codeFolding({ placeholderDOM: foldPlaceholderDom }),
|
|
291
297
|
themeCompartment.of(shikiHighlight(language, themes)),
|
|
292
298
|
surfaceTheme(),
|
|
293
299
|
// Line blame, when the panel turned it on: the labels, the state field they
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `…` a folded range collapses into.
|
|
8
|
+
*
|
|
9
|
+
* CodeMirror's default placeholder is a bare span whose only handler is
|
|
10
|
+
* `onclick`. That is enough on Chromium and not on WebKit: a `mousedown`
|
|
11
|
+
* inside the content DOM starts CodeMirror's own mouse selection, which
|
|
12
|
+
* re-creates the widget's DOM before `mouseup`, so the click lands on a node
|
|
13
|
+
* that is no longer in the document and the fold never opens — measured on
|
|
14
|
+
* WebKit 27 with `@codemirror/language` 6: the placeholder was removed and
|
|
15
|
+
* re-added inside the same mousedown, and no `click` event followed.
|
|
16
|
+
*
|
|
17
|
+
* Cancelling the press fixes it at the source: the editor never starts a
|
|
18
|
+
* selection over the widget, the node survives, and the browser dispatches the
|
|
19
|
+
* click the package already listens for. `preventDefault` alone is not enough
|
|
20
|
+
* to stop the DOM churn in every case, so propagation is stopped too — the
|
|
21
|
+
* widget owns its own pointer events and has nothing to hand upward.
|
|
22
|
+
*/
|
|
23
|
+
import type { EditorView } from '@codemirror/view';
|
|
24
|
+
|
|
25
|
+
export type FoldPlaceholderClick = (event: MouseEvent) => void;
|
|
26
|
+
|
|
27
|
+
/** The fold widget's DOM, wired so its click survives a press. */
|
|
28
|
+
export function foldPlaceholderDom(
|
|
29
|
+
view: EditorView,
|
|
30
|
+
onclick: FoldPlaceholderClick,
|
|
31
|
+
): HTMLElement {
|
|
32
|
+
const element = document.createElement('span');
|
|
33
|
+
element.className = 'cm-foldPlaceholder';
|
|
34
|
+
element.textContent = '…';
|
|
35
|
+
element.setAttribute('aria-label', view.state.phrase('folded code'));
|
|
36
|
+
element.title = view.state.phrase('unfold');
|
|
37
|
+
element.onclick = onclick;
|
|
38
|
+
element.addEventListener('mousedown', (event) => {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
event.stopPropagation();
|
|
41
|
+
});
|
|
42
|
+
return element;
|
|
43
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The 16px leading slot of a session row, in the `modern` style.
|
|
8
|
+
*
|
|
9
|
+
* One slot owns every glyph — never two side by side — which is the rule both
|
|
10
|
+
* shipped rows already follow and the reason a running session does not push
|
|
11
|
+
* its title sideways. The order of precedence is unchanged, because each rung
|
|
12
|
+
* is a bug the previous one fixed:
|
|
13
|
+
*
|
|
14
|
+
* 1. an in-flight rename — it answers a click that is still pending;
|
|
15
|
+
* 2. blocked on a question — says it is YOUR turn, not that work is happening;
|
|
16
|
+
* 3. a held prompt — the row exists only because a prompt is waiting;
|
|
17
|
+
* 4. a run in flight — the spinner;
|
|
18
|
+
* 5. the roster chevron, PINNED while the row has subagents.
|
|
19
|
+
*
|
|
20
|
+
* A batch checkbox replaces the whole slot: in that mode the row is a choice,
|
|
21
|
+
* and a run spinner beside a checkbox reads as a second, unrelated control.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import type { TargetedMouseEvent } from 'preact';
|
|
25
|
+
import { Check, ChevronDown, ChevronRight, CircleQuestionMark, Hourglass, Loader2 } from 'lucide-preact';
|
|
26
|
+
import { SelectionCheckbox } from '@/client/components/common/batch-selection/SelectionCheckbox';
|
|
27
|
+
|
|
28
|
+
export interface StatusSlotProps {
|
|
29
|
+
title: string;
|
|
30
|
+
status?: 'stream' | 'finish' | 'abort';
|
|
31
|
+
awaitingInput?: boolean;
|
|
32
|
+
renaming?: boolean;
|
|
33
|
+
waitingFor?: { title: string | null };
|
|
34
|
+
/** The row has a subagent roster, so the chevron exists. */
|
|
35
|
+
expandable?: boolean;
|
|
36
|
+
isExpanded?: boolean;
|
|
37
|
+
onToggleExpand?: (event: TargetedMouseEvent<HTMLElement>) => void;
|
|
38
|
+
selectable?: boolean;
|
|
39
|
+
selected?: boolean;
|
|
40
|
+
onToggleSelect?: () => void;
|
|
41
|
+
/** Larger glyphs for a touch row. */
|
|
42
|
+
touch?: boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function StatusSlot({
|
|
46
|
+
title,
|
|
47
|
+
status,
|
|
48
|
+
awaitingInput = false,
|
|
49
|
+
renaming = false,
|
|
50
|
+
waitingFor,
|
|
51
|
+
expandable = false,
|
|
52
|
+
isExpanded = false,
|
|
53
|
+
onToggleExpand,
|
|
54
|
+
selectable = false,
|
|
55
|
+
selected = false,
|
|
56
|
+
onToggleSelect,
|
|
57
|
+
touch = false,
|
|
58
|
+
}: StatusSlotProps) {
|
|
59
|
+
if (selectable) {
|
|
60
|
+
return (
|
|
61
|
+
<span className="flex shrink-0 items-center">
|
|
62
|
+
<SelectionCheckbox
|
|
63
|
+
checked={selected}
|
|
64
|
+
label={`Select ${title}`}
|
|
65
|
+
onChange={() => onToggleSelect?.()}
|
|
66
|
+
/>
|
|
67
|
+
<span className="w-2 shrink-0" />
|
|
68
|
+
</span>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const size = touch ? 14 : 13;
|
|
73
|
+
const waiting = Boolean(waitingFor);
|
|
74
|
+
const liveRun = awaitingInput || status === 'stream' || waiting;
|
|
75
|
+
const chevronPinned = Boolean(expandable && onToggleExpand) && !liveRun && !renaming;
|
|
76
|
+
// `waiting` belongs in this list on its own: a held prompt is a pending
|
|
77
|
+
// `new-…` chat, which has no transcript and therefore no `status` — without it
|
|
78
|
+
// the one cue saying the row exists at all was never drawn.
|
|
79
|
+
const showStatus = Boolean(renaming || awaitingInput || waiting || status) && !chevronPinned;
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<>
|
|
83
|
+
<span className={`relative shrink-0 ${touch ? 'w-[18px] h-5' : 'w-4 h-4'}`}>
|
|
84
|
+
{expandable && onToggleExpand && (
|
|
85
|
+
<button
|
|
86
|
+
type="button"
|
|
87
|
+
onClick={(event) => {
|
|
88
|
+
event.stopPropagation();
|
|
89
|
+
onToggleExpand(event);
|
|
90
|
+
}}
|
|
91
|
+
title={isExpanded ? 'Collapse subagents' : 'Expand subagents'}
|
|
92
|
+
aria-expanded={isExpanded}
|
|
93
|
+
aria-label={isExpanded ? 'Collapse subagents' : 'Expand subagents'}
|
|
94
|
+
className={`peer absolute inset-0 flex items-center justify-center rounded cursor-pointer transition-opacity ${
|
|
95
|
+
chevronPinned
|
|
96
|
+
? 'text-ink/55 hover:text-ink'
|
|
97
|
+
: 'text-ink/40 opacity-0 hover:text-ink group-hover/item:opacity-100 focus-visible:opacity-100'
|
|
98
|
+
}`}
|
|
99
|
+
>
|
|
100
|
+
{isExpanded ? <ChevronDown size={size} /> : <ChevronRight size={size} />}
|
|
101
|
+
</button>
|
|
102
|
+
)}
|
|
103
|
+
|
|
104
|
+
{showStatus && (
|
|
105
|
+
<span
|
|
106
|
+
className={`pointer-events-none absolute inset-0 flex items-center justify-center text-ink/60 transition-opacity ${
|
|
107
|
+
expandable ? 'group-hover/item:opacity-0 peer-focus-visible:opacity-0' : ''
|
|
108
|
+
}`}
|
|
109
|
+
>
|
|
110
|
+
{renaming ? (
|
|
111
|
+
<span role="status" aria-label="Generating a name…">
|
|
112
|
+
<Loader2 size={size - 1} className="animate-spin" />
|
|
113
|
+
</span>
|
|
114
|
+
) : awaitingInput ? (
|
|
115
|
+
<CircleQuestionMark size={size - 1} className="animate-pulse text-warning" />
|
|
116
|
+
) : waiting ? (
|
|
117
|
+
<span role="status" aria-label={`Waiting for ${waitingFor?.title ?? 'another session'}`}>
|
|
118
|
+
<Hourglass size={size - 1} className="animate-pulse" />
|
|
119
|
+
</span>
|
|
120
|
+
) : status === 'stream' ? (
|
|
121
|
+
<span role="status" aria-label="Running">
|
|
122
|
+
<Loader2 size={size - 1} className="animate-spin" />
|
|
123
|
+
</span>
|
|
124
|
+
) : (
|
|
125
|
+
<Check size={size - 1} />
|
|
126
|
+
)}
|
|
127
|
+
</span>
|
|
128
|
+
)}
|
|
129
|
+
</span>
|
|
130
|
+
<span className="w-2 shrink-0" />
|
|
131
|
+
</>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The trailing column of a `modern` session row: the age at rest, the actions
|
|
8
|
+
* trigger on hover.
|
|
9
|
+
*
|
|
10
|
+
* The two share ONE box because they answer the same question — "which of these
|
|
11
|
+
* identically-titled chats is this?" — and the row cannot afford both at the
|
|
12
|
+
* width a sidebar actually has (264px at its floor leaves ~176px for the
|
|
13
|
+
* title). The trigger is always in the DOM and always hit-testable: only its
|
|
14
|
+
* OPACITY moves, so a keyboard user reaches it with Tab, a browser spec clicks
|
|
15
|
+
* it by role and name, and nothing becomes unreachable when the pointer is
|
|
16
|
+
* elsewhere. On a touch row there is no hover to reveal anything, so both are
|
|
17
|
+
* drawn side by side.
|
|
18
|
+
*
|
|
19
|
+
* The trigger's BOX is 22px on desktop and 28px on touch — the same boxes the
|
|
20
|
+
* workspace header's action cluster uses, so the two `⋯` columns share one
|
|
21
|
+
* centre. A box that merely fit the glyph (14px + a 4px pad) put the row's dots
|
|
22
|
+
* 2px left of the header's on touch.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type { TargetedMouseEvent } from 'preact';
|
|
26
|
+
import { MoreHorizontal } from 'lucide-preact';
|
|
27
|
+
|
|
28
|
+
export interface TrailingSlotProps {
|
|
29
|
+
timeAgo?: string | null;
|
|
30
|
+
/** Null when the row has nothing to offer a menu. */
|
|
31
|
+
onOpenMenu?: (event: TargetedMouseEvent<HTMLElement>) => void;
|
|
32
|
+
menuOpen?: boolean;
|
|
33
|
+
touch?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function TrailingSlot({ timeAgo, onOpenMenu, menuOpen = false, touch = false }: TrailingSlotProps) {
|
|
37
|
+
if (!onOpenMenu) {
|
|
38
|
+
return timeAgo
|
|
39
|
+
? <span className="ml-2 shrink-0 font-mono text-[10px] text-ink/40">{timeAgo}</span>
|
|
40
|
+
: null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const trigger = (
|
|
44
|
+
<button
|
|
45
|
+
type="button"
|
|
46
|
+
onClick={onOpenMenu}
|
|
47
|
+
title="Session actions"
|
|
48
|
+
aria-label="Session actions"
|
|
49
|
+
aria-haspopup="menu"
|
|
50
|
+
aria-expanded={menuOpen}
|
|
51
|
+
className={`shrink-0 rounded text-ink/40 hover:bg-ink/10 hover:text-ink cursor-pointer ${
|
|
52
|
+
touch ? 'p-1.5' : 'p-1'
|
|
53
|
+
} ${
|
|
54
|
+
touch ? '' : 'opacity-0 transition-opacity group-hover/item:opacity-100 group-focus-within/item:opacity-100 focus-visible:opacity-100'
|
|
55
|
+
}`}
|
|
56
|
+
>
|
|
57
|
+
<MoreHorizontal size={touch ? 16 : 14} />
|
|
58
|
+
</button>
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
if (touch) {
|
|
62
|
+
return (
|
|
63
|
+
<span className="ml-1 flex shrink-0 items-center gap-0.5">
|
|
64
|
+
{timeAgo && <span className="font-mono text-[10px] text-ink/40">{timeAgo}</span>}
|
|
65
|
+
{trigger}
|
|
66
|
+
</span>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<span className="relative ml-2 flex h-4 w-8 shrink-0 items-center justify-end">
|
|
72
|
+
{timeAgo && (
|
|
73
|
+
<span className="absolute right-1 font-mono text-[10px] leading-none text-ink/40 transition-opacity group-hover/item:opacity-0 group-focus-within/item:opacity-0">
|
|
74
|
+
{timeAgo}
|
|
75
|
+
</span>
|
|
76
|
+
)}
|
|
77
|
+
{/* `-my-1`: the glyph's 22px hit area is larger than the row's trailing
|
|
78
|
+
box, and negative margin keeps that height out of the row's own — the
|
|
79
|
+
row is 30px by construction, not 30px plus whatever the trigger needs
|
|
80
|
+
for a comfortable tap. */}
|
|
81
|
+
<span className="absolute right-0 -my-1 flex">{trigger}</span>
|
|
82
|
+
</span>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One session row for the `modern` sidebar style, at both densities.
|
|
8
|
+
*
|
|
9
|
+
* ONE component for the desktop list and the phone drawer, because the row is
|
|
10
|
+
* the same decision in both places: which chat is this, is it running, does it
|
|
11
|
+
* have a roster, and what can I do to it. The densities differ in touch target
|
|
12
|
+
* and in how the trailing column reveals itself — `touch` has no hover, so the
|
|
13
|
+
* age and the actions trigger are drawn side by side — and in nothing else.
|
|
14
|
+
*
|
|
15
|
+
* Three facts are shared with the shipped rows rather than re-derived, because
|
|
16
|
+
* each one has a bug behind it:
|
|
17
|
+
*
|
|
18
|
+
* - the rename state comes from `useSessionRenaming`, so a rename started in
|
|
19
|
+
* either style (or on the phone) is visible here immediately;
|
|
20
|
+
* - the action menu is `SessionActionsMenu` + `useRowMenu`, so a new action
|
|
21
|
+
* appears in every row everywhere;
|
|
22
|
+
* - `data-testid="session-item"` and the row's accessible names are unchanged,
|
|
23
|
+
* so the browser specs address the same thing in both styles.
|
|
24
|
+
*
|
|
25
|
+
* ## The gutter is shared with the workspace header, numerically
|
|
26
|
+
*
|
|
27
|
+
* 4px of inset, the leading slot (16px; 18px on touch), then 8px before the
|
|
28
|
+
* text; and on the trailing side a 22px (28px on touch) box ending 4px inside
|
|
29
|
+
* the row's own edge — the same numbers `WorkspaceHeader` uses, so the status
|
|
30
|
+
* glyph sits under the folder mark, the title under the folder name, and the two
|
|
31
|
+
* `⋯` triggers share one column. `pl-1 pr-1`, not the `px-2` this row started
|
|
32
|
+
* with: the header's own `px-1` is inside a container that starts at the list's
|
|
33
|
+
* edge, and matching the row's padding to the header's is what makes the columns
|
|
34
|
+
* line up.
|
|
35
|
+
*
|
|
36
|
+
* ## The touch row is exactly as tall as the folder header
|
|
37
|
+
*
|
|
38
|
+
* `h-8` — 32px — is the workspace header's height on touch (`WorkspaceHeader`),
|
|
39
|
+
* and the rows under it must match it or the list reads as two rhythms: a thin
|
|
40
|
+
* name over tall items. The row's own height is driven by its tallest child,
|
|
41
|
+
* the 28px trailing action box (`p-1.5` + a 16px glyph, see `TrailingSlot`), so
|
|
42
|
+
* 2px of vertical padding lands on 32px. `py-0.5`, not a fixed `h-8`: a row that
|
|
43
|
+
* carries a second line (a held prompt, a worktree badge) has to grow, and a
|
|
44
|
+
* fixed height would clip it.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
import type { TargetedMouseEvent } from 'preact';
|
|
48
|
+
import { useInlineRename } from '@/client/hooks/ui/inline-rename';
|
|
49
|
+
import { useSessionRenaming } from '@/client/hooks/workspace/renaming-sessions';
|
|
50
|
+
import { SessionActionsMenu, useRowMenu } from '@/client/components/common/session-actions-menu';
|
|
51
|
+
import { StatusSlot } from '@/client/components/common/session-row/StatusSlot';
|
|
52
|
+
import { TrailingSlot } from '@/client/components/common/session-row/TrailingSlot';
|
|
53
|
+
import { WorktreeBadge } from '@/client/components/layout/session-sidebar/WorktreeBadge';
|
|
54
|
+
import type { SessionWorktreeInfo } from '@/shared/lib/workspace/worktree/types';
|
|
55
|
+
|
|
56
|
+
export type SessionRowDensity = 'compact' | 'touch';
|
|
57
|
+
|
|
58
|
+
export interface SessionRowProps {
|
|
59
|
+
sessionId: string | number;
|
|
60
|
+
title: string;
|
|
61
|
+
isActive?: boolean;
|
|
62
|
+
isArchived?: boolean;
|
|
63
|
+
status?: 'stream' | 'finish' | 'abort';
|
|
64
|
+
awaitingInput?: boolean;
|
|
65
|
+
timeAgo?: string | null;
|
|
66
|
+
worktree?: SessionWorktreeInfo;
|
|
67
|
+
/** The row's prompt is held until another session finishes. */
|
|
68
|
+
waitingFor?: { title: string | null };
|
|
69
|
+
hasSubagents?: boolean;
|
|
70
|
+
isExpanded?: boolean;
|
|
71
|
+
onToggleExpand?: (event: TargetedMouseEvent<HTMLElement>) => void;
|
|
72
|
+
onClick?: () => void;
|
|
73
|
+
onRename?: (name: string) => void;
|
|
74
|
+
onRenameWithAi?: () => void;
|
|
75
|
+
onArchive?: () => void;
|
|
76
|
+
/** Omitted for a chat that cannot be deleted yet (a pending `new-…` row). */
|
|
77
|
+
onDelete?: () => void;
|
|
78
|
+
onCancelWait?: () => void;
|
|
79
|
+
selectable?: boolean;
|
|
80
|
+
selected?: boolean;
|
|
81
|
+
onToggleSelect?: () => void;
|
|
82
|
+
density?: SessionRowDensity;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function SessionRow({
|
|
86
|
+
sessionId,
|
|
87
|
+
title,
|
|
88
|
+
isActive = false,
|
|
89
|
+
isArchived = false,
|
|
90
|
+
status,
|
|
91
|
+
awaitingInput = false,
|
|
92
|
+
timeAgo,
|
|
93
|
+
worktree,
|
|
94
|
+
waitingFor,
|
|
95
|
+
hasSubagents = false,
|
|
96
|
+
isExpanded = false,
|
|
97
|
+
onToggleExpand,
|
|
98
|
+
onClick,
|
|
99
|
+
onRename,
|
|
100
|
+
onRenameWithAi,
|
|
101
|
+
onArchive,
|
|
102
|
+
onDelete,
|
|
103
|
+
onCancelWait,
|
|
104
|
+
selectable = false,
|
|
105
|
+
selected = false,
|
|
106
|
+
onToggleSelect,
|
|
107
|
+
density = 'compact',
|
|
108
|
+
}: SessionRowProps) {
|
|
109
|
+
const touch = density === 'touch';
|
|
110
|
+
const renaming = useSessionRenaming(sessionId);
|
|
111
|
+
const menu = useRowMenu();
|
|
112
|
+
const {
|
|
113
|
+
isEditing,
|
|
114
|
+
draft,
|
|
115
|
+
setDraft,
|
|
116
|
+
inputRef,
|
|
117
|
+
startRename,
|
|
118
|
+
handleKeyDown,
|
|
119
|
+
handleBlur,
|
|
120
|
+
} = useInlineRename(title, onRename);
|
|
121
|
+
const hasActions = Boolean(onRename || onArchive || onDelete || onCancelWait);
|
|
122
|
+
const waiting = Boolean(waitingFor);
|
|
123
|
+
const displayTitle = title.charAt(0).toUpperCase() + title.slice(1);
|
|
124
|
+
|
|
125
|
+
if (isEditing) {
|
|
126
|
+
return (
|
|
127
|
+
<div className={`flex w-full items-center rounded-lg bg-ink/10 ${touch ? 'px-2 py-1.5' : 'px-2 py-1'}`}>
|
|
128
|
+
<input
|
|
129
|
+
ref={inputRef}
|
|
130
|
+
autoFocus
|
|
131
|
+
value={draft}
|
|
132
|
+
onChange={(event) => setDraft(event.currentTarget.value)}
|
|
133
|
+
onClick={(event) => event.stopPropagation()}
|
|
134
|
+
onKeyDown={handleKeyDown}
|
|
135
|
+
onBlur={handleBlur}
|
|
136
|
+
aria-label="Session name"
|
|
137
|
+
className="min-w-0 flex-1 rounded border border-ink/25 bg-paper px-2 py-0.5 text-xs text-ink outline-none focus:border-ink/50"
|
|
138
|
+
/>
|
|
139
|
+
</div>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<>
|
|
145
|
+
<div
|
|
146
|
+
data-testid="session-item"
|
|
147
|
+
data-session-id={String(sessionId)}
|
|
148
|
+
data-selected={selectable && selected ? 'true' : undefined}
|
|
149
|
+
onClick={selectable ? onToggleSelect : onClick}
|
|
150
|
+
onContextMenu={hasActions && !selectable ? menu.openAtCursor : undefined}
|
|
151
|
+
className={`group/item relative flex w-full items-center rounded-lg text-xs transition-colors select-none cursor-pointer ${
|
|
152
|
+
touch ? 'py-0.5 pl-1 pr-1' : 'py-[7px] pl-1 pr-1'
|
|
153
|
+
} ${
|
|
154
|
+
selectable && selected
|
|
155
|
+
? 'bg-ink/10 text-ink ring-1 ring-inset ring-ink/20'
|
|
156
|
+
: isActive
|
|
157
|
+
? 'bg-ink/[0.08] font-medium text-ink'
|
|
158
|
+
: 'text-ink/75 hover:bg-ink/[0.04] hover:text-ink'
|
|
159
|
+
}`}
|
|
160
|
+
>
|
|
161
|
+
{/* The active marker is a POSITION cue, not a tint: a 2px bar survives a
|
|
162
|
+
palette where `bg-ink/10` is nearly invisible, and it survives being
|
|
163
|
+
read by someone who cannot separate two low-contrast greys. */}
|
|
164
|
+
{isActive && !selectable && (
|
|
165
|
+
<span aria-hidden="true" className="absolute left-0 top-1.5 bottom-1.5 w-[2px] rounded-full bg-ink" />
|
|
166
|
+
)}
|
|
167
|
+
|
|
168
|
+
<StatusSlot
|
|
169
|
+
title={title}
|
|
170
|
+
status={status}
|
|
171
|
+
awaitingInput={awaitingInput}
|
|
172
|
+
renaming={renaming}
|
|
173
|
+
waitingFor={waitingFor}
|
|
174
|
+
expandable={hasSubagents}
|
|
175
|
+
isExpanded={isExpanded}
|
|
176
|
+
onToggleExpand={onToggleExpand}
|
|
177
|
+
selectable={selectable}
|
|
178
|
+
selected={selected}
|
|
179
|
+
onToggleSelect={onToggleSelect}
|
|
180
|
+
touch={touch}
|
|
181
|
+
/>
|
|
182
|
+
|
|
183
|
+
<span className={`flex min-w-0 flex-1 flex-col leading-snug ${isArchived ? 'text-ink/45' : ''}`}>
|
|
184
|
+
<span className="truncate">{displayTitle}</span>
|
|
185
|
+
{waiting && (
|
|
186
|
+
<span className="truncate text-[10px] font-normal text-ink/40">
|
|
187
|
+
waiting for {waitingFor?.title ?? 'another session'}
|
|
188
|
+
</span>
|
|
189
|
+
)}
|
|
190
|
+
{worktree && <WorktreeBadge worktree={worktree} />}
|
|
191
|
+
</span>
|
|
192
|
+
|
|
193
|
+
<TrailingSlot
|
|
194
|
+
timeAgo={timeAgo}
|
|
195
|
+
touch={touch}
|
|
196
|
+
menuOpen={menu.anchor !== null}
|
|
197
|
+
onOpenMenu={hasActions && !selectable ? menu.openBelow : undefined}
|
|
198
|
+
/>
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
{menu.anchor && (
|
|
202
|
+
<SessionActionsMenu
|
|
203
|
+
anchor={menu.anchor}
|
|
204
|
+
isArchived={isArchived}
|
|
205
|
+
onRename={onRename ? startRename : undefined}
|
|
206
|
+
onRenameWithAi={onRenameWithAi}
|
|
207
|
+
onArchive={onArchive}
|
|
208
|
+
onDelete={onDelete}
|
|
209
|
+
onCancelWait={onCancelWait}
|
|
210
|
+
onClose={menu.close}
|
|
211
|
+
/>
|
|
212
|
+
)}
|
|
213
|
+
</>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `modern` row: the same facts, the same names, the same contract.
|
|
8
|
+
*
|
|
9
|
+
* The style setting only swaps CHROME, so a row that loses an accessible name,
|
|
10
|
+
* a testid or a status label when it moves from `SessionItem` to `SessionRow`
|
|
11
|
+
* would break every browser spec and every screen-reader query without breaking
|
|
12
|
+
* the build. These assertions are the seam that keeps the two rows
|
|
13
|
+
* interchangeable, and each one names something a spec or a user relies on:
|
|
14
|
+
*
|
|
15
|
+
* - `data-testid="session-item"` scopes a list query;
|
|
16
|
+
* - `aria-label="Session actions"` is how a row's menu is found by role;
|
|
17
|
+
* - the run/blocked/held cues keep their `role="status"` labels;
|
|
18
|
+
* - the trailing slot keeps the age readable at rest and the trigger reachable
|
|
19
|
+
* by keyboard (opacity only — never `display: none`).
|
|
20
|
+
*
|
|
21
|
+
* Rendered with `h()` (no JSX) against happy-dom, following
|
|
22
|
+
* `session-sidebar/SessionItem.test.ts`.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
26
|
+
import { Window } from 'happy-dom';
|
|
27
|
+
import { h, render } from 'preact';
|
|
28
|
+
import { act } from 'preact/test-utils';
|
|
29
|
+
|
|
30
|
+
import { SessionRow } from '@/client/components/common/session-row';
|
|
31
|
+
import type { SessionRowProps } from '@/client/components/common/session-row';
|
|
32
|
+
import { setSessionRenaming } from '@/client/hooks/workspace/renaming-sessions';
|
|
33
|
+
|
|
34
|
+
const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'HTMLInputElement', 'Event', 'MouseEvent', 'KeyboardEvent'] as const;
|
|
35
|
+
const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
|
|
36
|
+
|
|
37
|
+
let container: HTMLElement;
|
|
38
|
+
|
|
39
|
+
beforeAll(() => {
|
|
40
|
+
const win = new Window({ url: 'http://localhost' });
|
|
41
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
42
|
+
for (const key of DOM_GLOBALS) {
|
|
43
|
+
if (!(key in nativeGlobals)) nativeGlobals[key] = target[key];
|
|
44
|
+
target[key] = (win as unknown as Record<string, unknown>)[key];
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
afterAll(() => {
|
|
49
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
50
|
+
for (const key of DOM_GLOBALS) {
|
|
51
|
+
if (nativeGlobals[key] === undefined) delete target[key];
|
|
52
|
+
else target[key] = nativeGlobals[key];
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
afterEach(() => {
|
|
57
|
+
if (container) render(null, container);
|
|
58
|
+
container?.remove();
|
|
59
|
+
setSessionRenaming('s1', false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
async function mount(overrides: Partial<SessionRowProps> = {}) {
|
|
63
|
+
container = document.createElement('div');
|
|
64
|
+
document.body.appendChild(container);
|
|
65
|
+
await act(async () => {
|
|
66
|
+
render(h(SessionRow, { sessionId: 's1', title: 'hello world', ...overrides }), container);
|
|
67
|
+
});
|
|
68
|
+
return container;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
describe('modern session row', () => {
|
|
72
|
+
test('keeps the testid and the session id every list query scopes on', async () => {
|
|
73
|
+
const el = await mount();
|
|
74
|
+
const row = el.querySelector('[data-testid="session-item"]');
|
|
75
|
+
expect(row).not.toBeNull();
|
|
76
|
+
expect(row?.getAttribute('data-session-id')).toBe('s1');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('capitalises the title the way both shipped rows do', async () => {
|
|
80
|
+
const el = await mount({ title: 'hello world' });
|
|
81
|
+
expect(el.textContent).toContain('Hello world');
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test('a live run keeps a labelled status cue', async () => {
|
|
85
|
+
const el = await mount({ status: 'stream' });
|
|
86
|
+
expect(el.querySelector('[role="status"]')?.getAttribute('aria-label')).toBe('Running');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('an agent blocked on a question is announced before any run cue', async () => {
|
|
90
|
+
const el = await mount({ status: 'stream', awaitingInput: true });
|
|
91
|
+
// The blocked cue is a pulse, not a spinner, and it carries no status role —
|
|
92
|
+
// the desktop row has always drawn it that way; what must not change is that
|
|
93
|
+
// it REPLACES the spinner rather than sitting beside it.
|
|
94
|
+
expect(el.querySelector('[role="status"]')).toBeNull();
|
|
95
|
+
expect(el.querySelector('.animate-pulse')).not.toBeNull();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('a held prompt says what it is waiting for', async () => {
|
|
99
|
+
const el = await mount({ waitingFor: { title: 'other chat' } });
|
|
100
|
+
expect(el.textContent).toContain('waiting for other chat');
|
|
101
|
+
expect(el.querySelector('[role="status"]')?.getAttribute('aria-label')).toBe('Waiting for other chat');
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test('an in-flight rename answers the click that is still pending', async () => {
|
|
105
|
+
setSessionRenaming('s1', true);
|
|
106
|
+
const el = await mount();
|
|
107
|
+
expect(el.querySelector('[role="status"]')?.getAttribute('aria-label')).toBe('Generating a name…');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('the actions trigger is drawn and named, and is not hidden from the keyboard', async () => {
|
|
111
|
+
const el = await mount({ onRename: () => {} });
|
|
112
|
+
const trigger = el.querySelector('[aria-label="Session actions"]');
|
|
113
|
+
expect(trigger).not.toBeNull();
|
|
114
|
+
// Hidden by opacity, never by `hidden`/`display`, so Tab still reaches it.
|
|
115
|
+
expect(trigger?.hasAttribute('hidden')).toBe(false);
|
|
116
|
+
expect(trigger?.getAttribute('style') ?? '').not.toContain('display: none');
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('the trailing slot keeps the age at rest', async () => {
|
|
120
|
+
const el = await mount({ timeAgo: '2m', onRename: () => {} });
|
|
121
|
+
expect(el.textContent).toContain('2m');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test('batch mode swaps the status slot for the checkbox', async () => {
|
|
125
|
+
const el = await mount({ selectable: true, selected: true, status: 'stream' });
|
|
126
|
+
expect(el.querySelector('input[type="checkbox"]')).not.toBeNull();
|
|
127
|
+
// The run cue and the checkbox are never both drawn: in this mode the row
|
|
128
|
+
// is a choice, not a status report.
|
|
129
|
+
expect(el.querySelector('[role="status"]')).toBeNull();
|
|
130
|
+
expect(el.querySelector('[data-testid="session-item"]')?.getAttribute('data-selected')).toBe('true');
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('the touch density draws the trigger without a hover reveal', async () => {
|
|
134
|
+
const el = await mount({ density: 'touch', onRename: () => {}, timeAgo: '5m' });
|
|
135
|
+
const trigger = el.querySelector('[aria-label="Session actions"]');
|
|
136
|
+
expect(trigger?.className ?? '').not.toContain('opacity-0');
|
|
137
|
+
expect(el.textContent).toContain('5m');
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
test('the touch row is as tall as the folder header, and can still grow', async () => {
|
|
141
|
+
const el = await mount({ density: 'touch', onRename: () => {} });
|
|
142
|
+
const row = el.querySelector('[data-testid="session-item"]');
|
|
143
|
+
// 2px of padding around the 28px trailing action box = the header's `h-8`.
|
|
144
|
+
expect(row?.className).toContain('py-0.5');
|
|
145
|
+
// Padding, never a fixed height: a held prompt or a worktree badge adds a
|
|
146
|
+
// line, and `h-8` would clip it.
|
|
147
|
+
expect(row?.className ?? '').not.toMatch(/\bh-8\b/);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
test('a row with nothing to offer draws no menu trigger', async () => {
|
|
151
|
+
const el = await mount();
|
|
152
|
+
expect(el.querySelector('[aria-label="Session actions"]')).toBeNull();
|
|
153
|
+
});
|
|
154
|
+
});
|