@lukstei/dsh-session-handoff 0.2.2-rc.5.4 → 0.2.2-rc.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -96,7 +96,7 @@ Id resolution: exact id first, then unique prefix over `sessionQuery.listSession
96
96
  1. Renders this session's brief.
97
97
  2. Creates a session via `sessionController.create()` in the current workspace (falls back to `cwd` when the session has no workspace), same `agentPreset`.
98
98
  3. Replays the current model selection onto the new agent.
99
- 4. Titles it `<source title> - Handoff` (or `Handoff <first 8 id chars>` when untitled). A user title pins it against auto-generated titles.
99
+ 4. Titles it with the full source title (or `Handoff <first 8 id chars>` when untitled) and renames the source to `<title> (Resumed)` unless it already ends with that. A user title pins it against auto-generated titles. Adds a Kanban link `Resumed from <source id>` (`dsh://sessions/<id>`, opens the source session) to record the origin.
100
100
  5. Runs `/kanban {"action":"init","createdAt":…}` against the new agent so it appears on the Kanban board. No `prompt` is sent, since that would seed the composer draft with the follow-up text.
101
101
  6. Copies the source session's kanban links by replaying its `add-link` commands against the new agent.
102
102
  7. Writes `HANDOFF.md` into the new session's scratch directory and queues the read-the-brief follow-up.
@@ -134,7 +134,7 @@ Files:
134
134
  Details:
135
135
 
136
136
  - The command declares `input: { hint: "[session-id]" }`. Without a declared input the client sends the raw line to the model as a prompt and the handler never runs.
137
- - A slash command has no structured return channel to the client, so the Host encodes the new id in the command result text, which is persisted in the `command/done` event. The client subscribes to every open session's event source and calls `ctx.splitView.toggleSession()` when it sees a successful `command/done` starting with `Handoff launched: `. It then sends `/kanban {"action":"done"}` to the source session and calls `ctx.splitView.removeSession()` on it, as the Kanban Done button does. A source never initialised in Kanban ignores the done action but still loses its pane.
137
+ - A slash command has no structured return channel to the client, so the Host encodes the new id in the command result text, which is persisted in the `command/done` event. The client subscribes to every open session's event source and calls `ctx.splitView.replaceSession()` when it sees a successful `command/done` starting with `Handoff launched: `, replacing the pane in-place atomically. It then sends `/kanban {"action":"done"}` to the source session, as the Kanban Done button does. A source never initialised in Kanban ignores the done action.
138
138
  - The pane is added through the split store, not `uiWorkspace.openSession()`. The split view patches that method into a read-only overlay without its own composer, so prompts would keep landing in the pane underneath.
139
139
  - The client reacts only to `append` changes. A `replace` replays the whole window on first open and after reconnect gaps and would reopen panes the user closed; the split view restores its panes from local storage.
140
140
  - Kanban membership is a session-log fact: the board lists only sessions whose `kanban` projection is initialized, which happens when `/kanban` runs in that session. Hence the explicit `init`.
