dsh-enhance 0.3.7 → 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 +204 -32
  2. package/lib/client.js +1841 -97
  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
@@ -699,18 +699,101 @@ body[data-ds-dark-theme] [class*="sidebarCol"] {
699
699
  [class*="sidebarCol"] [class*="sectionLabel"] {
700
700
  margin-left: 4px !important;
701
701
  }
702
- /* One indent for both row kinds.
702
+
703
+ /* The section heading gives up its words for two icon counts.
703
704
  *
704
- * Session rows and workspace rows previously used different start insets, which
705
- * made the tree look ragged: the folder title sat further right than the session
706
- * titles under it. Both now start at 5px.
705
+ * The host renders the words ("Workspaces", or "Sessions" in the flat
706
+ * grouping) and re-renders them, so the node stays put and only its text is
707
+ * hidden. The counts row is inserted right after it by section-stats.ts and
708
+ * takes the same line: the heading collapses to nothing, and the row is the
709
+ * heading's flex sibling, so it lands where the words were.
707
710
  *
708
- * A negative margin on the workspace row was tried and reverted: it dragged the
709
- * whole row — glyph included — past the sidebar's left edge, so every triangle
710
- * disappeared. The indent is the only lever that stays inside the column. */
711
+ * One of the two groups shows. The row carries data-active once a session is
712
+ * running or a finished one is still unread, and that group replaces the idle
713
+ * one — totals for sessions and workspaces — rather than sitting beside it.
714
+ * Four numbers on one line would no longer fit the heading's width.
715
+ */
716
+ [class*="sidebarCol"] [class*="sectionHeader"]:has([data-dsh-enhance-stats]) [class*="sectionLabel"] {
717
+ display: none !important;
718
+ }
719
+
720
+ /* The row starts on the sidebar's content edge, the line the reader marked in
721
+ * red. The heading's own padding puts it past that line, so the margin pulls
722
+ * the first icon back onto it. The tree rows below are pulled to the same
723
+ * line, which is what keeps the icons, the arrows and the folder names flush. */
724
+ [data-dsh-enhance-stats] {
725
+ display: inline-flex !important;
726
+ align-items: center !important;
727
+ gap: 10px !important;
728
+ min-width: 0 !important;
729
+ margin-left: -2px !important;
730
+ color: var(--dsw-alias-label-secondary) !important;
731
+ font-size: 12px !important;
732
+ line-height: 16px !important;
733
+ font-variant-numeric: tabular-nums !important;
734
+ }
735
+
736
+ [data-dsh-enhance-stats] [data-group] {
737
+ display: inline-flex !important;
738
+ align-items: center !important;
739
+ gap: 10px !important;
740
+ }
741
+
742
+ [data-dsh-enhance-stats]:not([data-active="true"]) [data-group="active"],
743
+ [data-dsh-enhance-stats][data-active="true"] [data-group="idle"] {
744
+ display: none !important;
745
+ }
746
+
747
+ /* The heading row is a fixed 36px tall and clips its overflow, so a 16px icon
748
+ * leaves a dead band above and below it where the pointer lands on the row
749
+ * instead of the count and the tip never shows. Stretching the count to the
750
+ * row's height makes the whole band the hover target; the icon stays centred. */
751
+ [data-dsh-enhance-stats] .dsh-enhance-stat {
752
+ display: inline-flex !important;
753
+ align-items: center !important;
754
+ gap: 1px !important;
755
+ height: 36px !important;
756
+ margin-top: -10px !important;
757
+ margin-bottom: -10px !important;
758
+ }
759
+
760
+ [data-dsh-enhance-stats] svg {
761
+ flex: none !important;
762
+ width: 14px !important;
763
+ height: 14px !important;
764
+ fill: none !important;
765
+ stroke: currentColor !important;
766
+ stroke-width: 2 !important;
767
+ stroke-linecap: round !important;
768
+ stroke-linejoin: round !important;
769
+ }
770
+
771
+ /* The bell's notification dot is a filled disc in the lucide glyph; the bell
772
+ * itself stays an outline. Filling only the circle keeps both. */
773
+ [data-dsh-enhance-stats] [data-count="unread"] svg circle {
774
+ fill: currentColor !important;
775
+ stroke: none !important;
776
+ }
777
+
778
+ /* The running mark is a filled silhouette, not a stroked outline like the
779
+ * other three, so it opts out of the stroke treatment above. The glyph faces
780
+ * right; the row reads left to right, so it is mirrored to run towards the
781
+ * counts that follow it. */
782
+ [data-dsh-enhance-stats] [data-count="running"] svg {
783
+ fill: currentColor !important;
784
+ stroke: none !important;
785
+ transform: scaleX(-1) !important;
786
+ }
787
+ /* One indent for both row kinds, and that indent is the content edge.
788
+ *
789
+ * The list pulls its rows back 4px and the rows themselves add a start inset,
790
+ * which left the disclosure arrows and the folder names short of the sidebar's
791
+ * content edge. Zeroing the inset lands both on that edge, the same line the
792
+ * counts row above is pulled to. A negative margin was tried instead and
793
+ * reverted: it dragged the whole row past the column, so the arrows vanished. */
711
794
  [role="treeitem"][data-row-key^="session:"],
712
795
  [role="treeitem"][data-row-key^="workspace:"] {
713
- padding-inline-start: 5px !important;
796
+ padding-inline-start: 4px !important;
714
797
  }
715
798
 
716
799
 
@@ -731,6 +814,13 @@ body[data-ds-dark-theme] [class*="sidebarCol"] {
731
814
  * more icons on the first line and the narrowest one (214px) still fits five
732
815
  * 36px buttons and four 2px gaps.
733
816
  *
817
+ * Every hover and active fill is that same square. The host paints the fill on
818
+ * the padding box and keeps a 3px transparent border on each side, the inset
819
+ * it uses to line labelled rows up. On a 36px button that leaves a 30×36
820
+ * painted background, a rectangle, while a plugin button in the same row has
821
+ * no such border and paints a 36px square. The border is dropped here, and the
822
+ * fill is clipped to the border box, so both kinds cover the whole square.
823
+ *
734
824
  * Scope excludes the collapsed rail: there the column is the app's 56px icon
735
825
  * strip (0px on macOS), a row of 36px buttons cannot fit it, and the host's own
736
826
  * vertical layout is the right shape. The rail is not reachable on macOS
@@ -749,13 +839,17 @@ body[data-ds-dark-theme] [class*="sidebarCol"] {
749
839
 
750
840
  [class*="sidebarCol"] [class*="panelList"] [class*="panelTitle"] { display: none !important; }
751
841
  [class*="sidebarCol"] [class*="panelList"] button[class*="panelRow"] {
842
+ box-sizing: border-box !important;
752
843
  width: 36px !important;
753
844
  height: 36px !important;
845
+ min-width: 36px !important;
754
846
  min-height: 36px !important;
755
847
  justify-content: center !important;
756
848
  gap: 0 !important;
757
849
  margin: 0 !important;
758
850
  padding: 0 !important;
851
+ border: none !important;
852
+ background-clip: border-box !important;
759
853
  border-radius: 12px !important;
760
854
  }
761
855
 
@@ -782,7 +876,9 @@ body[data-ds-dark-theme] [class*="sidebarCol"] {
782
876
  * trigger into an icon+label pill that fills that row's width, which means
783
877
  * justify-content:flex-start and a gap. In a 36px square that reads as an icon
784
878
  * glued to the left edge, so the box model is normalised here: centred, no
785
- * gap, no padding, one icon size for the whole row.
879
+ * gap, no padding, no border, one icon size for the whole row. The border goes
880
+ * too: a plugin border would inset the fill the same way the host's side
881
+ * border does, and the row would be back to mixed shapes.
786
882
  *
787
883
  * Only a trigger that carries an icon is normalised: a plugin may also put a
788
884
  * text-only control in the same slot (the Remote plugin's Exit link), and
@@ -798,10 +894,15 @@ body[data-ds-dark-theme] [class*="sidebarCol"] {
798
894
  justify-content: center !important;
799
895
  align-items: center !important;
800
896
  gap: 0 !important;
897
+ box-sizing: border-box !important;
801
898
  width: 36px !important;
802
899
  height: 36px !important;
900
+ min-width: 36px !important;
901
+ min-height: 36px !important;
803
902
  margin: 0 !important;
804
903
  padding: 0 !important;
904
+ border: none !important;
905
+ background-clip: border-box !important;
805
906
  border-radius: 12px !important;
806
907
  font-size: 0 !important;
807
908
  }
@@ -831,10 +932,248 @@ body[data-ds-dark-theme] [class*="sidebarCol"] {
831
932
  [class*="sidebarCol"] [class*="_root"][class*="collapsed"] [data-dsh-enhance-entries] {
832
933
  display: none !important;
833
934
  }
935
+
936
+ /* The right sidebar's Start page lists its tools as one centred column of
937
+ * 380px rounded rectangles (the host's guide entries). Two per row, wrapping,
938
+ * matches the host's own tool grid, and the column stops being a fixed width
939
+ * so the pair fills the pane. */
940
+ [class*="_guide"]:has([data-sidebar-right-guide-entry]) {
941
+ display: grid !important;
942
+ grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
943
+ align-content: center !important;
944
+ justify-items: stretch !important;
945
+ }
946
+ [class*="_guide"]:has([data-sidebar-right-guide-entry]) [class*="entryCell"],
947
+ [class*="_guide"]:has([data-sidebar-right-guide-entry]) [class*="moreAnchor"] {
948
+ width: auto !important;
949
+ max-width: none !important;
950
+ }
951
+ /* The entry sizes to its label, so it would sit as a short pill at the left of
952
+ * its cell. Stretching it makes each card fill its half of the row. The More
953
+ * tools card is the same entry class but carries no data attribute, so it is
954
+ * named alongside the attributed ones. */
955
+ [data-sidebar-right-guide-entry],
956
+ [class*="_guide"] [class$="_entry"] {
957
+ width: 100% !important;
958
+ max-width: none !important;
959
+ box-sizing: border-box !important;
960
+ }
961
+
962
+ /* The compass mark above the list is decoration; the entries name themselves. */
963
+ [class*="_guide"]:has([data-sidebar-right-guide-entry]) [class*="hero"] {
964
+ display: none !important;
965
+ }
966
+
967
+ /* The entries become pills, a third shorter than the host's 56px floor. The
968
+ * radius supplies the curve and the superellipse decides its shape: 1.5
969
+ * flattens the ends toward a rounded rectangle and higher values go squarer,
970
+ * so 1 — a plain ellipse — is the capsule. The attribute is the host's own
971
+ * marker on a guide entry, so no other button is touched. */
972
+ [data-sidebar-right-guide-entry],
973
+ [class*="_guide"] [class$="_entry"] {
974
+ border-radius: 999px !important;
975
+ corner-shape: superellipse(1) !important;
976
+ min-height: 0 !important;
977
+ height: 37px !important;
978
+ padding-top: 0 !important;
979
+ padding-bottom: 0 !important;
980
+ }
981
+
982
+ /* Two more chips that paint a small rounded rectangle: the preset picker in
983
+ * the composer (its hover fill shows the 8px radius) and the background-job
984
+ * count in the session header. Named exactly, because "_seat" and "_trigger"
985
+ * also occur inside the account menu, the access-mode picker and the model
986
+ * picker, which keep their own shape. */
987
+ .ufIuna_seat,
988
+ ._4iHfma_trigger {
989
+ border-radius: 999px !important;
990
+ corner-shape: superellipse(1) !important;
991
+ }
992
+
993
+ /* The composer's plain chips grow a rounded-rectangle hover fill: the
994
+ * workspace picker, the new-worktree toggle, the access-mode picker and the
995
+ * model picker. Only the hover fill changes shape, so the resting chip stays
996
+ * as the host drew it. */
997
+ ._8tPydW_workspace:hover,
998
+ .ZTF-0q_toggle:hover,
999
+ .SJRB_q_trigger:hover,
1000
+ .htuFrW_root:hover .htuFrW_trigger {
1001
+ border-radius: 999px !important;
1002
+ corner-shape: unset !important;
1003
+ }
1004
+
1005
+ /* The send button only looks solid while the pointer is over it: the host
1006
+ * fades it while disabled and swaps its fill for a darker one on hover. It keeps
1007
+ * the solid fill whenever it can be clicked, and stays faded when it cannot.
1008
+ *
1009
+ * While it can be clicked it is a solid disc of the deep blue with a white
1010
+ * arrow. The host's dark theme paints it in the pale accent instead, which
1011
+ * reads as a washed-out pill; the light theme already uses the deep blue, so
1012
+ * naming the static token makes the button look the same in both. */
1013
+ .JZLxKW_primary:not(:disabled) {
1014
+ background: var(--dsw-static-deepseek-500) !important;
1015
+ color: #fff !important;
1016
+ }
1017
+ .JZLxKW_primary:not(:disabled):hover {
1018
+ background: var(--dsw-static-deepseek-400) !important;
1019
+ }
1020
+
1021
+ /* The Preview chip and the "Into the Unknown" line are labels, not controls.
1022
+ * The whale stays. */
1023
+ ._8tPydW_previewBadge,
1024
+ ._8tPydW_titleGroup {
1025
+ display: none !important;
1026
+ }
1027
+
1028
+ .ga5fXW_split {
1029
+ border-radius: var(--dsw-radius-xl) !important;
1030
+ }
1031
+
1032
+ /* The whale swims the way a whale swims: one long, unhurried passage across
1033
+ * the open water of the headline row, a slow rise and fall, and two wide turns
1034
+ * at the ends of the row. The previous version darted between the edges every
1035
+ * few hundred milliseconds, which read as a fish being startled rather than one
1036
+ * making its way.
1037
+ *
1038
+ * Travel and body share one element and one transform. With the scale on a
1039
+ * parent, the parent's scale also scales the child's translation, so the
1040
+ * whale collapsed back to the start of the row while it turned. Here the turn
1041
+ * is a dip to edge-on inside the same transform as the swim, and the fish
1042
+ * never leaves the path it is swimming.
1043
+ *
1044
+ * The host draws the fish facing left, so the sign of the scale carries the
1045
+ * facing: mirrored while it swims right, upright while it swims left. The
1046
+ * rotations are negated in the mirrored stretch, because a mirrored element
1047
+ * turns the other way on screen. */
1048
+ @keyframes dsh-enhance-whale-travel {
1049
+ 0% {
1050
+ transform: translate(0, 0) rotate(0deg) scale(-1.05, 0.96);
1051
+ }
1052
+ 8% {
1053
+ transform: translate(66px, -14px) rotate(3deg) scale(-1.05, 0.96);
1054
+ }
1055
+ 16% {
1056
+ transform: translate(140px, -6px) rotate(-2deg) scale(-0.97, 1.04);
1057
+ }
1058
+ 24% {
1059
+ transform: translate(212px, -18px) rotate(3deg) scale(-1.05, 0.96);
1060
+ }
1061
+ 32% {
1062
+ transform: translate(280px, -8px) rotate(-2deg) scale(-0.97, 1.04);
1063
+ }
1064
+ 40% {
1065
+ transform: translate(336px, 8px) rotate(-5deg) scale(-1.05, 0.96);
1066
+ }
1067
+ 47% {
1068
+ transform: translate(368px, 30px) rotate(-11deg) scale(-0.97, 1.04);
1069
+ }
1070
+ 50% {
1071
+ transform: translate(378px, 42px) rotate(-13deg) scale(-0.5, 1);
1072
+ }
1073
+ 52% {
1074
+ transform: translate(372px, 48px) rotate(-12deg) scale(-0.06, 1.05);
1075
+ }
1076
+ 54% {
1077
+ transform: translate(358px, 52px) rotate(-8deg) scale(0.06, 1.05);
1078
+ }
1079
+ 57% {
1080
+ transform: translate(330px, 56px) rotate(4deg) scale(1.05, 0.96);
1081
+ }
1082
+ 63% {
1083
+ transform: translate(272px, 58px) rotate(3deg) scale(0.97, 1.04);
1084
+ }
1085
+ 71% {
1086
+ transform: translate(196px, 54px) rotate(5deg) scale(1.05, 0.96);
1087
+ }
1088
+ 78% {
1089
+ transform: translate(134px, 44px) rotate(7deg) scale(0.97, 1.04);
1090
+ }
1091
+ 86% {
1092
+ transform: translate(58px, 26px) rotate(8deg) scale(1.05, 0.96);
1093
+ }
1094
+ 93% {
1095
+ transform: translate(10px, 4px) rotate(6deg) scale(0.97, 1.04);
1096
+ }
1097
+ 95% {
1098
+ transform: translate(-14px, -12px) rotate(4deg) scale(0.2, 1.02);
1099
+ }
1100
+ 98% {
1101
+ transform: translate(-8px, -10px) rotate(-3deg) scale(-0.2, 1.02);
1102
+ }
1103
+ 100% {
1104
+ transform: translate(0, 0) rotate(0deg) scale(-1.05, 0.96);
1105
+ }
1106
+ }
1107
+ /* The bubbles the whale leaves behind. Each one is let go at the fish, rises,
1108
+ * swells on the way up, and pops: the last stretch of the keyframe opens the
1109
+ * ring and fades it out. */
1110
+ .dsh-enhance-bubble {
1111
+ position: fixed;
1112
+ border-radius: 50%;
1113
+ border: 1px solid rgba(72, 132, 180, 0.42);
1114
+ background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.98), rgba(186, 220, 242, 0.42) 72%);
1115
+ pointer-events: none;
1116
+ z-index: 30;
1117
+ animation: dsh-enhance-bubble 2.6s cubic-bezier(0.2, 0.6, 0.35, 1) forwards;
1118
+ }
1119
+ body[data-ds-dark-theme] .dsh-enhance-bubble {
1120
+ border-color: rgba(186, 224, 255, 0.5);
1121
+ background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.52), rgba(200, 230, 255, 0.08) 72%);
1122
+ }
1123
+ @keyframes dsh-enhance-bubble {
1124
+ 0% {
1125
+ transform: translate(0, 0) scale(0.3);
1126
+ opacity: 0;
1127
+ }
1128
+ 14% {
1129
+ opacity: 0.85;
1130
+ }
1131
+ 60% {
1132
+ transform: translate(2px, -30px) scale(1);
1133
+ opacity: 0.8;
1134
+ }
1135
+ 80% {
1136
+ transform: translate(-2px, -48px) scale(1.14);
1137
+ opacity: 0.75;
1138
+ }
1139
+ 100% {
1140
+ transform: translate(1px, -62px) scale(2.1);
1141
+ opacity: 0;
1142
+ }
1143
+ }
1144
+ /* The headline row is only as wide as its contents, which leaves the whale
1145
+ * nowhere to swim but across the letters. Stretching the row gives it open
1146
+ * water on both sides; the input card below keeps its own width. */
1147
+ ._8tPydW_headline {
1148
+ width: calc(100vw - 520px) !important;
1149
+ max-width: 960px !important;
1150
+ }
1151
+
1152
+ /* The GenUI prompt toggle paints an inset ring and a fill while a mode is on.
1153
+ * It rests plain and only shows its fill under the pointer. */
1154
+ .aG4Rta_trigger[data-active] {
1155
+ box-shadow: none !important;
1156
+ background: transparent !important;
1157
+ }
1158
+ .aG4Rta_trigger[data-active]:hover {
1159
+ background: var(--dsw-alias-interactive-bg-hover) !important;
1160
+ }
1161
+
1162
+ /* The host rounds every corner with a superellipse, which flattens a pill
1163
+ * back into a rounded rectangle. The variable is what that rule reads. */
1164
+ :root {
1165
+ --dsw-corner-shape: superellipse(1) !important;
1166
+ }
1167
+ @media (prefers-reduced-motion: no-preference) {
1168
+ ._8tPydW_fish {
1169
+ animation: dsh-enhance-whale-travel 24s linear infinite !important;
1170
+ transform-origin: 50% 60% !important;
1171
+ }
1172
+ }
834
1173
  `;
835
1174
  // src/client/styles/toolbar.ts
836
1175
  /** Global presentation owned by dsh-enhance: annotation popover and tray. */
837
- 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
838
1177
  mark survives focus moving into the note field (a native selection would not).
839
1178
  Same blue as the app's document selection, so it reads as the same gesture. */
840
1179
  ::highlight(dsh-enhance-annotation) {
@@ -1760,7 +2099,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1760
2099
  `;
1761
2100
  // src/client/styles/file-menu.ts
1762
2101
  /** Right-click file menu: a small native-looking panel over the transcript. */
1763
- 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
1764
2103
  its own type scale and surface. The dark variant keys off the same theme
1765
2104
  attribute the other sheets use, which the app sets on html or body. */
1766
2105
  .dsh-file-menu {
@@ -1891,22 +2230,594 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1891
2230
  color: #f2f2f4 !important;
1892
2231
  }
1893
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
+ }
1894
2788
  // src/client/styles.ts
1895
- /** Stable plugin identity stamped onto every injected style tag. */
1896
- const PLUGIN_ID = "dsh-enhance";
1897
- /** 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. */
1898
2790
  const SHEETS = [
1899
- ["document-preview.css", css$7],
1900
- ["chat-markdown.css", css$6],
1901
- ["rightbar-handle.css", css$5],
1902
- ["running-spinner.css", css$4],
1903
- ["sidebar-density.css", css$3],
1904
- ["sidebar-layout.css", css$2],
1905
- ["toolbar.css", css$1],
1906
- ["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]
1907
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
+ }
1908
2819
  /**
1909
- * Mount every global sheet for exactly the owning plugin lifetime.
2820
+ * Mount one surface's sheets for exactly the owning plugin lifetime.
1910
2821
  *
1911
2822
  * The tags carry `data-plugin`, so the client module system's entry lifecycle
1912
2823
  * evicts them when this plugin unloads even if the fiber is torn down abruptly.
@@ -1914,16 +2825,112 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1914
2825
  */
1915
2826
  function installStyles(ctx) {
1916
2827
  if (typeof document === "undefined") return;
1917
- 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(() => {
1918
2831
  const tag = document.createElement("style");
1919
- tag.dataset.plugin = PLUGIN_ID;
1920
- tag.dataset.pluginCss = `${PLUGIN_ID}/${name}`;
2832
+ tag.dataset.plugin = pluginId;
2833
+ tag.dataset.pluginCss = `${pluginId}/${name}`;
1921
2834
  tag.textContent = css;
1922
2835
  document.head.appendChild(tag);
1923
2836
  return () => {
1924
2837
  tag.remove();
1925
2838
  };
1926
- }, `dsh-enhance: ${name} stylesheet`);
2839
+ }, `${pluginId}: ${name} stylesheet`);
2840
+ }
2841
+ // src/client/whale-bubbles.ts
2842
+ /**
2843
+ * Small bubbles trailing the whale on the empty page.
2844
+ *
2845
+ * The whale is the host's own hero illustration, and the plugin drives it with
2846
+ * a stylesheet animation. A stylesheet cannot put a bubble where the fish
2847
+ * happens to be: the bubble has to be let go at the fish's current position
2848
+ * and then left behind, and only a script can do that. The bubble itself is
2849
+ * drawn and animated by the stylesheet — this module only decides where and
2850
+ * when one appears.
2851
+ *
2852
+ * The fish is found through the plugin's own travel animation rather than
2853
+ * through the host's hashed CSS-module class, so the lookup survives a host
2854
+ * release that renames that module. Under reduced motion the animation never
2855
+ * runs, no fish is found and no bubbles appear, which is the right outcome.
2856
+ */
2857
+ /** Name of the animation the plugin gives the whale; it identifies the fish. */
2858
+ const TRAVEL_ANIMATION = "dsh-enhance-whale-travel";
2859
+ /** Class the stylesheet draws the bubble with. */
2860
+ const BUBBLE_CLASS = "dsh-enhance-bubble";
2861
+ /** How often a bubble is let go, in milliseconds. */
2862
+ const INTERVAL = 620;
2863
+ /** Bubbles alive at once. Each lives about 2.6s, so the trail stays short. */
2864
+ const MAX_LIVE = 16;
2865
+ /** Smallest and largest bubble, in pixels. */
2866
+ const MIN_SIZE = 5;
2867
+ /**
2868
+ * Find the whale.
2869
+ *
2870
+ * The travel animation is applied to the fish by the plugin's own stylesheet,
2871
+ * so the animation is a stable handle on it: the host's class names are
2872
+ * hashed per release and change without notice.
2873
+ * @param root - document the plugin is mounted in.
2874
+ * @returns the whale element, or null when the page has no whale.
2875
+ */
2876
+ function findWhale(root) {
2877
+ for (const animation of root.getAnimations()) {
2878
+ if (animation.animationName !== TRAVEL_ANIMATION) continue;
2879
+ const target = animation.effect?.target;
2880
+ if (target === null || target === void 0) continue;
2881
+ const node = target;
2882
+ if (node.nodeType === 1 && typeof node.getBoundingClientRect === "function") return node;
2883
+ }
2884
+ return null;
2885
+ }
2886
+ /**
2887
+ * Let go one bubble at the whale.
2888
+ * @param root - document the plugin is mounted in.
2889
+ * @param whale - the fish to bubble from.
2890
+ * @returns the bubble element, or null when the fish is not on screen.
2891
+ */
2892
+ function spawn(root, whale) {
2893
+ const rect = whale.getBoundingClientRect();
2894
+ if (rect.width === 0) return null;
2895
+ const size = MIN_SIZE + Math.random() * 4;
2896
+ const bubble = root.createElement("div");
2897
+ bubble.className = BUBBLE_CLASS;
2898
+ bubble.style.width = `${size}px`;
2899
+ bubble.style.height = `${size}px`;
2900
+ bubble.style.marginLeft = `${-size / 2}px`;
2901
+ bubble.style.marginTop = `${-size / 2}px`;
2902
+ bubble.style.left = `${rect.left + rect.width * .5 + (Math.random() * 8 - 4)}px`;
2903
+ bubble.style.top = `${rect.top + rect.height * .3}px`;
2904
+ bubble.style.animationDuration = `${2.2 + Math.random() * .8}s`;
2905
+ root.body.appendChild(bubble);
2906
+ return bubble;
2907
+ }
2908
+ /**
2909
+ * Install the bubble trail.
2910
+ * @param root - document the plugin is mounted in.
2911
+ * @returns disposer that stops the trail and clears the bubbles still up.
2912
+ */
2913
+ function installWhaleBubbles(root) {
2914
+ let live = 0;
2915
+ const timer = window.setInterval(() => {
2916
+ const whale = findWhale(root);
2917
+ if (whale === null) return;
2918
+ if (live >= MAX_LIVE) return;
2919
+ const bubble = spawn(root, whale);
2920
+ if (bubble === null) return;
2921
+ live += 1;
2922
+ bubble.addEventListener("animationend", () => {
2923
+ live -= 1;
2924
+ bubble.remove();
2925
+ });
2926
+ }, INTERVAL);
2927
+ return () => {
2928
+ window.clearInterval(timer);
2929
+ live = 0;
2930
+ root.querySelectorAll(`.${BUBBLE_CLASS}`).forEach((bubble) => {
2931
+ bubble.remove();
2932
+ });
2933
+ };
1927
2934
  }
