@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
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `modern` sidebar's filter row: what the list is showing, plus the way into
|
|
8
|
+
* batch selection.
|
|
9
|
+
*
|
|
10
|
+
* Two chips and one mode, and they are two different kinds of thing:
|
|
11
|
+
*
|
|
12
|
+
* - **All / Running** are one choice — the focus. Selecting one deselects the
|
|
13
|
+
* other, so they are drawn as a segmented pair and report `aria-pressed`.
|
|
14
|
+
* - **Archived** is a separate axis: it changes which rows are OFFERED, and it
|
|
15
|
+
* can be on at the same time as either focus. It carries a colour
|
|
16
|
+
* (`--theme-warning`) because an archived list is not the list the user
|
|
17
|
+
* expects, and that fact should not be readable only from a label.
|
|
18
|
+
* - **Select** enters batch mode. It has TWO forms, chosen by measured width
|
|
19
|
+
* (`filterSelectForm`): a trailing glyph while the row is narrow, and a chip
|
|
20
|
+
* once four chips fit. Either way it is the LAST item and it alone sits at the
|
|
21
|
+
* row's trailing edge (`ml-auto`) — the three filter chips never move.
|
|
22
|
+
*
|
|
23
|
+
* **Only Select is right-aligned, never the chip group.** The group is a reading
|
|
24
|
+
* order — All, Running, Archived — and it starts at the same left edge as the
|
|
25
|
+
* search field and the rows below it. Pushing the group to the right edge when
|
|
26
|
+
* the fourth chip appears (which is what this row did first) made the filters
|
|
27
|
+
* jump sideways as the panel was dragged, and left them under the title column
|
|
28
|
+
* instead of over it.
|
|
29
|
+
*
|
|
30
|
+
* **This row never wraps.** It is a control strip, and a second line of chips
|
|
31
|
+
* pushes the list down and reads as a layout break: the four-chip version
|
|
32
|
+
* measured 265px against 256px of content at the 280px default, which is what
|
|
33
|
+
* `Select` falling onto a line of its own looked like.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
import { Archive, ListChecks, X } from 'lucide-preact';
|
|
37
|
+
import { useToolbarRowWidth } from '@/client/hooks/workspace/toolbar-row-width';
|
|
38
|
+
import { filterSelectForm } from '@/shared/lib/workspace/sidebar-filter-row';
|
|
39
|
+
import type { SessionFocus } from '@/shared/lib/workspace/session-focus';
|
|
40
|
+
|
|
41
|
+
interface FilterChipsProps {
|
|
42
|
+
focus: SessionFocus;
|
|
43
|
+
onFocusChange: (focus: SessionFocus) => void;
|
|
44
|
+
/** Rows the focus would keep, for the Running chip's badge. */
|
|
45
|
+
runningCount: number;
|
|
46
|
+
showArchived: boolean;
|
|
47
|
+
onToggleArchived: () => void;
|
|
48
|
+
/** True while a batch selection is active — the control reads pressed. */
|
|
49
|
+
selecting: boolean;
|
|
50
|
+
/** Enter or leave workspace batch-selection mode. */
|
|
51
|
+
onToggleSelect: () => void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const CHIP_BASE = 'inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium transition-colors cursor-pointer';
|
|
55
|
+
const CHIP_ON = 'border-ink bg-ink text-paper';
|
|
56
|
+
const CHIP_OFF = 'border-ink/15 text-ink/60 hover:border-ink/30 hover:text-ink';
|
|
57
|
+
const SELECT_LABEL = (selecting: boolean) => (selecting ? 'Cancel' : 'Select');
|
|
58
|
+
|
|
59
|
+
export function FilterChips({
|
|
60
|
+
focus,
|
|
61
|
+
onFocusChange,
|
|
62
|
+
runningCount,
|
|
63
|
+
showArchived,
|
|
64
|
+
onToggleArchived,
|
|
65
|
+
selecting,
|
|
66
|
+
onToggleSelect,
|
|
67
|
+
}: FilterChipsProps) {
|
|
68
|
+
// Measured, not guessed: the sidebar is dragged, so the form has to follow the
|
|
69
|
+
// panel's real content width (see `filterSelectForm`). The row carries no
|
|
70
|
+
// padding of its own — its `px-3` lives on the wrapper — hence `0`.
|
|
71
|
+
const { ref, width } = useToolbarRowWidth(0);
|
|
72
|
+
const form = filterSelectForm(width, runningCount);
|
|
73
|
+
const selectGlyph = selecting ? <X size={10} /> : <ListChecks size={10} />;
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<div className="px-3 pb-2">
|
|
77
|
+
<div ref={ref} className="flex flex-nowrap items-center gap-1">
|
|
78
|
+
<div className="flex shrink-0 items-center gap-1" role="group" aria-label="Session filters">
|
|
79
|
+
<button
|
|
80
|
+
type="button"
|
|
81
|
+
onClick={() => onFocusChange('all')}
|
|
82
|
+
aria-pressed={focus === 'all'}
|
|
83
|
+
className={`${CHIP_BASE} ${focus === 'all' ? CHIP_ON : CHIP_OFF}`}
|
|
84
|
+
>
|
|
85
|
+
All
|
|
86
|
+
</button>
|
|
87
|
+
<button
|
|
88
|
+
type="button"
|
|
89
|
+
onClick={() => onFocusChange('running')}
|
|
90
|
+
aria-pressed={focus === 'running'}
|
|
91
|
+
title={runningCount > 0 ? `${runningCount} running or waiting` : 'Nothing running'}
|
|
92
|
+
className={`${CHIP_BASE} ${focus === 'running' ? CHIP_ON : CHIP_OFF}`}
|
|
93
|
+
>
|
|
94
|
+
{/* A dot, not a spinner: the chip reports a COUNT of rows, and a
|
|
95
|
+
spinner here would claim the chip itself is loading. */}
|
|
96
|
+
<span
|
|
97
|
+
aria-hidden="true"
|
|
98
|
+
className={`h-1.5 w-1.5 rounded-full ${runningCount > 0 ? 'bg-current' : 'bg-current opacity-30'}`}
|
|
99
|
+
/>
|
|
100
|
+
Running
|
|
101
|
+
{runningCount > 0 && <span className="font-mono tabular-nums opacity-70">{runningCount}</span>}
|
|
102
|
+
</button>
|
|
103
|
+
<button
|
|
104
|
+
type="button"
|
|
105
|
+
onClick={onToggleArchived}
|
|
106
|
+
aria-pressed={showArchived}
|
|
107
|
+
title={showArchived ? 'Hide archived sessions' : 'Show archived sessions'}
|
|
108
|
+
className={`${CHIP_BASE} ${
|
|
109
|
+
showArchived ? 'border-warning/40 bg-warning/10 text-warning hover:bg-warning/15' : CHIP_OFF
|
|
110
|
+
}`}
|
|
111
|
+
>
|
|
112
|
+
<Archive size={10} />
|
|
113
|
+
Archived
|
|
114
|
+
</button>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
{/* Select is a SIBLING of the filter group, never a member of it. Inside
|
|
118
|
+
the group `ml-auto` has no free space to claim — the group is
|
|
119
|
+
`shrink-0` and only as wide as its chips — so the fourth chip landed
|
|
120
|
+
immediately after `Archived` instead of at the row's trailing edge.
|
|
121
|
+
Out here it is the row's own spare space that pushes it right. */}
|
|
122
|
+
{form === 'chip' ? (
|
|
123
|
+
<button
|
|
124
|
+
type="button"
|
|
125
|
+
onClick={onToggleSelect}
|
|
126
|
+
aria-pressed={selecting}
|
|
127
|
+
title={selecting ? 'Cancel selection' : 'Select workspaces'}
|
|
128
|
+
className={`${CHIP_BASE} ml-auto ${selecting ? CHIP_ON : CHIP_OFF}`}
|
|
129
|
+
>
|
|
130
|
+
{selectGlyph}
|
|
131
|
+
{SELECT_LABEL(selecting)}
|
|
132
|
+
</button>
|
|
133
|
+
) : (
|
|
134
|
+
<button
|
|
135
|
+
type="button"
|
|
136
|
+
onClick={onToggleSelect}
|
|
137
|
+
title={selecting ? 'Cancel selection' : 'Select workspaces'}
|
|
138
|
+
aria-label={selecting ? 'Cancel selection' : 'Select workspaces'}
|
|
139
|
+
aria-pressed={selecting}
|
|
140
|
+
className={`ml-auto inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md transition-colors cursor-pointer ${
|
|
141
|
+
selecting ? 'bg-ink/10 text-ink' : 'text-ink/55 hover:bg-ink/[0.06] hover:text-ink'
|
|
142
|
+
}`}
|
|
143
|
+
>
|
|
144
|
+
{selecting ? <X size={14} /> : <ListChecks size={14} />}
|
|
145
|
+
</button>
|
|
146
|
+
)}
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
);
|
|
150
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `modern` sidebar's search line.
|
|
8
|
+
*
|
|
9
|
+
* A FIELD, not a mode: the classic toolbar spends a 28px button on toggling a
|
|
10
|
+
* search box that then pushes the list down, which costs a click before the
|
|
11
|
+
* user can type and moves every row when it opens. Here the field is always
|
|
12
|
+
* there, at the top, and the list never shifts — so search is something you do,
|
|
13
|
+
* not something you enter.
|
|
14
|
+
*
|
|
15
|
+
* The icon, the input and the clear control are FLEX SIBLINGS inside the field
|
|
16
|
+
* box rather than three absolutely-positioned layers. The earlier version
|
|
17
|
+
* centred the glyph against the wrapper — which includes the field's own bottom
|
|
18
|
+
* margin — so the icon sat 4px below the placeholder's optical centre, and its
|
|
19
|
+
* `left`/`pl` pair had to be kept in sync by hand. As siblings they share one
|
|
20
|
+
* baseline and one vertical centre by construction.
|
|
21
|
+
*
|
|
22
|
+
* The clear control appears only while there is a query, and `aria-label` names
|
|
23
|
+
* it: an icon-only button with no name is unreachable to a screen reader and
|
|
24
|
+
* to `getByRole`, which is why every control in this app carries one.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import { Search, X } from 'lucide-preact';
|
|
28
|
+
|
|
29
|
+
interface SearchFieldProps {
|
|
30
|
+
value: string;
|
|
31
|
+
onChange: (value: string) => void;
|
|
32
|
+
/** Larger target and text for a touch row. */
|
|
33
|
+
touch?: boolean;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function SearchField({ value, onChange, touch = false }: SearchFieldProps) {
|
|
37
|
+
return (
|
|
38
|
+
// `pt-2`/`pt-3` keeps the field off the column's own top edge: flush against
|
|
39
|
+
// it the rounded corner read as the panel's corner, not as a control.
|
|
40
|
+
<div className={touch ? 'px-3 pt-3 pb-2' : 'px-3 pt-2 pb-2'}>
|
|
41
|
+
<div
|
|
42
|
+
className={`flex items-center gap-1.5 rounded-lg border border-ink/10 bg-ink/[0.04] px-2 transition-colors focus-within:border-ink/30 focus-within:bg-paper ${
|
|
43
|
+
touch ? 'h-9' : 'h-7'
|
|
44
|
+
}`}
|
|
45
|
+
>
|
|
46
|
+
<Search
|
|
47
|
+
size={touch ? 15 : 13}
|
|
48
|
+
aria-hidden="true"
|
|
49
|
+
className="shrink-0 text-ink/35"
|
|
50
|
+
/>
|
|
51
|
+
<input
|
|
52
|
+
type="search"
|
|
53
|
+
value={value}
|
|
54
|
+
onChange={(event) => onChange(event.currentTarget.value)}
|
|
55
|
+
placeholder="Search workspaces & sessions"
|
|
56
|
+
aria-label="Search workspaces and sessions"
|
|
57
|
+
className={`min-w-0 flex-1 bg-transparent text-ink outline-none placeholder:text-ink/40 ${
|
|
58
|
+
touch ? 'text-[13px]' : 'text-xs'
|
|
59
|
+
}`}
|
|
60
|
+
/>
|
|
61
|
+
{value.length > 0 && (
|
|
62
|
+
<button
|
|
63
|
+
type="button"
|
|
64
|
+
onClick={() => onChange('')}
|
|
65
|
+
title="Clear search"
|
|
66
|
+
aria-label="Clear search"
|
|
67
|
+
className="-mr-0.5 shrink-0 rounded p-0.5 text-ink/40 transition-colors cursor-pointer hover:bg-ink/10 hover:text-ink"
|
|
68
|
+
>
|
|
69
|
+
<X size={touch ? 14 : 12} />
|
|
70
|
+
</button>
|
|
71
|
+
)}
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `modern` sidebar's placeholder for the list area while the first fetch is
|
|
8
|
+
* in flight.
|
|
9
|
+
*
|
|
10
|
+
* It draws ONLY the list: the search line, the chips and the action row above
|
|
11
|
+
* it are real controls that render during initialization too, and a skeleton
|
|
12
|
+
* that drew its own copies of them put two search fields on screen for a beat
|
|
13
|
+
* and then moved the real one. The earlier version also carried its own
|
|
14
|
+
* `px-2 pb-3` while the view already padded the same box — 8px of double inset,
|
|
15
|
+
* visible as the placeholder sitting narrower than the rows it stood in for.
|
|
16
|
+
*
|
|
17
|
+
* The geometry is the live geometry, measured rather than approximated: the
|
|
18
|
+
* workspace header is 26px (32 on touch) with its mark in the same 4px + 16px
|
|
19
|
+
* (18px) gutter the real header uses, and the rows are 31px (32 on touch, the
|
|
20
|
+
* header's own `h-8` — see `common/session-row`) — the live row's own measured
|
|
21
|
+
* height, not `padding + bar`. A placeholder whose heights differ from the
|
|
22
|
+
* content is a layout shift with extra steps.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const PLACEHOLDER_FOLDERS = [3, 2];
|
|
26
|
+
|
|
27
|
+
export function ModernSidebarSkeleton({ touch = false }: { touch?: boolean }) {
|
|
28
|
+
return (
|
|
29
|
+
<div className="space-y-3" aria-hidden="true">
|
|
30
|
+
{PLACEHOLDER_FOLDERS.map((rows, folderIndex) => (
|
|
31
|
+
<div key={folderIndex} className="space-y-0.5">
|
|
32
|
+
<div className={`flex items-center gap-2 px-1 ${touch ? 'h-8' : 'h-[26px]'}`}>
|
|
33
|
+
<span className={`animate-pulse rounded-sm bg-ink/10 ${touch ? 'h-[18px] w-[18px]' : 'h-4 w-4'}`} />
|
|
34
|
+
<span className="h-3 w-24 animate-pulse rounded bg-ink/10" />
|
|
35
|
+
</div>
|
|
36
|
+
{Array.from({ length: rows }, (_, rowIndex) => (
|
|
37
|
+
<div
|
|
38
|
+
key={rowIndex}
|
|
39
|
+
className={`flex items-center gap-2 pl-1 pr-2 ${touch ? 'h-8' : 'h-[31px]'}`}
|
|
40
|
+
>
|
|
41
|
+
<span
|
|
42
|
+
className={`shrink-0 animate-pulse rounded-full bg-ink/10 ${
|
|
43
|
+
touch ? 'h-[18px] w-[18px]' : 'h-4 w-4'
|
|
44
|
+
}`}
|
|
45
|
+
/>
|
|
46
|
+
<span
|
|
47
|
+
className="h-3 animate-pulse rounded bg-ink/10"
|
|
48
|
+
style={{ width: `${58 - (rowIndex % 3) * 12}%` }}
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
))}
|
|
52
|
+
</div>
|
|
53
|
+
))}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A workspace's header in the `modern` sidebar: the mark, the name, how many
|
|
8
|
+
* chats it holds, and its two actions.
|
|
9
|
+
*
|
|
10
|
+
* Differences from the classic header are presentation only, and each one is
|
|
11
|
+
* there for a reason:
|
|
12
|
+
*
|
|
13
|
+
* - **It sticks.** Scrolling a long workspace used to leave the rows with no
|
|
14
|
+
* visible owner; the name is the only thing that says which project these
|
|
15
|
+
* chats belong to.
|
|
16
|
+
* - **It states a count.** "3" answers "does this workspace have anything in
|
|
17
|
+
* it?" without expanding it, which is the question a collapsed row raises.
|
|
18
|
+
* - **The mark keeps the accent.** A folder's colour is a fact the user chose;
|
|
19
|
+
* the classic header only shows it until hover, when the chevron replaces it.
|
|
20
|
+
* Here the accent is a dot beside the name, so it survives both states.
|
|
21
|
+
*
|
|
22
|
+
* ## The gutter is shared with the rows, numerically
|
|
23
|
+
*
|
|
24
|
+
* The icon column, the title column and the TRAILING column are the same columns
|
|
25
|
+
* as a session row's (`common/session-row`): 4px of inset, a 16px slot (18px on
|
|
26
|
+
* touch), then 8px before the text; and on the right, a 22px (28px on touch)
|
|
27
|
+
* action box ending 4px inside the list's content edge. Measured before this
|
|
28
|
+
* rule existed, the folder mark's centre sat at x=20 while the row's status glyph
|
|
29
|
+
* sat at 24, the folder name at 34 while the session title started at 40, and the
|
|
30
|
+
* two `⋯` triggers were 9px apart (8px vs 16px from the panel edge) — three steps
|
|
31
|
+
* that made the list look like two lists. A header that "looked about right" is
|
|
32
|
+
* what produced them: the pair has to be stated, so it is stated here and in
|
|
33
|
+
* `session-row`.
|
|
34
|
+
*
|
|
35
|
+
* The actions are the same components the classic header uses — `+` opens a
|
|
36
|
+
* chat in THIS folder and `⋯` is `WorkspaceOptionsMenu` — so pin, delete,
|
|
37
|
+
* reveal, worktree and session-selection exist in both styles by construction.
|
|
38
|
+
*
|
|
39
|
+
* ## The sticky surface is the list's surface
|
|
40
|
+
*
|
|
41
|
+
* The header must be opaque — rows scroll underneath it — and the colour it
|
|
42
|
+
* paints has to be the one the list sits on, or every folder draws a band.
|
|
43
|
+
* `--theme-paper` is the desktop column's surface and `--theme-canvas` the phone
|
|
44
|
+
* drawer's (see `shared/lib/theme/chrome.ts`); a single `bg-paper` therefore
|
|
45
|
+
* put a lighter stripe behind each folder in the phone drawer, where the rows
|
|
46
|
+
* behind it are canvas.
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
import type { ReactNode } from 'preact/compat';
|
|
50
|
+
import { ChevronDown, ChevronRight, MoreHorizontal, Pin, Plus } from 'lucide-preact';
|
|
51
|
+
import { SelectionCheckbox } from '@/client/components/common/batch-selection/SelectionCheckbox';
|
|
52
|
+
import type { CategoryHeaderCheckbox } from '@/client/components/layout/session-sidebar/CategoryHeader';
|
|
53
|
+
import { getProjectIcon } from '@/shared/lib/workspace/project-icon';
|
|
54
|
+
import type { WorkspaceFolderData } from '@/shared/types';
|
|
55
|
+
|
|
56
|
+
export interface WorkspaceHeaderProps {
|
|
57
|
+
folder: WorkspaceFolderData;
|
|
58
|
+
isOpen: boolean;
|
|
59
|
+
onToggleFolder: () => void;
|
|
60
|
+
/** Rows the folder offers under the current archive filter. */
|
|
61
|
+
sessionCount: number;
|
|
62
|
+
checkbox: CategoryHeaderCheckbox | null;
|
|
63
|
+
batchActive: boolean;
|
|
64
|
+
menuRef: { current: HTMLDivElement | null };
|
|
65
|
+
showMenu: boolean;
|
|
66
|
+
onToggleMenu: () => void;
|
|
67
|
+
onNewSession: () => void;
|
|
68
|
+
/** The menu body, drawn in this header's anchored container while open. */
|
|
69
|
+
menu?: ReactNode;
|
|
70
|
+
/** Taller row and larger tap targets for the phone drawer. */
|
|
71
|
+
touch?: boolean;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function WorkspaceHeader({
|
|
75
|
+
folder,
|
|
76
|
+
isOpen,
|
|
77
|
+
onToggleFolder,
|
|
78
|
+
sessionCount,
|
|
79
|
+
checkbox,
|
|
80
|
+
batchActive,
|
|
81
|
+
menuRef,
|
|
82
|
+
showMenu,
|
|
83
|
+
onToggleMenu,
|
|
84
|
+
onNewSession,
|
|
85
|
+
menu,
|
|
86
|
+
touch = false,
|
|
87
|
+
}: WorkspaceHeaderProps) {
|
|
88
|
+
const ProjectIcon = getProjectIcon(folder.icon);
|
|
89
|
+
const accent = folder.accentColor || undefined;
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<div
|
|
93
|
+
className={`group/ws sticky top-0 z-10 -mx-1 flex items-center gap-1 rounded-md px-1 text-xs font-semibold text-ink ${
|
|
94
|
+
touch ? 'h-8 bg-canvas' : 'h-[26px] bg-paper'
|
|
95
|
+
}`}
|
|
96
|
+
>
|
|
97
|
+
<button
|
|
98
|
+
type="button"
|
|
99
|
+
onClick={batchActive ? undefined : onToggleFolder}
|
|
100
|
+
aria-expanded={isOpen}
|
|
101
|
+
aria-label={`${folder.name}${isOpen ? ', collapse' : ', expand'}`}
|
|
102
|
+
className="flex h-full min-w-0 flex-1 items-center gap-2 rounded-md px-1 text-left cursor-pointer hover:bg-ink/[0.04]"
|
|
103
|
+
>
|
|
104
|
+
{checkbox ? (
|
|
105
|
+
<SelectionCheckbox
|
|
106
|
+
size="md"
|
|
107
|
+
checked={checkbox.checked}
|
|
108
|
+
indeterminate={checkbox.indeterminate}
|
|
109
|
+
label={checkbox.label}
|
|
110
|
+
onChange={checkbox.onChange}
|
|
111
|
+
/>
|
|
112
|
+
) : (
|
|
113
|
+
<span className={`relative flex shrink-0 items-center justify-center ${touch ? 'h-[18px] w-[18px]' : 'h-4 w-4'}`}>
|
|
114
|
+
{folder.customIconUrl ? (
|
|
115
|
+
<img
|
|
116
|
+
src={folder.customIconUrl}
|
|
117
|
+
alt=""
|
|
118
|
+
className="h-[15px] w-[15px] shrink-0 rounded-xs object-contain"
|
|
119
|
+
referrerPolicy="no-referrer"
|
|
120
|
+
/>
|
|
121
|
+
) : (
|
|
122
|
+
<ProjectIcon size={15} className="text-ink/70" style={{ color: accent }} />
|
|
123
|
+
)}
|
|
124
|
+
</span>
|
|
125
|
+
)}
|
|
126
|
+
|
|
127
|
+
<span className="truncate text-[13px] font-semibold tracking-tight">{folder.name}</span>
|
|
128
|
+
{folder.isPinned && <Pin size={10} className="shrink-0 text-ink/45" />}
|
|
129
|
+
|
|
130
|
+
{/* The accent as a dot: the icon column keeps the chevron's slot, so the
|
|
131
|
+
colour needs a place that is not hover-dependent. */}
|
|
132
|
+
{accent && !checkbox && (
|
|
133
|
+
<span aria-hidden="true" className="h-1.5 w-1.5 shrink-0 rounded-full" style={{ backgroundColor: accent }} />
|
|
134
|
+
)}
|
|
135
|
+
|
|
136
|
+
<span className="shrink-0 font-mono text-[10px] font-normal tabular-nums text-ink/35">{sessionCount}</span>
|
|
137
|
+
|
|
138
|
+
<span className="ml-auto shrink-0 text-ink/40">
|
|
139
|
+
{isOpen ? <ChevronDown size={touch ? 14 : 12} /> : <ChevronRight size={touch ? 14 : 12} />}
|
|
140
|
+
</span>
|
|
141
|
+
</button>
|
|
142
|
+
|
|
143
|
+
{/* `pr-1`: the action cluster ends where a session row's trailing control
|
|
144
|
+
ends (4px inside the list's content edge), so the two `⋯` columns are
|
|
145
|
+
one column — measured before this rule, the folder's sat 8px from the
|
|
146
|
+
panel edge and the row's 16px, a 9px step between glyph centres. */}
|
|
147
|
+
{!batchActive && (
|
|
148
|
+
<div className="flex shrink-0 items-center gap-0.5 pr-1">
|
|
149
|
+
<button
|
|
150
|
+
type="button"
|
|
151
|
+
title="New Session"
|
|
152
|
+
aria-label={`New session in ${folder.name}`}
|
|
153
|
+
onClick={(event) => {
|
|
154
|
+
event.stopPropagation();
|
|
155
|
+
onNewSession();
|
|
156
|
+
}}
|
|
157
|
+
className={`flex items-center justify-center rounded text-ink/40 transition-colors cursor-pointer hover:bg-ink/10 hover:text-ink ${
|
|
158
|
+
touch ? 'h-7 w-7' : 'h-[22px] w-[22px]'
|
|
159
|
+
}`}
|
|
160
|
+
>
|
|
161
|
+
<Plus size={touch ? 15 : 12} />
|
|
162
|
+
</button>
|
|
163
|
+
|
|
164
|
+
<div className="relative flex items-center" ref={menuRef}>
|
|
165
|
+
<button
|
|
166
|
+
type="button"
|
|
167
|
+
title={`Options for ${folder.name}`}
|
|
168
|
+
aria-label={`Options for ${folder.name}`}
|
|
169
|
+
aria-haspopup="menu"
|
|
170
|
+
aria-expanded={showMenu}
|
|
171
|
+
onClick={(event) => {
|
|
172
|
+
event.stopPropagation();
|
|
173
|
+
onToggleMenu();
|
|
174
|
+
}}
|
|
175
|
+
className={`flex items-center justify-center rounded text-ink/40 transition-colors cursor-pointer hover:bg-ink/10 hover:text-ink ${
|
|
176
|
+
touch ? 'h-7 w-7' : 'h-[22px] w-[22px]'
|
|
177
|
+
}`}
|
|
178
|
+
>
|
|
179
|
+
<MoreHorizontal size={touch ? 15 : 12} />
|
|
180
|
+
</button>
|
|
181
|
+
{/* The menu body is the caller's: it owns the state the menu acts
|
|
182
|
+
on (pin, delete confirmation, the worktree dialog). */}
|
|
183
|
+
{showMenu && menu && (
|
|
184
|
+
<div className="absolute right-0 top-full z-50 mt-1 w-44 rounded-md border border-ink/15 bg-paper py-1 text-xs shadow-lg">
|
|
185
|
+
{menu}
|
|
186
|
+
</div>
|
|
187
|
+
)}
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
)}
|
|
191
|
+
</div>
|
|
192
|
+
);
|
|
193
|
+
}
|