package/dist/client.js CHANGED
@@ -4,6 +4,7 @@ window.__ModuleLoader__.load({
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
6
6
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
+ let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
7
8
  let react = require("react");
8
9
  /**
9
10
  * The launched Session id carried by one durable event, or `undefined` when the
@@ -37,12 +38,12 @@ window.__ModuleLoader__.load({
37
38
  /** Anthropic prompt-cache TTL: past this idle gap the next turn re-writes the whole context. */
38
39
  const CACHE_TTL_MS = 3e5;
39
40
  const WARM = {
40
- soft: 7e4,
41
- strong: 1e5
41
+ soft: 1e5,
42
+ strong: 15e4
42
43
  };
43
44
  const COLD = {
44
- soft: 4e4,
45
- strong: 7e4
45
+ soft: 7e4,
46
+ strong: 1e5
46
47
  };
47
48
  const SOFT_WINDOW_SHARE = .6;
48
49
  const STRONG_WINDOW_SHARE = .8;
@@ -58,8 +59,8 @@ window.__ModuleLoader__.load({
58
59
  soft: "#d9a400",
59
60
  strong: "#d62839"
60
61
  };
61
- /** Small ring beside the send button once the session is big enough that `/handoff` pays off. */
62
- function HandoffRing({ sessionId, useProjection, useSession }) {
62
+ /** Gauge icon beside the send button once the session is big enough that `/handoff` pays off. */
63
+ function HandoffRing({ sessionId, useProjection, useSession, onHandoff }) {
63
64
  const pressure = useProjection("contextPressure");
64
65
  const running = useSession((session) => session.running);
65
66
  const [acp, setAcp] = (0, react.useState)(void 0);
@@ -89,19 +90,23 @@ window.__ModuleLoader__.load({
89
90
  }, [tokens, running]);
90
91
  const level = handoffLevel(tokens, window, cold);
91
92
  if (level === "none" || tokens === void 0) return null;
92
- const k = Math.round(tokens / 1e3);
93
- return (0, react.createElement)("span", {
94
- role: "img",
95
- title: `Context ${k}k tokens: ${cold ? "cache is cold, a fresh session is cheaper now" : "consider a fresh session"} (/handoff)`,
96
- "aria-label": `Handoff ${level === "strong" ? "recommended" : "suggested"}`,
97
- style: {
98
- width: 14,
99
- height: 14,
100
- boxSizing: "border-box",
101
- borderRadius: "50%",
102
- border: `2px solid ${COLOR[level]}`,
103
- flex: "none"
104
- }
93
+ const label = `Context ${Math.round(tokens / 1e3)}k tokens: ${cold ? "cache is cold, a fresh session is cheaper now" : "consider a fresh session"}. Click to hand off (/handoff)`;
94
+ return (0, react.createElement)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
95
+ label,
96
+ side: "top",
97
+ portal: true,
98
+ children: (0, react.createElement)(_deepseek_ai_dsh_client_ui_primitives.Button, {
99
+ variant: "ghost",
100
+ size: "sm",
101
+ "aria-label": label,
102
+ style: {
103
+ color: COLOR[level],
104
+ padding: 0,
105
+ width: 28
106
+ },
107
+ icon: (0, react.createElement)(_deepseek_ai_dsh_client_ui_primitives.IconGaugeOutlineMedium, { size: 16 }),
108
+ onClick: () => void onHandoff(sessionId)
109
+ })
105
110
  });
106
111
  }
107
112
  // src/client/index.ts
@@ -124,14 +129,18 @@ window.__ModuleLoader__.load({
124
129
  function apply(ctx) {
125
130
  const sessions = ctx.sessions;
126
131
  const off = /* @__PURE__ */ new Map();
127
- const finish = async (id) => {
132
+ const markDone = async (id) => {
128
133
  await sessions.using(id, { source: "splitView" }, async (reference) => {
129
134
  await reference.binding.session.command(`/kanban ${JSON.stringify({
130
135
  action: "done",
131
136
  doneAt: Date.now()
132
137
  })}`);
133
138
  });
134
- ctx.splitView.removeSession(id);
139
+ };
140
+ const handoff = async (id) => {
141
+ await sessions.using(id, { source: "splitView" }, async (reference) => {
142
+ await reference.binding.session.command("/handoff");
143
+ });
135
144
  };
136
145
  const watch = (id) => {
137
146
  const binding = sessions.binding(id);
@@ -143,8 +152,8 @@ window.__ModuleLoader__.load({
143
152
  if (entry.type !== "event") continue;
144
153
  const launched = launchedSessionId(entry.event);
145
154
  if (launched === void 0) continue;
146
- ctx.splitView.toggleSession(launched);
147
- finish(id);
155
+ ctx.splitView.replaceSession(id, launched);
156
+ markDone(id);
148
157
  return;
149
158
  }
150
159
  });
@@ -164,8 +173,8 @@ window.__ModuleLoader__.load({
164
173
  ctx.effect(() => ctx.slots.inject("conversation.input.right", () => ctx.slots.register({
165
174
  name: "conversation.input.right",
166
175
  id: "session-handoff.ring",
167
- order: 90,
168
- inject: () => ({})
176
+ order: 1e3,
177
+ inject: () => ({ onHandoff: handoff })
169
178
  }, HandoffRing)), "session-handoff: handoff ring");
170
179
  ctx.inject(["remote", "remote.dshAcp"], (acpCtx) => {
171
180
  const remote = acpCtx.remote.dshAcp;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lukstei/dsh-session-handoff",
3
- "version": "0.2.2-rc.5.4",
3
+ "version": "0.2.2-rc.5.5",
4
4
  "description": "Session handoff brief command for DSH",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -39,13 +39,14 @@
39
39
  }
40
40
  },
41
41
  "dependencies": {
42
- "@lukstei/dsh-scratch-dir": "0.2.2-rc.5.4"
42
+ "@lukstei/dsh-scratch-dir": "0.2.2-rc.5.5"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@deepseek-ai/cordis": "*",
46
46
  "@deepseek-ai/dsh-agent": "*",
47
47
  "@deepseek-ai/dsh-api-session-controller": "*",
48
48
  "@deepseek-ai/dsh-client-ui-conversation": "*",
49
+ "@deepseek-ai/dsh-client-ui-primitives": "*",
49
50
  "@deepseek-ai/dsh-client-ui-renderer": "*",
50
51
  "@deepseek-ai/dsh-client-ui-session": "*",
51
52
  "@deepseek-ai/dsh-client-ui-slots": "*",
@@ -65,6 +66,7 @@
65
66
  "@deepseek-ai/dsh-agent": "0.2.2-rc.5",
66
67
  "@deepseek-ai/dsh-api-session-controller": "0.2.2-rc.5",
67
68
  "@deepseek-ai/dsh-client-ui-conversation": "0.2.2-rc.5",
69
+ "@deepseek-ai/dsh-client-ui-primitives": "0.2.2-rc.5",
68
70
  "@deepseek-ai/dsh-client-ui-renderer": "0.2.2-rc.5",
69
71
  "@deepseek-ai/dsh-client-ui-session": "0.2.2-rc.5",
70
72
  "@deepseek-ai/dsh-client-ui-slots": "0.2.2-rc.5",
@@ -76,7 +78,7 @@
76
78
  "@deepseek-ai/dsh-token-meter": "0.2.2-rc.5",
77
79
  "@deepseek-ai/dsh-working-directory": "0.2.2-rc.5",
78
80
  "@deepseek-ai/dsh-workspace": "0.2.2-rc.5",
79
- "@lukstei/dsh-client-split-view": "0.2.2-rc.5.4",
81
+ "@lukstei/dsh-client-split-view": "0.2.2-rc.5.5",
80
82
  "@types/node": "^26.0.0",
81
83
  "@types/react": "^19.3.0",
82
84
  "@zaimokuza/dsh-acp-adapter": "0.2.2-rc.5.2",
@@ -28,14 +28,20 @@ export function apply(ctx: Context): void {
28
28
  const sessions = ctx.sessions as unknown as ISessions;
29
29
  const off = new Map<SessionId, () => void>();
30
30
 
31
- // Same effect as the Kanban Done button: record done, then close the pane.
32
- const finish = async (id: SessionId): Promise<void> => {
31
+ // Same effect as the Kanban Done button: record done.
32
+ const markDone = async (id: SessionId): Promise<void> => {
33
33
  await sessions.using(id, { source: "splitView" }, async (reference) => {
34
34
  await reference.binding.session.command(
35
35
  `/kanban ${JSON.stringify({ action: "done", doneAt: Date.now() })}`,
36
36
  );
37
37
  });
38
- ctx.splitView.removeSession(id);
38
+ };
39
+
40
+ // Same command the user would type; sent directly so the composer draft stays untouched.
41
+ const handoff = async (id: SessionId): Promise<void> => {
42
+ await sessions.using(id, { source: "splitView" }, async (reference) => {
43
+ await reference.binding.session.command("/handoff");
44
+ });
39
45
  };
40
46
 
41
47
  const watch = (id: SessionId): void => {
@@ -51,8 +57,8 @@ export function apply(ctx: Context): void {
51
57
  if (entry.type !== "event") continue;
52
58
  const launched = launchedSessionId(entry.event);
53
59
  if (launched === undefined) continue;
54
- ctx.splitView.toggleSession(launched);
55
- void finish(id);
60
+ ctx.splitView.replaceSession(id, launched);
61
+ void markDone(id);
56
62
  return;
57
63
  }
58
64
  });
@@ -78,8 +84,8 @@ export function apply(ctx: Context): void {
78
84
  {
79
85
  name: "conversation.input.right",
80
86
  id: "session-handoff.ring",
81
- order: 90,
82
- inject: () => ({}),
87
+ order: 1000,
88
+ inject: () => ({ onHandoff: handoff }),
83
89
  },
84
90
  HandoffRing,
85
91
  ),
@@ -5,8 +5,8 @@ export const CACHE_TTL_MS = 5 * 60_000;
5
5
 
6
6
  // Absolute prompt sizes, tuned by cost: a fresh session starts near 18k tokens, so a handoff
7
7
  // pays back sooner the more context a turn re-sends. A cold cache lowers both bars.
8
- const WARM = { soft: 70_000, strong: 100_000 };
9
- const COLD = { soft: 40_000, strong: 70_000 };
8
+ const WARM = { soft: 100_000, strong: 150_000 };
9
+ const COLD = { soft: 70_000, strong: 100_000 };
10
10
  // The window still caps the bars, so small-window models warn before compaction does.
11
11
  const SOFT_WINDOW_SHARE = 0.6;
12
12
  const STRONG_WINDOW_SHARE = 0.8;
@@ -1,3 +1,8 @@
1
+ import {
2
+ Button,
3
+ IconGaugeOutlineMedium,
4
+ Tooltip,
5
+ } from "@deepseek-ai/dsh-client-ui-primitives";
1
6
  import type {} from "@deepseek-ai/dsh-client-ui-session/client";
2
7
  import type { SessionStandardProps } from "@deepseek-ai/dsh-client-ui-slots";
3
8
  import type {} from "@deepseek-ai/dsh-token-meter/client";
@@ -16,12 +21,15 @@ import { CACHE_TTL_MS, handoffLevel } from "./level.ts";
16
21
 
17
22
  const COLOR = { soft: "#d9a400", strong: "#d62839" } as const;
18
23
 
19
- /** Small ring beside the send button once the session is big enough that `/handoff` pays off. */
24
+ /** Gauge icon beside the send button once the session is big enough that `/handoff` pays off. */
20
25
  export function HandoffRing({
21
26
  sessionId,
22
27
  useProjection,
23
28
  useSession,
24
- }: Pick<SessionStandardProps, "sessionId" | "useProjection" | "useSession">) {
29
+ onHandoff,
30
+ }: Pick<SessionStandardProps, "sessionId" | "useProjection" | "useSession"> & {
31
+ onHandoff: (sessionId: SessionStandardProps["sessionId"]) => Promise<void>;
32
+ }) {
25
33
  const pressure = useProjection("contextPressure");
26
34
  const running = useSession((session) => session.running);
27
35
  const [acp, setAcp] = useState<AcpUsage | undefined>(undefined);
@@ -69,17 +77,20 @@ export function HandoffRing({
69
77
  const hint = cold
70
78
  ? "cache is cold, a fresh session is cheaper now"
71
79
  : "consider a fresh session";
72
- return createElement("span", {
73
- role: "img",
74
- title: `Context ${k}k tokens: ${hint} (/handoff)`,
75
- "aria-label": `Handoff ${level === "strong" ? "recommended" : "suggested"}`,
76
- style: {
77
- width: 14,
78
- height: 14,
79
- boxSizing: "border-box",
80
- borderRadius: "50%",
81
- border: `2px solid ${COLOR[level]}`,
82
- flex: "none",
83
- },
80
+ const label = `Context ${k}k tokens: ${hint}. Click to hand off (/handoff)`;
81
+ return createElement(Tooltip, {
82
+ label,
83
+ side: "top",
84
+ portal: true,
85
+ // biome-ignore lint/correctness/noChildrenProp: Tooltip types `children` as a required prop, which createElement's 3rd argument does not satisfy
86
+ children: createElement(Button, {
87
+ variant: "ghost",
88
+ size: "sm",
89
+ "aria-label": label,
90
+ // the icon strokes with currentColor; 28px square instead of the text-button padding
91
+ style: { color: COLOR[level], padding: 0, width: 28 },
92
+ icon: createElement(IconGaugeOutlineMedium, { size: 16 }),
93
+ onClick: () => void onHandoff(sessionId),
94
+ }),
84
95
  });
85
96
  }
package/src/index.ts CHANGED
@@ -34,6 +34,7 @@ export const inject = [
34
34
  const HANDOFF_FILE = "HANDOFF.md";
35
35
  const RECENT_LIMIT = 5;
36
36
  const SHORT_ID_LENGTH = 8;
37
+ const RESUMED_SUFFIX = " (Resumed)";
37
38
 
38
39
  export function apply(ctx: Context): void {
39
40
  ctx.commands.register({
@@ -264,8 +265,17 @@ async function createBeside(
264
265
  agent.session,
265
266
  sourceTitle === undefined
266
267
  ? `Handoff ${shortId(targetId)}`
267
- : `${sourceTitle.title} - Handoff`,
268
+ : sourceTitle.title,
268
269
  );
270
+ if (
271
+ sourceTitle !== undefined &&
272
+ !sourceTitle.title.endsWith(RESUMED_SUFFIX)
273
+ ) {
274
+ ctx.sessionTitle.rename(
275
+ source.session,
276
+ `${sourceTitle.title}${RESUMED_SUFFIX}`,
277
+ );
278
+ }
269
279
 
270
280
  // edge case: a session the controller creates carries no kanban marker, so the
271
281
  // board would never list it; this is the init kanban's own client sends.
@@ -282,6 +292,19 @@ async function createBeside(
282
292
  await ctx.commands.execute(agent, `/kanban ${args}`, [], signal);
283
293
  }
284
294
 
295
+ const sourceLink = {
296
+ action: "add-link",
297
+ label: `Resumed from ${targetId}`,
298
+ url: `dsh://sessions/${targetId}`,
299
+ priority: 0,
300
+ };
301
+ await ctx.commands.execute(
302
+ agent,
303
+ `/kanban ${JSON.stringify(sourceLink)}`,
304
+ [],
305
+ signal,
306
+ );
307
+
285
308
  await deliver(ctx, agent, targetId, markdown);
286
309
  return created;
287
310
  }