1928
2935
  // src/client/sidebar-floor.ts
1929
2936
  /**
@@ -2271,6 +3278,604 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2271
3278
  else home.append(moved);
2272
3279
  };
2273
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
+ }
3679
+ // src/client/section-stats.ts
3680
+ /** Marks the injected row, for the stylesheet and the disposer. */
3681
+ const STATS_ATTRIBUTE = "data-dsh-enhance-stats";
3682
+ /**
3683
+ * Count what the row displays.
3684
+ *
3685
+ * Blank rows and subagent children are excluded from every session count: the
3686
+ * sidebar shows neither as a conversation of its own, so counting them would
3687
+ * disagree with the tree under the heading.
3688
+ * @param byId - the session list snapshot.
3689
+ * @param status - the session status snapshot.
3690
+ * @param workspaces - number of workspaces in the list.
3691
+ * @returns the four counts.
3692
+ */
3693
+ function sectionCounts(byId, status, workspaces) {
3694
+ let sessions = 0;
3695
+ let running = 0;
3696
+ let unread = 0;
3697
+ for (const [id, row] of Object.entries(byId)) {
3698
+ if (row.blank === true || row.origin === "subagent") continue;
3699
+ sessions += 1;
3700
+ if (row.running === true) running += 1;
3701
+ if (status.get(id)?.completionUnread === true) unread += 1;
3702
+ }
3703
+ return {
3704
+ sessions,
3705
+ workspaces,
3706
+ running,
3707
+ unread
3708
+ };
3709
+ }
3710
+ /**
3711
+ * The idle pair: how many conversations exist, and how many workspaces hold them.
3712
+ *
3713
+ * `message-circle-more` stands for a conversation, which is what a session is
3714
+ * here. `folder` stands for a workspace, the group the tree splits sessions into.
3715
+ */
3716
+ const IDLE_ITEMS = [{
3717
+ count: "sessions",
3718
+ tip: (count) => `${count} sessions`,
3719
+ icon: "<path d=\"M7.9 20A9 9 0 1 0 4 16.1L2 22Z\"/><path d=\"M8 12h.01\"/><path d=\"M12 12h.01\"/><path d=\"M16 12h.01\"/>"
3720
+ }, {
3721
+ count: "workspaces",
3722
+ tip: (count) => `${count} workspaces`,
3723
+ icon: "<path d=\"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z\"/>"
3724
+ }];
3725
+ /**
3726
+ * The active pair: conversations running right now, and ones that finished
3727
+ * without being looked at.
3728
+ *
3729
+ * `directions-run` is the running mark: a figure mid-stride, which reads as
3730
+ * running where a standing figure does not. `bell-dot` is the unread mark, a
3731
+ * bell with a dot, the same idea as the green dot on a finished session.
3732
+ */
3733
+ const ACTIVE_ITEMS = [{
3734
+ count: "running",
3735
+ tip: (count) => `${count} running`,
3736
+ icon: "<path d=\"M13.49 5.48c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m-3.6 13.9 1-4.4 2.1 2v6h2v-7.5l-2.1-2 .6-3c1.3 1.5 3.3 2.5 5.5 2.5v-2c-1.9 0-3.5-1-4.3-2.4l-1-1.6c-.4-.6-1-1-1.7-1-.3 0-.5.1-.8.1l-5.2 2.2v4.7h2v-3.4l1.8-.7-1.6 8.1-4.9-1-.4 2z\"/>"
3737
+ }, {
3738
+ count: "unread",
3739
+ tip: (count) => `${count} unread`,
3740
+ icon: "<path d=\"M19.4 14.9C20.2 16.4 21 17 21 17H3s3-2 3-9c0-3.3 2.7-6 6-6 .7 0 1.3.1 1.9.3\"/><path d=\"M10.3 21a1.94 1.94 0 0 0 3.4 0\"/><circle cx=\"18\" cy=\"8\" r=\"3\"/>"
3741
+ }];
3742
+ /** One count: the icon, then the number. The hover text starts empty and is filled with the number. */
3743
+ function item(entry) {
3744
+ return `<span class="dsh-enhance-stat" data-count="${entry.count}"><svg viewBox="0 0 24 24" aria-hidden="true">${entry.icon}</svg><span class="dsh-enhance-stat__value"></span></span>`;
3745
+ }
3746
+ /** Hover text for one count, looked up by the key the row stores on each item. */
3747
+ const TIPS = Object.fromEntries([...IDLE_ITEMS, ...ACTIVE_ITEMS].map((entry) => [entry.count, entry.tip]));
3748
+ /** The row: the idle pair and the active pair, one of them hidden by CSS. */
3749
+ function rowMarkup() {
3750
+ return `<span class="dsh-enhance-stats__group" data-group="idle">${IDLE_ITEMS.map(item).join("")}</span><span class="dsh-enhance-stats__group" data-group="active">${ACTIVE_ITEMS.map(item).join("")}</span>`;
3751
+ }
3752
+ /**
3753
+ * Write the four numbers into a row already in the document.
3754
+ *
3755
+ * Only a number that changed is touched, so a list update that moves nothing
3756
+ * this row cares about costs no layout.
3757
+ * @param row - the injected row.
3758
+ * @param counts - the numbers to show.
3759
+ * @param previous - the numbers currently shown, mutated to match.
3760
+ */
3761
+ function paintCounts(row, counts, previous) {
3762
+ const active = counts.running > 0 || counts.unread > 0;
3763
+ if (row.dataset.active !== String(active)) row.dataset.active = String(active);
3764
+ for (const key of [
3765
+ "sessions",
3766
+ "workspaces",
3767
+ "running",
3768
+ "unread"
3769
+ ]) {
3770
+ if (previous[key] === counts[key]) continue;
3771
+ previous[key] = counts[key];
3772
+ const value = row.querySelector(`[data-count="${key}"] .dsh-enhance-stat__value`);
3773
+ if (value !== null) value.textContent = String(counts[key]);
3774
+ const stat = row.querySelector(`[data-count="${key}"]`);
3775
+ if (stat !== null) stat.title = TIPS[key](counts[key]);
3776
+ }
3777
+ }
3778
+ /**
3779
+ * Install the counts in place of the section heading.
3780
+ * @param ctx - client root carrying the session list, its status and the workspaces.
3781
+ * @param root - document the plugin is mounted in.
3782
+ * @param sources - override the host stores, mainly for tests.
3783
+ * @returns disposer that removes the row.
3784
+ */
3785
+ function installSectionStats(ctx, root, sources) {
3786
+ const from = sources ?? sourcesFrom(ctx);
3787
+ if (from === void 0) return () => {};
3788
+ let frame = 0;
3789
+ let row = null;
3790
+ const shown = {};
3791
+ /** The heading the host renders, re-queried because a re-render replaces it. */
3792
+ const heading = () => {
3793
+ for (const column of root.querySelectorAll("[class*=\"sidebarCol\"]")) {
3794
+ const label = column.querySelector("[class*=\"sectionLabel\"]");
3795
+ if (label !== null) return label;
3796
+ }
3797
+ return null;
3798
+ };
3799
+ /** Build the row once and keep it next to the heading. */
3800
+ const place = () => {
3801
+ const label = heading();
3802
+ if (label === null || label.parentElement === null) return;
3803
+ if (row === null || !row.isConnected) {
3804
+ row = root.createElement("span");
3805
+ row.setAttribute(STATS_ATTRIBUTE, "");
3806
+ row.className = "dsh-enhance-stats";
3807
+ row.innerHTML = rowMarkup();
3808
+ for (const key of Object.keys(shown)) delete shown[key];
3809
+ }
3810
+ if (row.previousElementSibling !== label) label.after(row);
3811
+ };
3812
+ /** Recompute and paint. Cheap enough to run on every list change. */
3813
+ const paint = () => {
3814
+ place();
3815
+ if (row === null) return;
3816
+ paintCounts(row, sectionCounts(from.sessions().byId, from.status(), from.workspaces().length), shown);
3817
+ };
3818
+ const schedule = () => {
3819
+ if (frame !== 0) return;
3820
+ frame = requestAnimationFrame(() => {
3821
+ frame = 0;
3822
+ paint();
3823
+ });
3824
+ };
3825
+ let observer = null;
3826
+ let observed = null;
3827
+ const watch = () => {
3828
+ const column = root.querySelector("[class*=\"sidebarCol\"]");
3829
+ if (column === observed) return;
3830
+ observer?.disconnect();
3831
+ observer = new MutationObserver(schedule);
3832
+ observed = column;
3833
+ observer.observe(column ?? root.documentElement, {
3834
+ childList: true,
3835
+ subtree: true
3836
+ });
3837
+ };
3838
+ watch();
3839
+ paint();
3840
+ const stopSessions = from.subscribeSessions(paint);
3841
+ const stopStatus = from.subscribeStatus(paint);
3842
+ const stopWorkspaces = from.subscribeWorkspaces(paint);
3843
+ const mountWatcher = new MutationObserver(() => {
3844
+ if (observed !== null && observed.isConnected) return;
3845
+ watch();
3846
+ schedule();
3847
+ });
3848
+ mountWatcher.observe(root.documentElement, {
3849
+ childList: true,
3850
+ subtree: true
3851
+ });
3852
+ return () => {
3853
+ if (frame !== 0) cancelAnimationFrame(frame);
3854
+ observer?.disconnect();
3855
+ mountWatcher.disconnect();
3856
+ stopSessions();
3857
+ stopStatus();
3858
+ stopWorkspaces();
3859
+ row?.remove();
3860
+ row = null;
3861
+ };
3862
+ }
3863
+ /** The host stores behind the structural face, or undefined when one is missing. */
3864
+ function sourcesFrom(ctx) {
3865
+ const services = ctx;
3866
+ const sessions = services.sessions?.list;
3867
+ const status = services.uiSession?.sessionStatus;
3868
+ const workspaces = services.workspaces?.list;
3869
+ if (sessions === void 0 || status === void 0 || workspaces === void 0) return void 0;
3870
+ return {
3871
+ sessions: () => sessions.getSnapshot(),
3872
+ subscribeSessions: (listener) => sessions.subscribe(listener),
3873
+ status: () => status.getSnapshot(),
3874
+ subscribeStatus: (listener) => status.subscribe(listener),
3875
+ workspaces: () => ({ length: workspaces.getSnapshot().items.length }),
3876
+ subscribeWorkspaces: (listener) => workspaces.subscribe(listener)
3877
+ };
3878
+ }
2274
3879
  // src/client/sidebar-width.ts
