@lukstei/dsh-client-kanban 0.0.0-stage → 0.2.2-rc.5.3

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.
@@ -0,0 +1,177 @@
1
+ import type { SessionSummary } from "@deepseek-ai/dsh-api-session-controller/client";
2
+ import type { SessionId } from "@deepseek-ai/dsh-session/types";
3
+ import { useState } from "react";
4
+ import type { KanbanLane } from "../types.ts";
5
+ import { KanbanCard } from "./KanbanCard.tsx";
6
+ import { isKanbanTransitionAllowed, type KanbanSessionAlert } from "./store.ts";
7
+
8
+ export interface KanbanSectionProps {
9
+ readonly lane: KanbanLane;
10
+ readonly title: string;
11
+ readonly sessions: readonly SessionSummary[];
12
+ readonly selectedSessionId?: SessionId;
13
+ readonly isPreparing?: boolean;
14
+ readonly activeDragSourceLane?: KanbanLane;
15
+ readonly getAlert?: (id: SessionId) => KanbanSessionAlert | undefined;
16
+ readonly onSelect: (id: SessionId) => void;
17
+ readonly onDropSession: (
18
+ sessionId: SessionId,
19
+ targetLane: KanbanLane,
20
+ ) => void;
21
+ readonly onDragStart?: (id: SessionId, lane: KanbanLane) => void;
22
+ readonly onDragEnd?: () => void;
23
+ readonly onSubmitPrepare?: (prompt: string) => void;
24
+ readonly onCancelPrepare?: () => void;
25
+ readonly onTogglePin?: (id: SessionId) => void;
26
+ }
27
+
28
+ /**
29
+ * Purpose: Render a droppable Kanban column lane with header count, inline task preparer, and session cards.
30
+ * Contract:
31
+ * - Inputs: KanbanSectionProps containing lane identifier, title, sessions list, records map, and event handlers.
32
+ * - Outputs: Rendered JSX element for the column lane.
33
+ * - Throws / Errors: Never throws.
34
+ */
35
+ export function KanbanSection({
36
+ lane,
37
+ title,
38
+ sessions,
39
+ selectedSessionId,
40
+ isPreparing = false,
41
+ activeDragSourceLane,
42
+ getAlert,
43
+ onSelect,
44
+ onDropSession,
45
+ onDragStart,
46
+ onDragEnd,
47
+ onSubmitPrepare,
48
+ onCancelPrepare,
49
+ onTogglePin,
50
+ }: KanbanSectionProps) {
51
+ const [isCollapsed, setIsCollapsed] = useState(false);
52
+ const [isDragOver, setIsDragOver] = useState(false);
53
+ const canAcceptDrop =
54
+ activeDragSourceLane !== undefined &&
55
+ isKanbanTransitionAllowed(activeDragSourceLane, lane);
56
+ const [newPrompt, setNewPrompt] = useState("");
57
+
58
+ const handleDragOver = (e: React.DragEvent) => {
59
+ if (!canAcceptDrop) return;
60
+ e.preventDefault();
61
+ e.dataTransfer.dropEffect = "move";
62
+ if (!isDragOver) setIsDragOver(true);
63
+ };
64
+
65
+ const handleDragLeave = () => {
66
+ setIsDragOver(false);
67
+ };
68
+
69
+ const handleDrop = (e: React.DragEvent) => {
70
+ e.preventDefault();
71
+ setIsDragOver(false);
72
+ const rawId = e.dataTransfer.getData("text/plain");
73
+ if (rawId) {
74
+ onDropSession(rawId as SessionId, lane);
75
+ }
76
+ };
77
+
78
+ const handleSave = () => {
79
+ const trimmedPrompt = newPrompt.trim();
80
+ if (trimmedPrompt && onSubmitPrepare) {
81
+ onSubmitPrepare(trimmedPrompt);
82
+ setNewPrompt("");
83
+ }
84
+ };
85
+
86
+ const handleCancel = () => {
87
+ if (onCancelPrepare) onCancelPrepare();
88
+ setNewPrompt("");
89
+ };
90
+
91
+ const isEmpty = sessions.length === 0 && !isPreparing;
92
+
93
+ return (
94
+ <div
95
+ className={`dsh-kanban-section ${isDragOver ? "drag-over" : ""} ${isEmpty ? "is-empty" : ""} ${isCollapsed && !isPreparing ? "is-collapsed" : ""}`}
96
+ onDragOver={handleDragOver}
97
+ onDragLeave={handleDragLeave}
98
+ onDrop={handleDrop}
99
+ >
100
+ <div
101
+ className="dsh-kanban-section-header"
102
+ onClick={() => setIsCollapsed((prev) => !prev)}
103
+ >
104
+ <div className="dsh-kanban-section-title-wrap">
105
+ <span className="dsh-kanban-collapse-icon">
106
+ {isCollapsed && !isPreparing ? "▸" : "▾"}
107
+ </span>
108
+ <span>{title}</span>
109
+ <span className="dsh-kanban-pill">{sessions.length}</span>
110
+ </div>
111
+ </div>
112
+
113
+ <div className="dsh-kanban-lane-body">
114
+ {isPreparing && (
115
+ <div
116
+ className="dsh-kanban-new-card"
117
+ onClick={(e) => e.stopPropagation()}
118
+ >
119
+ <div className="dsh-kanban-prepare-label">Prepare Task</div>
120
+ <textarea
121
+ ref={(el) => el?.focus()}
122
+ className="dsh-kanban-new-card-textarea"
123
+ placeholder="Task instructions / prompt..."
124
+ rows={3}
125
+ value={newPrompt}
126
+ onChange={(e) => setNewPrompt(e.target.value)}
127
+ onKeyDown={(e) => {
128
+ if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
129
+ e.preventDefault();
130
+ handleSave();
131
+ } else if (e.key === "Escape") {
132
+ handleCancel();
133
+ }
134
+ }}
135
+ />
136
+ <div className="dsh-kanban-new-card-actions">
137
+ <button
138
+ type="button"
139
+ className="dsh-kanban-btn-add"
140
+ onClick={handleSave}
141
+ disabled={!newPrompt.trim()}
142
+ >
143
+ Save Task
144
+ </button>
145
+ <button
146
+ type="button"
147
+ className="dsh-kanban-btn-cancel"
148
+ onClick={handleCancel}
149
+ >
150
+ Cancel
151
+ </button>
152
+ </div>
153
+ </div>
154
+ )}
155
+
156
+ {sessions.length === 0 && !isPreparing ? (
157
+ <div className="dsh-kanban-empty">No sessions</div>
158
+ ) : (
159
+ sessions.map((session) => (
160
+ <KanbanCard
161
+ key={session.id}
162
+ session={session}
163
+ lane={lane}
164
+ alert={getAlert?.(session.id)}
165
+ isSelected={session.id === selectedSessionId}
166
+ onSelect={onSelect}
167
+ onDragStart={onDragStart}
168
+ onDragEnd={onDragEnd}
169
+ onTransition={onDropSession}
170
+ onTogglePin={onTogglePin}
171
+ />
172
+ ))
173
+ )}
174
+ </div>
175
+ </div>
176
+ );
177
+ }
@@ -0,0 +1,14 @@
1
+ import type { KanbanLane } from "../types.ts";
2
+
3
+ /**
4
+ * Purpose: Paint the shared six-pixel session status indicator.
5
+ * Contract:
6
+ * - Inputs: A resolved lane or alert state; the caller owns its meaning and label.
7
+ * - Outputs: A decorative dot using the shared status colors and animation.
8
+ * - Throws / Errors: None.
9
+ */
10
+ export function KanbanStatusDot({ state }: { state: KanbanLane | "alert" }) {
11
+ return (
12
+ <span className={`dsh-kanban-badge-dot is-${state}`} aria-hidden="true" />
13
+ );
14
+ }
@@ -0,0 +1,281 @@
1
+ import {
2
+ Button,
3
+ IconChevronDownOutlineRegular,
4
+ Menu,
5
+ } from "@deepseek-ai/dsh-client-ui-primitives";
6
+ import type { PropsRuntime } from "@deepseek-ai/dsh-client-ui-slots";
7
+ import type { SessionId } from "@deepseek-ai/dsh-session/types";
8
+ import { useMemo, useState } from "react";
9
+ import type { KanbanLane, KanbanRecord } from "../types.ts";
10
+ import { KanbanIcon } from "./KanbanIcon.tsx";
11
+ import { KanbanStatusDot } from "./KanbanStatusDot.tsx";
12
+ import { classifyKanbanSession } from "./store.ts";
13
+
14
+ function formatLaneLabel(lane: KanbanLane, record?: KanbanRecord): string {
15
+ if (lane === "active") return "In Progress";
16
+ if (lane === "review") return "In Review";
17
+ if (lane === "done") return "Done";
18
+ if (lane === "todo") {
19
+ return record?.heldAt !== undefined ? "On Hold" : "Todo";
20
+ }
21
+ return "Kanban";
22
+ }
23
+
24
+ function IconCheck({ size = 14 }: { size?: number }) {
25
+ return (
26
+ <svg
27
+ width={size}
28
+ height={size}
29
+ viewBox="0 0 16 16"
30
+ fill="none"
31
+ stroke="currentColor"
32
+ strokeWidth="1.3"
33
+ strokeLinecap="round"
34
+ strokeLinejoin="round"
35
+ aria-hidden="true"
36
+ >
37
+ <path d="M2.25 8.5L5.49732 11.7473C5.90519 12.1552 6.57263 12.1344 6.95426 11.7018L13.75 4" />
38
+ </svg>
39
+ );
40
+ }
41
+
42
+ function IconPause({ size = 14 }: { size?: number }) {
43
+ return (
44
+ <svg
45
+ width={size}
46
+ height={size}
47
+ viewBox="0 0 16 16"
48
+ fill="none"
49
+ stroke="currentColor"
50
+ strokeWidth="1.3"
51
+ aria-hidden="true"
52
+ >
53
+ <path d="M8 14.5C11.5899 14.5 14.5 11.5899 14.5 8C14.5 4.41015 11.5899 1.5 8 1.5C4.41015 1.5 1.5 4.41015 1.5 8C1.5 11.5899 4.41015 14.5 8 14.5Z" />
54
+ <path d="M6.5 5.5V10.5" strokeLinecap="round" />
55
+ <path d="M9.5 5.5V10.5" strokeLinecap="round" />
56
+ </svg>
57
+ );
58
+ }
59
+
60
+ function IconPlay({ size = 14 }: { size?: number }) {
61
+ return (
62
+ <svg
63
+ width={size}
64
+ height={size}
65
+ viewBox="0 0 16 16"
66
+ fill="none"
67
+ stroke="currentColor"
68
+ strokeWidth="1.3"
69
+ aria-hidden="true"
70
+ >
71
+ <path d="M4.5 3.5V12.5L12.5 8L4.5 3.5Z" strokeLinejoin="round" />
72
+ </svg>
73
+ );
74
+ }
75
+
76
+ function IconReopen({ size = 14 }: { size?: number }) {
77
+ return (
78
+ <svg
79
+ width={size}
80
+ height={size}
81
+ viewBox="0 0 16 16"
82
+ fill="none"
83
+ stroke="currentColor"
84
+ strokeWidth="1.3"
85
+ strokeLinecap="round"
86
+ strokeLinejoin="round"
87
+ aria-hidden="true"
88
+ >
89
+ <path d="M2.5 8a5.5 5.5 0 1 0 1.5-3.75L2 6" />
90
+ <path d="M2 2v4h4" />
91
+ </svg>
92
+ );
93
+ }
94
+
95
+ export interface KanbanTransitionActions {
96
+ readonly holdSession: (id: SessionId) => Promise<void>;
97
+ readonly unholdSession: (id: SessionId) => Promise<void>;
98
+ readonly markDone: (id: SessionId) => Promise<void>;
99
+ readonly reopen: (id: SessionId) => Promise<void>;
100
+ readonly startPreparedTask: (id: SessionId, prompt: string) => Promise<void>;
101
+ }
102
+
103
+ export type KanbanTransitionDropdownProps =
104
+ PropsRuntime<"conversation.input.left"> & KanbanTransitionActions;
105
+
106
+ /**
107
+ * Purpose: Render a dropdown button with the Kanban icon in the prompt input bar for task transitions.
108
+ * Contract:
109
+ * - Inputs: Session runtime hooks and injected Kanban transition mutation callbacks.
110
+ * - Outputs: Rendered JSX element with an accessible trigger button and transition popover menu.
111
+ * - Throws / Errors: Never throws; transition command failures are handled by callers.
112
+ */
113
+ export function KanbanTransitionDropdown({
114
+ sessionId,
115
+ useSession,
116
+ useSessions,
117
+ holdSession,
118
+ unholdSession,
119
+ markDone,
120
+ reopen,
121
+ startPreparedTask,
122
+ }: KanbanTransitionDropdownProps) {
123
+ const [open, setOpen] = useState(false);
124
+ const isRunning = useSession((s) => s.running);
125
+ const isBlank = useSession((s) => s.blank);
126
+ const hasPendingInteraction = useSession(
127
+ (s) => s.pendingSubmissions.length > 0,
128
+ );
129
+ const summary = useSessions((s) => s.byId[sessionId]);
130
+ const record = summary?.projectionValues?.kanban as KanbanRecord | undefined;
131
+
132
+ const fallbackRecord: KanbanRecord = {
133
+ sessionId,
134
+ createdAt: 0,
135
+ links: [],
136
+ };
137
+ const lane = classifyKanbanSession(
138
+ { running: isRunning, blank: isBlank },
139
+ record ?? fallbackRecord,
140
+ hasPendingInteraction,
141
+ );
142
+ const laneLabel = formatLaneLabel(lane, record);
143
+
144
+ const items = useMemo(() => {
145
+ if (lane === "active") return [];
146
+ if (lane === "review") {
147
+ return [
148
+ {
149
+ id: "done",
150
+ label: (
151
+ <span className="dsh-kanban-transition-item dsh-kanban-transition-item-primary">
152
+ <IconCheck size={14} />
153
+ <span>Mark task done</span>
154
+ </span>
155
+ ),
156
+ },
157
+ {
158
+ id: "hold",
159
+ label: (
160
+ <span className="dsh-kanban-transition-item">
161
+ <IconPause size={14} />
162
+ <span>Put on hold</span>
163
+ </span>
164
+ ),
165
+ },
166
+ ];
167
+ }
168
+ if (lane === "todo") {
169
+ return [
170
+ {
171
+ id: "resume",
172
+ label: (
173
+ <span className="dsh-kanban-transition-item">
174
+ <IconPlay size={14} />
175
+ <span>{isBlank ? "Start task" : "Resume task"}</span>
176
+ </span>
177
+ ),
178
+ },
179
+ {
180
+ id: "done",
181
+ label: (
182
+ <span className="dsh-kanban-transition-item">
183
+ <IconCheck size={14} />
184
+ <span>Mark task done</span>
185
+ </span>
186
+ ),
187
+ },
188
+ ];
189
+ }
190
+ if (lane === "done") {
191
+ return [
192
+ {
193
+ id: "reopen",
194
+ label: (
195
+ <span className="dsh-kanban-transition-item">
196
+ <IconReopen size={14} />
197
+ <span>Reopen task</span>
198
+ </span>
199
+ ),
200
+ },
201
+ {
202
+ id: "hold",
203
+ label: (
204
+ <span className="dsh-kanban-transition-item">
205
+ <IconPause size={14} />
206
+ <span>Put on hold</span>
207
+ </span>
208
+ ),
209
+ },
210
+ ];
211
+ }
212
+ return [];
213
+ }, [lane, isBlank]);
214
+
215
+ // Subagent sessions have no Kanban lane of their own.
216
+ if (summary?.origin === "subagent") return null;
217
+
218
+ return (
219
+ <Menu
220
+ open={open && !isRunning}
221
+ portal
222
+ side="top"
223
+ align="start"
224
+ className="dsh-kanban-transition-menu"
225
+ listClassName="dsh-kanban-transition-menu-list"
226
+ onClose={() => setOpen(false)}
227
+ onSelect={(id) => {
228
+ setOpen(false);
229
+ if (id === "hold") {
230
+ void holdSession(sessionId);
231
+ } else if (id === "done") {
232
+ void markDone(sessionId);
233
+ } else if (id === "reopen") {
234
+ void reopen(sessionId);
235
+ } else if (id === "resume") {
236
+ if (isBlank && record?.prompt) {
237
+ void startPreparedTask(sessionId, record.prompt);
238
+ } else {
239
+ void unholdSession(sessionId);
240
+ }
241
+ }
242
+ }}
243
+ items={items}
244
+ anchor={
245
+ <Button
246
+ variant="ghost"
247
+ size="sm"
248
+ className={`dsh-kanban-input-chip ${open ? "is-pressed" : ""}`}
249
+ title={
250
+ isRunning
251
+ ? "Task is in progress"
252
+ : `Kanban: ${laneLabel} (click to transition)`
253
+ }
254
+ aria-label={
255
+ isRunning
256
+ ? "Task is in progress"
257
+ : `Kanban: ${laneLabel} (click to transition)`
258
+ }
259
+ aria-haspopup="menu"
260
+ aria-expanded={open}
261
+ aria-pressed={open}
262
+ disabled={isRunning}
263
+ icon={<KanbanIcon size={18} strokeWidth={1} />}
264
+ onClick={(event) => {
265
+ event.stopPropagation();
266
+ if (!isRunning) {
267
+ setOpen((prev) => !prev);
268
+ }
269
+ }}
270
+ >
271
+ <KanbanStatusDot state={lane} />
272
+ <IconChevronDownOutlineRegular
273
+ size={12}
274
+ className="dsh-kanban-input-chip-chevron"
275
+ aria-hidden="true"
276
+ />
277
+ </Button>
278
+ }
279
+ />
280
+ );
281
+ }
@@ -0,0 +1,72 @@
1
+ import { Menu } from "@deepseek-ai/dsh-client-ui-primitives";
2
+ import { useState } from "react";
3
+ import type { KanbanRecord } from "../types.ts";
4
+
5
+ /**
6
+ * Purpose: Show collected session links in a shared icon-triggered popover.
7
+ * Contract:
8
+ * - Inputs: Validated projected links sorted by priority and collection order for ties.
9
+ * - Outputs: An accessible link menu, hidden for an empty collection.
10
+ * - Throws / Errors: Browser navigation errors propagate.
11
+ */
12
+ export function SessionLinks({
13
+ links,
14
+ }: {
15
+ readonly links: KanbanRecord["links"];
16
+ }) {
17
+ const [open, setOpen] = useState(false);
18
+ return (
19
+ links.length > 0 && (
20
+ <Menu
21
+ open={open}
22
+ portal
23
+ compact
24
+ align="end"
25
+ className="dsh-session-links"
26
+ listClassName="dsh-session-links-menu"
27
+ onClose={() => setOpen(false)}
28
+ onSelect={(url) => {
29
+ window.open(url, "_blank", "noopener,noreferrer");
30
+ setOpen(false);
31
+ }}
32
+ items={links.map((link) => ({
33
+ id: link.url,
34
+ label: <span className="dsh-session-link">{link.label}</span>,
35
+ }))}
36
+ anchor={
37
+ <button
38
+ type="button"
39
+ className="dsh-inflight-btn-action dsh-session-links-trigger"
40
+ aria-label={`Session links (${links.length})`}
41
+ title="Session links"
42
+ aria-haspopup="menu"
43
+ aria-expanded={open}
44
+ onClick={(event) => {
45
+ event.stopPropagation();
46
+ setOpen(!open);
47
+ }}
48
+ onDragStart={(event) => {
49
+ event.preventDefault();
50
+ event.stopPropagation();
51
+ }}
52
+ >
53
+ <svg
54
+ width="14"
55
+ height="14"
56
+ viewBox="0 0 24 24"
57
+ fill="none"
58
+ stroke="currentColor"
59
+ strokeWidth="2"
60
+ strokeLinecap="round"
61
+ strokeLinejoin="round"
62
+ aria-hidden="true"
63
+ >
64
+ <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" />
65
+ <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />
66
+ </svg>
67
+ </button>
68
+ }
69
+ />
70
+ )
71
+ );
72
+ }
@@ -0,0 +1,30 @@
1
+ /** Ambient runtime type augmentations for DSH Kanban. */
2
+ import type {} from "@deepseek-ai/dsh-api-remotes/client";
3
+ import type {} from "@deepseek-ai/dsh-api-workspace-controller/client";
4
+ import type {} from "@deepseek-ai/dsh-client-ui-chat/client";
5
+ import type {} from "@deepseek-ai/dsh-client-ui-conversation/client";
6
+ import type {} from "@deepseek-ai/dsh-client-ui-layout/client";
7
+ import type {} from "@deepseek-ai/dsh-client-ui-renderer/client";
8
+ import type {} from "@deepseek-ai/dsh-client-ui-session/client";
9
+ import type {} from "@deepseek-ai/dsh-client-ui-sidebar/client";
10
+ import type {} from "@deepseek-ai/dsh-client-ui-workspace/client";
11
+ import type {} from "@lukstei/dsh-client-split-view/client-contract";
12
+
13
+ export type {
14
+ IWorkspaces,
15
+ WorkspaceId,
16
+ WorkspaceSnapshot,
17
+ WorkspaceView,
18
+ } from "@deepseek-ai/dsh-api-workspace-controller/client";
19
+
20
+ declare module "@deepseek-ai/cordis" {
21
+ interface Context {
22
+ sidebarMode: import("./sidebar-mode.ts").SidebarModeStore;
23
+ }
24
+ }
25
+
26
+ declare module "@deepseek-ai/dsh-api-session-controller/client" {
27
+ interface SessionReferenceSourceMap {
28
+ kanban: unknown;
29
+ }
30
+ }