dsh-sidenote 0.4.5 → 0.4.6

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
@@ -3269,95 +3269,95 @@ ${entries.map((entry) => {
3269
3269
  document.head.appendChild(tag);
3270
3270
  }
3271
3271
  var sidechat_module_css_default = {
3272
+ "sentChip": "_5KEEsG_sentChip",
3273
+ "pendingQuestion": "_5KEEsG_pendingQuestion",
3274
+ "assistantBody": "_5KEEsG_assistantBody",
3275
+ "pendingTitle": "_5KEEsG_pendingTitle",
3276
+ "pendingQHeader": "_5KEEsG_pendingQHeader",
3277
+ "pendingBtnPrimary": "_5KEEsG_pendingBtnPrimary",
3278
+ "assistantRow": "_5KEEsG_assistantRow",
3279
+ "reflowButton": "_5KEEsG_reflowButton",
3280
+ "composerFoot": "_5KEEsG_composerFoot",
3281
+ "slashItemDetail": "_5KEEsG_slashItemDetail",
3282
+ "inheritedBody": "_5KEEsG_inheritedBody",
3283
+ "reasoningBody": "_5KEEsG_reasoningBody",
3284
+ "pendingQText": "_5KEEsG_pendingQText",
3285
+ "flowRowError": "_5KEEsG_flowRowError",
3286
+ "toolRunning": "_5KEEsG_toolRunning",
3287
+ "attachButton": "_5KEEsG_attachButton",
3288
+ "slashGroupTitle": "_5KEEsG_slashGroupTitle",
3272
3289
  "pendingOptionActive": "_5KEEsG_pendingOptionActive",
3273
- "sendButton": "_5KEEsG_sendButton",
3274
- "composerCard": "_5KEEsG_composerCard",
3275
- "modelLabel": "_5KEEsG_modelLabel",
3290
+ "toolBody": "_5KEEsG_toolBody",
3291
+ "pendingDesc": "_5KEEsG_pendingDesc",
3276
3292
  "transcript": "_5KEEsG_transcript",
3277
- "toolLocations": "_5KEEsG_toolLocations",
3278
- "densityToggle": "_5KEEsG_densityToggle",
3279
- "dotRunning": "_5KEEsG_dotRunning",
3280
- "dotPending": "_5KEEsG_dotPending",
3281
- "pendingCard": "_5KEEsG_pendingCard",
3282
3293
  "headerSide": "_5KEEsG_headerSide",
3283
- "pendingActions": "_5KEEsG_pendingActions",
3284
- "userRow": "_5KEEsG_userRow",
3285
- "input": "_5KEEsG_input",
3294
+ "reasoning": "_5KEEsG_reasoning",
3295
+ "composerChips": "_5KEEsG_composerChips",
3296
+ "pendingOption": "_5KEEsG_pendingOption",
3297
+ "rowActions": "_5KEEsG_rowActions",
3286
3298
  "snapshotText": "_5KEEsG_snapshotText",
3287
- "writeNotice": "_5KEEsG_writeNotice",
3288
- "empty": "_5KEEsG_empty",
3289
- "composer": "_5KEEsG_composer",
3290
- "slashItemActive": "_5KEEsG_slashItemActive",
3299
+ "pendingActions": "_5KEEsG_pendingActions",
3300
+ "parentStrip": "_5KEEsG_parentStrip",
3291
3301
  "root": "_5KEEsG_root",
3292
- "toolBody": "_5KEEsG_toolBody",
3293
- "sentChipRow": "_5KEEsG_sentChipRow",
3302
+ "actionGroup": "_5KEEsG_actionGroup",
3303
+ "emptyTitle": "_5KEEsG_emptyTitle",
3304
+ "flowRow": "_5KEEsG_flowRow",
3305
+ "jumpBottom": "_5KEEsG_jumpBottom",
3306
+ "emptyText": "_5KEEsG_emptyText",
3307
+ "slashItemName": "_5KEEsG_slashItemName",
3308
+ "attachImg": "_5KEEsG_attachImg",
3309
+ "attachRemove": "_5KEEsG_attachRemove",
3310
+ "pendingReason": "_5KEEsG_pendingReason",
3294
3311
  "modelSelect": "_5KEEsG_modelSelect",
3295
- "pendingTitle": "_5KEEsG_pendingTitle",
3296
- "toolGenericBody": "_5KEEsG_toolGenericBody",
3297
- "stopButton": "_5KEEsG_stopButton",
3298
- "toolBodyText": "_5KEEsG_toolBodyText",
3299
- "pendingBtnGhost": "_5KEEsG_pendingBtnGhost",
3300
- "pendingBtnPrimary": "_5KEEsG_pendingBtnPrimary",
3301
- "streamingHint": "_5KEEsG_streamingHint",
3302
- "writeNoticeClose": "_5KEEsG_writeNoticeClose",
3303
- "toolError": "_5KEEsG_toolError",
3304
3312
  "pendingBar": "_5KEEsG_pendingBar",
3305
- "densityRow": "_5KEEsG_densityRow",
3306
- "slashItemDetail": "_5KEEsG_slashItemDetail",
3307
- "pendingQuestion": "_5KEEsG_pendingQuestion",
3308
- "attachButton": "_5KEEsG_attachButton",
3309
- "assistantBody": "_5KEEsG_assistantBody",
3310
- "body": "_5KEEsG_body",
3311
- "slashGroupTitle": "_5KEEsG_slashGroupTitle",
3312
- "errorRow": "_5KEEsG_errorRow",
3313
- "slashItemName": "_5KEEsG_slashItemName",
3313
+ "todoBody": "_5KEEsG_todoBody",
3314
+ "input": "_5KEEsG_input",
3315
+ "toolHead": "_5KEEsG_toolHead",
3314
3316
  "userBubble": "_5KEEsG_userBubble",
3315
- "attachImg": "_5KEEsG_attachImg",
3317
+ "toolGenericBody": "_5KEEsG_toolGenericBody",
3318
+ "toolLocations": "_5KEEsG_toolLocations",
3316
3319
  "snapshotBody": "_5KEEsG_snapshotBody",
3317
- "pendingOption": "_5KEEsG_pendingOption",
3320
+ "slashItemActive": "_5KEEsG_slashItemActive",
3321
+ "pendingOptionDesc": "_5KEEsG_pendingOptionDesc",
3322
+ "stopButton": "_5KEEsG_stopButton",
3323
+ "pendingBtnGhost": "_5KEEsG_pendingBtnGhost",
3318
3324
  "toolCard": "_5KEEsG_toolCard",
3319
- "parentStrip": "_5KEEsG_parentStrip",
3320
- "pendingCustom": "_5KEEsG_pendingCustom",
3321
- "attachRail": "_5KEEsG_attachRail",
3322
- "stateScreen": "_5KEEsG_stateScreen",
3323
- "nativeHost": "_5KEEsG_nativeHost",
3324
- "emptyTitle": "_5KEEsG_emptyTitle",
3325
- "attachThumb": "_5KEEsG_attachThumb",
3326
- "sentChip": "_5KEEsG_sentChip",
3327
- "dotIdle": "_5KEEsG_dotIdle",
3328
- "rowActions": "_5KEEsG_rowActions",
3329
- "todoDot": "_5KEEsG_todoDot",
3330
- "composerFoot": "_5KEEsG_composerFoot",
3331
3325
  "rowPreview": "_5KEEsG_rowPreview",
3332
- "inheritedBody": "_5KEEsG_inheritedBody",
3333
- "todoBody": "_5KEEsG_todoBody",
3334
- "actionGroup": "_5KEEsG_actionGroup",
3326
+ "densityToggle": "_5KEEsG_densityToggle",
3327
+ "pendingHead": "_5KEEsG_pendingHead",
3328
+ "dotRunning": "_5KEEsG_dotRunning",
3335
3329
  "stateDetail": "_5KEEsG_stateDetail",
3336
- "pendingQText": "_5KEEsG_pendingQText",
3337
- "reasoning": "_5KEEsG_reasoning",
3338
- "flowRowError": "_5KEEsG_flowRowError",
3339
- "toolHead": "_5KEEsG_toolHead",
3340
- "slashItem": "_5KEEsG_slashItem",
3341
- "toolRunning": "_5KEEsG_toolRunning",
3342
- "reasoningBody": "_5KEEsG_reasoningBody",
3343
- "reflowButton": "_5KEEsG_reflowButton",
3344
- "todoItem": "_5KEEsG_todoItem",
3345
- "jumpBottom": "_5KEEsG_jumpBottom",
3346
- "attachRemove": "_5KEEsG_attachRemove",
3347
- "pendingQHeader": "_5KEEsG_pendingQHeader",
3348
- "pendingOptionDesc": "_5KEEsG_pendingOptionDesc",
3349
- "todoText": "_5KEEsG_todoText",
3350
- "emptyText": "_5KEEsG_emptyText",
3330
+ "dotPending": "_5KEEsG_dotPending",
3331
+ "toolBodyText": "_5KEEsG_toolBodyText",
3332
+ "dotIdle": "_5KEEsG_dotIdle",
3333
+ "userRow": "_5KEEsG_userRow",
3351
3334
  "sidechat-pulse": "_5KEEsG_sidechat-pulse",
3352
- "pendingDesc": "_5KEEsG_pendingDesc",
3335
+ "modelLabel": "_5KEEsG_modelLabel",
3336
+ "todoDot": "_5KEEsG_todoDot",
3337
+ "empty": "_5KEEsG_empty",
3338
+ "pendingCard": "_5KEEsG_pendingCard",
3339
+ "writeNotice": "_5KEEsG_writeNotice",
3340
+ "todoItem": "_5KEEsG_todoItem",
3341
+ "pendingCustom": "_5KEEsG_pendingCustom",
3342
+ "body": "_5KEEsG_body",
3343
+ "writeNoticeClose": "_5KEEsG_writeNoticeClose",
3344
+ "attachRail": "_5KEEsG_attachRail",
3345
+ "slashMenu": "_5KEEsG_slashMenu",
3346
+ "slashItem": "_5KEEsG_slashItem",
3347
+ "sendButton": "_5KEEsG_sendButton",
3353
3348
  "noticeRow": "_5KEEsG_noticeRow",
3354
- "pendingReason": "_5KEEsG_pendingReason",
3355
- "pendingHead": "_5KEEsG_pendingHead",
3356
- "composerChips": "_5KEEsG_composerChips",
3349
+ "toolError": "_5KEEsG_toolError",
3350
+ "composer": "_5KEEsG_composer",
3351
+ "streamingHint": "_5KEEsG_streamingHint",
3352
+ "todoText": "_5KEEsG_todoText",
3353
+ "densityRow": "_5KEEsG_densityRow",
3354
+ "nativeHost": "_5KEEsG_nativeHost",
3355
+ "sentChipRow": "_5KEEsG_sentChipRow",
3357
3356
  "emptyIcon": "_5KEEsG_emptyIcon",
3358
- "flowRow": "_5KEEsG_flowRow",
3359
- "assistantRow": "_5KEEsG_assistantRow",
3360
- "slashMenu": "_5KEEsG_slashMenu"
3357
+ "errorRow": "_5KEEsG_errorRow",
3358
+ "attachThumb": "_5KEEsG_attachThumb",
3359
+ "stateScreen": "_5KEEsG_stateScreen",
3360
+ "composerCard": "_5KEEsG_composerCard"
3361
3361
  };
3362
3362
  //#endregion
3363
3363
  //#region src/client/chat/ToolCard.tsx
@@ -6237,43 +6237,43 @@ ${entries.map((entry) => {
6237
6237
  document.head.appendChild(tag);
6238
6238
  }
6239
6239
  var annotate_module_css_default = {
6240
- "chipClearAll": "_SVViG_chipClearAll",
6241
- "badge": "_SVViG_badge",
6240
+ "confirmButton": "_SVViG_confirmButton",
6241
+ "editorTarget": "_SVViG_editorTarget",
6242
+ "highlight": "_SVViG_highlight",
6243
+ "toolbarBelow": "_SVViG_toolbarBelow",
6242
6244
  "editorFooter": "_SVViG_editorFooter",
6243
- "hintClose": "_SVViG_hintClose",
6244
- "sentCardQuote": "_SVViG_sentCardQuote",
6245
- "chipRow": "_SVViG_chipRow",
6246
- "chipRemove": "_SVViG_chipRemove",
6247
- "chipNumber": "_SVViG_chipNumber",
6248
- "editorError": "_SVViG_editorError",
6249
- "editorAskRow": "_SVViG_editorAskRow",
6250
6245
  "badgeSent": "_SVViG_badgeSent",
6251
- "hint": "_SVViG_hint",
6252
- "toolbarBelow": "_SVViG_toolbarBelow",
6246
+ "badge": "_SVViG_badge",
6253
6247
  "chipNote": "_SVViG_chipNote",
6254
- "saveButton": "_SVViG_saveButton",
6255
- "chip": "_SVViG_chip",
6256
- "chipWrap": "_SVViG_chipWrap",
6248
+ "editorAskRow": "_SVViG_editorAskRow",
6249
+ "editorError": "_SVViG_editorError",
6250
+ "toolbar": "_SVViG_toolbar",
6251
+ "editorNew": "_SVViG_editorNew",
6252
+ "editorEdit": "_SVViG_editorEdit",
6253
+ "sentCardTitle": "_SVViG_sentCardTitle",
6254
+ "sentChip": "_SVViG_sentChip",
6255
+ "chipClearAll": "_SVViG_chipClearAll",
6256
+ "chipText": "_SVViG_chipText",
6257
+ "editorInput": "_SVViG_editorInput",
6258
+ "dshSidenoteHintIn": "_SVViG_dshSidenoteHintIn",
6257
6259
  "sentChipRow": "_SVViG_sentChipRow",
6260
+ "editorSpacer": "_SVViG_editorSpacer",
6258
6261
  "deleteButton": "_SVViG_deleteButton",
6259
6262
  "cancelButton": "_SVViG_cancelButton",
6263
+ "chipWrap": "_SVViG_chipWrap",
6260
6264
  "toolbarButton": "_SVViG_toolbarButton",
6261
- "sentChip": "_SVViG_sentChip",
6262
- "editorTarget": "_SVViG_editorTarget",
6263
- "confirmButton": "_SVViG_confirmButton",
6265
+ "editorTextarea": "_SVViG_editorTextarea",
6266
+ "saveButton": "_SVViG_saveButton",
6264
6267
  "editorAsk": "_SVViG_editorAsk",
6265
- "sentCardTitle": "_SVViG_sentCardTitle",
6266
- "editorNew": "_SVViG_editorNew",
6268
+ "chip": "_SVViG_chip",
6267
6269
  "chipPanel": "_SVViG_chipPanel",
6268
- "editorEdit": "_SVViG_editorEdit",
6269
- "editorTextarea": "_SVViG_editorTextarea",
6270
- "highlight": "_SVViG_highlight",
6271
- "editorSpacer": "_SVViG_editorSpacer",
6272
- "editorInput": "_SVViG_editorInput",
6273
- "chipText": "_SVViG_chipText",
6274
- "toolbar": "_SVViG_toolbar",
6275
- "dshSidenoteHintIn": "_SVViG_dshSidenoteHintIn",
6276
- "sentCardNote": "_SVViG_sentCardNote"
6270
+ "chipRemove": "_SVViG_chipRemove",
6271
+ "sentCardNote": "_SVViG_sentCardNote",
6272
+ "hint": "_SVViG_hint",
6273
+ "chipRow": "_SVViG_chipRow",
6274
+ "chipNumber": "_SVViG_chipNumber",
6275
+ "sentCardQuote": "_SVViG_sentCardQuote",
6276
+ "hintClose": "_SVViG_hintClose"
6277
6277
  };
6278
6278
  //#endregion
6279
6279
  //#region src/client/annotate/hint.tsx
@@ -6530,7 +6530,7 @@ ${entries.map((entry) => {
6530
6530
  }
6531
6531
  closeEditor();
6532
6532
  }
6533
- }),
6533
+ }, `${editor.annotationId}:${editor.mode}`),
6534
6534
  sideDraft !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SideChatNoteEditor, {
6535
6535
  x: sideDraft.x,
6536
6536
  y: sideDraft.y,
@@ -6795,12 +6795,17 @@ ${entries.map((entry) => {
6795
6795
  }
6796
6796
  /**
6797
6797
  * The annotation editor popover. 新建态: input + ✓ 确认 (允许空注解直接保存;
6798
- * 点击外部/Esc 取消且无显式取消按钮). 重开态: 已有注解 + 🗑 删除 + 取消/保存.
6798
+ * 点击外部 = 确认、Esc = 取消,无显式取消按钮). 重开态: 已有注解 + 🗑 删除 +
6799
+ * 取消/保存.
6800
+ *
6801
+ * 导出供单测直接挂载(tests/annotate-editor.spec.tsx)。
6799
6802
  */
6800
6803
  function AnnotationEditor(props) {
6801
6804
  useLocaleTick();
6802
6805
  const [note, setNote] = (0, react.useState)(props.annotation.note);
6803
6806
  const rootRef = (0, react.useRef)(null);
6807
+ const noteRef = (0, react.useRef)(note);
6808
+ noteRef.current = note;
6804
6809
  (0, react.useEffect)(() => {
6805
6810
  const onKeyDown = (event) => {
6806
6811
  if (event.key === "Escape") {
@@ -6813,7 +6818,8 @@ ${entries.map((entry) => {
6813
6818
  if (root === null || !(event.target instanceof Node)) return;
6814
6819
  if (root.contains(event.target)) return;
6815
6820
  if (event.target instanceof Element && event.target.closest("[data-dsh-sidenote]") !== null) return;
6816
- props.onCancel();
6821
+ if (props.mode === "new") props.onSave(noteRef.current);
6822
+ else props.onCancel();
6817
6823
  };
6818
6824
  document.addEventListener("keydown", onKeyDown, true);
6819
6825
  document.addEventListener("mousedown", onMouseDown, true);
@@ -1,7 +1,7 @@
1
1
  import { Component } from 'react';
2
2
  import type { ReactNode } from 'react';
3
3
  import type { Context } from '../host/contracts.ts';
4
- import type { AnnotationStore } from './model.ts';
4
+ import type { Annotation, AnnotationStore } from './model.ts';
5
5
  import type { SelectionController } from './selection.ts';
6
6
  interface OverlayProps {
7
7
  readonly ctx: Context;
@@ -24,4 +24,20 @@ export declare class AnnotateErrorBoundary extends Component<{
24
24
  render(): ReactNode;
25
25
  }
26
26
  export declare function AnnotateOverlay(props: OverlayProps): ReactNode;
27
+ /**
28
+ * The annotation editor popover. 新建态: input + ✓ 确认 (允许空注解直接保存;
29
+ * 点击外部 = 确认、Esc = 取消,无显式取消按钮). 重开态: 已有注解 + 🗑 删除 +
30
+ * 取消/保存.
31
+ *
32
+ * 导出供单测直接挂载(tests/annotate-editor.spec.tsx)。
33
+ */
34
+ export declare function AnnotationEditor(props: {
35
+ annotation: Annotation;
36
+ mode: 'new' | 'edit';
37
+ x: number;
38
+ y: number;
39
+ onSave: (note: string) => void;
40
+ onDelete: () => void;
41
+ onCancel: () => void;
42
+ }): ReactNode;
27
43
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-sidenote",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "DSH web plugin: Codex-style side chat (fork the current session into a persistent side panel) + selection annotations with numbered badges and a composer chip. Runs directly on the DSH native right sidebar (DSH ≥ 0.1.5); dsh-better-sidebar is an optional peer for older hosts. / Codex 风格侧边聊天 + 划选注释的 DSH 插件。",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -222,6 +222,7 @@ function AnnotateOverlayInner({ ctx, store, controller }: OverlayProps): ReactNo
222
222
  />
223
223
  {editingAnnotation !== undefined && editor !== null && (
224
224
  <AnnotationEditor
225
+ key={`${editor.annotationId}:${editor.mode}`}
225
226
  annotation={editingAnnotation}
226
227
  mode={editor.mode}
227
228
  x={editor.x}
@@ -542,9 +543,12 @@ function BadgeLayer(props: {
542
543
 
543
544
  /**
544
545
  * The annotation editor popover. 新建态: input + ✓ 确认 (允许空注解直接保存;
545
- * 点击外部/Esc 取消且无显式取消按钮). 重开态: 已有注解 + 🗑 删除 + 取消/保存.
546
+ * 点击外部 = 确认、Esc = 取消,无显式取消按钮). 重开态: 已有注解 + 🗑 删除 +
547
+ * 取消/保存.
548
+ *
549
+ * 导出供单测直接挂载(tests/annotate-editor.spec.tsx)。
546
550
  */
547
- function AnnotationEditor(props: {
551
+ export function AnnotationEditor(props: {
548
552
  annotation: Annotation
549
553
  mode: 'new' | 'edit'
550
554
  x: number
@@ -556,6 +560,10 @@ function AnnotationEditor(props: {
556
560
  useLocaleTick()
557
561
  const [note, setNote] = useState(props.annotation.note)
558
562
  const rootRef = useRef<HTMLDivElement | null>(null)
563
+ // 外点确认读「当前」注解:下面的 effect 是空依赖闭包,直接捕获 note 会永远停在
564
+ // 首次渲染的值——用户敲完注解再点别处,那段注解会静默丢掉。
565
+ const noteRef = useRef(note)
566
+ noteRef.current = note
559
567
 
560
568
  useEffect(() => {
561
569
  const onKeyDown = (event: KeyboardEvent): void => {
@@ -571,7 +579,11 @@ function AnnotationEditor(props: {
571
579
  // 本插件自身的 DOM(角标/工具条)不算「外部」:点击角标由它自己的
572
580
  // click 处理器接管编辑器,不能先被外部点击取消掉。
573
581
  if (event.target instanceof Element && event.target.closest('[data-dsh-sidenote]') !== null) return
574
- props.onCancel()
582
+ // 新建态点外部 = 确认这一条:点输入框准备写问题是最常见的下一步动作,以前这里
583
+ // 走 onCancel → 刚创建的注释被整条删除,用户划选的引用凭空消失(Esc 才是显式放弃)。
584
+ // 重开态点外部仍是取消——只关编辑器,已有注解不受影响。
585
+ if (props.mode === 'new') props.onSave(noteRef.current)
586
+ else props.onCancel()
575
587
  }
576
588
  document.addEventListener('keydown', onKeyDown, true)
577
589
  document.addEventListener('mousedown', onMouseDown, true)