2275
3880
  /**
2276
3881
  * The sidebar width the shell opens with, and the one it is left at.
@@ -2289,6 +3894,10 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2289
3894
  */
2290
3895
  /** localStorage key holding the last width this plugin settled on. */
2291
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
+ }
2292
3901
  /**
2293
3902
  * Read a remembered width, rejecting anything outside the contract range.
2294
3903
  * @param raw - the stored string, or null.
@@ -2308,7 +3917,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2308
3917
  function startupSidebarWidth(store) {
2309
3918
  if (store === null) return 214;
2310
3919
  try {
2311
- return readSidebarWidth(store.getItem("dsh-enhance.sidebar-width.v1")) ?? 214;
3920
+ return readSidebarWidth(store.getItem(storageKeyFor$1(currentSurface()))) ?? 214;
2312
3921
  } catch {
2313
3922
  return 214;
2314
3923
  }
@@ -2322,7 +3931,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2322
3931
  if (store === null) return;
2323
3932
  const bounded = Math.round(Math.min(Math.max(width, 214), 420));
2324
3933
  try {
2325
- store.setItem(STORAGE_KEY$1, String(bounded));
3934
+ store.setItem(storageKeyFor$1(currentSurface()), String(bounded));
2326
3935
  } catch {}
2327
3936
  }
2328
3937
  /**
@@ -2361,6 +3970,10 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2361
3970
  */
