dsh-enhance 0.3.8 → 0.3.9

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.
Files changed (4) hide show
  1. package/README.md +201 -36
  2. package/lib/client.js +1177 -81
  3. package/lib/index.js +45 -44
  4. package/package.json +2 -1
package/lib/client.js CHANGED
@@ -9,7 +9,7 @@ window.__ModuleLoader__.load({
9
9
  let react_jsx_runtime = require("react/jsx-runtime");
10
10
  // src/client/styles/document-preview.ts
11
11
  /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
12
- const css$7 = String.raw`body[data-ds-dark-theme] [data-document-markdown] {
12
+ const css$9 = String.raw`body[data-ds-dark-theme] [data-document-markdown] {
13
13
  --md-text: #e9e9e9;
14
14
  --md-text-strong: #fff;
15
15
  --md-text-muted: #a5a5a5;
@@ -191,7 +191,7 @@ body:not([data-ds-dark-theme]) [data-document-markdown] {
191
191
  `;
192
192
  // src/client/styles/chat-markdown.ts
193
193
  /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
194
- const css$6 = String.raw`:is([data-ds-dark-theme], [data-ds-dark-theme] body) :is([data-chat-flow-kind="assistant-step"], [class*="_markdown"]) {
194
+ const css$8 = String.raw`:is([data-ds-dark-theme], [data-ds-dark-theme] body) :is([data-chat-flow-kind="assistant-step"], [class*="_markdown"]) {
195
195
  --md-text: #efefef;
196
196
  --md-text-strong: #fff;
197
197
  --md-text-muted: #a5a5a5;
@@ -425,7 +425,7 @@ body:not([data-ds-dark-theme]) [data-document-markdown] {
425
425
  `;
426
426
  // src/client/styles/rightbar-handle.ts
427
427
  /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
428
- const css$5 = String.raw`[data-side="rightbar"] {
428
+ const css$7 = String.raw`[data-side="rightbar"] {
429
429
  width: 18px !important;
430
430
  margin-left: -9px !important;
431
431
  cursor: col-resize;
@@ -457,7 +457,7 @@ body:not([data-ds-dark-theme]) [data-document-markdown] {
457
457
  `;
458
458
  // src/client/styles/running-spinner.ts
459
459
  /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
460
- const css$4 = String.raw`/* A running session's marker is the host's StateDot in its "ongoing" form: an
460
+ const css$6 = String.raw`/* A running session's marker is the host's StateDot in its "ongoing" form: an
461
461
  inline SVG holding two circles — a faint track and a dashed arc that spins
462
462
  and lengthens. Both circles stroke with currentColor, and the host paints
463
463
  that token as label-tertiary, a grey, so a live session reads exactly as
@@ -506,7 +506,7 @@ body:not([data-ds-dark-theme]) [data-document-markdown] {
506
506
  `;
507
507
  // src/client/styles/sidebar-density.ts
508
508
  /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
509
- const css$3 = String.raw`/* Workspace rows: swap the folder icon for the disclosure triangle in every
509
+ const css$5 = String.raw`/* Workspace rows: swap the folder icon for the disclosure triangle in every
510
510
  state, not only on hover.
511
511
 
512
512
  The row already renders both slots — a folder span followed by a chevron span
@@ -690,7 +690,7 @@ body[data-ds-dark-theme] [class*="sidebarCol"] {
690
690
  `;
691
691
  // src/client/styles/sidebar-layout.ts
692
692
  /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
693
- const css$2 = String.raw`[class*="sidebarCol"] [class*="_root"] { position: relative !important; }
693
+ const css$4 = String.raw`[class*="sidebarCol"] [class*="_root"] { position: relative !important; }
694
694
  [class*="sidebarCol"] [class*="logoRow"] { display: none !important; }
695
695
  /* New Session bar removed by local preference: hides it in both the expanded
696
696
  sidebar and the collapsed rail. Sessions are still created with the app's
@@ -1173,7 +1173,7 @@ body[data-ds-dark-theme] .dsh-enhance-bubble {
1173
1173
  `;
1174
1174
  // src/client/styles/toolbar.ts
1175
1175
  /** Global presentation owned by dsh-enhance: annotation popover and tray. */
1176
- const css$1 = String.raw`/* The passage being annotated, painted through the Custom Highlight API so the
1176
+ const css$3 = String.raw`/* The passage being annotated, painted through the Custom Highlight API so the
1177
1177
  mark survives focus moving into the note field (a native selection would not).
1178
1178
  Same blue as the app's document selection, so it reads as the same gesture. */
1179
1179
  ::highlight(dsh-enhance-annotation) {
@@ -2099,7 +2099,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2099
2099
  `;
2100
2100
  // src/client/styles/file-menu.ts
2101
2101
  /** Right-click file menu: a small native-looking panel over the transcript. */
2102
- const css = String.raw`/* The menu is appended to body, outside every chat container, so it needs
2102
+ const css$2 = String.raw`/* The menu is appended to body, outside every chat container, so it needs
2103
2103
  its own type scale and surface. The dark variant keys off the same theme
2104
2104
  attribute the other sheets use, which the app sets on html or body. */
2105
2105
  .dsh-file-menu {
@@ -2230,22 +2230,594 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2230
2230
  color: #f2f2f4 !important;
2231
2231
  }
2232
2232
  `;
2233
+ // src/client/surfaces/ds-bot/chrome.ts
2234
+ /** DS Bot-only chrome. Shared Markdown and annotation sheets are unchanged.
2235
+ * The desktop preload sets data-windows-titlebar, caption height 40px and
2236
+ * --dsh-frame-chrome-top:0px: the viewport reaches the native window top.
2237
+ * material.css pads the chat column by the caption height; remove that padding
2238
+ * so the host's absolute header can keep its horizontal layout at top:20px.
2239
+ */
2240
+ const CORNER_ROW = ":is(.bt-pane, .bt-panel) .bt-drawer-top";
2241
+ const PILL_HEADER = "header[class*=\"_header\"]:has(.bt-head)";
2242
+ const css$1 = `
2243
+ /* Keep user messages on the current theme's surface instead of an inverted
2244
+ black/white slab. Theme inks retain readable text and adapt to custom themes. */
2245
+ body {
2246
+ --bt-user: color-mix(in srgb, var(--bt-ink) 7%, var(--bt-main)) !important;
2247
+ --bt-user-ink: var(--bt-ink) !important;
2248
+ }
2249
+ body[data-ds-dark-theme] {
2250
+ --bt-user: color-mix(in srgb, var(--bt-ink) 12%, var(--bt-main)) !important;
2251
+ }
2252
+
2253
+ /* Shift the entire sidebar stack, including the list, with its action row.
2254
+ The native traffic-light/sidebar switch belongs to another shell element.
2255
+ The row sits in the 40px caption band: its buttons are 30px, starting at
2256
+ 5px so their centre (20px) lines up with the 14px traffic lights. */
2257
+ .bt-leftcol {
2258
+ padding-top: 5px !important;
2259
+ }
2260
+ .bt-leftcol .bt-side-top {
2261
+ padding-top: 0 !important;
2262
+ padding-right: 0 !important;
2263
+ gap: 3px !important;
2264
+ -webkit-app-region: no-drag !important;
2265
+ }
2266
+ .bt-leftcol .bt-side-top button {
2267
+ -webkit-app-region: no-drag !important;
2268
+ width: 30px !important;
2269
+ height: 30px !important;
2270
+ }
2271
+ .bt-leftcol .bt-side-top .bt-round svg {
2272
+ width: 18px !important;
2273
+ height: 18px !important;
2274
+ }
2275
+
2276
+ /* The visible inner corner belongs to the chat column, not .bt-leftcol.
2277
+ Removing its caption padding also keeps the header inside its clipping root. */
2278
+ html[data-windows-titlebar] div[class*="_centerCol"] {
2279
+ padding-top: 0 !important;
2280
+ border-top-left-radius: 0 !important;
2281
+ }
2282
+
2283
+ /* Desktop material.css reserves a second caption band on the host's right
2284
+ column using a 40px top border. File, browser and terminal tabs share this
2285
+ column; let their own tab-strip padding supply the top clearance instead. */
2286
+ html[data-windows-titlebar] div[class*="_rightbarCol"] {
2287
+ border-top: 0 !important;
2288
+ }
2289
+
2290
+ /* With that 40px band gone the dockkit tab strip sits inside the native
2291
+ title-bar drag region. The host marks the strip itself as a window drag
2292
+ handle (data-window-drag → app-region: drag), so the strip's own padding,
2293
+ the gap between tabs and the empty span beside the buttons all drag the
2294
+ window: a click there moves the window instead of reaching the bar, and the
2295
+ whole row reads as dead. Make the entire strip — tabs, close, +, split,
2296
+ fullscreen, collapse and the space around them — one no-drag island.
2297
+ Nothing is repositioned, so the removed 40px blank band stays gone. */
2298
+ html[data-windows-titlebar] [class*="_tabStrip_"],
2299
+ html[data-windows-titlebar] [class*="_tabStrip_"] *,
2300
+ html[data-windows-titlebar] [class*="_stripTabs_"],
2301
+ html[data-windows-titlebar] [class*="_stripChrome_"],
2302
+ html[data-windows-titlebar] [class*="_tab_"],
2303
+ html[data-windows-titlebar] [class*="_tabClose_"],
2304
+ html[data-windows-titlebar] [class*="_addTab_"] {
2305
+ -webkit-app-region: no-drag !important;
2306
+ }
2307
+
2308
+ /* The composer's "/" command menu is nested inside the composer card, which
2309
+ sets its own backdrop-filter. A backdrop-filter turns its element into a
2310
+ backdrop root, so the menu material's own backdrop-filter (the host declares
2311
+ blur(40px)) has nothing to sample and never paints: the conversation text
2312
+ behind the menu reads straight through it. Drop the card's blur only while
2313
+ one of the composer's trigger menus is open, so the menu can sample the page
2314
+ again and its declared blur finally frosts out the text behind it. The card's
2315
+ blur returns as soon as the menu closes; the title pill and every menu that
2316
+ is not rendered inside the composer card are untouched. */
2317
+ [data-composer-card]:has([data-trigger-menu]) {
2318
+ -webkit-backdrop-filter: none !important;
2319
+ backdrop-filter: none !important;
2320
+ }
2321
+
2322
+ /* Keep the user's settled 12px top offset. Absolute positioning preserves
2323
+ the host's horizontal centring as the sidebar and detail panel resize. */
2324
+ ${PILL_HEADER} {
2325
+ top: 12px !important;
2326
+ padding: 0 !important;
2327
+ }
2328
+
2329
+ /* The host's fading header backdrop must not paint a horizontal light band,
2330
+ and its 60px-tall ::before band also intercepted clicks over the pill's top
2331
+ half (only the bottom sliver stayed hittable). Remove it entirely. */
2332
+ ${PILL_HEADER}::before {
2333
+ content: none !important;
2334
+ background: none !important;
2335
+ height: 0 !important;
2336
+ pointer-events: none !important;
2337
+ }
2338
+
2339
+ /* Keep the pill fully clickable: the header/head pass clicks through except on
2340
+ the pill itself, and the pill is never a window-drag handle. */
2341
+ ${PILL_HEADER} .bt-head {
2342
+ height: 50px !important;
2343
+ pointer-events: none !important;
2344
+ }
2345
+ ${PILL_HEADER} .bt-pill,
2346
+ ${PILL_HEADER} .bt-pill * {
2347
+ pointer-events: auto !important;
2348
+ -webkit-app-region: no-drag !important;
2349
+ }
2350
+
2351
+ /* Liquid glass on the session-title pill, ported from
2352
+ lucasromerodb/liquid-glass-effect-macos (the source behind the user's
2353
+ CodeSandbox reference nn5q2y; that repo ships no LICENSE and is used as an
2354
+ effect reference only). The reference layers one clipped shape as:
2355
+ effect layer - backdrop-filter: blur(3px) AND filter: url(#glass-distortion)
2356
+ on the SAME element, so the backdrop is softened first and
2357
+ bent afterwards by the turbulence displacement map;
2358
+ tint layer - a flat white 25% film over the bend;
2359
+ shine layer - two inset white shadows that draw the lit lip;
2360
+ text layer - the content, above every layer.
2361
+ Here the effect layer is ::before, the tint and the shine share ::after, and
2362
+ the pill's own box clips both to the capsule. The pill carries no border: the
2363
+ reference has none, and its only outline is the shine. The soft drop shadow
2364
+ is kept light. Padding grows by 5px on each side; height grows accordingly
2365
+ so the avatar and title keep the same space inside the capsule. */
2366
+ ${PILL_HEADER} .bt-pill {
2367
+ position: relative !important;
2368
+ height: 50px !important;
2369
+ padding: 12.5px 18.5px 12.5px 12.5px !important;
2370
+ /* Own the silhouette instead of inheriting a host/theme corner radius. */
2371
+ border-radius: 9999px !important;
2372
+ corner-shape: round !important;
2373
+ overflow: hidden !important;
2374
+ background: transparent !important;
2375
+ -webkit-backdrop-filter: none !important;
2376
+ backdrop-filter: none !important;
2377
+ --dsh-lg-tint: rgba(255, 255, 255, .25);
2378
+ /* No border: the reference draws the edge with the shine layer alone. */
2379
+ border: none !important;
2380
+ box-shadow:
2381
+ 0 2px 5px rgba(0, 0, 0, .10),
2382
+ 0 0 8px rgba(0, 0, 0, .04) !important;
2383
+ }
2384
+
2385
+ /* Dark glass takes a much lighter white tint: the backdrop is already dark, and
2386
+ the reference's 25% film over it turns the pill into a grey card. */
2387
+ body[data-ds-dark-theme] ${PILL_HEADER} .bt-pill {
2388
+ --dsh-lg-tint: rgba(255, 255, 255, .08);
2389
+ box-shadow:
2390
+ 0 3px 3px rgba(0, 0, 0, .34),
2391
+ 0 0 10px rgba(0, 0, 0, .18) !important;
2392
+ }
2393
+
2394
+ /* The glass itself: the softening pass and the bend ride the same element, as
2395
+ in the reference. The bend uses the plain filter property because Chromium
2396
+ drops a url() from backdrop-filter; the unset variable keeps this at none, so
2397
+ the frosted fallback still works. */
2398
+ ${PILL_HEADER} .bt-pill::before {
2399
+ content: "" !important;
2400
+ position: absolute !important;
2401
+ inset: 0 !important;
2402
+ z-index: 0 !important;
2403
+ border-radius: inherit !important;
2404
+ corner-shape: round !important;
2405
+ overflow: hidden !important;
2406
+ isolation: isolate !important;
2407
+ -webkit-backdrop-filter: var(--dsh-lg-backdrop, blur(3px)) !important;
2408
+ backdrop-filter: var(--dsh-lg-backdrop, blur(3px)) !important;
2409
+ -webkit-filter: var(--dsh-lg-filter, none) !important;
2410
+ filter: var(--dsh-lg-filter, none) !important;
2411
+ pointer-events: none !important;
2412
+ }
2413
+
2414
+ /* The body of the glass and its lip: the reference's flat white film plus its
2415
+ two inset shines, one catching the light on the top-left curve and one
2416
+ holding the bottom-right edge. That pair is what makes the outline read as
2417
+ a thin bright lip at 1x; a single top highlight only brightens the top. */
2418
+ ${PILL_HEADER} .bt-pill::after {
2419
+ content: "" !important;
2420
+ position: absolute !important;
2421
+ inset: 0 !important;
2422
+ z-index: 2 !important;
2423
+ border-radius: inherit !important;
2424
+ corner-shape: round !important;
2425
+ background: var(--dsh-lg-tint) !important;
2426
+ box-shadow:
2427
+ inset .5px .5px .75px 0 rgba(255, 255, 255, .45),
2428
+ inset -.5px -.5px .75px 0 rgba(255, 255, 255, .28) !important;
2429
+ pointer-events: none !important;
2430
+ }
2431
+
2432
+ /* Avatar, name and back arrow sit above both layers so the text stays crisp
2433
+ instead of getting washed by the tint. */
2434
+ ${PILL_HEADER} .bt-pill > * {
2435
+ position: relative !important;
2436
+ z-index: 3 !important;
2437
+ }
2438
+
2439
+ /* A single gentle squash-and-stretch on entry, then settle at the original
2440
+ size. The outer header stays still, preserving centring and hit geometry. */
2441
+ @keyframes dsh-pill-pop {
2442
+ 0% { transform: scale(1); }
2443
+ 35% { transform: scale(1.045, .96); }
2444
+ 65% { transform: scale(.985, 1.025); }
2445
+ 100% { transform: scale(1); }
2446
+ }
2447
+ ${PILL_HEADER} .bt-pill:hover {
2448
+ --dsh-lg-tint: rgba(255, 255, 255, .32);
2449
+ animation: dsh-pill-pop 440ms cubic-bezier(.22, .61, .36, 1) both !important;
2450
+ }
2451
+ body[data-ds-dark-theme] ${PILL_HEADER} .bt-pill:hover {
2452
+ --dsh-lg-tint: rgba(255, 255, 255, .12);
2453
+ }
2454
+ ${PILL_HEADER} .bt-pill:active {
2455
+ animation: none !important;
2456
+ transform: scale(.97) !important;
2457
+ }
2458
+ @media (prefers-reduced-motion: reduce) {
2459
+ ${PILL_HEADER} .bt-pill:hover,
2460
+ ${PILL_HEADER} .bt-pill:active {
2461
+ animation: none !important;
2462
+ transform: none !important;
2463
+ }
2464
+ }
2465
+
2466
+ /* The settled panel starts at chrome-top. Absolute positioning also follows
2467
+ its entrance animation instead of changing fixed containing blocks midway.
2468
+ Top-aligned with the 14px traffic lights (their top sits at 13px in the 40px
2469
+ band), as requested — the row's own top edge matches the lights' top edge. */
2470
+ ${CORNER_ROW} {
2471
+ position: absolute !important;
2472
+ top: calc(13px - var(--dsh-frame-chrome-top, 0px)) !important;
2473
+ right: 20px !important;
2474
+ margin: 0 !important;
2475
+ padding: 0 !important;
2476
+ z-index: 50 !important;
2477
+ justify-content: flex-end !important;
2478
+ }
2479
+
2480
+ /* Buttons inside the native caption band must remain interactive. The host
2481
+ already exempts the pill; also exempt the relocated panel controls. */
2482
+ ${CORNER_ROW},
2483
+ ${CORNER_ROW} button,
2484
+ .bt-panel .bt-subhead button {
2485
+ -webkit-app-region: no-drag !important;
2486
+ }
2487
+
2488
+ /* Reserve the detached buttons' 36px height down to viewport y=49 (13 + 36). */
2489
+ .bt-panel-view:has(> .bt-drawer-top) {
2490
+ padding-top: max(0px, calc(49px - var(--bt-caption-band, 0px))) !important;
2491
+ }
2492
+
2493
+ /* The settings view uses an in-flow subheader instead of .bt-drawer-top.
2494
+ Without a tab strip, replace the inherited 40px band with the 20px inset
2495
+ (10px panel clearance plus the subheader's existing 10px padding). */
2496
+ html[data-windows-titlebar] .bt-panel:not(:has(> .bt-ptabs)):has(> .bt-panel-view > .bt-subhead) {
2497
+ padding-top: 10px !important;
2498
+ }
2499
+
2500
+ /* The host paints its whole --bt-caption-band as a positioned, drag-region
2501
+ ::before strip on the panel. This panel's top inset is only 10px, so that
2502
+ 40px strip reached down over the subheader and swallowed clicks on the top
2503
+ half of the back/close buttons (their own no-drag is painted over by the
2504
+ strip, which sits above the static subheader). Clamp the strip to the same
2505
+ 10px inset so it never overlaps the interactive row. */
2506
+ html[data-windows-titlebar] .bt-panel:not(:has(> .bt-ptabs)):has(> .bt-panel-view > .bt-subhead)::before {
2507
+ height: 10px !important;
2508
+ }
2509
+
2510
+ /* Also lift the whole subheader above any residual drag strip and make it and
2511
+ every descendant a no-drag island, so the back/close controls (Bot settings
2512
+ and Group settings share this in-flow subheader) stay clickable at every
2513
+ height, top edge included. */
2514
+ html[data-windows-titlebar] .bt-panel:has(> .bt-panel-view > .bt-subhead) > .bt-panel-view > .bt-subhead {
2515
+ position: relative !important;
2516
+ z-index: 1 !important;
2517
+ }
2518
+ html[data-windows-titlebar] .bt-panel:has(> .bt-panel-view > .bt-subhead) > .bt-panel-view > .bt-subhead,
2519
+ html[data-windows-titlebar] .bt-panel:has(> .bt-panel-view > .bt-subhead) > .bt-panel-view > .bt-subhead * {
2520
+ -webkit-app-region: no-drag !important;
2521
+ }
2522
+
2523
+ /* Only expanded columns have an expanded minimum; the width module owns the
2524
+ actual drag. This keeps the static floor below the host's 264px. */
2525
+ .bt-leftcol:is([data-left="open"], [data-left="drawer"]) {
2526
+ min-width: 220px !important;
2527
+ }
2528
+ .bt-leftcol[data-left="rail"] {
2529
+ min-width: 0 !important;
2530
+ /* With the toggle removed, keep the first avatar below native window controls.
2531
+ The live inline width still owns both the rail and its resize boundary. */
2532
+ padding-top: max(20px, calc(var(--bt-lc-clear, 0px) + 8px)) !important;
2533
+ }
2534
+
2535
+ /* ---- Sidebar section headers (DS Bot tree) ---- */
2536
+
2537
+ /* The disclosure chevron's glyph sits ~2.5px right of the hover guide line
2538
+ that descends through the child rows (the 14px chev box is centred at 25px,
2539
+ the guide at ~22.75px), so its tip misses the line. Nudge only the glyph
2540
+ left with a relative offset so the tip lands on the guide; the title row,
2541
+ its spacing and the button hit area stay exactly where they were. */
2542
+ .bt-leftcol .bt-sec-chev {
2543
+ position: relative !important;
2544
+ left: -2.5px !important;
2545
+ }
2546
+
2547
+ /* The "…" section action renders as three ~1px dots in a 13px svg and reads far
2548
+ fainter than the "+" beside it, although both share the same ink colour and
2549
+ opacity (so colour is not the cause — the glyph is). Give the dots a slightly
2550
+ larger glyph box (15px) and a heavier stroke so the three dots read at the
2551
+ same weight as the "+"; colour, opacity and the button hit area are unchanged. */
2552
+ .bt-leftcol .bt-sec-acts .bt-sec-act:last-child svg {
2553
+ width: 15px !important;
2554
+ height: 15px !important;
2555
+ }
2556
+ .bt-leftcol .bt-sec-acts .bt-sec-act:last-child svg path {
2557
+ stroke-width: 2.8 !important;
2558
+ }
2559
+
2560
+ /* The three sidebar actions read as normal tools, not filled buttons:
2561
+ secondary ink on the surface, with the shared hover treatment. */
2562
+ .bt-side-top .bt-round {
2563
+ background: transparent !important;
2564
+ border-color: transparent !important;
2565
+ color: var(--bt-ink-2) !important;
2566
+ }
2567
+ .bt-side-top .bt-round:hover {
2568
+ background: color-mix(in srgb, var(--bt-hover) 60%, transparent) !important;
2569
+ color: var(--bt-ink) !important;
2570
+ }
2571
+
2572
+ /* The rail's + button carries the same disc as the account and plugins
2573
+ buttons: those wrap their icon in a 36px round bt-you disc, which is a
2574
+ #262626 fill with a 1px inner ring, and that ring reads as the button face.
2575
+ The host's .bt-round only fills the button, so paint the same disc here. */
2576
+ .bt-leftcol-foot-rail .bt-round {
2577
+ width: 36px !important;
2578
+ height: 36px !important;
2579
+ border-radius: 50% !important;
2580
+ border-color: transparent !important;
2581
+ background: #262626 !important;
2582
+ box-shadow: inset 0 0 0 1px rgba(242, 242, 242, .08) !important;
2583
+ color: var(--bt-ink-2) !important;
2584
+ }
2585
+ .bt-leftcol-foot-rail .bt-round:hover {
2586
+ background: color-mix(in srgb, #262626 82%, var(--bt-hover)) !important;
2587
+ color: var(--bt-ink) !important;
2588
+ }
2589
+
2590
+ /* Sidebar visibility is controlled by the host shortcut and the existing grip.
2591
+ Hide the Bot controls and the shell fallback, which is exposed after the Bot
2592
+ column unmounts. Otherwise hiding the sidebar reveals another open button. */
2593
+ .bt-title-toggle,
2594
+ .bt-side-collapse,
2595
+ button[data-sidebar-toggle],
2596
+ button[data-sidebar-opener] {
2597
+ display: none !important;
2598
+ }
2599
+
2600
+ .bt-leftcol,
2601
+ .bt-leftcol > :first-child {
2602
+ border-top-right-radius: 0 !important;
2603
+ }
2604
+
2605
+ .bt-side-top .bt-brand {
2606
+ display: none !important;
2607
+ }
2608
+
2609
+ /* ---- Account menu (bottom-left gear) — frostier, more opaque, larger radius ---- */
2610
+
2611
+ /* The host paints every pop menu as a 78% (light) / 74% (dark) glass tint with
2612
+ a 24px blur, so the sidebar's session titles still read through the bottom-left
2613
+ account menu. Deepen only this menu: a stronger blur plus a more opaque surface
2614
+ hide the text behind it, and a larger corner radius softens its edges. Scoped to
2615
+ .bt-account-menu so the other pop menus keep the host's look; corner-shape is
2616
+ left untouched so the curve stays consistent with the rest of the shell. */
2617
+ .bt-account-menu {
2618
+ -webkit-backdrop-filter: blur(40px) saturate(180%) !important;
2619
+ backdrop-filter: blur(40px) saturate(180%) !important;
2620
+ background: color-mix(in srgb, var(--bt-main) 92%, transparent) !important;
2621
+ border-radius: 16px !important;
2622
+ }
2623
+ body[data-ds-dark-theme] .bt-account-menu {
2624
+ background: color-mix(in srgb, var(--bt-main) 90%, transparent) !important;
2625
+ }
2626
+ `;
2627
+ // src/client/surfaces/ds-bot/markdown-anchors.ts
2628
+ /**
2629
+ * DS Bot's own bubble CSS outranks the shared markdown sheet:
2630
+ * .bt-bubble [class*="_markdown"] { color/font-size/line-height: inherit !important }
2631
+ * .bt-bubble p { margin: 0 }
2632
+ * .bt-bubble [class*="_markdown"] li::marker { color: var(--bt-ink-2) }
2633
+ *
2634
+ * The first rule carries !important at (0,2,0), while the shared sheet states
2635
+ * its measure at (0,1,0) on `[class*="_markdown"]`, so the host wins and the
2636
+ * body inherits the bubble's 14px. Restate the same declarations under a
2637
+ * three-anchor selector (0,3,0) plus a node-free fallback, so they win on
2638
+ * specificity rather than on load order. Only the measured declarations are
2639
+ * repeated; every other markdown rule stays on the shared sheet.
2640
+ */
2641
+ const bubble = ".bt-bubble";
2642
+ const md = `[data-slot="conversation.chat.node"] ${bubble} [class*="_markdown"]`;
2643
+ const fallback = `${bubble} [class*="_markdown"][class*="_markdown"]`;
2644
+ /** The DS Bot anchor overlay. Not mounted on DeepSeek Harness. */
2645
+ const css = `${md},
2646
+ ${fallback} {
2647
+ color: var(--md-text) !important;
2648
+ font-size: 13px !important;
2649
+ line-height: 1.75 !important;
2650
+ letter-spacing: .01em;
2651
+ }
2652
+ ${md} p,
2653
+ ${fallback} p {
2654
+ margin: 0 0 1em !important;
2655
+ font-size: 13px !important;
2656
+ line-height: 1.75 !important;
2657
+ }
2658
+ ${md} li::marker,
2659
+ ${fallback} li::marker {
2660
+ color: var(--md-accent) !important;
2661
+ font-weight: 700 !important;
2662
+ }
2663
+ `;
2664
+ // src/client/surface.ts
2665
+ /** DS Bot draws its own left column under this class. */
2666
+ const DS_BOT_COLUMN = ".bt-leftcol";
2667
+ /** A service id that names the ds-bot bundle, not a longer unrelated token. */
2668
+ const DS_BOT_SERVICE = /(^|[\/.:])ds-bot($|[\/.:@])/;
2669
+ /**
2670
+ * Decide the surface from a probe.
2671
+ *
2672
+ * A `ds-bot` service or bundle name wins. Otherwise the host's own left column
2673
+ * means DS Bot. Anything else is DeepSeek Harness.
2674
+ * @param probe - names and an optional DOM root. Omit both for the page default.
2675
+ * @returns the surface this process should mount.
2676
+ */
2677
+ function detectSurface(probe = {}) {
2678
+ if ((probe.serviceNames ?? []).some((name) => DS_BOT_SERVICE.test(name))) return "ds-bot";
2679
+ try {
2680
+ if (probe.root?.querySelector?.(DS_BOT_COLUMN) != null) return "ds-bot";
2681
+ } catch {}
2682
+ return "dsh";
2683
+ }
2684
+ let decided;
2685
+ /**
2686
+ * The surface for this process. The first call wins; later probes are ignored.
2687
+ * @param probe - optional probe used only while the surface is still undecided.
2688
+ * @returns the remembered surface.
2689
+ */
2690
+ function currentSurface(probe) {
2691
+ if (decided !== void 0) return decided;
2692
+ decided = detectSurface(probe ?? defaultProbe());
2693
+ return decided;
2694
+ }
2695
+ /**
2696
+ * Probe the page: the boot graph first, then the DS Bot column.
2697
+ *
2698
+ * DS Boot injects `window.__DSH_BOOT__` as a manifest whose `entries` is an
2699
+ * array of `WebBootEntry` rows carrying an `id` (`"ds-bot"` for DS Bot's own
2700
+ * bundle). Older/alternate shapes expose `bundles` or `services` instead, so
2701
+ * every field is read. The DOM column is only a fallback: DS Bot mounts
2702
+ * `.bt-leftcol` after plugins have already been asked to decide.
2703
+ * @returns the probe `currentSurface` uses when the caller does not pass one.
2704
+ */
2705
+ function defaultProbe() {
2706
+ const names = [];
2707
+ const boot = globalThis.__DSH_BOOT__;
2708
+ collectNames(boot?.entries, names);
2709
+ collectNames(boot?.bundles, names);
2710
+ collectNames(boot?.services, names);
2711
+ collectNames(boot?.batches, names);
2712
+ return {
2713
+ serviceNames: names,
2714
+ root: typeof document === "undefined" ? null : document
2715
+ };
2716
+ }
2717
+ /**
2718
+ * Pull string names out of a boot payload, recursing through nested rows.
2719
+ * @param value - a name, a list, or a map of boot entries.
2720
+ * @param into - the list being filled.
2721
+ */
2722
+ function collectNames(value, into) {
2723
+ if (typeof value === "string") {
2724
+ into.push(value);
2725
+ return;
2726
+ }
2727
+ if (Array.isArray(value)) {
2728
+ for (const item of value) collectNames(item, into);
2729
+ return;
2730
+ }
2731
+ if (value !== null && typeof value === "object") for (const [key, item] of Object.entries(value)) {
2732
+ into.push(key);
2733
+ if (typeof item === "string") into.push(item);
2734
+ else collectNames(item, into);
2735
+ }
2736
+ }
2737
+ /**
2738
+ * Feature switches for one surface.
2739
+ *
2740
+ * DS Bot draws its own sidebar, so the DSH chrome (width, icon row, section
2741
+ * counts, whale, window geometry) stays off there. Annotations, side chat,
2742
+ * both context menus, markdown, document preview, and the badge mechanism stay
2743
+ * on. The running-marker and send-button looks are part of the DSH chrome
2744
+ * sheets, so they stay off with those sheets. Edge refraction belongs to the
2745
+ * DS Bot pill only: DSH draws no such pill, so it stays off there.
2746
+ * @param surface - the decided surface.
2747
+ * @returns the switches `apply` reads.
2748
+ */
2749
+ function featuresFor(surface) {
2750
+ const shared = {
2751
+ annotations: true,
2752
+ sideChat: true,
2753
+ fileMenu: true,
2754
+ markdown: true,
2755
+ documentPreview: true,
2756
+ badge: true,
2757
+ panelWidths: true
2758
+ };
2759
+ if (surface === "ds-bot") return {
2760
+ ...shared,
2761
+ sidebarFloor: false,
2762
+ sidebarTopRow: false,
2763
+ sectionStats: false,
2764
+ whale: false,
2765
+ windowGeometry: false,
2766
+ liquidGlass: true
2767
+ };
2768
+ return {
2769
+ ...shared,
2770
+ sidebarFloor: true,
2771
+ sidebarTopRow: true,
2772
+ sectionStats: true,
2773
+ whale: true,
2774
+ windowGeometry: true,
2775
+ panelWidths: false,
2776
+ liquidGlass: false
2777
+ };
2778
+ }
2779
+ /**
2780
+ * Style-tag identity. The two surfaces never share a prefix, so a page can
2781
+ * show which set is mounted.
2782
+ * @param surface - the decided surface.
2783
+ * @returns the `data-plugin` value.
2784
+ */
2785
+ function stylePluginId(surface) {
2786
+ return surface === "ds-bot" ? "ds-bot-enhance" : "dsh-enhance";
2787
+ }
2233
2788
  // src/client/styles.ts
2234
- /** Stable plugin identity stamped onto every injected style tag. */
2235
- const PLUGIN_ID = "dsh-enhance";
2236
- /** Sheet name to CSS, in cascade order: later sheets win ties against earlier ones. */
2789
+ /** DSH sheet name to CSS, in cascade order: later sheets win ties against earlier ones. */
2237
2790
  const SHEETS = [
2238
- ["document-preview.css", css$7],
2239
- ["chat-markdown.css", css$6],
2240
- ["rightbar-handle.css", css$5],
2241
- ["running-spinner.css", css$4],
2242
- ["sidebar-density.css", css$3],
2243
- ["sidebar-layout.css", css$2],
2244
- ["toolbar.css", css$1],
2245
- ["file-menu.css", css]
2791
+ ["document-preview.css", css$9],
2792
+ ["chat-markdown.css", css$8],
2793
+ ["rightbar-handle.css", css$7],
2794
+ ["running-spinner.css", css$6],
2795
+ ["sidebar-density.css", css$5],
2796
+ ["sidebar-layout.css", css$4],
2797
+ ["toolbar.css", css$3],
2798
+ ["file-menu.css", css$2]
2246
2799
  ];
2800
+ /** DS Bot mounts the shared rules plus its own chrome and md anchors; no DSH chrome. */
2801
+ const DS_BOT_SHEETS = [
2802
+ ...[
2803
+ ["document-preview.css", css$9],
2804
+ ["chat-markdown.css", css$8],
2805
+ ["toolbar.css", css$3],
2806
+ ["file-menu.css", css$2]
2807
+ ],
2808
+ ["ds-bot-chrome.css", css$1],
2809
+ ["ds-bot-markdown-anchors.css", css]
2810
+ ];
2811
+ /**
2812
+ * The sheet set for one surface. The two sets never mount together.
2813
+ * @param surface - the decided surface.
2814
+ * @returns that surface's sheets.
2815
+ */
2816
+ function sheetsFor(surface) {
2817
+ return surface === "ds-bot" ? DS_BOT_SHEETS : SHEETS;
2818
+ }
2247
2819
  /**
2248
- * Mount every global sheet for exactly the owning plugin lifetime.
2820
+ * Mount one surface's sheets for exactly the owning plugin lifetime.
2249
2821
  *
2250
2822
  * The tags carry `data-plugin`, so the client module system's entry lifecycle
2251
2823
  * evicts them when this plugin unloads even if the fiber is torn down abruptly.
@@ -2253,16 +2825,18 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2253
2825
  */
2254
2826
  function installStyles(ctx) {
2255
2827
  if (typeof document === "undefined") return;
2256
- for (const [name, css] of SHEETS) ctx.effect(() => {
2828
+ const surface = currentSurface();
2829
+ const pluginId = stylePluginId(surface);
2830
+ for (const [name, css] of sheetsFor(surface)) ctx.effect(() => {
2257
2831
  const tag = document.createElement("style");
2258
- tag.dataset.plugin = PLUGIN_ID;
2259
- tag.dataset.pluginCss = `${PLUGIN_ID}/${name}`;
2832
+ tag.dataset.plugin = pluginId;
2833
+ tag.dataset.pluginCss = `${pluginId}/${name}`;
2260
2834
  tag.textContent = css;
2261
2835
  document.head.appendChild(tag);
2262
2836
  return () => {
2263
2837
  tag.remove();
2264
2838
  };
2265
- }, `dsh-enhance: ${name} stylesheet`);
2839
+ }, `${pluginId}: ${name} stylesheet`);
2266
2840
  }
2267
2841
  // src/client/whale-bubbles.ts
2268
2842
  /**
@@ -2704,6 +3278,404 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2704
3278
  else home.append(moved);
2705
3279
  };
2706
3280
  }
3281
+ const LEFT_MAX = 420;
3282
+ const DETAILS_MAX = 520;
3283
+ const CHAT_MIN = 420;
3284
+ const RAIL_SNAP = 176;
3285
+ const LEFT_KEY = "ds-bot-enhance.sidebar-width.v1";
3286
+ const RIGHT_KEY = "ds-bot-enhance.details-width.v1";
3287
+ function installPanelWidths(root) {
3288
+ const win = root.defaultView;
3289
+ const preferred = {};
3290
+ const owned = {
3291
+ left: /* @__PURE__ */ new Map(),
3292
+ right: /* @__PURE__ */ new Map()
3293
+ };
3294
+ let drag;
3295
+ let nativeDrag = false;
3296
+ let replaying = false;
3297
+ let frame = 0;
3298
+ let disposed = false;
3299
+ const key = (side) => side === "left" ? LEFT_KEY : RIGHT_KEY;
3300
+ const minimum = (side) => side === "left" ? 220 : 260;
3301
+ const maximum = (side) => side === "left" ? LEFT_MAX : DETAILS_MAX;
3302
+ for (const side of ["left", "right"]) try {
3303
+ const raw = win.localStorage.getItem(key(side));
3304
+ const n = raw === null ? NaN : Number(raw);
3305
+ if (Number.isFinite(n) && n >= minimum(side) && n <= maximum(side)) preferred[side] = Math.round(n);
3306
+ } catch {}
3307
+ const save = (side) => {
3308
+ try {
3309
+ const width = preferred[side];
3310
+ if (width === void 0) win.localStorage.removeItem(key(side));
3311
+ else win.localStorage.setItem(key(side), String(width));
3312
+ } catch {}
3313
+ };
3314
+ const put = (side, element, property, value) => {
3315
+ let properties = owned[side].get(element);
3316
+ if (!properties) {
3317
+ properties = /* @__PURE__ */ new Map();
3318
+ owned[side].set(element, properties);
3319
+ }
3320
+ if (!properties.has(property)) properties.set(property, {
3321
+ value: element.style.getPropertyValue(property),
3322
+ priority: element.style.getPropertyPriority(property)
3323
+ });
3324
+ if (element.style.getPropertyValue(property) !== value || element.style.getPropertyPriority(property) !== "important") element.style.setProperty(property, value, "important");
3325
+ };
3326
+ const clear = (side) => {
3327
+ for (const [element, properties] of owned[side]) for (const [property, original] of properties) if (original.value) element.style.setProperty(property, original.value, original.priority);
3328
+ else element.style.removeProperty(property);
3329
+ owned[side].clear();
3330
+ };
3331
+ const leftColumn = () => root.querySelector(".bt-leftcol");
3332
+ const detailPanel = () => root.querySelector(".bt-panel[data-view=\"details\"]:not([data-leaving])");
3333
+ const centers = () => [...root.querySelectorAll("[class*=\"_centerCol\"]")];
3334
+ const shellWidth = () => root.querySelector("[class*=\"_sidebarCol\"]")?.getBoundingClientRect().width ?? 0;
3335
+ const bound = (side, value) => {
3336
+ const left = leftColumn();
3337
+ const occupied = left?.dataset.left === "open" ? left.getBoundingClientRect().width : left?.dataset.left === "rail" ? 88 : 0;
3338
+ const available = side === "right" ? win.innerWidth - occupied - CHAT_MIN : win.innerWidth - CHAT_MIN;
3339
+ return Math.round(Math.max(minimum(side), Math.min(value, maximum(side), Math.max(minimum(side), available))));
3340
+ };
3341
+ const paint = () => {
3342
+ if (disposed || nativeDrag) return;
3343
+ const left = leftColumn();
3344
+ const mode = left?.dataset.left;
3345
+ if (left && preferred.left !== void 0 && (mode === "open" || mode === "drawer")) {
3346
+ const width = bound("left", preferred.left);
3347
+ put("left", left, "width", `${width}px`);
3348
+ put("left", left, "--bt-lc-w", `${width}px`);
3349
+ const occupied = mode === "open" ? width : 88;
3350
+ if (mode === "open") for (const center of centers()) put("left", center, "margin-left", `${Math.max(0, occupied - shellWidth())}px`);
3351
+ for (const pane of root.querySelectorAll(".bt-pane")) put("left", pane, "left", `${occupied}px`);
3352
+ } else clear("left");
3353
+ const panel = detailPanel();
3354
+ if (panel && preferred.right !== void 0) {
3355
+ const width = bound("right", preferred.right);
3356
+ put("right", panel, "width", `${width}px`);
3357
+ put("right", panel, "--bt-panel-w", `${width}px`);
3358
+ if (!panel.hasAttribute("data-overlay")) for (const center of centers()) put("right", center, "margin-right", `${width}px`);
3359
+ else for (const center of centers()) {
3360
+ const properties = owned.right.get(center);
3361
+ if (properties) {
3362
+ for (const [property, original] of properties) if (original.value) center.style.setProperty(property, original.value, original.priority);
3363
+ else center.style.removeProperty(property);
3364
+ owned.right.delete(center);
3365
+ }
3366
+ }
3367
+ } else clear("right");
3368
+ for (const side of ["left", "right"]) for (const element of owned[side].keys()) if (!element.isConnected) owned[side].delete(element);
3369
+ observer.takeRecords();
3370
+ };
3371
+ const schedule = () => {
3372
+ if (disposed || frame) return;
3373
+ frame = win.requestAnimationFrame(() => {
3374
+ frame = 0;
3375
+ paint();
3376
+ });
3377
+ };
3378
+ const observer = new MutationObserver(schedule);
3379
+ const finish = (commit) => {
3380
+ const active = drag;
3381
+ if (!active) {
3382
+ nativeDrag = false;
3383
+ schedule();
3384
+ return;
3385
+ }
3386
+ drag = void 0;
3387
+ if (!commit) preferred[active.side] = active.previous;
3388
+ else save(active.side);
3389
+ if (active.grip.hasPointerCapture?.(active.id)) active.grip.releasePointerCapture(active.id);
3390
+ root.documentElement.removeAttribute("data-ds-enhance-resizing");
3391
+ if (preferred[active.side] === void 0) clear(active.side);
3392
+ paint();
3393
+ };
3394
+ const onDown = (event) => {
3395
+ if (replaying || event.button !== 0 || !(event.target instanceof Element)) return;
3396
+ const grip = event.target.closest(".bt-leftcol-grip, .bt-panel-grip");
3397
+ if (!grip) return;
3398
+ const side = grip.classList.contains("bt-leftcol-grip") ? "left" : "right";
3399
+ const element = side === "left" ? grip.closest(".bt-leftcol") : grip.closest(".bt-panel");
3400
+ if (!element) return;
3401
+ if (side === "left" && !["open", "drawer"].includes(element.dataset.left ?? "") || side === "right" && element.dataset.view !== "details") {
3402
+ nativeDrag = true;
3403
+ return;
3404
+ }
3405
+ event.preventDefault();
3406
+ event.stopImmediatePropagation();
3407
+ drag = {
3408
+ side,
3409
+ grip,
3410
+ id: event.pointerId,
3411
+ x: event.clientX,
3412
+ width: element.getBoundingClientRect().width,
3413
+ previous: preferred[side]
3414
+ };
3415
+ root.documentElement.setAttribute("data-ds-enhance-resizing", "");
3416
+ grip.setPointerCapture?.(event.pointerId);
3417
+ };
3418
+ const track = (event) => {
3419
+ if (!drag || event.pointerId !== drag.id) return;
3420
+ const active = drag;
3421
+ if (active.side === "left" && event.clientX < RAIL_SNAP) {
3422
+ finish(false);
3423
+ nativeDrag = true;
3424
+ clear("left");
3425
+ replaying = true;
3426
+ try {
3427
+ active.grip.dispatchEvent(new PointerEvent("pointerdown", {
3428
+ bubbles: true,
3429
+ button: 0,
3430
+ buttons: 1,
3431
+ pointerId: event.pointerId,
3432
+ clientX: event.clientX,
3433
+ clientY: event.clientY
3434
+ }));
3435
+ active.grip.dispatchEvent(new PointerEvent("pointermove", {
3436
+ bubbles: true,
3437
+ buttons: 1,
3438
+ pointerId: event.pointerId,
3439
+ clientX: event.clientX,
3440
+ clientY: event.clientY
3441
+ }));
3442
+ } finally {
3443
+ replaying = false;
3444
+ }
3445
+ return;
3446
+ }
3447
+ preferred[active.side] = bound(active.side, active.width + (event.clientX - active.x) * (active.side === "left" ? 1 : -1));
3448
+ paint();
3449
+ };
3450
+ const onMove = (event) => {
3451
+ if (!drag) return;
3452
+ if (event.buttons === 0) {
3453
+ finish(true);
3454
+ return;
3455
+ }
3456
+ event.stopImmediatePropagation();
3457
+ track(event);
3458
+ };
3459
+ const onUp = (event) => {
3460
+ if (drag) {
3461
+ event.stopImmediatePropagation();
3462
+ track(event);
3463
+ finish(true);
3464
+ } else if (nativeDrag) {
3465
+ nativeDrag = false;
3466
+ const left = leftColumn();
3467
+ if (left && left.dataset.left === "open" && event.target instanceof Element && event.target.closest(".bt-leftcol-grip")) {
3468
+ preferred.left = bound("left", left.getBoundingClientRect().width);
3469
+ save("left");
3470
+ }
3471
+ schedule();
3472
+ }
3473
+ };
3474
+ const onCancel = () => {
3475
+ finish(false);
3476
+ };
3477
+ const style = root.createElement("style");
3478
+ style.dataset.plugin = "ds-bot-enhance-widths";
3479
+ style.textContent = "[data-ds-enhance-resizing] :is(.bt-leftcol,.bt-panel,[class*=\"_centerCol\"]){transition:none!important}[data-ds-enhance-resizing] *{cursor:col-resize!important;user-select:none!important}";
3480
+ root.head.appendChild(style);
3481
+ root.addEventListener("pointerdown", onDown, true);
3482
+ root.addEventListener("pointermove", onMove, true);
3483
+ root.addEventListener("pointerup", onUp, true);
3484
+ root.addEventListener("pointercancel", onCancel, true);
3485
+ win.addEventListener("blur", onCancel);
3486
+ win.addEventListener("resize", schedule);
3487
+ observer.observe(root.body, {
3488
+ childList: true,
3489
+ subtree: true,
3490
+ attributes: true,
3491
+ attributeFilter: [
3492
+ "style",
3493
+ "data-left",
3494
+ "data-view",
3495
+ "data-overlay",
3496
+ "data-leaving"
3497
+ ]
3498
+ });
3499
+ paint();
3500
+ return () => {
3501
+ disposed = true;
3502
+ finish(false);
3503
+ observer.disconnect();
3504
+ win.cancelAnimationFrame(frame);
3505
+ root.removeEventListener("pointerdown", onDown, true);
3506
+ root.removeEventListener("pointermove", onMove, true);
3507
+ root.removeEventListener("pointerup", onUp, true);
3508
+ root.removeEventListener("pointercancel", onCancel, true);
3509
+ win.removeEventListener("blur", onCancel);
3510
+ win.removeEventListener("resize", schedule);
3511
+ clear("left");
3512
+ clear("right");
3513
+ style.remove();
3514
+ };
3515
+ }
3516
+ // src/client/surfaces/ds-bot/liquid-glass.ts
3517
+ /** Liquid-glass refraction for the DS Bot session pill.
3518
+ *
3519
+ * Ported from `lucasromerodb/liquid-glass-effect-macos`
3520
+ * (https://github.com/lucasromerodb/liquid-glass-effect-macos) — the source
3521
+ * behind the user's CodeSandbox reference (nn5q2y). That repository ships no
3522
+ * LICENSE file, so it is used here as an effect reference only.
3523
+ *
3524
+ * The reference does not build a displacement map by hand. It generates a
3525
+ * low-frequency fractal noise, blurs it, and bends the element's backdrop with
3526
+ * feDisplacementMap; the element that carries the refraction also carries the
3527
+ * backdrop-filter, so the backdrop is softened first and bent afterwards. The
3528
+ * visible distortion comes from that chain. feComponentTransfer and
3529
+ * feSpecularLighting are part of the original markup and are kept verbatim,
3530
+ * even though the reference's own chain never reads their results back.
3531
+ *
3532
+ * The filter is written once and needs no per-frame work: the turbulence is a
3533
+ * pure function of user space, and `filterUnits="objectBoundingBox"` lets the
3534
+ * region follow the pill's box, so the filter survives the pill growing when
3535
+ * the back arrow appears.
3536
+ *
3537
+ * chrome.ts carries the layering: `::before` is the effect layer (softening
3538
+ * pass plus the bend on the same element, exactly like the reference), `::after`
3539
+ * is the tint and the lip, and the pill's own box clips both to the capsule.
3540
+ */
3541
+ const NS = "http://www.w3.org/2000/svg";
3542
+ /** The one filter id this module owns on the page. */
3543
+ const FILTER_ID = "dsh-lg-pill";
3544
+ /** CSS variable chrome.ts reads for the softening pass; unset means "frosted fallback". */
3545
+ const BACKDROP_VAR = "--dsh-lg-backdrop";
3546
+ /** CSS variable chrome.ts reads for the SVG distortion. */
3547
+ const FILTER_VAR = "--dsh-lg-filter";
3548
+ /** Page attribute that says which look is live, for tests and inspection. */
3549
+ const MODE_ATTR = "data-dsh-lg";
3550
+ /** The reference's softening pass on the effect layer: `blur(3px)`. The
3551
+ * backdrop is blurred before it is bent, which is what keeps the bend reading
3552
+ * as glass instead of as a smeared copy of the text behind. */
3553
+ const GLASS_SOFTEN = { blur: 3 };
3554
+ /** Keep the CodeSandbox reference's turbulence and displacement unchanged.
3555
+ * Scaling the displacement down and increasing blur erased the visible glass
3556
+ * effect in earlier revisions. The capsule clips the reference effect; only
3557
+ * its text/content is excluded from filtering. */
3558
+ const GLASS_DISTORTION = {
3559
+ baseFrequencyX: .001,
3560
+ baseFrequencyY: .005,
3561
+ numOctaves: 1,
3562
+ seed: 17,
3563
+ stdDeviation: 3,
3564
+ scale: 200,
3565
+ surfaceScale: 5,
3566
+ specularConstant: 1,
3567
+ specularExponent: 100,
3568
+ lightX: -200,
3569
+ lightY: -200,
3570
+ lightZ: 300
3571
+ };
3572
+ /** The value published to `--dsh-lg-backdrop`: the softening pass only. It
3573
+ * intentionally carries no url() — Chromium ignores the whole declaration when
3574
+ * backdrop-filter references an SVG filter, which is why the bend rides the
3575
+ * plain `filter` property, exactly like the reference does. */
3576
+ const BACKDROP_VALUE = `blur(${GLASS_SOFTEN.blur}px)`;
3577
+ /** The value published to `--dsh-lg-filter`: the reference's distortion. */
3578
+ const FILTER_VALUE = `url(#${FILTER_ID})`;
3579
+ const inert = () => {};
3580
+ /** Build the reference's filter: turbulence → component transfer → blur →
3581
+ * specular lighting → composite → displacement. */
3582
+ function buildFilter(root) {
3583
+ const svg = root.createElementNS(NS, "svg");
3584
+ svg.setAttribute("aria-hidden", "true");
3585
+ svg.setAttribute("data-plugin", "ds-bot-enhance-liquid-glass");
3586
+ svg.style.cssText = "position:absolute;width:0;height:0;overflow:hidden;pointer-events:none";
3587
+ const filter = root.createElementNS(NS, "filter");
3588
+ filter.setAttribute("id", FILTER_ID);
3589
+ filter.setAttribute("x", "0%");
3590
+ filter.setAttribute("y", "0%");
3591
+ filter.setAttribute("width", "100%");
3592
+ filter.setAttribute("height", "100%");
3593
+ filter.setAttribute("filterUnits", "objectBoundingBox");
3594
+ const turbulence = root.createElementNS(NS, "feTurbulence");
3595
+ turbulence.setAttribute("type", "fractalNoise");
3596
+ turbulence.setAttribute("baseFrequency", `${GLASS_DISTORTION.baseFrequencyX} ${GLASS_DISTORTION.baseFrequencyY}`);
3597
+ turbulence.setAttribute("numOctaves", String(GLASS_DISTORTION.numOctaves));
3598
+ turbulence.setAttribute("seed", String(GLASS_DISTORTION.seed));
3599
+ turbulence.setAttribute("result", "turbulence");
3600
+ const transfer = root.createElementNS(NS, "feComponentTransfer");
3601
+ transfer.setAttribute("in", "turbulence");
3602
+ transfer.setAttribute("result", "mapped");
3603
+ const funcR = root.createElementNS(NS, "feFuncR");
3604
+ funcR.setAttribute("type", "gamma");
3605
+ funcR.setAttribute("amplitude", "1");
3606
+ funcR.setAttribute("exponent", "10");
3607
+ funcR.setAttribute("offset", "0.5");
3608
+ const funcG = root.createElementNS(NS, "feFuncG");
3609
+ funcG.setAttribute("type", "gamma");
3610
+ funcG.setAttribute("amplitude", "0");
3611
+ funcG.setAttribute("exponent", "1");
3612
+ funcG.setAttribute("offset", "0");
3613
+ const funcB = root.createElementNS(NS, "feFuncB");
3614
+ funcB.setAttribute("type", "gamma");
3615
+ funcB.setAttribute("amplitude", "0");
3616
+ funcB.setAttribute("exponent", "1");
3617
+ funcB.setAttribute("offset", "0.5");
3618
+ transfer.append(funcR, funcG, funcB);
3619
+ const blur = root.createElementNS(NS, "feGaussianBlur");
3620
+ blur.setAttribute("in", "turbulence");
3621
+ blur.setAttribute("stdDeviation", String(GLASS_DISTORTION.stdDeviation));
3622
+ blur.setAttribute("result", "softMap");
3623
+ const specular = root.createElementNS(NS, "feSpecularLighting");
3624
+ specular.setAttribute("in", "softMap");
3625
+ specular.setAttribute("surfaceScale", String(GLASS_DISTORTION.surfaceScale));
3626
+ specular.setAttribute("specularConstant", String(GLASS_DISTORTION.specularConstant));
3627
+ specular.setAttribute("specularExponent", String(GLASS_DISTORTION.specularExponent));
3628
+ specular.setAttribute("lighting-color", "white");
3629
+ specular.setAttribute("result", "specLight");
3630
+ const pointLight = root.createElementNS(NS, "fePointLight");
3631
+ pointLight.setAttribute("x", String(GLASS_DISTORTION.lightX));
3632
+ pointLight.setAttribute("y", String(GLASS_DISTORTION.lightY));
3633
+ pointLight.setAttribute("z", String(GLASS_DISTORTION.lightZ));
3634
+ specular.append(pointLight);
3635
+ const composite = root.createElementNS(NS, "feComposite");
3636
+ composite.setAttribute("in", "specLight");
3637
+ composite.setAttribute("operator", "arithmetic");
3638
+ composite.setAttribute("k1", "0");
3639
+ composite.setAttribute("k2", "1");
3640
+ composite.setAttribute("k3", "1");
3641
+ composite.setAttribute("k4", "0");
3642
+ composite.setAttribute("result", "litImage");
3643
+ const bend = root.createElementNS(NS, "feDisplacementMap");
3644
+ bend.setAttribute("in", "SourceGraphic");
3645
+ bend.setAttribute("in2", "softMap");
3646
+ bend.setAttribute("scale", String(GLASS_DISTORTION.scale));
3647
+ bend.setAttribute("xChannelSelector", "R");
3648
+ bend.setAttribute("yChannelSelector", "G");
3649
+ filter.append(turbulence, transfer, blur, specular, composite, bend);
3650
+ svg.appendChild(filter);
3651
+ return {
3652
+ svg,
3653
+ filter
3654
+ };
3655
+ }
3656
+ /**
3657
+ * Publish the reference's liquid-glass distortion for the session pill on this
3658
+ * document.
3659
+ * @param root - the document the plugin runs in.
3660
+ * @returns the dispose function; a no-op when the shell cannot refract.
3661
+ */
3662
+ function installLiquidGlass(root) {
3663
+ const win = root.defaultView;
3664
+ if (!win || !root.body || typeof win.CSS?.supports !== "function") return inert;
3665
+ if (!win.CSS.supports("filter", `url(#dsh-lg-pill)`)) return inert;
3666
+ root.getElementById?.(FILTER_ID)?.remove();
3667
+ const { svg } = buildFilter(root);
3668
+ root.body.appendChild(svg);
3669
+ root.documentElement.style.setProperty(BACKDROP_VAR, BACKDROP_VALUE);
3670
+ root.documentElement.style.setProperty(FILTER_VAR, FILTER_VALUE);
3671
+ root.documentElement.setAttribute(MODE_ATTR, "refract");
3672
+ return () => {
3673
+ svg.remove();
3674
+ root.documentElement.style.removeProperty(BACKDROP_VAR);
3675
+ root.documentElement.style.removeProperty(FILTER_VAR);
3676
+ root.documentElement.removeAttribute(MODE_ATTR);
3677
+ };
3678
+ }
2707
3679
  // src/client/section-stats.ts
2708
3680
  /** Marks the injected row, for the stylesheet and the disposer. */
2709
3681
  const STATS_ATTRIBUTE = "data-dsh-enhance-stats";
@@ -2922,6 +3894,10 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2922
3894
  */
2923
3895
  /** localStorage key holding the last width this plugin settled on. */
2924
3896
  const STORAGE_KEY$1 = "dsh-enhance.sidebar-width.v1";
3897
+ /** DS Bot keeps its own width preference; the two apps never share one. */
3898
+ function storageKeyFor$1(surface) {
3899
+ return surface === "ds-bot" ? "ds-bot-enhance.sidebar-width.v1" : STORAGE_KEY$1;
3900
+ }
2925
3901
  /**
2926
3902
  * Read a remembered width, rejecting anything outside the contract range.
2927
3903
  * @param raw - the stored string, or null.
@@ -2941,7 +3917,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2941
3917
  function startupSidebarWidth(store) {
2942
3918
  if (store === null) return 214;
2943
3919
  try {
2944
- return readSidebarWidth(store.getItem("dsh-enhance.sidebar-width.v1")) ?? 214;
3920
+ return readSidebarWidth(store.getItem(storageKeyFor$1(currentSurface()))) ?? 214;
2945
3921
  } catch {
2946
3922
  return 214;
2947
3923
  }
@@ -2955,7 +3931,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2955
3931
  if (store === null) return;
2956
3932
  const bounded = Math.round(Math.min(Math.max(width, 214), 420));
2957
3933
  try {
2958
- store.setItem(STORAGE_KEY$1, String(bounded));
3934
+ store.setItem(storageKeyFor$1(currentSurface()), String(bounded));
2959
3935
  } catch {}
2960
3936
  }
2961
3937
  /**
@@ -2994,6 +3970,10 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2994
3970
  */
2995
3971
  /** localStorage key holding the last close's frame. */
2996
3972
  const STORAGE_KEY = "dsh-enhance.window-geometry.v1";
3973
+ /** DS Bot keeps its own frame; the two apps never share one. */
3974
+ function storageKeyFor(surface) {
3975
+ return surface === "ds-bot" ? "ds-bot-enhance.window-geometry.v1" : STORAGE_KEY;
3976
+ }
2997
3977
  /**
2998
3978
  * Read the work area out of a window's screen.
2999
3979
  *
@@ -3176,7 +4156,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3176
4156
  const maximized = isFilled(frame, area);
3177
4157
  if (!maximized) normal = frame;
3178
4158
  try {
3179
- storage.setItem(STORAGE_KEY, JSON.stringify({
4159
+ storage.setItem(storageKeyFor(currentSurface()), JSON.stringify({
3180
4160
  normal,
3181
4161
  maximized
3182
4162
  }));
@@ -3191,7 +4171,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3191
4171
  const onVisibilityChange = () => {
3192
4172
  if (win.document.visibilityState === "hidden") save();
3193
4173
  };
3194
- restore(storage === null ? void 0 : readSavedGeometry(storage.getItem(STORAGE_KEY)));
4174
+ restore(storage === null ? void 0 : readSavedGeometry(storage.getItem(storageKeyFor(currentSurface()))));
3195
4175
  win.addEventListener("resize", schedule);
3196
4176
  win.addEventListener("blur", schedule);
3197
4177
  win.addEventListener("visibilitychange", onVisibilityChange);
@@ -3220,18 +4200,112 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3220
4200
  }
3221
4201
  }
3222
4202
  // src/badge-route.ts
4203
+ /** Return the badge route for one surface. */
4204
+ function badgeRouteFor(surface) {
4205
+ return surface === "ds-bot" ? "/ds-bot-enhance/badge" : "/dsh-enhance/badge";
4206
+ }
4207
+ // src/client/badge-policy.ts
4208
+ /** The dots DS Bot renders on its left column. */
4209
+ const DS_BOT_UNREAD_DOT = ".bt-leftcol .bt-row .bt-unread";
4210
+ /** The row a dot belongs to; one row may carry several marks. */
4211
+ const DS_BOT_ROW = ".bt-row";
4212
+ /**
4213
+ * Visible rows whose completion is unread, plus the attention overlay.
4214
+ *
4215
+ * Blank placeholders and subagent children are skipped. Statuses whose row is
4216
+ * gone are skipped too.
4217
+ * @param byId - list rows by id.
4218
+ * @param status - session status by id.
4219
+ * @param attention - extra ids that finished in the background.
4220
+ * @returns the ids, in list order.
4221
+ */
4222
+ function completionUnreadIds(byId, status, attention) {
4223
+ const unread = [];
4224
+ for (const [id, row] of Object.entries(byId)) {
4225
+ if (row.blank === true || row.origin === "subagent") continue;
4226
+ if (status.get(id)?.completionUnread === true || attention?.has(id) === true) unread.push(id);
4227
+ }
4228
+ return unread;
4229
+ }
4230
+ /**
4231
+ * The rows DS Bot renders with an unread dot.
4232
+ *
4233
+ * One row is one bot, so the number of rows is the number the sidebar shows.
4234
+ * Several marks on one row count once; a mark that is not laid out (a hidden
4235
+ * section, a collapsed group) is skipped.
4236
+ * @param root - the document, or a stand-in in tests. Defaults to `document`.
4237
+ * @returns one entry per unread row, capped at the Host's own badge ceiling.
4238
+ */
4239
+ function unreadSidebarRows(root) {
4240
+ const scope = root ?? defaultRoot();
4241
+ if (scope === void 0 || scope === null) return [];
4242
+ const rows = /* @__PURE__ */ new Set();
4243
+ for (const dot of Array.from(scope.querySelectorAll(DS_BOT_UNREAD_DOT))) {
4244
+ if (!isLaidOut(dot)) continue;
4245
+ const row = dot.closest?.(DS_BOT_ROW) ?? dot;
4246
+ rows.add(row);
4247
+ if (rows.size >= 999) break;
4248
+ }
4249
+ return [...rows];
4250
+ }
3223
4251
  /**
3224
- * The one path the browser half and the Host half share for the Dock badge.
4252
+ * Whether an element occupies space on the page.
3225
4253
  *
3226
- * The two halves are separate bundles (node ESM for the Host, a module-table
3227
- * factory for the page) and cannot call each other directly, so the count
3228
- * travels over the Host's own HTTP surface: the page POSTs it, the Host paints
3229
- * the Dock tile. Keeping the path in one module is what stops the two halves
3230
- * from drifting apart silently — a mismatch would look exactly like a badge
3231
- * that never appears.
3232
- */
3233
- /** Host route that paints the Dock badge; also the URL the page POSTs to. */
3234
- const BADGE_ROUTE = "/dsh-enhance/badge";
4254
+ * A stand-in without layout methods counts as shown, so a test can model only
4255
+ * the structure it cares about.
4256
+ * @param element - the candidate.
4257
+ * @returns false only when the element reports that it has no boxes.
4258
+ */
4259
+ function isLaidOut(element) {
4260
+ if (typeof element.getClientRects !== "function") return true;
4261
+ try {
4262
+ return element.getClientRects().length > 0;
4263
+ } catch {
4264
+ return true;
4265
+ }
4266
+ }
4267
+ /**
4268
+ * The page's document, when there is one.
4269
+ * @returns the document as a counting root, or undefined outside a DOM.
4270
+ */
4271
+ function defaultRoot() {
4272
+ if (typeof document === "undefined") return void 0;
4273
+ return document;
4274
+ }
4275
+ /**
4276
+ * A stable key for one row, so `select` can return ids rather than elements.
4277
+ * @param row - the row element.
4278
+ * @param index - its position, used when the row carries no id.
4279
+ * @returns the row's bot or room id, else its index.
4280
+ */
4281
+ function rowKey(row, index) {
4282
+ const id = row.getAttribute?.("data-bot-id") ?? row.getAttribute?.("data-room-id");
4283
+ return id === null || id === void 0 || id === "" ? `row-${index}` : id;
4284
+ }
4285
+ /**
4286
+ * The counting rule for one surface.
4287
+ *
4288
+ * DS Bot counts the unread rows its own left column renders, which is exactly
4289
+ * the number of green dots the reader sees. An empty sidebar therefore clears
4290
+ * the tile, and an unrendered history session can never inflate it.
4291
+ * @param surface - the decided surface.
4292
+ * @param options - `root` overrides the document in tests.
4293
+ * @returns the policy `installTurnBadge` calls.
4294
+ */
4295
+ function badgePolicyFor(surface, options = {}) {
4296
+ if (surface === "ds-bot") return {
4297
+ id: "ds-bot-sidebar-unread-rows",
4298
+ pending: false,
4299
+ note: "One count per unread row in the DS Bot left column: the same rows that carry a green dot.",
4300
+ select: () => unreadSidebarRows(options.root).map(rowKey)
4301
+ };
4302
+ return {
4303
+ id: "dsh-completion-unread",
4304
+ pending: false,
4305
+ note: "",
4306
+ select: completionUnreadIds
4307
+ };
4308
+ }
3235
4309
  // src/client/turn-badge.ts
3236
4310
  /** localStorage key of the pre-v2 accumulating badge; cleared once on mount. */
3237
4311
  const LEGACY_STORAGE_KEY = "dsh-enhance.turn-badge.v1";
@@ -3248,7 +4322,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3248
4322
  if (typeof base !== "string" || base === "") return;
3249
4323
  let url;
3250
4324
  try {
3251
- url = new URL(BADGE_ROUTE, base).href;
4325
+ url = new URL(badgeRouteFor(currentSurface()), base).href;
3252
4326
  } catch {
3253
4327
  return;
3254
4328
  }
@@ -3261,24 +4335,6 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3261
4335
  } catch {}
3262
4336
  }
3263
4337
  /**
3264
- * Ids of visible (non-blank, non-subagent) sessions whose completion is
3265
- * unread. Statuses of rows the list no longer carries are skipped: a deleted
3266
- * conversation shows no dot in the sidebar either.
3267
- * @param byId - the list snapshot's rows by id.
3268
- * @param status - the Session status snapshot.
3269
- * @param attention - sessions that finished while the window was in the
3270
- * background; the Host's projection does not mark those.
3271
- * @returns the ids to count on the tile, in list order.
3272
- */
3273
- function unreadVisibleIds(byId, status, attention) {
3274
- const unread = [];
3275
- for (const [id, row] of Object.entries(byId)) {
3276
- if (row.blank === true || row.origin === "subagent") continue;
3277
- if (status.get(id)?.completionUnread === true || attention?.has(id) === true) unread.push(id);
3278
- }
3279
- return unread;
3280
- }
3281
- /**
3282
4338
  * The page's own attention source: the window focus the browser reports, with
3283
4339
  * a hidden (minimised or fully occluded) document counting as unfocused.
3284
4340
  * @returns the source, or undefined outside a DOM.
@@ -3317,7 +4373,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3317
4373
  const statusStore = deps.statusSource ?? ctx.uiSession?.sessionStatus;
3318
4374
  if (statusStore === void 0) return () => {};
3319
4375
  try {
3320
- localStorage.removeItem(LEGACY_STORAGE_KEY);
4376
+ localStorage.removeItem(currentSurface() === "ds-bot" ? "ds-bot-enhance.badge.legacy.v1" : LEGACY_STORAGE_KEY);
3321
4377
  } catch {}
3322
4378
  let painted;
3323
4379
  /** Sessions that finished while the window was in the background. */
@@ -3345,7 +4401,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3345
4401
  const paint = () => {
3346
4402
  const byId = ctx.sessions.list.getSnapshot().byId;
3347
4403
  observeRunning(byId);
3348
- const count = unreadVisibleIds(byId, statusStore.getSnapshot(), attention).length;
4404
+ const count = badgePolicyFor(currentSurface()).select(byId, { get: (id) => statusStore.getSnapshot().get(id) }, attention).length;
3349
4405
  if (painted === count) return;
3350
4406
  painted = count;
3351
4407
  paintHost(count);
@@ -4982,6 +6038,19 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
4982
6038
  /** Column the body of an entry sits at, so it lines up under its label. */
4983
6039
  const INDENT = " ";
4984
6040
  /**
6041
+ * Put a block of text under the annotation's labels, one indented line per
6042
+ * line of the original.
6043
+ *
6044
+ * A passage can cover several lines of the transcript, and a comment can be
6045
+ * written with Shift+Enter. Folding both onto one line lost that shape, so the
6046
+ * line breaks are kept and every line sits at the same column.
6047
+ * @param text - the text to indent.
6048
+ * @returns the indented lines.
6049
+ */
6050
+ function indentedLines(text) {
6051
+ return text.split("\n").map((line) => line.length === 0 ? "" : `${INDENT}${line}`);
6052
+ }
6053
+ /**
4985
6054
  * Render one annotation as two labelled blocks: the passage, then the comment.
4986
6055
  *
4987
6056
  * One line with a dash between the two read badly as soon as the passage was
@@ -4991,19 +6060,21 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
4991
6060
  * already says what the text under it is. Without a comment only the passage
4992
6061
  * block is sent — an empty label would ask the model to answer nothing.
4993
6062
  *
6063
+ * The comment label follows the passage on the very next line: a blank line
6064
+ * between them read as if the comment belonged to nothing above it.
6065
+ *
4994
6066
  * The number goes on in `annotationsPrompt`, which keeps this text contiguous:
4995
6067
  * the composer looks for it in the draft before carrying an annotation again.
4996
6068
  * @param annotation - the annotation to render.
4997
6069
  * @returns message text for one annotation, its continuation lines indented.
4998
6070
  */
4999
6071
  function annotationBlock(annotation) {
5000
- const passage = annotation.passage.replace(/\s+/g, " ").trim();
5001
- const quoted = passage.length > 140 ? `${passage.slice(0, 139)}…` : passage;
5002
- const lines = ["Selected text:", `${INDENT}${quoted}`];
6072
+ const passage = annotation.passage.replace(/\r\n|\r/g, "\n").trim();
6073
+ const lines = ["Selected text:", ...indentedLines(passage.length > 140 ? `${passage.slice(0, 139)}…` : passage)];
5003
6074
  const note = annotation.note.replace(/\r\n|\r/g, "\n").trim();
5004
6075
  if (note.length > 0) {
5005
- lines.push("", `${INDENT}User comment:`);
5006
- for (const line of note.split("\n")) lines.push(`${INDENT}${line}`);
6076
+ lines.push(`${INDENT}User comment:`);
6077
+ lines.push(...indentedLines(note));
5007
6078
  }
5008
6079
  return lines.join("\n");
5009
6080
  }
@@ -5020,6 +6091,25 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
5020
6091
  return annotations.map((annotation, index) => `${index + 1}. ${annotationBlock(annotation)}`).join("\n\n");
5021
6092
  }
5022
6093
  /**
6094
+ * The text the composer inserts for the marked passages.
6095
+ *
6096
+ * The reader's own summary is already in the draft, and the passages follow it.
6097
+ * Left on the same line, the summary and the first entry read as one sentence,
6098
+ * so the passages start on the next line whenever something precedes them. The
6099
+ * block itself keeps one blank line between entries, and the trailing blank
6100
+ * line leaves room for the reader's body text under the passages.
6101
+ * @param draft - the text already in the composer.
6102
+ * @param annotations - the annotations being carried.
6103
+ * @param caret - where the passages are inserted, as an offset into the draft.
6104
+ * @returns the text to insert, or an empty string when there is nothing to carry.
6105
+ */
6106
+ function annotationInsertion(draft, annotations, caret = draft.length) {
6107
+ const block = annotationsPrompt(annotations);
6108
+ if (block === "") return "";
6109
+ const at = Math.max(0, Math.min(caret, draft.length));
6110
+ return `${draft.slice(0, at).trim().length > 0 ? "\n" : ""}${block}\n\n`;
6111
+ }
6112
+ /**
5023
6113
  * Annotations whose passage is rendered in one Session's transcript.
5024
6114
  *
5025
6115
  * An annotation is listed under the composer it will be sent from, but its mark
@@ -5714,10 +6804,11 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
5714
6804
  try {
5715
6805
  const missing = annotations.filter((annotation) => !draft.includes(annotationBlock(annotation)));
5716
6806
  if (missing.length > 0) {
5717
- const text = `${annotationsPrompt(missing)}\n\n`;
5718
6807
  const insertion = inputActions.captureInsertion();
6808
+ const text = annotationInsertion(draft, missing, insertion.start);
5719
6809
  if (!inputActions.insertText(text, insertion)) {
5720
- inputActions.setDraft(`${draft}${draft === "" ? "" : "\n\n"}${text}`);
6810
+ const fallback = annotationInsertion(draft, missing);
6811
+ inputActions.setDraft(`${draft}${fallback}`);
5721
6812
  inputActions.persistDraft();
5722
6813
  }
5723
6814
  }
@@ -5986,25 +7077,30 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
5986
7077
  */
5987
7078
  function apply(ctx) {
5988
7079
  const t = ctx.locale.bind(LOCALE_NS);
7080
+ const features = featuresFor(currentSurface());
5989
7081
  ctx.effect(() => ctx.locale.register(LOCALE_NS, {
5990
7082
  zh,
5991
7083
  en
5992
7084
  }), "dsh-enhance: dictionaries");
5993
7085
  installStyles(ctx);
5994
- ctx.effect(() => installWhaleBubbles(document), "dsh-enhance: whale bubbles");
5995
- ctx.effect(() => installFileMenu(ctx, t), "dsh-enhance: file context menu");
5996
- const widthStore = pageStorage();
5997
- ctx.effect(() => installSidebarFloor(document, {
5998
- initialWidth: startupSidebarWidth(widthStore),
5999
- onCommit: (width) => {
6000
- rememberSidebarWidth(widthStore, width);
6001
- }
6002
- }), "dsh-enhance: sidebar floor");
6003
- ctx.effect(() => installSidebarTopRow(document), "dsh-enhance: sidebar top row");
6004
- ctx.effect(() => installSectionStats(ctx, document), "dsh-enhance: section stats");
6005
- if (isDesktopShell()) ctx.effect(() => installStartupGeometry(window), "dsh-enhance: window geometry");
6006
- ctx.effect(() => installTurnBadge(ctx), "dsh-enhance: turn badge");
6007
- registerSideChat(ctx, t);
7086
+ if (features.whale) ctx.effect(() => installWhaleBubbles(document), "dsh-enhance: whale bubbles");
7087
+ if (features.fileMenu) ctx.effect(() => installFileMenu(ctx, t), "dsh-enhance: file context menu");
7088
+ if (features.sidebarFloor) {
7089
+ const widthStore = pageStorage();
7090
+ ctx.effect(() => installSidebarFloor(document, {
7091
+ initialWidth: startupSidebarWidth(widthStore),
7092
+ onCommit: (width) => {
7093
+ rememberSidebarWidth(widthStore, width);
7094
+ }
7095
+ }), "dsh-enhance: sidebar floor");
7096
+ }
7097
+ if (features.sidebarTopRow) ctx.effect(() => installSidebarTopRow(document), "dsh-enhance: sidebar top row");
7098
+ if (features.panelWidths) ctx.effect(() => installPanelWidths(document), "dsh-enhance: panel widths");
7099
+ if (features.liquidGlass) ctx.effect(() => installLiquidGlass(document), "dsh-enhance: liquid glass");
7100
+ if (features.sectionStats) ctx.effect(() => installSectionStats(ctx, document), "dsh-enhance: section stats");
7101
+ if (features.windowGeometry && isDesktopShell()) ctx.effect(() => installStartupGeometry(window), "dsh-enhance: window geometry");
7102
+ if (features.badge) ctx.effect(() => installTurnBadge(ctx), "dsh-enhance: turn badge");
7103
+ if (features.sideChat) registerSideChat(ctx, t);
6008
7104
  /**
6009
7105
  * Open a side conversation beside the current one and hand it the passage as
6010
7106
  * an annotation, not as typed text.
@@ -6040,7 +7136,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
6040
7136
  if (openingSideChat === work) openingSideChat = void 0;
6041
7137
  }
6042
7138
  };
6043
- ctx.effect(() => ctx.slots.inject("conversation.input.overlay", () => ctx.slots.register({
7139
+ if (features.annotations) ctx.effect(() => ctx.slots.inject("conversation.input.overlay", () => ctx.slots.register({
6044
7140
  name: "conversation.input.overlay",
6045
7141
  id: "dsh-enhance-annotations",
6046
7142
  order: 10,