dsh-enhance 0.1.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -7,9 +7,9 @@ window.__ModuleLoader__.load({
7
7
  let react = require("react");
8
8
  let react_dom = require("react-dom");
9
9
  let react_jsx_runtime = require("react/jsx-runtime");
10
- //#region src/client/styles/document-preview.ts
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$5 = String.raw`body[data-ds-dark-theme] [data-document-markdown] {
12
+ const css$6 = 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;
@@ -189,10 +189,9 @@ body:not([data-ds-dark-theme]) [data-document-markdown] {
189
189
  border-radius: var(--md-radius-md);
190
190
  }
191
191
  `;
192
- //#endregion
193
- //#region src/client/styles/chat-markdown.ts
192
+ // src/client/styles/chat-markdown.ts
194
193
  /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
195
- const css$4 = String.raw`:is([data-ds-dark-theme], [data-ds-dark-theme] body) :is([data-chat-flow-kind="assistant-step"], [class*="_markdown"]) {
194
+ const css$5 = String.raw`:is([data-ds-dark-theme], [data-ds-dark-theme] body) :is([data-chat-flow-kind="assistant-step"], [class*="_markdown"]) {
196
195
  --md-text: #efefef;
197
196
  --md-text-strong: #fff;
198
197
  --md-text-muted: #a5a5a5;
@@ -424,10 +423,9 @@ body:not([data-ds-dark-theme]) [data-document-markdown] {
424
423
  border-radius: var(--md-radius-md);
425
424
  }
426
425
  `;
427
- //#endregion
428
- //#region src/client/styles/rightbar-handle.ts
426
+ // src/client/styles/rightbar-handle.ts
429
427
  /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
430
- const css$3 = String.raw`[data-side="rightbar"] {
428
+ const css$4 = String.raw`[data-side="rightbar"] {
431
429
  width: 18px !important;
432
430
  margin-left: -9px !important;
433
431
  cursor: col-resize;
@@ -457,10 +455,88 @@ body:not([data-ds-dark-theme]) [data-document-markdown] {
457
455
  opacity: 1;
458
456
  }
459
457
  `;
460
- //#endregion
461
- //#region src/client/styles/sidebar-density.ts
458
+ // src/client/styles/running-spinner.ts
462
459
  /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
463
- const css$2 = String.raw`/* Light-surface sidebar text scale. The app's own de-emphasised label tokens
460
+ const css$3 = String.raw`/* A running session's marker is the host's StateDot in its "ongoing" form: an
461
+ inline SVG holding two circles — a faint track and a dashed arc that spins
462
+ and lengthens. Both circles stroke with currentColor, and the host paints
463
+ that token as label-tertiary, a grey, so a live session reads exactly as
464
+ muted as an idle one.
465
+
466
+ Because the colour arrives through currentColor, one declaration recolours
467
+ the whole ring: the color property on the svg root. The spectrum then comes
468
+ from a hue-rotate on that same root, which walks both circles together, so
469
+ the track stays a dim version of the arc instead of drifting into a second
470
+ hue.
471
+
472
+ Nothing here touches the dash or the spin. Those carry the information
473
+ (something is happening) and belong to the host; only the paint is ours.
474
+ That is also why no stroke rule is written at all — the host's animation on
475
+ the arc would be outranked by any !important on it, freezing the dashes.
476
+
477
+ Scope is the sidebar's status slot. StateDots elsewhere (jobs, approval,
478
+ workflow runs) keep the host's own treatment. */
479
+ [class*="sidebarCol"] svg[data-state="ongoing"][class*="spinner"] {
480
+ color: #3b82f6;
481
+ filter: drop-shadow(0 0 2.5px rgb(96 165 250 / 55%));
482
+ animation: dsh-enhance-spinner-spectrum 4s linear infinite;
483
+ }
484
+
485
+ /* Blue, violet, magenta, amber, blue: every stop stays legible against both
486
+ the light and the dark sidebar, and the loop returns to its start hue so
487
+ there is no jump at the seam. The glow rotates with the ring. */
488
+ @keyframes dsh-enhance-spinner-spectrum {
489
+ 0% { filter: drop-shadow(0 0 2.5px rgb(96 165 250 / 55%)) hue-rotate(0deg); }
490
+ 25% { filter: drop-shadow(0 0 2.5px rgb(96 165 250 / 55%)) hue-rotate(70deg); }
491
+ 50% { filter: drop-shadow(0 0 2.5px rgb(96 165 250 / 55%)) hue-rotate(150deg); }
492
+ 75% { filter: drop-shadow(0 0 2.5px rgb(96 165 250 / 55%)) hue-rotate(280deg); }
493
+ to { filter: drop-shadow(0 0 2.5px rgb(96 165 250 / 55%)) hue-rotate(360deg); }
494
+ }
495
+
496
+ /* Motion is decoration here; the colour is the message. Reduced motion keeps
497
+ the ring vivid and stops neither the host's spin nor its dash — only this
498
+ colour cycle goes away, which is also what the host's own reduced-motion
499
+ block asks of a status marker. */
500
+ @media (prefers-reduced-motion: reduce) {
501
+ [class*="sidebarCol"] svg[data-state="ongoing"][class*="spinner"] {
502
+ animation: none;
503
+ color: #6366f1;
504
+ }
505
+ }
506
+ `;
507
+ // src/client/styles/sidebar-density.ts
508
+ /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
509
+ const css$2 = String.raw`/* Workspace rows: swap the folder icon for the disclosure triangle in every
510
+ state, not only on hover.
511
+
512
+ The row already renders both slots — a folder span followed by a chevron span
513
+ that holds a right-pointing filled triangle rotated 90deg when expanded. The
514
+ app's own rules are:
515
+ .projectRow .chevron { display: none }
516
+ .projectRow:hover .chevron { display: inline-flex }
517
+ .projectRow:hover .folder { display: none }
518
+ so the triangle exists all along and only the hover swap is what the folder
519
+ icon wins on. Reversing those two declarations permanently is the whole
520
+ change: the folder is hidden at rest, the chevron shows at rest. Both rows
521
+ keep their own reveal on hover, so the hover state needs no rule of its own.
522
+ Class names are hashed per build, hence the substring selectors. */
523
+ [role="treeitem"][data-row-key^="workspace:"] [class*="folder"] {
524
+ display: none !important;
525
+ }
526
+
527
+ [role="treeitem"][data-row-key^="workspace:"] [class*="chevron"] {
528
+ display: inline-flex !important;
529
+ color: var(--dsw-alias-label-secondary) !important;
530
+ }
531
+
532
+ /* The triangle is the row's only leading glyph now, so it takes the 16px slot
533
+ the folder used to occupy. */
534
+ [role="treeitem"][data-row-key^="workspace:"] [class*="chevron"] svg {
535
+ width: 16px !important;
536
+ height: 16px !important;
537
+ }
538
+
539
+ /* Light-surface sidebar text scale. The app's own de-emphasised label tokens
464
540
  resolve to bluish-600 (3.58:1) against the light sidebar, which reads as dim.
465
541
  Titles and labels move up to label-primary, and the one step below them
466
542
  (section headings, timestamps, key caps) to label-secondary (5.6:1). Both
@@ -493,14 +569,21 @@ body:not([data-ds-dark-theme]) [data-document-markdown] {
493
569
 
494
570
  /* Dark mode: the app's label tokens resolve to near-white (label-primary #f9fafb,
495
571
  label-secondary #cfd3d6), which reads as glare against the dark sidebar surface.
496
- Redefining the two tokens inside the sidebar subtree dims only its text; the centre
497
- column, the right panel and the app's own dark palette keep their values. Measured
498
- against the dark sidebar surface this takes label-primary from ~16.6:1 to ~11:1 and
499
- label-secondary from ~11.5:1 to ~7.3:1, so both stay above WCAG AA. The variable
500
- override needs no !important: every rule above resolves through these tokens. */
572
+ Redefining the tokens inside the sidebar subtree dims only its text; the centre
573
+ column, the right panel and the app's own dark palette keep their values.
574
+
575
+ Measured live against the dark sidebar (#1b1b1c): titles and workspace names
576
+ paint through label-primary, section headings and timestamps through
577
+ label-secondary, and the overflow row ("Show N more sessions") plus the
578
+ running-status slot through label-tertiary. All three move down one step
579
+ together, so the whole column dims evenly instead of one row staying bright.
580
+ Against that surface the step lands at about 9.2:1, 6.2:1 and 6.7:1, all
581
+ still above WCAG AA. The variable override needs no !important: the rules
582
+ above, and the host's own rows, resolve through these tokens. */
501
583
  body[data-ds-dark-theme] [class*="sidebarCol"] {
502
- --dsw-alias-label-primary: #c9ced6;
503
- --dsw-alias-label-secondary: #a2a8b0;
584
+ --dsw-alias-label-primary: #bbc0c8;
585
+ --dsw-alias-label-secondary: #949aa2;
586
+ --dsw-alias-label-tertiary: #9fa4aa;
504
587
  }
505
588
 
506
589
  /* Text scale for a sidebar this plugin allows to be much narrower than upstream's
@@ -512,10 +595,25 @@ body[data-ds-dark-theme] [class*="sidebarCol"] {
512
595
  font-size: 11px !important;
513
596
  }
514
597
 
598
+ /* One type scale for both row kinds.
599
+ *
600
+ * The folder title is a span inside projectText and the session title is a bare
601
+ * span; both carry the app's hashed class, and that class rule (14px) outranks a
602
+ * plain descendant selector. The folder name therefore kept 14px while session
603
+ * titles had shrunk — the mismatch that reads as the two titles not being the
604
+ * same size.
605
+ *
606
+ * Each selector below repeats both the sidebar and row attributes, putting
607
+ * specificity at (0,3,x), and the declaration is marked important: together they
608
+ * beat the app's hashed class whatever order the sheets load in. The nested
609
+ * "span span" form covers the projectText > title wrapper. */
515
610
  [class*="sidebarCol"] [role="treeitem"][data-row-key^="workspace:"] span,
516
- [class*="sidebarCol"] [role="treeitem"][data-row-key^="session:"] span {
517
- font-size: 11px !important;
518
- line-height: 15px !important;
611
+ [class*="sidebarCol"] [role="treeitem"][data-row-key^="workspace:"] span span,
612
+ [class*="sidebarCol"] [role="treeitem"][data-row-key^="workspace:"] [class*="projectText"] span,
613
+ [class*="sidebarCol"] [role="treeitem"][data-row-key^="session:"] span,
614
+ [class*="sidebarCol"] [role="treeitem"][data-row-key^="session:"] span span {
615
+ font-size: 12px !important;
616
+ line-height: 16px !important;
519
617
  }
520
618
 
521
619
  [class*="sidebarCol"] [class*="brandName"] {
@@ -535,9 +633,52 @@ body[data-ds-dark-theme] [class*="sidebarCol"] {
535
633
  font-size: 12px !important;
536
634
  }
537
635
 
636
+
637
+ /* Fold the folder title in beside its triangle.
638
+ *
639
+ * The row spends a 16px glyph lane plus its gap before the title, so the folder
640
+ * name starts well right of the session titles underneath it even though both
641
+ * now use the same type scale. Only the text container moves — the triangle
642
+ * keeps its native size, its lane, and its position — which closes most of the
643
+ * visible step without dragging the row past the sidebar edge (an earlier
644
+ * row-level negative margin did exactly that and hid every glyph).
645
+ *
646
+ * Percentage-free: -8px reclaims the row gap and part of the lane, leaving the
647
+ * glyph clear of the first letter at both 11px and the app's default scales. */
648
+ [role="treeitem"][data-row-key^="workspace:"] [class*="projectText"] {
649
+ /* Measured in the browser against the live DOM: the session title starts at
650
+ 37px (row 12 + padding 5 + its own 4px margin + the workspace indent), the
651
+ folder title at 39px before this shift. -2px lands the folder title on the
652
+ same 37px edge while keeping the 16px triangle lane untouched. */
653
+ margin-inline-start: -2px !important;
654
+ }
655
+
656
+ /* Same-row attribute, same proven selector shape as the rule above (which does
657
+ take effect), applied to the text itself. The folder title's own hashed class
658
+ sets 14px and wins over an inherited value, so the size is set on every
659
+ descendant rather than on the container. Matching the session titles is what
660
+ removes the "two or three pixel" step the reader sees between the two rows. */
661
+ [role="treeitem"][data-row-key^="workspace:"] [class*="projectText"] * {
662
+ font-size: 12px !important;
663
+ line-height: 16px !important;
664
+ }
665
+
666
+ /* Force the folder title onto the session titles' type scale.
667
+ *
668
+ * The folder title is projectText > span, and the span carries the app's own
669
+ * hashed class whose 14px rule wins against inherited values. The rows also live
670
+ * in a hashed container class, so this selector keys off the row attribute only,
671
+ * with no assumption about the sidebar wrapper. Measured against a screenshot:
672
+ * the folder title rendered at 14px while session titles rendered at 11px, which
673
+ * is the "two or three pixels" size step the reader reports. */
674
+ [role="treeitem"][data-row-key^="workspace:"] [class*="projectText"],
675
+ [role="treeitem"][data-row-key^="workspace:"] [class*="projectText"] span,
676
+ [role="treeitem"][data-row-key^="workspace:"] [class*="_title"] {
677
+ font-size: 12px !important;
678
+ line-height: 16px !important;
679
+ }
538
680
  `;
539
- //#endregion
540
- //#region src/client/styles/sidebar-layout.ts
681
+ // src/client/styles/sidebar-layout.ts
541
682
  /** Global presentation owned by dsh-enhance (migrated from the installer's injected styles). */
542
683
  const css$1 = String.raw`[class*="sidebarCol"] [class*="_root"] { position: relative !important; }
543
684
  [class*="sidebarCol"] [class*="logoRow"] { display: none !important; }
@@ -548,22 +689,52 @@ body[data-ds-dark-theme] [class*="sidebarCol"] {
548
689
  [class*="sidebarCol"] [class*="sectionLabel"] {
549
690
  margin-left: 4px !important;
550
691
  }
551
- [role="treeitem"][data-row-key^="session:"] {
552
- padding-left: 10px !important;
692
+ /* One indent for both row kinds.
693
+ *
694
+ * Session rows and workspace rows previously used different start insets, which
695
+ * made the tree look ragged: the folder title sat further right than the session
696
+ * titles under it. Both now start at 5px.
697
+ *
698
+ * A negative margin on the workspace row was tried and reverted: it dragged the
699
+ * whole row — glyph included — past the sidebar's left edge, so every triangle
700
+ * disappeared. The indent is the only lever that stays inside the column. */
701
+ [role="treeitem"][data-row-key^="session:"],
702
+ [role="treeitem"][data-row-key^="workspace:"] {
703
+ padding-inline-start: 5px !important;
553
704
  }
554
- [class*="sidebarCol"] [class*="panelList"] {
555
- position: absolute !important;
556
- right: 12px !important;
557
- bottom: 14px !important;
558
- z-index: 5;
559
- /* Upstream stacks the Plugins and Automation icons in a column. A row keeps
560
- both reachable on one line beside the account name instead. */
705
+
706
+
707
+
708
+ /* Panel shortcuts open the sidebar, above the workspace tree.
709
+ *
710
+ * The sidebar's own DOM already puts this nav between the (hidden) New Session
711
+ * bar and the region tree, so the top placement needs no move at all: upstream
712
+ * simply starts the nav wherever its flex column lands, and releasing it from
713
+ * the bottom-right absolute position (this plugin's earlier choice) leaves it
714
+ * above WORKSPACES.
715
+ *
716
+ * The row is kept — upstream stacks these icons in a column, which costs one
717
+ * row per shortcut at the top of the tree.
718
+ *
719
+ * Five per line, wrapping beyond that. The count is enforced by max-width
720
+ * rather than by the sidebar's own width: five 36px buttons and four 2px gaps
721
+ * are 188px, so a wider sidebar cannot fit a sixth on the first line.
722
+ *
723
+ * Scope excludes the collapsed rail: there the column is the app's 56px icon
724
+ * strip (0px on macOS), a row of 36px buttons cannot fit it, and the host's own
725
+ * vertical layout is the right shape. The rail is not reachable on macOS
726
+ * desktop, but this plugin also loads in the web profile.
727
+ */
728
+ [class*="sidebarCol"] [class*="_root"]:not([class*="collapsed"]) [class*="panelList"] {
561
729
  flex-direction: row !important;
730
+ flex-wrap: wrap !important;
562
731
  align-items: center !important;
563
- justify-content: flex-end !important;
564
- gap: 0 !important;
565
- margin: 0 !important;
732
+ justify-content: flex-start !important;
733
+ gap: 2px !important;
734
+ margin: 0 0 6px 0 !important;
735
+ max-width: calc(36px * 5 + 2px * 4) !important;
566
736
  }
737
+
567
738
  [class*="sidebarCol"] [class*="panelList"] [class*="panelTitle"] { display: none !important; }
568
739
  [class*="sidebarCol"] [class*="panelList"] button[class*="panelRow"] {
569
740
  width: 36px !important;
@@ -575,15 +746,70 @@ body[data-ds-dark-theme] [class*="sidebarCol"] {
575
746
  padding: 0 !important;
576
747
  border-radius: 12px !important;
577
748
  }
749
+
750
+ /* Plugin icons that the host renders in the sidebar footer join the same row.
751
+ *
752
+ * The footer keeps its own flex layout, which is why the moved container is
753
+ * dissolved rather than laid out: display:contents drops its box, and every
754
+ * wrapper up to the actual button is dissolved the same way, so each plugin's
755
+ * button becomes a direct item of the panel row and takes its turn in the
756
+ * five-per-line count. The buttons keep their own look; only size and shape
757
+ * are normalised to the row's rhythm.
758
+ *
759
+ * One level of wrapper is dissolved generically (every non-button child), one
760
+ * more by the host's own entry-row class: the installed plugins wrap their
761
+ * button in an entry row, and a future plugin that omits it still lands as a
762
+ * direct child.
763
+ */
764
+ [class*="sidebarCol"] [class*="panelList"] > [data-dsh-enhance-entries],
765
+ [class*="sidebarCol"] [class*="panelList"] > [data-dsh-enhance-entries] > :not(button),
766
+ [class*="sidebarCol"] [class*="panelList"] [class*="entryRow"] {
767
+ display: contents !important;
768
+ }
769
+ /* The plugin's own "wide" variant is built for the footer row: it turns the
770
+ * trigger into an icon+label pill that fills that row's width, which means
771
+ * justify-content:flex-start and a gap. In a 36px square that reads as an icon
772
+ * glued to the left edge, so the box model is normalised here: centred, no
773
+ * gap, no padding, one icon size for the whole row. */
774
+ [class*="sidebarCol"] [class*="panelList"] > [data-dsh-enhance-entries] button {
775
+ flex: none !important;
776
+ display: inline-flex !important;
777
+ justify-content: center !important;
778
+ align-items: center !important;
779
+ gap: 0 !important;
780
+ width: 36px !important;
781
+ height: 36px !important;
782
+ margin: 0 !important;
783
+ padding: 0 !important;
784
+ border-radius: 12px !important;
785
+ }
786
+ [class*="sidebarCol"] [class*="panelList"] > [data-dsh-enhance-entries] button svg {
787
+ flex: none !important;
788
+ width: 16px !important;
789
+ height: 16px !important;
790
+ }
791
+ /* The rail keeps the host's own treatment: the footer action block is hidden
792
+ there exactly as the host hides it, so the strip keeps only the app's icons. */
793
+ [class*="sidebarCol"] [class*="_root"][class*="collapsed"] [data-dsh-enhance-entries] {
794
+ display: none !important;
795
+ }
578
796
  `;
579
- //#endregion
580
- //#region src/client/styles/toolbar.ts
797
+ // src/client/styles/toolbar.ts
581
798
  /** Global presentation owned by dsh-enhance: annotation popover and tray. */
582
799
  const css = String.raw`/* The passage being annotated, painted through the Custom Highlight API so the
583
800
  mark survives focus moving into the note field (a native selection would not).
584
801
  Same blue as the app's document selection, so it reads as the same gesture. */
585
802
  ::highlight(dsh-enhance-annotation) {
586
- background-color: var(--dsw-alias-bg-document-selection);
803
+ /* Literal, not a token: a highlight pseudo-element does not inherit custom
804
+ properties from the element it paints, so the document-selection token
805
+ resolved to nothing and clicking an annotation showed no
806
+ selection wash at all. Same blue the app uses for its own selection. */
807
+ background-color: rgb(59 130 246 / 32%);
808
+ color: inherit;
809
+ }
810
+
811
+ body[data-ds-dark-theme] ::highlight(dsh-enhance-annotation) {
812
+ background-color: rgb(96 165 250 / 34%);
587
813
  color: inherit;
588
814
  }
589
815
 
@@ -616,9 +842,9 @@ body[data-ds-dark-theme] ::highlight(dsh-enhance-annotation-mark) {
616
842
  display: inline-flex;
617
843
  align-items: center;
618
844
  justify-content: center;
619
- width: 30px;
620
- height: 30px;
621
- margin: 0 5px;
845
+ width: 26px;
846
+ height: 26px;
847
+ margin: 0 4px;
622
848
  padding: 0;
623
849
  border: 0;
624
850
  border-radius: 0;
@@ -635,10 +861,12 @@ body[data-ds-dark-theme] ::highlight(dsh-enhance-annotation-mark) {
635
861
  transition: transform 110ms ease, filter 110ms ease;
636
862
  }
637
863
 
864
+ /* The badge is one numbered disc. Height drives the scale and the width follows
865
+ the viewBox, so a two-digit pill stays the same height as a single digit. */
638
866
  .dsh-enhance-badge svg {
639
867
  display: block;
640
- width: 22px;
641
868
  height: 22px;
869
+ width: auto;
642
870
  }
643
871
 
644
872
  .dsh-enhance-badge:hover {
@@ -666,7 +894,10 @@ body[data-ds-dark-theme] ::highlight(dsh-enhance-annotation-mark) {
666
894
  flex-direction: column;
667
895
  width: 340px;
668
896
  max-width: calc(100vw - 24px);
669
- padding: 6px;
897
+ /* No inset of its own: the textarea sits on the frame's surface, flush with
898
+ the top and both sides. The only breathing room is the field's own
899
+ horizontal padding, so text never touches the rounded corners. */
900
+ padding: 0;
670
901
  border-radius: 18px;
671
902
  border: 0.5px solid color-mix(in srgb, var(--dsw-alias-label-primary) 14%, transparent);
672
903
  background: color-mix(in srgb, var(--dsw-alias-bg-elevated, var(--dsw-alias-bg-l1, #fff)) 76%, transparent);
@@ -689,22 +920,28 @@ body[data-ds-dark-theme] .dsh-enhance-popover {
689
920
  .dsh-enhance-popover { animation: none; }
690
921
  }
691
922
 
692
- /* The field owns the whole top row; the confirm affordance sits inside it. */
923
+ /* The field row carries no inset and no panel of its own: the textarea sits
924
+ flush with the popover's own surface, so the words line up with the frame
925
+ instead of floating in a lighter box inside it. */
693
926
  .dsh-enhance-popover__field {
694
927
  display: flex;
695
928
  align-items: flex-end;
696
929
  gap: 6px;
697
- padding: 6px 6px 6px 12px;
698
- border-radius: 13px;
699
- background: color-mix(in srgb, var(--dsw-alias-label-primary) 5%, transparent);
930
+ padding: 10px 8px 6px 14px;
931
+ border-radius: 0;
932
+ background: transparent;
700
933
  }
701
934
 
935
+ /* Height follows the text. The element is a textarea because the note is
936
+ multi-line, but it must never grow a scrollbar: no max-height, no vertical
937
+ overflow, and the rows are driven from JS on every input (see the seat), so
938
+ the panel grows with what is typed rather than clipping it. */
702
939
  .dsh-enhance-popover__input {
703
940
  flex: 1;
704
941
  min-width: 0;
705
942
  min-height: 24px;
706
- max-height: 96px;
707
- padding: 3px 0;
943
+ max-height: none;
944
+ padding: 0;
708
945
  border: 0;
709
946
  background: transparent;
710
947
  color: var(--dsw-alias-label-primary);
@@ -712,6 +949,7 @@ body[data-ds-dark-theme] .dsh-enhance-popover {
712
949
  font-size: 13px;
713
950
  line-height: 20px;
714
951
  resize: none;
952
+ overflow-y: hidden;
715
953
  }
716
954
 
717
955
  .dsh-enhance-popover__input::placeholder {
@@ -753,12 +991,14 @@ body[data-ds-dark-theme] .dsh-enhance-popover {
753
991
  }
754
992
 
755
993
  /* Footer: the quoted passage on the left, the side-chat action on the right. */
994
+ /* The popover frame has no inset of its own (the field is flush with it), so
995
+ the footer carries the frame's own horizontal and bottom spacing. */
756
996
  .dsh-enhance-popover__footer {
757
997
  display: flex;
758
998
  align-items: center;
759
999
  justify-content: space-between;
760
1000
  gap: 10px;
761
- padding: 6px 8px 2px 12px;
1001
+ padding: 6px 14px 10px;
762
1002
  }
763
1003
 
764
1004
  .dsh-enhance-popover__quote {
@@ -973,8 +1213,9 @@ body[data-ds-dark-theme] .dsh-enhance-tray__list {
973
1213
  display: flex;
974
1214
  align-items: center;
975
1215
  gap: 2px;
976
- padding: 2px;
977
- border-radius: 10px;
1216
+ padding: 3px;
1217
+ /* Capsule, matching the shape language of the rest of the composer chrome. */
1218
+ border-radius: 999px;
978
1219
  /* A solid pill, not a gradient: fading over text looked like a smudge, and the
979
1220
  icons must stay readable on top of the note they cover. */
980
1221
  background: var(--dsw-alias-bg-elevated, #1b1b1c);
@@ -994,10 +1235,10 @@ body[data-ds-dark-theme] .dsh-enhance-tray__actions {
994
1235
  display: inline-flex;
995
1236
  align-items: center;
996
1237
  justify-content: center;
997
- width: 30px;
998
- height: 30px;
1238
+ width: 26px;
1239
+ height: 26px;
999
1240
  border: 0;
1000
- border-radius: 8px;
1241
+ border-radius: 999px;
1001
1242
  background: transparent;
1002
1243
  color: var(--dsw-alias-label-secondary);
1003
1244
  cursor: pointer;
@@ -1066,8 +1307,12 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1066
1307
  /* The header is text, not a bar: it names the passage and doubles as the drag
1067
1308
  surface, so no grip row is spent on it. */
1068
1309
  .dsh-enhance-edit__head {
1310
+ display: flex;
1311
+ align-items: center;
1312
+ gap: 6px;
1069
1313
  min-width: 0;
1070
- padding: 2px 4px 6px;
1314
+ /* Carries the dialog's own top inset now that the frame has no padding. */
1315
+ padding: 10px 14px 6px;
1071
1316
  cursor: grab;
1072
1317
  touch-action: none;
1073
1318
  user-select: none;
@@ -1079,6 +1324,8 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1079
1324
 
1080
1325
  .dsh-enhance-edit__label {
1081
1326
  display: block;
1327
+ flex: 1;
1328
+ min-width: 0;
1082
1329
  overflow: hidden;
1083
1330
  color: var(--dsw-alias-label-tertiary, var(--dsw-alias-label-secondary));
1084
1331
  font-size: 11px;
@@ -1087,12 +1334,47 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1087
1334
  white-space: nowrap;
1088
1335
  }
1089
1336
 
1337
+ /* Removal action on the editor header. Quiet by default — it sits beside the
1338
+ quoted passage, which is the header's real job — and takes the danger colour
1339
+ only on hover, so it never competes with the confirm check. */
1340
+ .dsh-enhance-edit__delete {
1341
+ appearance: none;
1342
+ -webkit-appearance: none;
1343
+ display: inline-flex;
1344
+ align-items: center;
1345
+ justify-content: center;
1346
+ flex: none;
1347
+ width: 30px;
1348
+ height: 30px;
1349
+ padding: 0;
1350
+ border: 0;
1351
+ border-radius: 999px;
1352
+ background: transparent;
1353
+ color: var(--dsw-alias-label-tertiary, var(--dsw-alias-label-secondary));
1354
+ cursor: pointer;
1355
+ opacity: 0.7;
1356
+ transition: background-color 110ms ease, color 110ms ease, opacity 110ms ease;
1357
+ }
1358
+
1359
+ .dsh-enhance-edit__delete:hover {
1360
+ opacity: 1;
1361
+ color: #e5484d;
1362
+ background: rgb(229 72 77 / 12%);
1363
+ }
1364
+
1365
+ .dsh-enhance-edit__delete:focus-visible {
1366
+ outline: 2px solid var(--dsw-alias-state-business-primary, #4d6bfe);
1367
+ outline-offset: 1px;
1368
+ }
1369
+
1090
1370
  /* The field and its one action share a row: the check sits at the end of the text
1091
1371
  it publishes rather than in a footer of its own. */
1092
1372
  .dsh-enhance-edit__body {
1093
1373
  display: flex;
1094
1374
  align-items: flex-end;
1095
1375
  gap: 6px;
1376
+ /* Matches the header's inset so the note and the quoted passage line up. */
1377
+ padding: 0 8px 8px 12px;
1096
1378
  }
1097
1379
 
1098
1380
  .dsh-enhance-edit__field {
@@ -1122,8 +1404,8 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1122
1404
  align-items: center;
1123
1405
  justify-content: center;
1124
1406
  flex: none;
1125
- width: 30px;
1126
- height: 30px;
1407
+ width: 24px;
1408
+ height: 24px;
1127
1409
  margin-bottom: 2px;
1128
1410
  padding: 0;
1129
1411
  border: 0;
@@ -1191,7 +1473,11 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1191
1473
  align-items: center;
1192
1474
  gap: 7px;
1193
1475
  min-width: 0;
1194
- padding: 2px 4px 0;
1476
+ /* Sits on the dialog's own edge: a small inset on every side is enough to
1477
+ keep the text off the rounded corner, no wider. Both the header and the
1478
+ field share the same left inset so the quote and the note start on one
1479
+ line. */
1480
+ padding: 8px 8px 4px 12px;
1195
1481
  cursor: grab;
1196
1482
  touch-action: none;
1197
1483
  user-select: none;
@@ -1300,10 +1586,12 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1300
1586
  transform: translate(-50%, -50%);
1301
1587
  display: flex;
1302
1588
  flex-direction: column;
1303
- gap: 8px;
1589
+ gap: 0;
1304
1590
  width: 420px;
1305
1591
  max-width: calc(100vw - 32px);
1306
- padding: 12px;
1592
+ /* Flush like the selection popover: the field and the header sit on the
1593
+ dialog's own surface instead of inside a second inset frame. */
1594
+ padding: 0;
1307
1595
  border: 0.5px solid color-mix(in srgb, var(--dsw-alias-label-primary) 14%, transparent);
1308
1596
  border-radius: 16px;
1309
1597
  background: color-mix(in srgb, var(--dsw-alias-bg-elevated, var(--dsw-alias-bg-l1, #fff)) 90%, transparent);
@@ -1328,25 +1616,30 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1328
1616
  box-sizing: border-box;
1329
1617
  display: block;
1330
1618
  width: 100%;
1331
- min-height: 68px;
1332
- padding: 8px 10px;
1619
+ /* Height follows the text, never a scrollbar: no max-height, no vertical
1620
+ overflow, sized from scrollHeight on every change (see the editor). */
1621
+ min-height: 24px;
1622
+ max-height: none;
1623
+ /* No horizontal inset of its own: the body row already carries the dialog's
1624
+ left edge, and doubling it pushed the note 12px right of the quote. */
1625
+ padding: 4px 0 8px;
1333
1626
  max-width: 100%;
1334
1627
  border: 0;
1335
- border-radius: 11px;
1336
- /* No second frame inside the dialog: the dialog itself is the surface, and a
1337
- nested border plus wash read as a stray box. The field only tints slightly
1338
- so the caret area is still distinguishable. */
1339
- background: color-mix(in srgb, var(--dsw-alias-label-primary) 4%, transparent);
1628
+ border-radius: 0;
1629
+ /* No frame of its own: the dialog is the surface, so the words sit directly
1630
+ on it. */
1631
+ background: transparent;
1340
1632
  color: var(--dsw-alias-label-primary);
1341
1633
  font: inherit;
1342
1634
  font-size: 13px;
1343
1635
  line-height: 20px;
1344
- resize: vertical;
1636
+ resize: none;
1637
+ overflow-y: hidden;
1345
1638
  }
1346
1639
 
1347
1640
  .dsh-enhance-edit__field:focus {
1348
1641
  outline: none;
1349
- background: color-mix(in srgb, var(--dsw-alias-label-primary) 7%, transparent);
1642
+ background: transparent;
1350
1643
  }
1351
1644
 
1352
1645
  .dsh-enhance-edit__row {
@@ -1390,15 +1683,15 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1390
1683
  opacity: .88;
1391
1684
  }
1392
1685
  `;
1393
- //#endregion
1394
- //#region src/client/styles.ts
1686
+ // src/client/styles.ts
1395
1687
  /** Stable plugin identity stamped onto every injected style tag. */
1396
1688
  const PLUGIN_ID = "dsh-enhance";
1397
1689
  /** Sheet name to CSS, in cascade order: later sheets win ties against earlier ones. */
1398
1690
  const SHEETS = [
1399
- ["document-preview.css", css$5],
1400
- ["chat-markdown.css", css$4],
1401
- ["rightbar-handle.css", css$3],
1691
+ ["document-preview.css", css$6],
1692
+ ["chat-markdown.css", css$5],
1693
+ ["rightbar-handle.css", css$4],
1694
+ ["running-spinner.css", css$3],
1402
1695
  ["sidebar-density.css", css$2],
1403
1696
  ["sidebar-layout.css", css$1],
1404
1697
  ["toolbar.css", css]
@@ -1423,8 +1716,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1423
1716
  };
1424
1717
  }, `dsh-enhance: ${name} stylesheet`);
1425
1718
  }
1426
- //#endregion
1427
- //#region src/client/sidebar-floor.ts
1719
+ // src/client/sidebar-floor.ts
1428
1720
  /**
1429
1721
  * A sidebar drag floor 50px below the app's own.
1430
1722
  *
@@ -1439,7 +1731,11 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1439
1731
  * owns the gesture. One writer, one width, no fighting.
1440
1732
  *
1441
1733
  * Three places paint the same number and all three are written here: the shell's
1442
- * grid track, the sidebar content's inline width, and the handle's `left`.
1734
+ * grid track, the sidebar content's inline width, and the handle's `left`. Only
1735
+ * elements that actually mirror the column width are rewritten — an element
1736
+ * carrying some other fixed px width (a row's timestamp column, an icon box)
1737
+ * must not be stamped with the sidebar width, or the row's inner layout breaks
1738
+ * into a dead strip.
1443
1739
  */
1444
1740
  /** This plugin's floor: 50px below the app's own 264px minimum. */
1445
1741
  const RELAXED_FLOOR = 214;
@@ -1447,12 +1743,15 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1447
1743
  const CEILING = 420;
1448
1744
  /** Attribute marking the shell frame this module is driving. */
1449
1745
  const FRAME_ATTRIBUTE = "data-dsh-enhance-frame";
1746
+ /** Attribute the shell sets on the frame while the sidebar is collapsed. */
1747
+ const COLLAPSED_ATTRIBUTE = "data-sidebar-collapsed";
1450
1748
  /**
1451
1749
  * Install the relaxed drag floor.
1452
1750
  * @param root - document the plugin is mounted in.
1751
+ * @param options - startup width and drag commit hook.
1453
1752
  * @returns disposer that stops intercepting and restores the app's own value.
1454
1753
  */
1455
- function installSidebarFloor(root) {
1754
+ function installSidebarFloor(root, options = {}) {
1456
1755
  /** Shell grid frame, once located. */
1457
1756
  let frame = null;
1458
1757
  /** The width the plugin last painted, when it is below the app's floor. */
@@ -1461,6 +1760,16 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1461
1760
  const restored = /* @__PURE__ */ new Map();
1462
1761
  let dragStart = null;
1463
1762
  let applying = false;
1763
+ /** Clamp a width into the range this module is willing to paint. */
1764
+ const clampWidth = (width) => Math.min(Math.max(width, RELAXED_FLOOR), CEILING);
1765
+ /**
1766
+ * The width the column belongs at, across collapses.
1767
+ *
1768
+ * Kept apart from `held` because a collapse is painted by the app as a 0px
1769
+ * track: the module has nothing to hold then, but it must still know where to
1770
+ * put the column when the reader expands it again.
1771
+ */
1772
+ let preferred = options.initialWidth === void 0 ? void 0 : clampWidth(options.initialWidth);
1464
1773
  /** Find the shell frame: the grid whose first child is the sidebar column. */
1465
1774
  const findFrame = () => {
1466
1775
  for (const element of root.querySelectorAll("div[style*=\"grid-template-columns\"]")) {
@@ -1474,16 +1783,31 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1474
1783
  const match = /^\s*(\d+(?:\.\d+)?)px/.exec(frame?.style.gridTemplateColumns ?? "");
1475
1784
  return match === null ? 0 : Number(match[1]);
1476
1785
  };
1477
- /** Every element inside the column that carries a px inline width. */
1478
- const widthCarriers = () => {
1786
+ /**
1787
+ * Elements inside the column that mirror the sidebar width.
1788
+ *
1789
+ * Only a child whose inline width equals the width the app just painted on
1790
+ * the track (or the width this module last painted) counts as a mirror.
1791
+ * Foreign fixed widths — a co-installed plugin's panel, an icon box — must
1792
+ * never be stamped, or their internal layout breaks into a dead strip.
1793
+ * @param mirrors - widths to accept as "the column's own value".
1794
+ * @returns the mirror elements, in document order.
1795
+ */
1796
+ const widthCarriers = (mirrors) => {
1479
1797
  const column = frame?.firstElementChild;
1480
1798
  if (column === null || column === void 0) return [];
1481
1799
  const carriers = [];
1800
+ const qualifies = (element) => {
1801
+ const match = /^(\d+(?:\.\d+)?)px$/.exec(element.style.width);
1802
+ if (match === null) return false;
1803
+ const width = Number(match[1]);
1804
+ return mirrors.some((mirror) => Math.abs(width - mirror) <= 1);
1805
+ };
1482
1806
  const visit = (element, depth) => {
1483
1807
  if (depth > 3) return;
1484
1808
  for (const child of element.children) {
1485
1809
  if (!(child instanceof HTMLElement)) continue;
1486
- if (/^\d+(?:\.\d+)?px$/.test(child.style.width)) carriers.push(child);
1810
+ if (qualifies(child)) carriers.push(child);
1487
1811
  visit(child, depth + 1);
1488
1812
  }
1489
1813
  };
@@ -1497,8 +1821,11 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1497
1821
  applying = true;
1498
1822
  try {
1499
1823
  const rounded = Math.round(width);
1824
+ const mirrors = [painted(), rounded];
1500
1825
  target.style.gridTemplateColumns = target.style.gridTemplateColumns.replace(/^\s*\d+(?:\.\d+)?px/, `${rounded}px`);
1501
- for (const carrier of widthCarriers()) {
1826
+ const carriers = new Set(widthCarriers(mirrors));
1827
+ for (const element of restored.keys()) if (element.isConnected) carriers.add(element);
1828
+ for (const carrier of carriers) {
1502
1829
  if (!restored.has(carrier)) restored.set(carrier, carrier.style.width);
1503
1830
  carrier.style.width = `${rounded}px`;
1504
1831
  }
@@ -1516,22 +1843,36 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1516
1843
  held = void 0;
1517
1844
  };
1518
1845
  /**
1519
- * Keep the plugin's width while the app still reports its own floor.
1846
+ * Keep the column at the width the reader left it at.
1520
1847
  *
1521
- * The app repaints the grid whenever unrelated layout state changes. Re-applying
1522
- * only when the painted value differs from the held one keeps that cheap and
1523
- * keeps the sidebar where the reader put it.
1848
+ * The app repaints the grid whenever unrelated layout state changes, and it
1849
+ * re-renders the content element's width (React re-mounts it on right-panel
1850
+ * transitions) without touching the grid string at all. Watching both: a
1851
+ * drifted track is re-held, a drifted mirror is re-stamped even when the track
1852
+ * still reads the held width, and a column the app re-expanded is moved back
1853
+ * to the remembered width instead of the app's own 280px default.
1524
1854
  */
1525
1855
  const reconcile = () => {
1526
1856
  if (applying) return;
1527
1857
  frame ??= findFrame();
1528
1858
  if (frame === null) return;
1529
- if (held === void 0) return;
1859
+ for (const element of [...restored.keys()]) if (!element.isConnected) restored.delete(element);
1860
+ if (frame.hasAttribute(COLLAPSED_ATTRIBUTE)) {
1861
+ if (held !== void 0) restore();
1862
+ return;
1863
+ }
1864
+ if (preferred === void 0) return;
1865
+ if (held === void 0) {
1866
+ held = clampWidth(preferred);
1867
+ apply(held);
1868
+ return;
1869
+ }
1870
+ const drifted = restored.size === 0 ? false : [...restored.keys()].some((element) => element.style.width !== `${Math.round(held)}px`);
1530
1871
  if (Math.abs(painted() - held) > .5) {
1531
- adoptAppWidth();
1532
- if (held === void 0) return;
1533
1872
  apply(held);
1873
+ return;
1534
1874
  }
1875
+ if (drifted) apply(held);
1535
1876
  };
1536
1877
  const frameObserver = new MutationObserver(() => {
1537
1878
  reconcile();
@@ -1544,10 +1885,17 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1544
1885
  frame = target;
1545
1886
  frame.setAttribute(FRAME_ATTRIBUTE, "");
1546
1887
  frameObserver.observe(frame, {
1888
+ attributes: true,
1889
+ attributeFilter: ["style", COLLAPSED_ATTRIBUTE]
1890
+ });
1891
+ const column = frame.firstElementChild;
1892
+ if (column !== null) frameObserver.observe(column, {
1893
+ childList: true,
1894
+ subtree: true,
1547
1895
  attributes: true,
1548
1896
  attributeFilter: ["style"]
1549
1897
  });
1550
- if (held !== void 0) apply(held);
1898
+ reconcile();
1551
1899
  };
1552
1900
  const onPointerDown = (event) => {
1553
1901
  const handle = event.target;
@@ -1571,24 +1919,16 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1571
1919
  }
1572
1920
  event.stopPropagation();
1573
1921
  const wanted = dragStart.width + (event.clientX - dragStart.x);
1574
- const next = Math.min(Math.max(wanted, RELAXED_FLOOR), CEILING);
1922
+ const next = clampWidth(wanted);
1575
1923
  held = next;
1576
1924
  apply(next);
1577
1925
  };
1578
1926
  const endDrag = () => {
1579
1927
  if (dragStart === null) return;
1580
1928
  dragStart = null;
1581
- };
1582
- /**
1583
- * Drop the overrides when the app takes the column over on its own.
1584
- *
1585
- * A collapse (to the 56px rail) is the app's gesture, not this module's: the
1586
- * plugin has no width to hold there, and repainting one would fight the rail.
1587
- */
1588
- const adoptAppWidth = () => {
1589
1929
  if (held === void 0) return;
1590
- const current = painted();
1591
- if (current > 0 && current < RELAXED_FLOOR) restore();
1930
+ preferred = held;
1931
+ options.onCommit?.(held);
1592
1932
  };
1593
1933
  attach();
1594
1934
  root.addEventListener("pointerdown", onPointerDown, true);
@@ -1613,8 +1953,482 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1613
1953
  frame?.removeAttribute(FRAME_ATTRIBUTE);
1614
1954
  };
1615
1955
  }
1616
- //#endregion
1617
- //#region src/client/locales.ts
1956
+ // src/client/sidebar-top-row.ts
1957
+ /**
1958
+ * Put the sidebar's footer plugin icons into the top panel row.
1959
+ *
1960
+ * Plugins that add a sidebar entry choose a slot; two are in use in practice.
1961
+ * A *panel* (`panelList`, the nav the app renders) is already at the top. A
1962
+ * *footer action* (`sidebar.footer.action`, rendered inside `footArea`) lands
1963
+ * next to the account row at the bottom — which is why a newly installed plugin
1964
+ * shows up there and reads as a different kind of control from the icons above.
1965
+ *
1966
+ * CSS cannot merge the two: they are separate flex containers with separate
1967
+ * parents, and no amount of `order` moves a node into a sibling container. So
1968
+ * this module moves the footer's action container into the panel nav once the
1969
+ * shell exists, and the stylesheet dissolves it (`display: contents`) so its
1970
+ * buttons join the row the nav lays out. Five per line, wrapping beyond that:
1971
+ * the nav's own max-width does the counting (see sidebar-layout.css).
1972
+ *
1973
+ * The relocated element is the *container* the host owns, not the entries a
1974
+ * plugin renders. React updates those entries inside it and removes them from
1975
+ * it, and both keep working because their parent never changed; the container
1976
+ * itself is rendered unconditionally by the sidebar shell, so it is not a node
1977
+ * React re-parents. Verified on a live web instance: moving it, opening the
1978
+ * plugin's own panel (a fixed overlay), collapsing and expanding the sidebar
1979
+ * produced no console errors, no duplicated container, and no lost entry.
1980
+ *
1981
+ * If a future re-render does put the container back, the observer moves it
1982
+ * again on the next frame; the move is idempotent.
1983
+ */
1984
+ /** Marks the relocated container, for both the stylesheet and the disposer. */
1985
+ const ENTRIES_ATTRIBUTE = "data-dsh-enhance-entries";
1986
+ /**
1987
+ * Install the relocation.
1988
+ * @param root - document the plugin is mounted in.
1989
+ * @returns disposer that puts the container back where the host rendered it.
1990
+ */
1991
+ function installSidebarTopRow(root) {
1992
+ /** Original parent and the sibling it sat before, for the disposer. */
1993
+ let home = null;
1994
+ let homeNext = null;
1995
+ let frame = 0;
1996
+ /** The sidebar's panel nav and footer action container, re-queried each pass. */
1997
+ const locate = () => {
1998
+ for (const column of root.querySelectorAll("[class*=\"sidebarCol\"]")) {
1999
+ const nav = column.querySelector("[class*=\"panelList\"]");
2000
+ const actions = column.querySelector("[class*=\"footerActions\"]");
2001
+ if (nav !== null && actions !== null) return {
2002
+ nav,
2003
+ actions
2004
+ };
2005
+ }
2006
+ return null;
2007
+ };
2008
+ /** Move the footer's action container into the panel row, once. */
2009
+ const relocate = () => {
2010
+ const found = locate();
2011
+ if (found === null) return;
2012
+ const { nav, actions } = found;
2013
+ if (actions.parentElement === nav) return;
2014
+ home = actions.parentElement;
2015
+ homeNext = actions.nextElementSibling;
2016
+ actions.setAttribute(ENTRIES_ATTRIBUTE, "");
2017
+ nav.append(actions);
2018
+ };
2019
+ const schedule = () => {
2020
+ if (frame !== 0) return;
2021
+ frame = requestAnimationFrame(() => {
2022
+ frame = 0;
2023
+ relocate();
2024
+ });
2025
+ };
2026
+ let observer = null;
2027
+ let observed = null;
2028
+ const watch = () => {
2029
+ const column = root.querySelector("[class*=\"sidebarCol\"]");
2030
+ if (column === observed) return;
2031
+ observer?.disconnect();
2032
+ observer = new MutationObserver(schedule);
2033
+ observed = column;
2034
+ observer.observe(column ?? root.documentElement, {
2035
+ childList: true,
2036
+ subtree: true
2037
+ });
2038
+ };
2039
+ const start = () => {
2040
+ watch();
2041
+ relocate();
2042
+ };
2043
+ start();
2044
+ const mountWatcher = new MutationObserver(() => {
2045
+ if (observed !== null && observed.isConnected) return;
2046
+ watch();
2047
+ schedule();
2048
+ });
2049
+ mountWatcher.observe(root.documentElement, {
2050
+ childList: true,
2051
+ subtree: true
2052
+ });
2053
+ return () => {
2054
+ if (frame !== 0) cancelAnimationFrame(frame);
2055
+ observer?.disconnect();
2056
+ mountWatcher.disconnect();
2057
+ const moved = root.querySelector(`[${ENTRIES_ATTRIBUTE}]`);
2058
+ if (moved === null || home === null) return;
2059
+ moved.removeAttribute(ENTRIES_ATTRIBUTE);
2060
+ if (homeNext !== null && homeNext.parentElement === home) home.insertBefore(moved, homeNext);
2061
+ else home.append(moved);
2062
+ };
2063
+ }
2064
+ // src/client/sidebar-width.ts
2065
+ /**
2066
+ * The sidebar width the shell opens with, and the one it is left at.
2067
+ *
2068
+ * The app keeps its sidebar width in an in-memory store created fresh on every
2069
+ * load (`sidebar: 280`), so a reload snaps the column back to 280 and nothing
2070
+ * outside the layout package can read or write that value. The one persistent
2071
+ * handle a plugin has is the painted px, which this plugin already owns through
2072
+ * the relaxed drag floor — so the width is remembered here instead: first run
2073
+ * opens at the narrowest width the gesture allows, later runs at whatever the
2074
+ * reader dragged it to.
2075
+ *
2076
+ * Only the drag that this plugin performs is recorded. The app's own collapse
2077
+ * (and any width it paints on its own) never reaches this module, so a rail or
2078
+ * a reset cannot overwrite the remembered value.
2079
+ */
2080
+ /** localStorage key holding the last width this plugin settled on. */
2081
+ const STORAGE_KEY$1 = "dsh-enhance.sidebar-width.v1";
2082
+ /**
2083
+ * Read a remembered width, rejecting anything outside the contract range.
2084
+ * @param raw - the stored string, or null.
2085
+ * @returns the width in px, or undefined when absent or unusable.
2086
+ */
2087
+ function readSidebarWidth(raw) {
2088
+ if (raw === null || raw.trim() === "") return void 0;
2089
+ const width = Number(raw);
2090
+ if (!Number.isFinite(width) || width < 214 || width > 420) return void 0;
2091
+ return Math.round(width);
2092
+ }
2093
+ /**
2094
+ * The width the shell should open with.
2095
+ * @param store - storage to read, or null where storage is blocked.
2096
+ * @returns the remembered width, or the narrow default on a first run.
2097
+ */
2098
+ function startupSidebarWidth(store) {
2099
+ if (store === null) return 214;
2100
+ try {
2101
+ return readSidebarWidth(store.getItem("dsh-enhance.sidebar-width.v1")) ?? 214;
2102
+ } catch {
2103
+ return 214;
2104
+ }
2105
+ }
2106
+ /**
2107
+ * Remember the width a drag settled on.
2108
+ * @param store - storage to write, or null where storage is blocked.
2109
+ * @param width - the settled width in px.
2110
+ */
2111
+ function rememberSidebarWidth(store, width) {
2112
+ if (store === null) return;
2113
+ const bounded = Math.round(Math.min(Math.max(width, 214), 420));
2114
+ try {
2115
+ store.setItem(STORAGE_KEY$1, String(bounded));
2116
+ } catch {}
2117
+ }
2118
+ /**
2119
+ * The page's localStorage, or null where storage is blocked.
2120
+ * @returns the storage face, or null.
2121
+ */
2122
+ function pageStorage() {
2123
+ try {
2124
+ return globalThis.localStorage ?? null;
2125
+ } catch {
2126
+ return null;
2127
+ }
2128
+ }
2129
+ // src/client/window-geometry.ts
2130
+ /**
2131
+ * Fill the screen on the first desktop launch, then remember the geometry.
2132
+ *
2133
+ * The Electron shell creates its main window at a fixed 1280x820 and records
2134
+ * nothing about where it was left, so every launch re-centres it. The bundle
2135
+ * cannot be patched here: `/Applications/DeepSeek Harness.app` ships a signed,
2136
+ * integrity-fused `app.asar`, and its preload exposes no window API to plugins.
2137
+ * The renderer half of that same window, however, is allowed to call
2138
+ * `window.resizeTo` / `window.moveTo` — verified to drive a sandboxed,
2139
+ * context-isolated Electron 44 window whose size is then reported as
2140
+ * maximized by the main process.
2141
+ *
2142
+ * So this module owns the geometry from the page: first launch (nothing saved)
2143
+ * fills the work area, later launches restore what the last one closed with.
2144
+ * Only the dimensions and the maximized flag are stored; the position is kept
2145
+ * so a window left on a second display reopens there. A saved frame that no
2146
+ * longer fits — monitor unplugged, resolution changed — is clamped into the
2147
+ * work area rather than restored off-screen.
2148
+ *
2149
+ * A plain browser tab has no work area of its own and `resizeTo` is a no-op
2150
+ * there, so the whole module stays inert outside the Electron shell.
2151
+ */
2152
+ /** localStorage key holding the last close's frame. */
2153
+ const STORAGE_KEY = "dsh-enhance.window-geometry.v1";
2154
+ /**
2155
+ * Read the work area out of a window's screen.
2156
+ *
2157
+ * `availLeft` / `availTop` exist in Chromium (they are how a maximized window
2158
+ * knows where the menu bar is), but not in the DOM typings, so they are read
2159
+ * defensively and default to the origin.
2160
+ * @param win - the driven window.
2161
+ * @returns the area a maximized window would fill.
2162
+ */
2163
+ function workAreaOf(win) {
2164
+ return {
2165
+ left: win.screen.availLeft ?? 0,
2166
+ top: win.screen.availTop ?? 0,
2167
+ width: win.screen.availWidth,
2168
+ height: win.screen.availHeight
2169
+ };
2170
+ }
2171
+ /** How long a resize or move must settle before the frame is written. */
2172
+ const SAVE_DELAY_MS = 400;
2173
+ /** How long the startup paint must settle before its own events stop counting. */
2174
+ const RESTORE_SETTLE_MS = 600;
2175
+ /**
2176
+ * A window within this many pixels of the work area counts as filled.
2177
+ *
2178
+ * Measured on macOS: a maximized window settles at exactly the work area, but
2179
+ * reports a few pixels less for the frame between the resize and the next
2180
+ * layout pass (1420x923 for a 1424x923 area). The tolerance covers that
2181
+ * transient without letting an ordinary window pass as maximized — 8px is
2182
+ * under 0.6% of the width on any display this app runs on.
2183
+ */
2184
+ const MAXIMIZED_TOLERANCE = 8;
2185
+ /**
2186
+ * Whether the page runs inside the Electron shell.
2187
+ *
2188
+ * The desktop preload has no window-geometry bridge to probe, and `resizeTo`
2189
+ * exists in every browser while doing nothing for a tab, so the user agent is
2190
+ * the discriminator: only the packaged shell reports `Electron/`.
2191
+ * @returns true when the module may drive its own window.
2192
+ */
2193
+ function isDesktopShell() {
2194
+ if (typeof navigator === "undefined") return false;
2195
+ return navigator.userAgent.includes("Electron/");
2196
+ }
2197
+ /**
2198
+ * Read a persisted frame, ignoring anything that is not a sane rectangle.
2199
+ * @param raw - the stored JSON string, or null.
2200
+ * @returns the parsed record, or undefined when absent or malformed.
2201
+ */
2202
+ function readSavedGeometry(raw) {
2203
+ if (raw === null || raw === "") return void 0;
2204
+ let parsed;
2205
+ try {
2206
+ parsed = JSON.parse(raw);
2207
+ } catch {
2208
+ return;
2209
+ }
2210
+ if (typeof parsed !== "object" || parsed === null) return void 0;
2211
+ const record = parsed;
2212
+ if (!isFrame(record.normal)) return void 0;
2213
+ return {
2214
+ normal: record.normal,
2215
+ maximized: record.maximized === true
2216
+ };
2217
+ }
2218
+ /**
2219
+ * Whether a value is a frame with positive dimensions.
2220
+ * @param value - candidate record.
2221
+ * @returns true when it can be restored.
2222
+ */
2223
+ function isFrame(value) {
2224
+ if (typeof value !== "object" || value === null) return false;
2225
+ const frame = value;
2226
+ return [
2227
+ "x",
2228
+ "y",
2229
+ "width",
2230
+ "height"
2231
+ ].every((key) => typeof frame[key] === "number" && Number.isFinite(frame[key])) && frame.width > 0 && frame.height > 0;
2232
+ }
2233
+ /**
2234
+ * Keep a frame inside the work area, without shrinking it below a usable size.
2235
+ *
2236
+ * A frame is never enlarged here: a window saved small stays small. It only
2237
+ * ensures enough of the title bar is on screen to grab, and that the whole
2238
+ * window fits when the display got smaller than the window.
2239
+ * @param frame - the frame to restore.
2240
+ * @param area - the work area it must live in.
2241
+ * @returns a frame that can be painted on screen.
2242
+ */
2243
+ function clampToArea(frame, area) {
2244
+ const width = Math.min(frame.width, area.width);
2245
+ const height = Math.min(frame.height, area.height);
2246
+ const minVisible = 120;
2247
+ const x = Math.min(Math.max(frame.x, area.left - width + minVisible), area.left + area.width - minVisible);
2248
+ const y = Math.min(Math.max(frame.y, area.top), area.top + area.height - 40);
2249
+ return {
2250
+ x: Math.round(x),
2251
+ y: Math.round(y),
2252
+ width: Math.round(width),
2253
+ height: Math.round(height)
2254
+ };
2255
+ }
2256
+ /**
2257
+ * Whether the window currently fills its work area.
2258
+ * @param frame - the live frame.
2259
+ * @param area - the work area.
2260
+ * @returns true when the dimensions match the work area.
2261
+ */
2262
+ function isFilled(frame, area) {
2263
+ return Math.abs(frame.width - area.width) <= MAXIMIZED_TOLERANCE && Math.abs(frame.height - area.height) <= MAXIMIZED_TOLERANCE;
2264
+ }
2265
+ /**
2266
+ * The frame the window reports right now.
2267
+ * @param win - the driven window.
2268
+ * @returns its current outer frame.
2269
+ */
2270
+ function currentFrame(win) {
2271
+ return {
2272
+ x: Math.round(win.screenX),
2273
+ y: Math.round(win.screenY),
2274
+ width: Math.round(win.outerWidth),
2275
+ height: Math.round(win.outerHeight)
2276
+ };
2277
+ }
2278
+ /**
2279
+ * Fill the work area.
2280
+ *
2281
+ * Resizing before moving keeps the final position exact: the platform clamps a
2282
+ * move against the *new* size, so moving a 1280-wide window to the work-area
2283
+ * origin first and then widening it would leave it offset.
2284
+ * @param win - the driven window.
2285
+ * @param area - the work area to fill.
2286
+ */
2287
+ function fill(win, area) {
2288
+ win.resizeTo(area.width, area.height);
2289
+ win.moveTo(area.left, area.top);
2290
+ }
2291
+ /**
2292
+ * Drive the window's startup geometry and keep the frame it closes with.
2293
+ *
2294
+ * The caller decides whether this applies at all — see {@link isDesktopShell}.
2295
+ * A plain browser tab ignores `resizeTo` / `moveTo`, so calling it there is
2296
+ * harmless, but a tab also has no work area of its own to fill.
2297
+ * @param win - the Electron window's renderer `window`.
2298
+ * @param store - storage to read and write; omit to use the page's localStorage.
2299
+ * @returns disposer that stops persisting further changes.
2300
+ */
2301
+ function installStartupGeometry(win, store) {
2302
+ const storage = store ?? safeStorage();
2303
+ const area = workAreaOf(win);
2304
+ if (!(area.width > 0) || !(area.height > 0)) return () => {};
2305
+ /** The last frame seen while the window was not filling the area. */
2306
+ let normal = currentFrame(win);
2307
+ /** True while this module's own paint is still settling. */
2308
+ let restoring = false;
2309
+ let timer;
2310
+ let settle;
2311
+ /**
2312
+ * Paint the saved frame, or fill the screen when nothing was saved.
2313
+ * @param geometry - what the previous launch left behind.
2314
+ */
2315
+ const restore = (geometry) => {
2316
+ restoring = true;
2317
+ if (geometry === void 0 || geometry.maximized) fill(win, area);
2318
+ else {
2319
+ const frame = clampToArea(geometry.normal, area);
2320
+ normal = frame;
2321
+ win.resizeTo(frame.width, frame.height);
2322
+ win.moveTo(frame.x, frame.y);
2323
+ }
2324
+ settle = setTimeout(() => {
2325
+ restoring = false;
2326
+ save();
2327
+ }, RESTORE_SETTLE_MS);
2328
+ };
2329
+ /** Write the current state, keeping the last non-filled frame as "normal". */
2330
+ const save = () => {
2331
+ if (storage === null || restoring) return;
2332
+ const frame = currentFrame(win);
2333
+ const maximized = isFilled(frame, area);
2334
+ if (!maximized) normal = frame;
2335
+ try {
2336
+ storage.setItem(STORAGE_KEY, JSON.stringify({
2337
+ normal,
2338
+ maximized
2339
+ }));
2340
+ } catch {}
2341
+ };
2342
+ const schedule = () => {
2343
+ if (restoring) return;
2344
+ if (timer !== void 0) clearTimeout(timer);
2345
+ timer = setTimeout(save, SAVE_DELAY_MS);
2346
+ };
2347
+ /** Persist as soon as the page is hidden, which is what a close looks like. */
2348
+ const onVisibilityChange = () => {
2349
+ if (win.document.visibilityState === "hidden") save();
2350
+ };
2351
+ restore(storage === null ? void 0 : readSavedGeometry(storage.getItem(STORAGE_KEY)));
2352
+ win.addEventListener("resize", schedule);
2353
+ win.addEventListener("blur", schedule);
2354
+ win.addEventListener("visibilitychange", onVisibilityChange);
2355
+ win.addEventListener("pagehide", save);
2356
+ return () => {
2357
+ if (timer !== void 0) clearTimeout(timer);
2358
+ if (settle !== void 0) clearTimeout(settle);
2359
+ win.removeEventListener("resize", schedule);
2360
+ win.removeEventListener("blur", schedule);
2361
+ win.removeEventListener("visibilitychange", onVisibilityChange);
2362
+ win.removeEventListener("pagehide", save);
2363
+ restoring = false;
2364
+ save();
2365
+ };
2366
+ }
2367
+ /**
2368
+ * The page's localStorage, or null where storage is blocked (a sandboxed
2369
+ * iframe, a privacy mode that throws on access).
2370
+ * @returns the storage face, or null.
2371
+ */
2372
+ function safeStorage() {
2373
+ try {
2374
+ return globalThis.localStorage ?? null;
2375
+ } catch {
2376
+ return null;
2377
+ }
2378
+ }
2379
+ // src/client/turn-badge.ts
2380
+ /** localStorage key of the pre-v2 accumulating badge; cleared once on mount. */
2381
+ const LEGACY_STORAGE_KEY = "dsh-enhance.turn-badge.v1";
2382
+ /**
2383
+ * Ids of visible (non-blank, non-subagent) sessions whose completion is
2384
+ * unread. Statuses of rows the list no longer carries are skipped: a deleted
2385
+ * conversation shows no dot in the sidebar either.
2386
+ * @param byId - the list snapshot's rows by id.
2387
+ * @param status - the Session status snapshot.
2388
+ * @returns the ids to count on the tile, in list order.
2389
+ */
2390
+ function unreadVisibleIds(byId, status) {
2391
+ const unread = [];
2392
+ for (const [id, row] of Object.entries(byId)) {
2393
+ if (row.blank === true || row.origin === "subagent") continue;
2394
+ if (status.get(id)?.completionUnread === true) unread.push(id);
2395
+ }
2396
+ return unread;
2397
+ }
2398
+ /**
2399
+ * Install the unread-session Dock badge.
2400
+ * @param ctx - client root context providing the sessions and uiSession services.
2401
+ * @param deps - seams, overridable in tests.
2402
+ * @returns disposer.
2403
+ */
2404
+ function installTurnBadge(ctx, deps = {}) {
2405
+ const badgeNavigator = navigator;
2406
+ const badge = deps.badge ?? (typeof badgeNavigator.setAppBadge === "function" ? {
2407
+ set: (contents) => badgeNavigator.setAppBadge?.(contents) ?? Promise.resolve(),
2408
+ clear: () => badgeNavigator.clearAppBadge?.() ?? Promise.resolve()
2409
+ } : void 0);
2410
+ if (badge === void 0) return () => {};
2411
+ const statusStore = deps.statusSource ?? ctx.uiSession?.sessionStatus;
2412
+ if (statusStore === void 0) return () => {};
2413
+ try {
2414
+ localStorage.removeItem(LEGACY_STORAGE_KEY);
2415
+ } catch {}
2416
+ let painted;
2417
+ const paint = () => {
2418
+ const count = unreadVisibleIds(ctx.sessions.list.getSnapshot().byId, statusStore.getSnapshot()).length;
2419
+ if (painted === count) return;
2420
+ painted = count;
2421
+ (count > 0 ? badge.set(count) : badge.clear()).catch(() => {});
2422
+ };
2423
+ const stopStatus = statusStore.subscribe(paint);
2424
+ const stopList = ctx.sessions.list.subscribe(paint);
2425
+ paint();
2426
+ return () => {
2427
+ stopStatus();
2428
+ stopList();
2429
+ };
2430
+ }
2431
+ // src/client/locales.ts
1618
2432
  /** Copy for the transcript selection toolbar, in every shipped locale. */
1619
2433
  /** Locale namespace this plugin owns. */
1620
2434
  const LOCALE_NS = "dshEnhance";
@@ -1749,8 +2563,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1749
2563
  left: Math.min(Math.max(8, centered), Math.max(8, viewport.width - width - 8))
1750
2564
  };
1751
2565
  }
1752
- //#endregion
1753
- //#region src/client/anchors.ts
2566
+ // src/client/anchors.ts
1754
2567
  /** Any transcript row the plugin may anchor to. */
1755
2568
  const ROW_SELECTOR = "[data-chat-flow-key], [data-chat-anchor-key]";
1756
2569
  /**
@@ -1947,17 +2760,47 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
1947
2760
  if (transcript !== null && transcript !== void 0 && !roots.includes(transcript)) roots.push(transcript);
1948
2761
  const ranges = [];
1949
2762
  for (const root of roots) for (const text of textNodesOf(root)) {
1950
- const index = text.data.replace(/\s+/g, " ").indexOf(needle);
1951
- if (index < 0) continue;
2763
+ const hit = text.data.replace(/\s+/g, " ").indexOf(needle);
2764
+ if (hit < 0) continue;
2765
+ const start = rawIndexOf(text.data, hit);
2766
+ const end = rawIndexOf(text.data, hit + needle.length);
2767
+ if (start === void 0 || end === void 0) continue;
1952
2768
  const range = document.createRange();
1953
- range.setStart(text, index);
1954
- range.setEnd(text, Math.min(index + needle.length, text.data.length));
2769
+ range.setStart(text, start);
2770
+ range.setEnd(text, end);
1955
2771
  ranges.push(range);
1956
2772
  return ranges;
1957
2773
  }
1958
2774
  return ranges;
1959
2775
  }
1960
2776
  /**
2777
+ * Map an offset in the whitespace-collapsed text back to the raw text.
2778
+ *
2779
+ * `collapsedOffset` counts characters after every run of whitespace became a
2780
+ * single space, so walking the raw string while emitting one position per
2781
+ * collapsed character gives the matching raw index. A collapsed offset equal to
2782
+ * the collapsed length maps to the end of the raw string.
2783
+ * @param raw - the node's actual text.
2784
+ * @param collapsedOffset - the index in `raw.replace(/\s+/g, ' ')`.
2785
+ * @returns the equivalent index in `raw`.
2786
+ */
2787
+ function rawIndexOf(raw, collapsedOffset) {
2788
+ if (collapsedOffset < 0) return void 0;
2789
+ let produced = 0;
2790
+ let index = 0;
2791
+ while (index < raw.length) {
2792
+ if (produced === collapsedOffset) return index;
2793
+ if (/\s/.test(raw[index] ?? "")) {
2794
+ while (index < raw.length && /\s/.test(raw[index] ?? "")) index += 1;
2795
+ produced += 1;
2796
+ continue;
2797
+ }
2798
+ index += 1;
2799
+ produced += 1;
2800
+ }
2801
+ return produced === collapsedOffset ? raw.length : void 0;
2802
+ }
2803
+ /**
1961
2804
  * Scroll a marked passage into view and paint it.
1962
2805
  * @param annotation - the annotation whose row should be shown.
1963
2806
  * @returns whether the passage was found and revealed.
@@ -2073,17 +2916,33 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2073
2916
  /** Attribute marking an inline annotation badge this plugin inserted. */
2074
2917
  const BADGE_ATTRIBUTE = "data-dsh-enhance-badge";
2075
2918
  /**
2076
- * Pin glyph for the inline badge.
2919
+ * One solid disc carrying the reading-order number.
2077
2920
  *
2078
- * Drawn rather than typed: an emoji renders at the platform's own size and
2079
- * baseline, which made the marker look different in every app it appeared in.
2080
- * `currentColor` keeps it on the badge's own palette in both themes.
2081
- */
2082
- const PIN_GLYPH = `<svg viewBox="0 0 16 16" width="11" height="11" aria-hidden="true" focusable="false">
2083
- <path d="M8 1.6c2.5 0 4.5 2 4.5 4.5 0 3.2-4.5 8.3-4.5 8.3S3.5 9.3 3.5 6.1C3.5 3.6 5.5 1.6 8 1.6Z"
2084
- fill="none" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/>
2085
- <circle cx="8" cy="6.2" r="1.7" fill="currentColor"/>
2921
+ * Earlier takes drew a pin with a counter beside it, or a counter notched into
2922
+ * the pin's outline; both read as two shapes on one line. A single filled disc
2923
+ * with the digits inside is one mark with one silhouette, which is what the
2924
+ * inline marker needs to be. The disc grows into a pill for two and three
2925
+ * digits so the number never outgrows the shape.
2926
+ * @param number - the annotation's 1-based position.
2927
+ * @returns the SVG markup for one badge.
2928
+ */
2929
+ function badgeGlyph(number) {
2930
+ const digits = String(number);
2931
+ const length = digits.length;
2932
+ const side = 22;
2933
+ const width = length > 1 ? side + (length - 1) * 11 : side;
2934
+ const ring = 1.1;
2935
+ const radius = 8.6;
2936
+ const fontSize = length > 2 ? 10.5 : length > 1 ? 12 : 13.5;
2937
+ return `<svg viewBox="0 0 ${width} ${side}" width="${width}" height="${side}" aria-hidden="true" focusable="false">
2938
+ <rect x="${ring / 2}" y="${ring / 2}" width="${width - ring}" height="20.9"
2939
+ rx="${radius}" fill="#0268cc" stroke="#e9e9e9" stroke-width="${ring}"/>
2940
+ <text x="${width / 2}" y="11.5" text-anchor="middle" dominant-baseline="central"
2941
+ font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif"
2942
+ font-size="${fontSize}" font-weight="500" fill="#fff"
2943
+ style="font-variant-numeric: tabular-nums">${digits}</text>
2086
2944
  </svg>`;
2945
+ }
2087
2946
  /**
2088
2947
  * Place one annotation badge at the end of every marked passage.
2089
2948
  *
@@ -2097,14 +2956,24 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2097
2956
  * @returns how many badges are currently mounted.
2098
2957
  */
2099
2958
  function mountBadges(annotations, onClick) {
2100
- const existing = new Set([...document.querySelectorAll(`[${BADGE_ATTRIBUTE}]`)].map((badge) => badge.getAttribute("data-dsh-enhance-badge") ?? ""));
2959
+ const existing = /* @__PURE__ */ new Map();
2960
+ for (const badge of document.querySelectorAll(`[${BADGE_ATTRIBUTE}]`)) existing.set(badge.getAttribute("data-dsh-enhance-badge") ?? "", badge);
2101
2961
  let mounted = 0;
2102
- for (const annotation of annotations) {
2103
- if (existing.has(annotation.id)) continue;
2962
+ annotations.forEach((annotation, offset) => {
2963
+ const number = offset + 1;
2964
+ const live = existing.get(annotation.id);
2965
+ if (live !== void 0) {
2966
+ live.dataset.dshEnhanceBadgeNumber = String(number);
2967
+ live.setAttribute("aria-label", badgeLabel(annotation, number));
2968
+ live.title = badgeLabel(annotation, number);
2969
+ const slot = live.querySelector("svg text");
2970
+ if (slot !== null && slot.textContent !== String(number)) live.innerHTML = badgeGlyph(number);
2971
+ return;
2972
+ }
2104
2973
  const ranges = rangesOf(annotation);
2105
2974
  const last = ranges[ranges.length - 1];
2106
- if (last === void 0) continue;
2107
- const badge = createBadge(annotation, onClick);
2975
+ if (last === void 0) return;
2976
+ const badge = createBadge(annotation, number, onClick);
2108
2977
  const anchor = document.createElement("span");
2109
2978
  anchor.setAttribute("data-dsh-enhance-badge-anchor", "");
2110
2979
  anchor.appendChild(badge);
@@ -2116,24 +2985,42 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2116
2985
  else text.parentNode?.insertBefore(anchor, text.splitText(at));
2117
2986
  } else container.parentNode?.insertBefore(anchor, container.nextSibling);
2118
2987
  mounted += 1;
2119
- }
2988
+ });
2120
2989
  return mounted;
2121
2990
  }
2122
2991
  /**
2992
+ * Accessible name for one badge: the reading order number, then the note (or
2993
+ * the passage when the reader left the note empty).
2994
+ * @param annotation - the annotation it marks.
2995
+ * @param number - its 1-based position in the Session's annotation list.
2996
+ * @returns the label shared by `title` and `aria-label`.
2997
+ */
2998
+ function badgeLabel(annotation, number) {
2999
+ return `${number}. ${annotation.note.trim().length > 0 ? annotation.note : annotation.passage}`;
3000
+ }
3001
+ /**
2123
3002
  * Build one badge button.
3003
+ *
3004
+ * The badge carries the annotation's position, not just a pin: with several
3005
+ * passages marked in one conversation, an unnumbered pin says "something here"
3006
+ * where the reader needs "this is the one the tray's first row refers to". The
3007
+ * number sits in a filled circle beside the pin, matching the marker shape the
3008
+ * annotation list uses.
2124
3009
  * @param annotation - the annotation it marks.
3010
+ * @param number - its 1-based position among the Session's annotations.
2125
3011
  * @param onClick - called with the annotation id when activated.
2126
3012
  * @returns the detached button.
2127
3013
  */
2128
- function createBadge(annotation, onClick) {
3014
+ function createBadge(annotation, number, onClick) {
2129
3015
  const badge = document.createElement("button");
2130
3016
  badge.type = "button";
2131
3017
  badge.setAttribute(BADGE_ATTRIBUTE, annotation.id);
2132
3018
  badge.className = "dsh-enhance-badge";
2133
- const label = annotation.note.trim().length > 0 ? annotation.note : annotation.passage;
3019
+ badge.dataset.dshEnhanceBadgeNumber = String(number);
3020
+ const label = badgeLabel(annotation, number);
2134
3021
  badge.title = label;
2135
3022
  badge.setAttribute("aria-label", label);
2136
- badge.innerHTML = PIN_GLYPH;
3023
+ badge.innerHTML = badgeGlyph(number);
2137
3024
  badge.addEventListener("click", (event) => {
2138
3025
  event.stopPropagation();
2139
3026
  event.preventDefault();
@@ -2151,8 +3038,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2151
3038
  parent?.normalize();
2152
3039
  }
2153
3040
  }
2154
- //#endregion
2155
- //#region src/client/SelectionToolbar.tsx
3041
+ // src/client/SelectionToolbar.tsx
2156
3042
  /**
2157
3043
  * Annotation popover: the small composer that appears next to a transcript
2158
3044
  * selection.
@@ -2261,8 +3147,17 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2261
3147
  width: window.innerWidth,
2262
3148
  height: window.innerHeight
2263
3149
  }));
2264
- input.current?.focus({ preventScroll: true });
2265
3150
  }, [captured]);
3151
+ (0, react.useEffect)(() => {
3152
+ if (placement === void 0) return;
3153
+ input.current?.focus({ preventScroll: true });
3154
+ }, [placement]);
3155
+ (0, react.useLayoutEffect)(() => {
3156
+ const field = input.current;
3157
+ if (field === null) return;
3158
+ field.style.height = "auto";
3159
+ field.style.height = `${field.scrollHeight}px`;
3160
+ }, [note, placement]);
2266
3161
  const confirm = (0, react.useCallback)(() => {
2267
3162
  const current = latest.current;
2268
3163
  if (current === void 0) return;
@@ -2298,7 +3193,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2298
3193
  t
2299
3194
  ]);
2300
3195
  if (captured === void 0 || placement === void 0) return null;
2301
- return (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
3196
+ const portal = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2302
3197
  ref: surface,
2303
3198
  className: "dsh-enhance-popover",
2304
3199
  "data-dsh-enhance-toolbar": "",
@@ -2350,7 +3245,8 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2350
3245
  children: busy ? t("toolbar.sideChat.busy") : t("toolbar.sideChat")
2351
3246
  })]
2352
3247
  })]
2353
- }), document.body);
3248
+ });
3249
+ return (0, react_dom.createPortal)(portal, document.body);
2354
3250
  }
2355
3251
  /**
2356
3252
  * Whether a node sits inside the popover surface.
@@ -2389,8 +3285,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2389
3285
  })
2390
3286
  });
2391
3287
  }
2392
- //#endregion
2393
- //#region src/client/annotations.ts
3288
+ // src/client/annotations.ts
2394
3289
  /** Session id → its ordered annotations. */
2395
3290
  const store = /* @__PURE__ */ new Map();
2396
3291
  /** Identity counter per Session, so ids never repeat within a list. */
@@ -2550,8 +3445,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2550
3445
  }
2551
3446
  return visible.length === 0 ? EMPTY : visible;
2552
3447
  }
2553
- //#endregion
2554
- //#region src/client/AnnotationTray.tsx
3448
+ // src/client/AnnotationTray.tsx
2555
3449
  /**
2556
3450
  * Annotation tray: the pill above the composer, its hover preview, and the
2557
3451
  * editing dialog.
@@ -2575,6 +3469,13 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2575
3469
  const [editing, setEditing] = (0, react.useState)(void 0);
2576
3470
  const [editAnchor, setEditAnchor] = (0, react.useState)(void 0);
2577
3471
  /** Open the editor for one annotation, anchored under the badge that asked. */
3472
+ /**
3473
+ * Whether the editor dialog is open, read from inside timer and pointer
3474
+ * callbacks. A ref keeps the dismissal callbacks stable instead of rebuilding
3475
+ * them on every keystroke in the note field.
3476
+ */
3477
+ const editorOpen = (0, react.useRef)(false);
3478
+ editorOpen.current = editing !== void 0;
2578
3479
  const setEditingAt = (annotation, anchor) => {
2579
3480
  setEditing(annotation);
2580
3481
  setEditAnchor(anchor);
@@ -2589,7 +3490,10 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2589
3490
  (0, react.useEffect)(() => {
2590
3491
  if (editRequest === void 0) return;
2591
3492
  const target = annotations.find((annotation) => annotation.id === editRequest);
2592
- if (target !== void 0) setEditingAt(target, document.querySelector(`[data-dsh-enhance-badge="${editRequest}"]`)?.getBoundingClientRect());
3493
+ if (target !== void 0) {
3494
+ const badge = document.querySelector(`[data-dsh-enhance-badge="${editRequest}"]`);
3495
+ setEditingAt(target, badge?.getBoundingClientRect());
3496
+ }
2593
3497
  onEditRequestHandled?.();
2594
3498
  }, [
2595
3499
  annotations,
@@ -2617,6 +3521,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2617
3521
  closeTimer.current = setTimeout(() => {
2618
3522
  closeTimer.current = null;
2619
3523
  setOpen(false);
3524
+ if (editorOpen.current) return;
2620
3525
  clearHighlight();
2621
3526
  }, 180);
2622
3527
  }, [keepOpen]);
@@ -2624,11 +3529,19 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2624
3529
  const dismissAll = (0, react.useCallback)(() => {
2625
3530
  keepOpen();
2626
3531
  setOpen(false);
3532
+ if (editorOpen.current) return;
2627
3533
  clearHighlight();
2628
3534
  }, [keepOpen]);
2629
3535
  (0, react.useEffect)(() => () => {
2630
3536
  keepOpen();
2631
3537
  }, [keepOpen]);
3538
+ (0, react.useEffect)(() => {
3539
+ if (editing === void 0) return;
3540
+ highlightAnnotation(editing);
3541
+ return () => {
3542
+ clearHighlight();
3543
+ };
3544
+ }, [editing]);
2632
3545
  (0, react.useLayoutEffect)(() => {
2633
3546
  if (!open) {
2634
3547
  setListStyle(void 0);
@@ -2664,7 +3577,8 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2664
3577
  const { clientX: x, clientY: y } = event;
2665
3578
  const overPill = inside(pill.current, x, y);
2666
3579
  const overList = inside(list.current, x, y);
2667
- if (overPill || overList) {
3580
+ const overEditor = editing !== void 0 && inside(document.querySelector("[data-dsh-enhance-edit]"), x, y);
3581
+ if (overPill || overList || overEditor) {
2668
3582
  keepOpen();
2669
3583
  setOpen(true);
2670
3584
  return;
@@ -2677,6 +3591,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2677
3591
  };
2678
3592
  }, [
2679
3593
  annotations.length,
3594
+ editing,
2680
3595
  keepOpen,
2681
3596
  scheduleClose
2682
3597
  ]);
@@ -2780,10 +3695,10 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2780
3695
  className: "dsh-enhance-tray__row",
2781
3696
  "aria-label": t("tray.reveal"),
2782
3697
  onMouseEnter: () => {
2783
- highlightAnnotation(annotation);
3698
+ if (editing === void 0) highlightAnnotation(annotation);
2784
3699
  },
2785
3700
  onMouseLeave: () => {
2786
- clearHighlight();
3701
+ if (editing === void 0) clearHighlight();
2787
3702
  },
2788
3703
  onClick: () => {
2789
3704
  revealAnnotation(annotation);
@@ -2810,7 +3725,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2810
3725
  "aria-label": t("tray.edit"),
2811
3726
  title: t("tray.edit"),
2812
3727
  onMouseEnter: () => {
2813
- highlightAnnotation(annotation);
3728
+ if (editing === void 0) highlightAnnotation(annotation);
2814
3729
  },
2815
3730
  onClick: () => {
2816
3731
  setEditingAt(annotation);
@@ -2839,6 +3754,11 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2839
3754
  onSave: (note) => {
2840
3755
  onEdit(editing.id, note);
2841
3756
  setEditingAt(void 0);
3757
+ },
3758
+ onDelete: () => {
3759
+ onRemove(editing.id);
3760
+ setEditingAt(void 0);
3761
+ dismissAll();
2842
3762
  }
2843
3763
  })
2844
3764
  ]
@@ -2851,15 +3771,25 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2851
3771
  * reading the passage behind it, so the header doubles as a drag handle and the
2852
3772
  * panel never blocks the page.
2853
3773
  */
2854
- function AnnotationEditor({ t, annotation, anchor, onCancel, onSave }) {
3774
+ function AnnotationEditor({ t, annotation, anchor, onCancel, onSave, onDelete }) {
2855
3775
  const [value, setValue] = (0, react.useState)(annotation.note);
2856
3776
  const field = (0, react.useRef)(null);
2857
3777
  const surface = (0, react.useRef)(null);
2858
3778
  const [style, setStyle] = (0, react.useState)(void 0);
2859
3779
  const drag = (0, react.useRef)(null);
2860
3780
  (0, react.useEffect)(() => {
2861
- field.current?.focus({ preventScroll: true });
3781
+ const element = field.current;
3782
+ if (element === null) return;
3783
+ element.focus({ preventScroll: true });
3784
+ const end = element.value.length;
3785
+ element.setSelectionRange(end, end);
2862
3786
  }, []);
3787
+ (0, react.useLayoutEffect)(() => {
3788
+ const element = field.current;
3789
+ if (element === null) return;
3790
+ element.style.height = "auto";
3791
+ element.style.height = `${element.scrollHeight}px`;
3792
+ }, [value]);
2863
3793
  (0, react.useLayoutEffect)(() => {
2864
3794
  if (anchor === void 0) return;
2865
3795
  const element = surface.current;
@@ -2910,17 +3840,29 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
2910
3840
  role: "dialog",
2911
3841
  "aria-label": t("tray.edit"),
2912
3842
  style,
2913
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3843
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2914
3844
  className: "dsh-enhance-edit__head",
2915
3845
  title: annotation.passage,
2916
3846
  onPointerDown,
2917
3847
  onPointerMove,
2918
3848
  onPointerUp: endDrag,
2919
3849
  onPointerCancel: endDrag,
2920
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
3850
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2921
3851
  className: "dsh-enhance-edit__label",
2922
3852
  children: collapse(annotation.passage)
2923
- })
3853
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
3854
+ type: "button",
3855
+ className: "dsh-enhance-edit__delete",
3856
+ "aria-label": t("tray.remove"),
3857
+ title: t("tray.remove"),
3858
+ onPointerDown: (event) => {
3859
+ event.stopPropagation();
3860
+ },
3861
+ onClick: () => {
3862
+ onDelete();
3863
+ },
3864
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TrashGlyph, {})
3865
+ })]
2924
3866
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2925
3867
  className: "dsh-enhance-edit__body",
2926
3868
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
@@ -3002,24 +3944,40 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3002
3944
  }
3003
3945
  /** Trash glyph. */
3004
3946
  function TrashGlyph() {
3005
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
3947
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
3006
3948
  viewBox: "0 0 16 16",
3007
- width: "18",
3008
- height: "18",
3949
+ width: "16",
3950
+ height: "16",
3009
3951
  "aria-hidden": "true",
3010
3952
  focusable: "false",
3011
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
3012
- d: "M3.4 4.6h9.2M6.4 4.6V3.2h3.2v1.4M4.8 4.6l.6 8.2h5.2l.6-8.2",
3013
- fill: "none",
3014
- stroke: "currentColor",
3015
- strokeWidth: "1.2",
3016
- strokeLinecap: "round",
3017
- strokeLinejoin: "round"
3018
- })
3953
+ children: [
3954
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
3955
+ d: "M2.6 4.4h10.8M6.1 4.4V2.9h3.8v1.5",
3956
+ fill: "none",
3957
+ stroke: "currentColor",
3958
+ strokeWidth: "1.35",
3959
+ strokeLinecap: "round",
3960
+ strokeLinejoin: "round"
3961
+ }),
3962
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
3963
+ d: "M4.1 4.4h7.8l-.7 8.1a2 2 0 0 1-2 1.8H6.8a2 2 0 0 1-2-1.8Z",
3964
+ fill: "none",
3965
+ stroke: "currentColor",
3966
+ strokeWidth: "1.35",
3967
+ strokeLinecap: "round",
3968
+ strokeLinejoin: "round"
3969
+ }),
3970
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
3971
+ d: "M6.7 7.2v4.2M9.3 7.2v4.2",
3972
+ fill: "none",
3973
+ stroke: "currentColor",
3974
+ strokeWidth: "1.35",
3975
+ strokeLinecap: "round"
3976
+ })
3977
+ ]
3019
3978
  });
3020
3979
  }
3021
- //#endregion
3022
- //#region src/client/AnnotationSeat.tsx
3980
+ // src/client/AnnotationSeat.tsx
3023
3981
  /**
3024
3982
  * Mount point for the annotation tray and its popover.
3025
3983
  *
@@ -3060,6 +4018,8 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3060
4018
  */
3061
4019
  (0, react.useEffect)(() => {
3062
4020
  const onClick = (id) => {
4021
+ const target = annotationsVisibleIn(sessionId).find((annotation) => annotation.id === id);
4022
+ if (target !== void 0) highlightAnnotation(target);
3063
4023
  setEditingId(id);
3064
4024
  };
3065
4025
  /** Repaint marks and badges; idempotent, so calling it twice costs nothing. */
@@ -3097,6 +4057,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3097
4057
  return () => {
3098
4058
  observer.disconnect();
3099
4059
  removeBadges();
4060
+ clearHighlight();
3100
4061
  clearMarks(sessionId);
3101
4062
  };
3102
4063
  }, [annotations, sessionId]);
@@ -3107,18 +4068,46 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3107
4068
  if (annotations.length === 0) return;
3108
4069
  const card = root.current?.closest("[data-composer-card]");
3109
4070
  if (card === null || card === void 0) return;
4071
+ const primaryOf = () => {
4072
+ return card.querySelector("button[class*=\"_primary\"]") ?? void 0;
4073
+ };
4074
+ /**
4075
+ * Lift the composer's own `empty` decision off the send button.
4076
+ *
4077
+ * React re-renders the button on every draft/store change and puts
4078
+ * `disabled` back, so this runs from the observer below as well as up front.
4079
+ * The attribute is removed rather than faked with CSS: a `disabled` button
4080
+ * swallows the click entirely, and the click is what carries the passages.
4081
+ */
4082
+ const enable = () => {
4083
+ const button = primaryOf();
4084
+ if (button === void 0) return;
4085
+ if (button.disabled) button.disabled = false;
4086
+ if (button.getAttribute("aria-disabled") === "true") button.removeAttribute("aria-disabled");
4087
+ button.dataset.dshEnhanceSendReady = "";
4088
+ };
4089
+ let carrying = false;
3110
4090
  const carry = () => {
3111
- const text = `${annotationsPrompt(annotations)}\n\n`;
3112
- const insertion = inputActions.captureInsertion();
3113
- if (!inputActions.insertText(text, insertion)) {
3114
- inputActions.setDraft(`${draft}${draft === "" ? "" : "\n\n"}${text}`);
3115
- inputActions.persistDraft();
4091
+ if (carrying) return;
4092
+ carrying = true;
4093
+ try {
4094
+ const missing = annotations.filter((annotation) => !draft.includes(annotationLine(annotation)));
4095
+ if (missing.length > 0) {
4096
+ const text = `${annotationsPrompt(missing)}\n\n`;
4097
+ const insertion = inputActions.captureInsertion();
4098
+ if (!inputActions.insertText(text, insertion)) {
4099
+ inputActions.setDraft(`${draft}${draft === "" ? "" : "\n\n"}${text}`);
4100
+ inputActions.persistDraft();
4101
+ }
4102
+ }
4103
+ clearAnnotations(sessionId);
4104
+ } finally {
4105
+ carrying = false;
3116
4106
  }
3117
- clearAnnotations(sessionId);
3118
4107
  };
3119
- const onPointer = (event) => {
4108
+ const onClick = (event) => {
3120
4109
  const target = event.target;
3121
- if (target instanceof Element && target.closest("[class*=\"_primary\"]") !== null) carry();
4110
+ if (target instanceof Element && target.closest("button[class*=\"_primary\"]") !== null) carry();
3122
4111
  };
3123
4112
  const onKey = (event) => {
3124
4113
  if (!(event instanceof KeyboardEvent)) return;
@@ -3126,11 +4115,23 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3126
4115
  const target = event.target;
3127
4116
  if (target instanceof Element && target.closest("[contenteditable=\"true\"]") !== null) carry();
3128
4117
  };
3129
- card.addEventListener("click", onPointer, true);
4118
+ enable();
4119
+ const observer = new MutationObserver(() => {
4120
+ enable();
4121
+ });
4122
+ const button = primaryOf();
4123
+ if (button !== void 0) observer.observe(button, {
4124
+ attributes: true,
4125
+ attributeFilter: ["disabled"]
4126
+ });
4127
+ card.addEventListener("click", onClick, true);
3130
4128
  card.addEventListener("keydown", onKey, true);
3131
4129
  return () => {
3132
- card.removeEventListener("click", onPointer, true);
4130
+ observer.disconnect();
4131
+ card.removeEventListener("click", onClick, true);
3133
4132
  card.removeEventListener("keydown", onKey, true);
4133
+ const current = primaryOf();
4134
+ if (current !== void 0) delete current.dataset.dshEnhanceSendReady;
3134
4135
  };
3135
4136
  }, [
3136
4137
  annotations,
@@ -3186,8 +4187,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3186
4187
  return element.closest("[data-sidebar-chat], [data-dsh-enhance-side-chat]") === null;
3187
4188
  }, [root]);
3188
4189
  }
3189
- //#endregion
3190
- //#region src/client/SideChatBody.tsx
4190
+ // src/client/SideChatBody.tsx
3191
4191
  /**
3192
4192
  * Bind the tab's retained conversation around its slot.
3193
4193
  * @param props - slot shares for this tab occurrence.
@@ -3222,8 +4222,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3222
4222
  hero: false
3223
4223
  }, { slots: { views: FixedChatConversationView } });
3224
4224
  }
3225
- //#endregion
3226
- //#region src/client/side-chat.ts
4225
+ // src/client/side-chat.ts
3227
4226
  /** Stable implementation identity for this plugin's tab type and body. */
3228
4227
  const SIDE_CHAT_TAB_ID = "dsh-enhance";
3229
4228
  /** Resource scheme for one side conversation. */
@@ -3248,7 +4247,7 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3248
4247
  * @returns the session id, or undefined when the address is not ours.
3249
4248
  */
3250
4249
  function parseSideChatAddress(address) {
3251
- if (!address.startsWith(SIDE_CHAT_ADDRESS)) return void 0;
4250
+ if (!address.startsWith("dsh-resource://dshenhancechat/session/")) return void 0;
3252
4251
  const raw = address.slice(SIDE_CHAT_ADDRESS.length);
3253
4252
  if (raw.length === 0 || raw.includes("/") || raw.includes("?")) return void 0;
3254
4253
  try {
@@ -3338,15 +4337,15 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3338
4337
  locale: LOCALE_NS
3339
4338
  }, SideChatConversation)), "dsh-enhance: side chat conversation");
3340
4339
  }
3341
- //#endregion
3342
- //#region src/client/index.tsx
4340
+ // src/client/index.tsx
3343
4341
  /** The one side conversation this page opens; later requests add to it. */
3344
4342
  let openSideChat;
3345
- /** Required services: slots, dictionaries, session creation, and the right Sidebar. */
4343
+ /** Required services: slots, dictionaries, session status, the Workspace list, and the right Sidebar. */
3346
4344
  const inject = [
3347
4345
  "slots",
3348
4346
  "locale",
3349
4347
  "sessions",
4348
+ "uiSession",
3350
4349
  "workspaces",
3351
4350
  "conversation",
3352
4351
  "sidebarRight",
@@ -3364,7 +4363,16 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3364
4363
  en
3365
4364
  }), "dsh-enhance: dictionaries");
3366
4365
  installStyles(ctx);
3367
- ctx.effect(() => installSidebarFloor(document), "dsh-enhance: sidebar floor");
4366
+ const widthStore = pageStorage();
4367
+ ctx.effect(() => installSidebarFloor(document, {
4368
+ initialWidth: startupSidebarWidth(widthStore),
4369
+ onCommit: (width) => {
4370
+ rememberSidebarWidth(widthStore, width);
4371
+ }
4372
+ }), "dsh-enhance: sidebar floor");
4373
+ ctx.effect(() => installSidebarTopRow(document), "dsh-enhance: sidebar top row");
4374
+ if (isDesktopShell()) ctx.effect(() => installStartupGeometry(window), "dsh-enhance: window geometry");
4375
+ ctx.effect(() => installTurnBadge(ctx), "dsh-enhance: turn badge");
3368
4376
  registerSideChat(ctx, t);
3369
4377
  /**
3370
4378
  * Open a side conversation beside the current one and hand it the passage as
@@ -3423,7 +4431,6 @@ body[data-ds-dark-theme] .dsh-enhance-edit {
3423
4431
  const trimmed = (text.split("\n").find((candidate) => candidate.trim().length > 0) ?? text).replace(/^>\s?/, "").trim();
3424
4432
  return trimmed.length > 48 ? `${trimmed.slice(0, 47)}…` : trimmed;
3425
4433
  }
3426
- //#endregion
3427
4434
  exports.apply = apply;
3428
4435
  exports.inject = inject;
3429
4436
  return module.exports;