2362
3971
  /** localStorage key holding the last close's frame. */
2363
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
+ }
2364
3977
  /**
2365
3978
  * Read the work area out of a window's screen.
2366
3979
  *
@@ -2543,7 +4156,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2543
4156
  const maximized = isFilled(frame, area);
2544
4157
  if (!maximized) normal = frame;
2545
4158
  try {
2546
- storage.setItem(STORAGE_KEY, JSON.stringify({
4159
+ storage.setItem(storageKeyFor(currentSurface()), JSON.stringify({
2547
4160
  normal,
2548
4161
  maximized
2549
4162
  }));
@@ -2558,7 +4171,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2558
4171
  const onVisibilityChange = () => {
2559
4172
  if (win.document.visibilityState === "hidden") save();
2560
4173
  };
2561
- restore(storage === null ? void 0 : readSavedGeometry(storage.getItem(STORAGE_KEY)));
4174
+ restore(storage === null ? void 0 : readSavedGeometry(storage.getItem(storageKeyFor(currentSurface()))));
2562
4175
  win.addEventListener("resize", schedule);
2563
4176
  win.addEventListener("blur", schedule);
2564
4177
  win.addEventListener("visibilitychange", onVisibilityChange);
@@ -2587,18 +4200,112 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2587
4200
  }
2588
4201
  }
2589
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";
2590
4212
  /**
2591
- * The one path the browser half and the Host half share for the Dock badge.
4213
+ * Visible rows whose completion is unread, plus the attention overlay.
2592
4214
  *
2593
- * The two halves are separate bundles (node ESM for the Host, a module-table
2594
- * factory for the page) and cannot call each other directly, so the count
2595
- * travels over the Host's own HTTP surface: the page POSTs it, the Host paints
2596
- * the Dock tile. Keeping the path in one module is what stops the two halves
2597
- * from drifting apart silently — a mismatch would look exactly like a badge
2598
- * that never appears.
2599
- */
2600
- /** Host route that paints the Dock badge; also the URL the page POSTs to. */
2601
- const BADGE_ROUTE = "/dsh-enhance/badge";
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
+ }
4251
+ /**
4252
+ * Whether an element occupies space on the page.
4253
+ *
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
+ }
2602
4309
  // src/client/turn-badge.ts
2603
4310
  /** localStorage key of the pre-v2 accumulating badge; cleared once on mount. */
2604
4311
  const LEGACY_STORAGE_KEY = "dsh-enhance.turn-badge.v1";
@@ -2615,7 +4322,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2615
4322
  if (typeof base !== "string" || base === "") return;
2616
4323
  let url;
2617
4324
  try {
2618
- url = new URL(BADGE_ROUTE, base).href;
4325
+ url = new URL(badgeRouteFor(currentSurface()), base).href;
2619
4326
  } catch {
2620
4327
  return;
2621
4328
  }
@@ -2628,24 +4335,6 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2628
4335
  } catch {}
2629
4336
  }
2630
4337
  /**
2631
- * Ids of visible (non-blank, non-subagent) sessions whose completion is
2632
- * unread. Statuses of rows the list no longer carries are skipped: a deleted
2633
- * conversation shows no dot in the sidebar either.
2634
- * @param byId - the list snapshot's rows by id.
2635
- * @param status - the Session status snapshot.
2636
- * @param attention - sessions that finished while the window was in the
2637
- * background; the Host's projection does not mark those.
2638
- * @returns the ids to count on the tile, in list order.
2639
- */
2640
- function unreadVisibleIds(byId, status, attention) {
2641
- const unread = [];
2642
- for (const [id, row] of Object.entries(byId)) {
2643
- if (row.blank === true || row.origin === "subagent") continue;
2644
- if (status.get(id)?.completionUnread === true || attention?.has(id) === true) unread.push(id);
2645
- }
2646
- return unread;
2647
- }
2648
- /**
2649
4338
  * The page's own attention source: the window focus the browser reports, with
2650
4339
  * a hidden (minimised or fully occluded) document counting as unfocused.
2651
4340
  * @returns the source, or undefined outside a DOM.
@@ -2684,7 +4373,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2684
4373
  const statusStore = deps.statusSource ?? ctx.uiSession?.sessionStatus;
2685
4374
  if (statusStore === void 0) return () => {};
2686
4375
  try {
2687
- localStorage.removeItem(LEGACY_STORAGE_KEY);
4376
+ localStorage.removeItem(currentSurface() === "ds-bot" ? "ds-bot-enhance.badge.legacy.v1" : LEGACY_STORAGE_KEY);
2688
4377
  } catch {}
2689
4378
  let painted;
2690
4379
  /** Sessions that finished while the window was in the background. */
@@ -2712,7 +4401,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2712
4401
  const paint = () => {
2713
4402
  const byId = ctx.sessions.list.getSnapshot().byId;
2714
4403
  observeRunning(byId);
2715
- const count = unreadVisibleIds(byId, statusStore.getSnapshot(), attention).length;
4404
+ const count = badgePolicyFor(currentSurface()).select(byId, { get: (id) => statusStore.getSnapshot().get(id) }, attention).length;
2716
4405
  if (painted === count) return;
2717
4406
  painted = count;
2718
4407
  paintHost(count);
@@ -4346,32 +6035,79 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
4346
6035
  refresh(sessionId);
4347
6036
  publish();
4348
6037
  }
6038
+ /** Column the body of an entry sits at, so it lines up under its label. */
6039
+ const INDENT = " ";
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
+ }
4349
6053
  /**
4350
- * Render one annotation as the compact reference the composer carries.
6054
+ * Render one annotation as two labelled blocks: the passage, then the comment.
6055
+ *
6056
+ * One line with a dash between the two read badly as soon as the passage was
6057
+ * long: the quotation, the truncation ellipsis and the reader's own sentence
6058
+ * ran together, and the words they typed were no longer visibly theirs. Named
6059
+ * blocks keep each half on its own lines, and drop the quotes, since the label
6060
+ * already says what the text under it is. Without a comment only the passage
6061
+ * block is sent — an empty label would ask the model to answer nothing.
4351
6062
  *
4352
- * The composer is a reading surface, not a document: a whole annotation block
4353
- * dumped into it buries what the reader was writing. One line per annotation
4354
- * keeps the draft readable while still carrying both halves the model needs.
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
+ *
6066
+ * The number goes on in `annotationsPrompt`, which keeps this text contiguous:
6067
+ * the composer looks for it in the draft before carrying an annotation again.
4355
6068
  * @param annotation - the annotation to render.
4356
- * @returns one line of message text.
6069
+ * @returns message text for one annotation, its continuation lines indented.
4357
6070
  */
4358
- function annotationLine(annotation) {
4359
- const passage = annotation.passage.replace(/\s+/g, " ").trim();
4360
- const quoted = passage.length > 140 ? `${passage.slice(0, 139)}…` : passage;
4361
- const note = annotation.note.trim();
4362
- return note.length === 0 ? `"${quoted}"` : `"${quoted}" — ${note}`;
6071
+ function annotationBlock(annotation) {
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)];
6074
+ const note = annotation.note.replace(/\r\n|\r/g, "\n").trim();
6075
+ if (note.length > 0) {
6076
+ lines.push(`${INDENT}User comment:`);
6077
+ lines.push(...indentedLines(note));
6078
+ }
6079
+ return lines.join("\n");
4363
6080
  }
4364
6081
  /**
4365
6082
  * Render the marked passages as the preamble of an outgoing message.
4366
6083
  *
4367
- * The block lists what the instructions refer to, then leaves the reader's own
4368
- * words as the body of the message underneath.
6084
+ * Each annotation becomes a numbered entry, and the reader's own words follow
6085
+ * the last one as the body of the message.
4369
6086
  * @param annotations - the annotations being sent.
4370
6087
  * @returns message text, or an empty string when there are none.
4371
6088
  */
4372
6089
  function annotationsPrompt(annotations) {
4373
6090
  if (annotations.length === 0) return "";
4374
- return `Regarding these passages:\n${annotations.map((annotation) => `- ${annotationLine(annotation)}`).join("\n")}`;
6091
+ return annotations.map((annotation, index) => `${index + 1}. ${annotationBlock(annotation)}`).join("\n\n");
6092
+ }
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`;
4375
6111
  }
4376
6112
  /**
4377
6113
  * Annotations whose passage is rendered in one Session's transcript.
@@ -5066,12 +6802,13 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
5066
6802
  if (carrying) return;
5067
6803
  carrying = true;
5068
6804
  try {
5069
- const missing = annotations.filter((annotation) => !draft.includes(annotationLine(annotation)));
6805
+ const missing = annotations.filter((annotation) => !draft.includes(annotationBlock(annotation)));
5070
6806
  if (missing.length > 0) {
5071
- const text = `${annotationsPrompt(missing)}\n\n`;
5072
6807
  const insertion = inputActions.captureInsertion();
6808
+ const text = annotationInsertion(draft, missing, insertion.start);
5073
6809
  if (!inputActions.insertText(text, insertion)) {
5074
- inputActions.setDraft(`${draft}${draft === "" ? "" : "\n\n"}${text}`);
6810
+ const fallback = annotationInsertion(draft, missing);
6811
+ inputActions.setDraft(`${draft}${fallback}`);
5075
6812
  inputActions.persistDraft();
5076
6813
  }
5077
6814
  }
@@ -5340,23 +7077,30 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
5340
7077
  */
5341
7078
  function apply(ctx) {
5342
7079
  const t = ctx.locale.bind(LOCALE_NS);
7080
+ const features = featuresFor(currentSurface());
5343
7081
  ctx.effect(() => ctx.locale.register(LOCALE_NS, {
5344
7082
  zh,
5345
7083
  en
5346
7084
  }), "dsh-enhance: dictionaries");
5347
7085
  installStyles(ctx);
5348
- ctx.effect(() => installFileMenu(ctx, t), "dsh-enhance: file context menu");
5349
- const widthStore = pageStorage();
5350
- ctx.effect(() => installSidebarFloor(document, {
5351
- initialWidth: startupSidebarWidth(widthStore),
5352
- onCommit: (width) => {
5353
- rememberSidebarWidth(widthStore, width);
5354
- }
5355
- }), "dsh-enhance: sidebar floor");
5356
- ctx.effect(() => installSidebarTopRow(document), "dsh-enhance: sidebar top row");
5357
- if (isDesktopShell()) ctx.effect(() => installStartupGeometry(window), "dsh-enhance: window geometry");
5358
- ctx.effect(() => installTurnBadge(ctx), "dsh-enhance: turn badge");
5359
- 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);
5360
7104
  /**
5361
7105
  * Open a side conversation beside the current one and hand it the passage as
5362
7106
  * an annotation, not as typed text.
@@ -5392,7 +7136,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
5392
7136
  if (openingSideChat === work) openingSideChat = void 0;
5393
7137
  }
5394
7138
  };
5395
- 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({
5396
7140
  name: "conversation.input.overlay",
5397
7141
  id: "dsh-enhance-annotations",
5398
7142
  order: 10,