dsh-ide-window 0.4.1 → 0.4.3

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/client.js CHANGED
@@ -341,6 +341,7 @@ window.__ModuleLoader__.load({
341
341
  "floatCollapse": "Collapse",
342
342
  "floatExpand": "Expand assistant",
343
343
  "floatEmpty": "Ask something; the answer lands in this session",
344
+ "floatLoadingOlder": "Loading earlier messages…",
344
345
  "floatNoSession": "No session bound yet",
345
346
  "floatNoWorkspace": "no workspace",
346
347
  "floatPlaceholder": "Message or create a task, / for commands, @ for files or chats",
@@ -373,6 +374,17 @@ window.__ModuleLoader__.load({
373
374
  "floatNoticeAttempt": "Attempt failed",
374
375
  "floatNoticeRetry": "Model retry",
375
376
  "floatNoticeApproval": "Approval requested",
377
+ "floatApprovalPending": "Waiting for approval",
378
+ "floatApprovalSettled": "Approval result",
379
+ "floatApprovalTitle": "A tool asks for more access",
380
+ "floatApprovalTool": "Tool",
381
+ "floatApprovalHint": "Approvals are answered in the conversation",
382
+ "floatApprovalGo": "Go to the conversation",
383
+ "floatApprovalBallHint": "An approval is waiting — click to open",
384
+ "floatApprovalAllowed": "Allowed once",
385
+ "floatApprovalRejected": "Rejected",
386
+ "floatApprovalCancelled": "Cancelled",
387
+ "floatApprovalUnavailable": "No answerer available",
376
388
  "floatNoticeApprovalResult": "Approval result",
377
389
  "floatNoticeApprovalPolicy": "Approval policy",
378
390
  "floatNoticeWorkspace": "Workspace changed",
@@ -394,6 +406,12 @@ window.__ModuleLoader__.load({
394
406
  "floatAttachReference": "Reference the open file",
395
407
  "floatNeedsFile": "Open a file first",
396
408
  "floatPermission": "Permission",
409
+ "floatMode": "Mode",
410
+ "floatImageMissing": "Image unavailable",
411
+ "floatModeStandard": "Standard mode",
412
+ "floatModePtc": "PTC mode",
413
+ "floatModeMinimal": "Minimal mode",
414
+ "floatModeCordis": "Cordis mode",
397
415
  "floatPermissionReadOnly": "Read only",
398
416
  "floatPermissionWorkspace": "Workspace write",
399
417
  "floatPermissionFull": "Full access",
@@ -409,6 +427,7 @@ window.__ModuleLoader__.load({
409
427
  "floatSessionFailed": "Switching the session failed",
410
428
  "floatCurrentWorkspace": "current",
411
429
  "settingsFloat": "Floating assistant",
430
+ "settingsFloatEnable": "Enable",
412
431
  "settingsFloatHint": "When off, the floating card no longer opens in the code workspace",
413
432
  "settingsOn": "On",
414
433
  "settingsOff": "Off",
@@ -438,6 +457,10 @@ window.__ModuleLoader__.load({
438
457
  "floatCloseViewer": "Close",
439
458
  "settingsFloatDetach": "Detach from the workspace",
440
459
  "settingsFloatDetachHint": "Keep the card on screen when you switch to another panel or back to the conversation",
460
+ "settingsFloatGroup": "Floating card",
461
+ "settingsFloatFollow": "Follow the current conversation",
462
+ "settingsFloatFollowHint": "When off, switching conversations in DSH leaves the card alone; switch inside the card's title menu instead",
463
+ "floatPinnedHint": "Not following DSH · pick a conversation below",
441
464
  "settingsFloatEvents": "Show full detail",
442
465
  "settingsFloatEventsHint": "List reasoning, context, Tool arguments and system events; off shows only the latest status line",
443
466
  "floatWrap": "Wrap lines",
@@ -776,6 +799,7 @@ window.__ModuleLoader__.load({
776
799
  "floatCollapse": "收起",
777
800
  "floatExpand": "展开助手",
778
801
  "floatEmpty": "问点什么,回答会出现在当前会话里",
802
+ "floatLoadingOlder": "正在加载更早的消息…",
779
803
  "floatNoSession": "还没有绑定会话",
780
804
  "floatNoWorkspace": "未选择工作区",
781
805
  "floatPlaceholder": "发消息或创建任务,/ 调用指令,@ 文件或对话",
@@ -808,6 +832,17 @@ window.__ModuleLoader__.load({
808
832
  "floatNoticeAttempt": "模型尝试失败",
809
833
  "floatNoticeRetry": "模型重试",
810
834
  "floatNoticeApproval": "审批请求",
835
+ "floatApprovalPending": "等待审批",
836
+ "floatApprovalSettled": "审批结果",
837
+ "floatApprovalTitle": "工具请求更高权限",
838
+ "floatApprovalTool": "工具",
839
+ "floatApprovalHint": "审批只能在对话里作答",
840
+ "floatApprovalGo": "去对话处理",
841
+ "floatApprovalBallHint": "有审批在等,点开处理",
842
+ "floatApprovalAllowed": "已允许这一次",
843
+ "floatApprovalRejected": "已拒绝",
844
+ "floatApprovalCancelled": "已取消",
845
+ "floatApprovalUnavailable": "没有可用的审批人",
811
846
  "floatNoticeApprovalResult": "审批结果",
812
847
  "floatNoticeApprovalPolicy": "审批策略",
813
848
  "floatNoticeWorkspace": "文件变更",
@@ -829,6 +864,12 @@ window.__ModuleLoader__.load({
829
864
  "floatAttachReference": "引用当前文件",
830
865
  "floatNeedsFile": "先打开一个文件",
831
866
  "floatPermission": "权限",
867
+ "floatMode": "模式",
868
+ "floatImageMissing": "图片无法加载",
869
+ "floatModeStandard": "标准模式",
870
+ "floatModePtc": "PTC 模式",
871
+ "floatModeMinimal": "精简模式",
872
+ "floatModeCordis": "Cordis 模式",
832
873
  "floatPermissionReadOnly": "仅可查看",
833
874
  "floatPermissionWorkspace": "工作区内修改",
834
875
  "floatPermissionFull": "完全权限",
@@ -844,6 +885,7 @@ window.__ModuleLoader__.load({
844
885
  "floatSessionFailed": "切换会话失败",
845
886
  "floatCurrentWorkspace": "当前",
846
887
  "settingsFloat": "悬浮助手卡",
888
+ "settingsFloatEnable": "启用",
847
889
  "settingsFloatHint": "关掉后进入代码工作区不再自动弹出悬浮卡",
848
890
  "settingsOn": "已启用",
849
891
  "settingsOff": "已关闭",
@@ -873,6 +915,10 @@ window.__ModuleLoader__.load({
873
915
  "floatCloseViewer": "关闭",
874
916
  "settingsFloatDetach": "脱离代码工作区",
875
917
  "settingsFloatDetachHint": "开启后悬浮框不再跟着代码工作区出现与消失:切到其他插件视图或回到对话时它依然在",
918
+ "settingsFloatGroup": "悬浮助手卡",
919
+ "settingsFloatFollow": "跟随当前会话",
920
+ "settingsFloatFollowHint": "关闭后,在 DSH 里切换会话不会带动悬浮卡;只能在悬浮卡标题菜单里手动切换",
921
+ "floatPinnedHint": "不跟随当前会话 · 在下面手动切换",
876
922
  "settingsFloatEvents": "显示详细过程",
877
923
  "settingsFloatEventsHint": "把思考、上下文注入、工具参数与系统事件全部列出来;关闭时只显示最新一条状态",
878
924
  "floatWrap": "自动换行",
@@ -2055,7 +2101,26 @@ html.iw-select-code .iw-code .iw-vision {
2055
2101
  /* Every child measures like the card, or a 100%-wide textarea with its own
2056
2102
  padding pokes through the right border (rounded on one side, square on the other). */
2057
2103
  .iw-float, .iw-float *, .iw-float *::before, .iw-float *::after { box-sizing: border-box; }
2058
- .iw-float-head { display: flex; align-items: center; gap: 6px; cursor: grab; user-select: none; touch-action: none; }
2104
+ .iw-float-head {
2105
+ position: relative;
2106
+ display: flex;
2107
+ align-items: center;
2108
+ justify-content: center;
2109
+ gap: 6px;
2110
+ min-height: 24px;
2111
+ cursor: grab;
2112
+ user-select: none;
2113
+ touch-action: none;
2114
+ }
2115
+ /* 左右两簇贴边,标题才能在整个表头里居中(而不是在剩余空隙里居中)。 */
2116
+ .iw-float-head > .iw-float-dot { position: absolute; left: 0; }
2117
+ .iw-float-head-right {
2118
+ position: absolute;
2119
+ right: 0;
2120
+ display: flex;
2121
+ align-items: center;
2122
+ gap: 2px;
2123
+ }
2059
2124
  .iw-float-head:active { cursor: grabbing; }
2060
2125
  .iw-float-collapsed {
2061
2126
  padding: 4px;
@@ -2595,9 +2660,11 @@ html.iw-select-code .iw-code .iw-vision {
2595
2660
  .iw-float-title-btn {
2596
2661
  display: inline-flex;
2597
2662
  align-items: center;
2663
+ justify-content: center;
2598
2664
  gap: 3px;
2599
2665
  min-width: 0;
2600
- max-width: 46%;
2666
+ /* 20 个字左右:标题是最能区分会话的东西,别只剩半截;但要给右侧按钮组让位。 */
2667
+ max-width: min(calc(100% - 96px), 21em);
2601
2668
  flex: 0 1 auto;
2602
2669
  padding: 1px 4px;
2603
2670
  border: 0;
@@ -2610,11 +2677,43 @@ html.iw-select-code .iw-code .iw-vision {
2610
2677
  overflow: hidden;
2611
2678
  }
2612
2679
  /* The label truncates; the caret must never be the thing that gets clipped. */
2613
- .iw-float-title-text {
2680
+ /* 两个类的选择器:基础 .iw-float-title 也落在这个 span 上,靠顺序会被它压回去。 */
2681
+ .iw-float-title-btn .iw-float-title-text {
2614
2682
  min-width: 0;
2683
+ max-width: 100%;
2684
+ font-size: 16px;
2685
+ line-height: 24px;
2686
+ letter-spacing: 0.1px;
2615
2687
  overflow: hidden;
2616
2688
  text-overflow: ellipsis;
2617
2689
  white-space: nowrap;
2690
+ /* 按工作区取色(--iw-float-hue),再和正文主色混,浅色/深色都压得住对比度。 */
2691
+ color: color-mix(
2692
+ in oklab,
2693
+ hsl(var(--iw-float-hue, 214) 68% 52%) 72%,
2694
+ var(--dsw-alias-label-primary, currentColor)
2695
+ );
2696
+ }
2697
+ .iw-float-mode {
2698
+ flex: 0 0 auto;
2699
+ max-width: 132px;
2700
+ overflow: hidden;
2701
+ text-overflow: ellipsis;
2702
+ white-space: nowrap;
2703
+ padding: 1px 7px;
2704
+ border-radius: var(--dsw-radius-sm, 6px);
2705
+ background: var(--dsw-alias-bg-layer-3, rgba(128, 128, 128, 0.12));
2706
+ color: var(--dsw-alias-label-secondary, inherit);
2707
+ font-size: 12.5px;
2708
+ line-height: 18px;
2709
+ }
2710
+ .iw-float-older {
2711
+ flex: 0 0 auto;
2712
+ padding: 2px 0 6px;
2713
+ text-align: center;
2714
+ font-size: 12.5px;
2715
+ line-height: 18px;
2716
+ color: var(--dsw-alias-label-tertiary, #81858c);
2618
2717
  }
2619
2718
  .iw-float-title-btn:hover { background: var(--dsw-alias-card-fill-hover, rgba(255, 255, 255, 0.08)); }
2620
2719
  /* A model row must be clickable across its whole width, not just on the text. */
@@ -2670,7 +2769,6 @@ html.iw-select-code .iw-code .iw-vision {
2670
2769
  overflow: hidden;
2671
2770
  text-overflow: ellipsis;
2672
2771
  white-space: nowrap;
2673
- max-width: 150px;
2674
2772
  }
2675
2773
  .iw-float-model { font-size: 11px; color: var(--dsw-alias-label-tertiary, inherit); }
2676
2774
  .iw-float-icon {
@@ -2776,6 +2874,27 @@ html.iw-select-code .iw-code .iw-vision {
2776
2874
  .iw-float-ask-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
2777
2875
  .iw-float-ask-hint { font-size: 12.5px; line-height: 18px; color: var(--dsw-alias-label-tertiary, #81858c); }
2778
2876
  .iw-float-ask-go { flex: 0 0 auto; }
2877
+ /* 审批卡:和问答卡同一张纸,只是多一段「为什么要批」的说明。 */
2878
+ .iw-float-approval-done { opacity: 0.9; }
2879
+ /* 收起成球时,等着的审批用一个小告警点表示。 */
2880
+ .iw-float-ball-btn { position: relative; }
2881
+ .iw-float-ball-dot {
2882
+ position: absolute;
2883
+ top: 7px;
2884
+ right: 7px;
2885
+ width: 9px;
2886
+ height: 9px;
2887
+ border-radius: 50%;
2888
+ background: var(--dsw-alias-state-warn-primary, #d97706);
2889
+ box-shadow: 0 0 0 2px var(--dsw-alias-bg-layer-1, #ffffff);
2890
+ }
2891
+ .iw-float-approval-reason {
2892
+ font-size: 13px;
2893
+ line-height: 20px;
2894
+ color: var(--dsw-alias-label-secondary, #61666b);
2895
+ white-space: pre-wrap;
2896
+ overflow-wrap: anywhere;
2897
+ }
2779
2898
  /* The问答 card, borrowed from the conversation: the bubble is the user's own,
2780
2899
  header and question in the secondary colour, the picked answer in primary. */
2781
2900
  .iw-float-question { display: flex; flex-direction: column; }
@@ -2908,6 +3027,38 @@ html.iw-select-code .iw-code .iw-vision {
2908
3027
  border-radius: 6px;
2909
3028
  border: 0.5px solid var(--dsw-alias-border-l1, rgba(255, 255, 255, 0.1));
2910
3029
  }
3030
+ /* 图片文件不在了:一行说明,别只留一枚裂图标。 */
3031
+ .iw-float-img-missing {
3032
+ display: inline-flex;
3033
+ align-items: center;
3034
+ max-width: 100%;
3035
+ padding: 4px 10px;
3036
+ margin: 6px 0;
3037
+ border-radius: var(--dsw-radius-sm, 6px);
3038
+ background: var(--dsw-alias-bg-layer-3, rgba(128, 128, 128, 0.12));
3039
+ color: var(--dsw-alias-label-tertiary, inherit);
3040
+ font-size: 12.5px;
3041
+ line-height: 18px;
3042
+ overflow: hidden;
3043
+ text-overflow: ellipsis;
3044
+ white-space: nowrap;
3045
+ }
3046
+ .iw-float-pic-missing {
3047
+ display: flex;
3048
+ align-items: center;
3049
+ justify-content: center;
3050
+ max-width: 220px;
3051
+ min-height: 40px;
3052
+ padding: 6px 12px;
3053
+ border-radius: 8px;
3054
+ background: var(--dsw-alias-bg-layer-3, rgba(128, 128, 128, 0.12));
3055
+ color: var(--dsw-alias-label-tertiary, inherit);
3056
+ font-size: 12.5px;
3057
+ line-height: 18px;
3058
+ overflow: hidden;
3059
+ text-overflow: ellipsis;
3060
+ white-space: nowrap;
3061
+ }
2911
3062
  .iw-float-filelist { display: flex; flex-direction: column; gap: 4px; }
2912
3063
  .iw-float-file {
2913
3064
  display: flex;
@@ -5034,6 +5185,10 @@ function ideCreateStore(refs) {
5034
5185
  floatEvents: prefs.floatEvents === true,
5035
5186
  // Detached cards stay on screen in every panel, not only the workspace.
5036
5187
  floatDetached: prefs.floatDetached === true,
5188
+ // 跟随当前会话(默认):关掉后,DSH 里切会话不再带动卡片,只能在卡片里手动切。
5189
+ floatFollow: prefs.floatFollow !== false,
5190
+ // 不跟随时卡片自己钉住的会话(只本次进程有效,重启回到当前会话)。
5191
+ floatSessionId: null,
5037
5192
  floatClosed: false,
5038
5193
  // One reference waiting to be appended to the card's draft.
5039
5194
  floatInsert: null,
@@ -5538,6 +5693,25 @@ function ideCreateStore(refs) {
5538
5693
  if (next) patch({ floatOpen: true, floatClosed: false })
5539
5694
  }
5540
5695
 
5696
+ /**
5697
+ * 悬浮卡要不要跟着当前会话走(持久化,默认跟)。
5698
+ * 关掉的瞬间把当前会话钉住,否则「当前会话」一变它又跟着跑了。
5699
+ */
5700
+ function setFloatFollow(floatFollow) {
5701
+ const next = floatFollow !== false
5702
+ if (state.floatFollow === next) return
5703
+ ideWritePrefs({ floatFollow: next })
5704
+ // 关掉时把当前会话钉住;重新打开跟随就把钉子清掉,避免下次关掉时用旧值。
5705
+ patch(next ? { floatFollow: true, floatSessionId: null } : { floatFollow: false, floatSessionId: state.sessionId })
5706
+ }
5707
+
5708
+ /** 不跟随时,卡片自己选中的会话(`null` = 还没有手动选过)。 */
5709
+ function setFloatSessionId(floatSessionId) {
5710
+ const next = typeof floatSessionId === 'string' && floatSessionId !== '' ? floatSessionId : null
5711
+ if (state.floatSessionId === next) return
5712
+ patch({ floatSessionId: next })
5713
+ }
5714
+
5541
5715
  /** Turn the floating card on or off (persisted). */
5542
5716
  function setFloatEvents(floatEvents) {
5543
5717
  const next = floatEvents === true
@@ -6242,6 +6416,8 @@ function ideCreateStore(refs) {
6242
6416
  setFloatSize,
6243
6417
  setFloatDefaultSize,
6244
6418
  setFloatEnabled,
6419
+ setFloatFollow,
6420
+ setFloatSessionId,
6245
6421
  setFloatEvents,
6246
6422
  setFloatDetached,
6247
6423
  setFloatClosed,
@@ -9825,9 +10001,45 @@ function IdeWorkspaceSettingsSection(props) {
9825
10001
  ])
9826
10002
  : null,
9827
10003
  h('div', { key: 'basic', className: 'iw-settings-group' }, tr('settingsBasic')),
10004
+ h('div', { key: 'font', className: 'iw-settings-item' }, [
10005
+ h('span', { key: 'l', className: 'iw-settings-item-label' }, tr('settingsFont')),
10006
+ h('button', {
10007
+ key: 'b',
10008
+ type: 'button',
10009
+ className: 'iw-gesture-chip',
10010
+ onClick: () => setFontsOpen(!fontsOpen),
10011
+ }, fontsOpen ? tr('settingsCollapse') : `${codeSize} / ${treeSize} px`),
10012
+ ]),
10013
+ fontsOpen
10014
+ ? h('div', { key: 'fontbody', className: 'iw-settings-body' }, [
10015
+ stepper('code', tr('settingsCodeFont'), codeSize, (next) => store.setCodeFontSize(next)),
10016
+ stepper('tree', tr('settingsTreeFont'), treeSize, (next) => store.setTreeFontSize(next)),
10017
+ ])
10018
+ : null,
10019
+ h('div', { key: 'maven', className: 'iw-settings-maven' }, [
10020
+ h('div', { key: 'row', className: 'iw-settings-maven-row' }, [
10021
+ h('span', { key: 'l', className: 'iw-settings-item-label' }, tr('settingsMavenRepo')),
10022
+ h('input', {
10023
+ key: 'i',
10024
+ className: 'iw-settings-input',
10025
+ type: 'text',
10026
+ spellCheck: false,
10027
+ defaultValue: state.mavenRepo,
10028
+ placeholder: tr('settingsMavenRepoAuto'),
10029
+ title: tr('settingsMavenRepoHint'),
10030
+ onKeyDown: (event) => {
10031
+ if (event.key === 'Enter') event.currentTarget.blur()
10032
+ },
10033
+ onBlur: (event) => store.setMavenRepo(event.target.value),
10034
+ }),
10035
+ ]),
10036
+ mavenRowHint(tr, state),
10037
+ ]),
10038
+ // 悬浮卡自己的那一组:启用、跟随、脱离、详细过程、默认大小,跟其它设置分开。
10039
+ h('div', { key: 'floatgroup', className: 'iw-settings-group' }, tr('settingsFloatGroup')),
9828
10040
  // The floating card is on by default; this is where it is turned off.
9829
10041
  h('div', { key: 'float', className: 'iw-settings-item' }, [
9830
- h('span', { key: 'l', className: 'iw-settings-item-label' }, tr('settingsFloat')),
10042
+ h('span', { key: 'l', className: 'iw-settings-item-label' }, tr('settingsFloatEnable')),
9831
10043
  h('button', {
9832
10044
  key: 'b',
9833
10045
  type: 'button',
@@ -9836,6 +10048,17 @@ function IdeWorkspaceSettingsSection(props) {
9836
10048
  onClick: () => store.setFloatEnabled(state.floatEnabled === false),
9837
10049
  }, state.floatEnabled !== false ? tr('settingsOn') : tr('settingsOff')),
9838
10050
  ]),
10051
+ // 默认跟随当前会话;关掉后 DSH 里切会话不带动卡片,只能在卡片里切。
10052
+ h('div', { key: 'floatfollow', className: 'iw-settings-item' }, [
10053
+ h('span', { key: 'l', className: 'iw-settings-item-label' }, tr('settingsFloatFollow')),
10054
+ h('button', {
10055
+ key: 'b',
10056
+ type: 'button',
10057
+ className: `iw-gesture-chip${state.floatFollow !== false ? ' on' : ''}`,
10058
+ title: tr('settingsFloatFollowHint'),
10059
+ onClick: () => store.setFloatFollow(state.floatFollow === false),
10060
+ }, state.floatFollow !== false ? tr('settingsOn') : tr('settingsOff')),
10061
+ ]),
9839
10062
  // A card that lives on its own stays visible in other panels too.
9840
10063
  h('div', { key: 'floatdetach', className: 'iw-settings-item' }, [
9841
10064
  h('span', { key: 'l', className: 'iw-settings-item-label' }, tr('settingsFloatDetach')),
@@ -9881,42 +10104,8 @@ function IdeWorkspaceSettingsSection(props) {
9881
10104
  (next) => store.setFloatDefaultSize(floatWidth, next)),
9882
10105
  ])
9883
10106
  : null,
9884
- h('div', { key: 'font', className: 'iw-settings-item' }, [
9885
- h('span', { key: 'l', className: 'iw-settings-item-label' }, tr('settingsFont')),
9886
- h('button', {
9887
- key: 'b',
9888
- type: 'button',
9889
- className: 'iw-gesture-chip',
9890
- onClick: () => setFontsOpen(!fontsOpen),
9891
- }, fontsOpen ? tr('settingsCollapse') : `${codeSize} / ${treeSize} px`),
9892
- ]),
9893
- fontsOpen
9894
- ? h('div', { key: 'fontbody', className: 'iw-settings-body' }, [
9895
- stepper('code', tr('settingsCodeFont'), codeSize, (next) => store.setCodeFontSize(next)),
9896
- stepper('tree', tr('settingsTreeFont'), treeSize, (next) => store.setTreeFontSize(next)),
9897
- ])
9898
- : null,
9899
10107
  // Dependency sources come from a Maven repository; the Host detects the
9900
10108
  // usual places, and this field covers repositories kept anywhere else.
9901
- h('div', { key: 'maven', className: 'iw-settings-maven' }, [
9902
- h('div', { key: 'row', className: 'iw-settings-maven-row' }, [
9903
- h('span', { key: 'l', className: 'iw-settings-item-label' }, tr('settingsMavenRepo')),
9904
- h('input', {
9905
- key: 'i',
9906
- className: 'iw-settings-input',
9907
- type: 'text',
9908
- spellCheck: false,
9909
- defaultValue: state.mavenRepo,
9910
- placeholder: tr('settingsMavenRepoAuto'),
9911
- title: tr('settingsMavenRepoHint'),
9912
- onKeyDown: (event) => {
9913
- if (event.key === 'Enter') event.currentTarget.blur()
9914
- },
9915
- onBlur: (event) => store.setMavenRepo(event.target.value),
9916
- }),
9917
- ]),
9918
- mavenRowHint(tr, state),
9919
- ]),
9920
10109
  ]),
9921
10110
  ])
9922
10111
  }
@@ -13524,6 +13713,14 @@ function IdeScreenshotEditor({ store, tr, onInsert, onCopy, onOpenSettings, onCl
13524
13713
  const IDE_DATA_WINDOW_KEY = '__DSH_DATA_WINDOW_BRIDGE__'
13525
13714
  const IDE_DATA_WINDOW_REQUEST = 'dsh-data-window:request'
13526
13715
  const IDE_DATA_WINDOW_RESPONSE = 'dsh-data-window:response'
13716
+ /**
13717
+ * 一个标签的属性区,引号里的 `>` 不算标签结束。
13718
+ *
13719
+ * `<if test="billStatusList != null and billStatusList.size() > 0">` 这种写法到处都是;
13720
+ * 用 `[^>]*>` 会在第一个 `>` 处截断,把剩下的 ` 0">` 当成 SQL 留在语句里。
13721
+ */
13722
+ const IDE_DATA_WINDOW_TAG_ATTRS = String.raw`(?:"[^"]*"|'[^']*'|[^>"'])*`
13723
+
13527
13724
  const IDE_DATA_WINDOW_ACK_MS = 2000
13528
13725
 
13529
13726
  /** Whether the data window plugin is installed and active in this page. */
@@ -13712,7 +13909,10 @@ const IDE_DATA_WINDOW_INCLUDE_DEPTH = 8
13712
13909
  */
13713
13910
  function ideDataWindowSqlFragments(text) {
13714
13911
  const fragments = {}
13715
- const pattern = /<sql\b[^>]*\bid\s*=\s*["']([^"']+)["'][^>]*>([\s\S]*?)<\/\s*sql\s*>/gi
13912
+ const pattern = new RegExp(
13913
+ `<sql\\b${IDE_DATA_WINDOW_TAG_ATTRS}\\bid\\s*=\\s*["']([^"']+)["']${IDE_DATA_WINDOW_TAG_ATTRS}>([\\s\\S]*?)<\\/\\s*sql\\s*>`,
13914
+ 'gi',
13915
+ )
13716
13916
  let match
13717
13917
  while ((match = pattern.exec(String(text ?? ''))) !== null) {
13718
13918
  fragments[match[1]] = match[2]
@@ -13778,7 +13978,7 @@ function ideDataWindowIncludes(body) {
13778
13978
  /** `<include>` 里 `<property name=... value=.../>` 提供的占位符值。 */
13779
13979
  function ideDataWindowIncludeProps(body) {
13780
13980
  const props = {}
13781
- for (const match of String(body ?? '').matchAll(/<property\b[^>]*\/?\s*>/gi)) {
13981
+ for (const match of String(body ?? '').matchAll(new RegExp(`<property\\b${IDE_DATA_WINDOW_TAG_ATTRS}\\/?\\s*>`, 'gi'))) {
13782
13982
  const attrs = ideDataWindowXmlAttrs(match[0])
13783
13983
  if (attrs.name !== undefined && attrs.value !== undefined) props[attrs.name] = attrs.value
13784
13984
  }
@@ -13855,7 +14055,7 @@ async function ideDataWindowXmlSql(root, fqcn, symbol) {
13855
14055
  const text = await ideDataWindowReadFile(root, path)
13856
14056
  if (text === '') return null
13857
14057
  const pattern = new RegExp(
13858
- `<\\s*(select|insert|update|delete)\\b[^>]*\\bid\\s*=\\s*["']${ideDataWindowEscape(symbol)}["'][^>]*>([\\s\\S]*?)<\\s*/\\s*\\1\\s*>`,
14058
+ `<\\s*(select|insert|update|delete)\\b${IDE_DATA_WINDOW_TAG_ATTRS}\\bid\\s*=\\s*["']${ideDataWindowEscape(symbol)}["']${IDE_DATA_WINDOW_TAG_ATTRS}>([\\s\\S]*?)<\\s*/\\s*\\1\\s*>`,
13859
14059
  'i',
13860
14060
  )
13861
14061
  const match = pattern.exec(text)
@@ -13937,7 +14137,7 @@ function ideDataWindowValueFor(expr, params, index, item) {
13937
14137
  /** Expand `<foreach>` into three default rows so the SQL can run as-is. */
13938
14138
  function ideDataWindowExpandForeach(sql, params) {
13939
14139
  let result = String(sql ?? '')
13940
- const pattern = /<foreach\b([^>]*)>([\s\S]*?)<\/foreach>/i
14140
+ const pattern = new RegExp(`<foreach\\b(${IDE_DATA_WINDOW_TAG_ATTRS})>([\\s\\S]*?)<\\/foreach>`, 'i')
13941
14141
  let match
13942
14142
  while ((match = pattern.exec(result)) !== null) {
13943
14143
  const attrs = ideDataWindowXmlAttrs(match[1])
@@ -13963,19 +14163,20 @@ function ideDataWindowStripTags(sql) {
13963
14163
  let result = String(sql ?? '')
13964
14164
  // CDATA 里是原样 SQL,先去壳,否则会被下面「未知标签」那条清理连内容一起吞掉。
13965
14165
  result = result.replace(/<!\[CDATA\[([\s\S]*?)\]\]>/g, '$1')
13966
- result = result.replace(/<\s*script\b[^>]*>/gi, '').replace(/<\s*\/\s*script\s*>/gi, '')
13967
- result = result.replace(/<choose\b[^>]*>([\s\S]*?)<\/choose>/gi, (whole, body) => {
13968
- const when = /<when\b[^>]*>([\s\S]*?)<\/when>/i.exec(body)
13969
- const otherwise = /<otherwise\b[^>]*>([\s\S]*?)<\/otherwise>/i.exec(body)
14166
+ const open = (tag) => new RegExp(`<\\s*${tag}\\b${IDE_DATA_WINDOW_TAG_ATTRS}>`, 'gi')
14167
+ result = result.replace(open('script'), '').replace(/<\s*\/\s*script\s*>/gi, '')
14168
+ result = result.replace(new RegExp(`<choose\\b${IDE_DATA_WINDOW_TAG_ATTRS}>([\\s\\S]*?)<\\/choose>`, 'gi'), (whole, body) => {
14169
+ const when = new RegExp(`<when\\b${IDE_DATA_WINDOW_TAG_ATTRS}>([\\s\\S]*?)<\\/when>`, 'i').exec(body)
14170
+ const otherwise = new RegExp(`<otherwise\\b${IDE_DATA_WINDOW_TAG_ATTRS}>([\\s\\S]*?)<\\/otherwise>`, 'i').exec(body)
13970
14171
  return when !== null ? when[1] : otherwise !== null ? otherwise[1] : ''
13971
14172
  })
13972
- result = result.replace(/<where\b[^>]*>([\s\S]*?)<\/where>/gi, (whole, body) => (
14173
+ result = result.replace(new RegExp(`<where\\b${IDE_DATA_WINDOW_TAG_ATTRS}>([\\s\\S]*?)<\\/where>`, 'gi'), (whole, body) => (
13973
14174
  ` WHERE ${body.replace(/^\s*(and|or)\b/i, '')} `
13974
14175
  ))
13975
- result = result.replace(/<set\b[^>]*>([\s\S]*?)<\/set>/gi, (whole, body) => (
14176
+ result = result.replace(new RegExp(`<set\\b${IDE_DATA_WINDOW_TAG_ATTRS}>([\\s\\S]*?)<\\/set>`, 'gi'), (whole, body) => (
13976
14177
  ` SET ${body.replace(/,\s*$/, '')} `
13977
14178
  ))
13978
- result = result.replace(/<trim\b([^>]*)>([\s\S]*?)<\/trim>/gi, (whole, attrText, body) => {
14179
+ result = result.replace(new RegExp(`<trim\\b(${IDE_DATA_WINDOW_TAG_ATTRS})>([\\s\\S]*?)<\\/trim>`, 'gi'), (whole, attrText, body) => {
13979
14180
  const attrs = ideDataWindowXmlAttrs(attrText)
13980
14181
  let inner = body
13981
14182
  for (const prefix of String(attrs.prefixOverrides ?? '').split('|')) {
@@ -13989,14 +14190,14 @@ function ideDataWindowStripTags(sql) {
13989
14190
  return `${String(attrs.prefix ?? '').trim()} ${inner} ${String(attrs.suffix ?? '').trim()}`
13990
14191
  })
13991
14192
  for (const tag of ['if', 'when', 'otherwise']) {
13992
- const pattern = new RegExp(`<\\s*${tag}\\b[^>]*>([\\s\\S]*?)<\\s*/\\s*${tag}\\s*>`, 'gi')
14193
+ const pattern = new RegExp(`<\\s*${tag}\\b${IDE_DATA_WINDOW_TAG_ATTRS}>([\\s\\S]*?)<\\s*/\\s*${tag}\\s*>`, 'gi')
13993
14194
  result = result.replace(pattern, '$1')
13994
14195
  }
13995
- result = result.replace(/<bind\b[^>]*\/?\s*>/gi, '')
14196
+ result = result.replace(new RegExp(`<bind\\b${IDE_DATA_WINDOW_TAG_ATTRS}\\/?\\s*>`, 'gi'), '')
13996
14197
  // Anything left (foreach and include are already expanded) is an unsupported tag: drop it.
13997
14198
  // 只认「XML 形状」的标签(字母或 `!` 开头):`a &lt; 5` 解出来是比较运算符,
13998
14199
  // 按 `<[^>]+>` 删会把 `<` 到后面某个 `>` 之间的真实 SQL 一起吞掉。
13999
- result = result.replace(/<\/?[A-Za-z!][^>]*>/g, '')
14200
+ result = result.replace(new RegExp(`<\\/?[A-Za-z!]${IDE_DATA_WINDOW_TAG_ATTRS}>`, 'g'), '')
14000
14201
  // `<where>` may have wrapped its leading AND/OR inside a stripped `<if>`.
14001
14202
  result = result.replace(/\bWHERE\s+(AND|OR)\b/gi, 'WHERE')
14002
14203
  // 条件被动态标签或解析失败的 include 吃光后只剩一个 WHERE,留着就是语法错误。
@@ -14104,6 +14305,8 @@ async function ideDataWindowOpenMapper(store, tr, root, path, symbol, line) {
14104
14305
  // everything but the last few rows off a long turn; the card scrolls, so the
14105
14306
  // whole tail of the log is worth keeping.
14106
14307
  const IDE_FLOAT_MESSAGES = 200
14308
+ /** 表头标题最多显示多少个字(超出加省略号)。 */
14309
+ const IDE_FLOAT_TITLE_CHARS = 20
14107
14310
  /** Longest text a folded row shows once opened; longer payloads are clipped. */
14108
14311
  const IDE_FLOAT_DETAIL_MAX = 6000
14109
14312
  /** How long after `compositionend` an Enter still counts as "confirm the IME". */
@@ -14243,6 +14446,76 @@ function ideFloatCallsDetail(calls) {
14243
14446
  }).join('\n\n')
14244
14447
  }
14245
14448
 
14449
+ /** 还没决定的审批数量:折叠成球时靠它在球上点一个告警点。 */
14450
+ function ideFloatPendingApprovals(rows) {
14451
+ return Array.isArray(rows) ? rows.filter((row) => row?.role === 'approval' && row.pending === true).length : 0
14452
+ }
14453
+
14454
+ /**
14455
+ * 卡片当前展示哪个会话。
14456
+ *
14457
+ * 默认跟随面板(`state.sessionId`);设置里关掉「跟随当前会话」后,卡片只认自己
14458
+ * 钉住的那个 `state.floatSessionId`,DSH 里怎么切都不动。
14459
+ */
14460
+ function ideFloatTargetSession(state) {
14461
+ const panel = typeof state?.sessionId === 'string' ? state.sessionId : ''
14462
+ if (state?.floatFollow !== false) return panel
14463
+ const pinned = typeof state?.floatSessionId === 'string' ? state.floatSessionId : ''
14464
+ return pinned !== '' ? pinned : panel
14465
+ }
14466
+
14467
+ /** 会话的模式:`agentPreset` 投影的值(字符串或 `{currentValue}`,没配置就是空)。 */
14468
+ function ideFloatPresetId(value) {
14469
+ if (typeof value === 'string') return value
14470
+ if (value !== null && typeof value === 'object' && typeof value.currentValue === 'string') return value.currentValue
14471
+ return ''
14472
+ }
14473
+
14474
+ /** 模式的名字:自定义预设用自己的名字,内置预设交给调用方翻译,最后兜底 id。 */
14475
+ function ideFloatPresetName(presets, id, translate) {
14476
+ if (typeof id !== 'string' || id === '') return ''
14477
+ const entry = Array.isArray(presets) ? presets.find((item) => item?.id === id) : undefined
14478
+ const named = typeof entry?.name === 'string' ? entry.name.trim() : ''
14479
+ if (named !== '') return named
14480
+ const text = typeof translate === 'function' ? translate(id) : ''
14481
+ return typeof text === 'string' && text !== '' ? text : id
14482
+ }
14483
+
14484
+ /** 表头标题最多 `limit` 个字,超出用省略号——再长就分不清是哪个会话了。 */
14485
+ function ideFloatTitleText(text, limit = IDE_FLOAT_TITLE_CHARS) {
14486
+ const value = String(text ?? '').trim()
14487
+ const chars = [...value]
14488
+ if (chars.length <= limit) return value
14489
+ return `${chars.slice(0, limit).join('')}…`
14490
+ }
14491
+
14492
+ /**
14493
+ * 一个工作区固定一个色相:同一个目录永远是同一个颜色,不同工作区尽量分开。
14494
+ * 只给表头标题上色,且和正文主色混合,浅色/深色主题下都保持可读。
14495
+ */
14496
+ function ideFloatWorkspaceHue(path) {
14497
+ const text = String(path ?? '').trim()
14498
+ if (text === '') return 214
14499
+ let hash = 0
14500
+ for (let index = 0; index < text.length; index += 1) {
14501
+ hash = (hash * 33 + text.charCodeAt(index)) % 360
14502
+ }
14503
+ return hash
14504
+ }
14505
+
14506
+ /** 审批结果的一句话说法;后续版本出现新结果时原样显示,不吞掉。 */
14507
+ function ideFloatApprovalOutcome(outcome, tr) {
14508
+ const value = String(outcome ?? '')
14509
+ const labels = {
14510
+ 'allowed-once': 'floatApprovalAllowed',
14511
+ rejected: 'floatApprovalRejected',
14512
+ cancelled: 'floatApprovalCancelled',
14513
+ unavailable: 'floatApprovalUnavailable',
14514
+ }
14515
+ const key = labels[value]
14516
+ return key === undefined ? `${tr('floatApprovalSettled')} · ${value}`.trim() : tr(key)
14517
+ }
14518
+
14246
14519
  function ideFloatRow(row, tr, io) {
14247
14520
  const { setViewing, store, pictures } = io
14248
14521
  // Compact (the default) is about WHICH rows show, not about cutting the text:
@@ -14301,6 +14574,35 @@ function ideFloatRow(row, tr, io) {
14301
14574
  // Questions cannot be answered here: DSH only accepts the answer in the
14302
14575
  // Conversation, so the card's button navigates there instead.
14303
14576
  const goToChat = typeof io.goToChat === 'function' ? io.goToChat : () => {}
14577
+ // 审批也一样:`approval/request` 是 waterfall 事件,唯一的作答入口是 DSH 自己的
14578
+ // 审批插件(它把审批卡挂在对话的输入区)。插件再抢这份事件会把对话那张卡顶掉,
14579
+ // 一旦卡片被收起,审批就彻底没人能答。所以这里只展示 + 把人送回对话。
14580
+ if (row.role === 'approval') {
14581
+ const settled = row.pending !== true
14582
+ return h('div', { key: row.key, className: 'iw-float-row' }, [
14583
+ h('div', { key: 'card', className: `iw-float-ask iw-float-approval${settled ? ' iw-float-approval-done' : ''}` }, [
14584
+ h('div', { key: 'head', className: 'iw-float-ask-head' }, [
14585
+ h('div', { key: 'e', className: 'iw-float-ask-eyebrow' },
14586
+ settled ? tr('floatApprovalSettled') : tr('floatApprovalPending')),
14587
+ h('div', { key: 't', className: 'iw-float-ask-title' },
14588
+ row.tool === '' ? tr('floatApprovalTitle') : `${tr('floatApprovalTool')} · ${row.tool}`),
14589
+ ]),
14590
+ row.reason === '' ? null : h('div', { key: 'r', className: 'iw-float-approval-reason' }, row.reason),
14591
+ h('div', { key: 'foot', className: 'iw-float-ask-foot' }, [
14592
+ h('span', { key: 'hint', className: 'iw-float-ask-hint' },
14593
+ settled ? ideFloatApprovalOutcome(row.outcome, tr) : tr('floatApprovalHint')),
14594
+ settled
14595
+ ? null
14596
+ : h('button', {
14597
+ key: 'go',
14598
+ type: 'button',
14599
+ className: 'iw-btn primary iw-float-ask-go',
14600
+ onClick: () => { goToChat() },
14601
+ }, tr('floatApprovalGo')),
14602
+ ]),
14603
+ ]),
14604
+ ])
14605
+ }
14304
14606
  if (row.role === 'files') {
14305
14607
  return h('div', { key: row.key, className: 'iw-float-row iw-float-files' }, [
14306
14608
  h('span', { key: 'who', className: 'iw-float-who' }, tr('floatFiles')),
@@ -14329,7 +14631,12 @@ function ideFloatRow(row, tr, io) {
14329
14631
  const body = row.text === '' ? null : h(IdeFloatMarkdown, { key: 'text', text: row.text, tr })
14330
14632
  const pics = row.images === undefined || row.images.length === 0 ? null : h('div', { key: 'pics', className: 'iw-float-pics' }, row.images.map((image, index) => {
14331
14633
  const url = pictures[image.attachmentId] ?? ''
14332
- if (url === '') return h('div', { key: `pic${index}`, className: 'iw-float-pic iw-float-pic-wait' })
14634
+ // 还没读到用骨架,读失败用一行提示(`''` 是「试过了、失败」的标记)。
14635
+ if (url === '') {
14636
+ return Object.prototype.hasOwnProperty.call(picturesRef.current, image.attachmentId)
14637
+ ? h('div', { key: `pic${index}`, className: 'iw-float-pic iw-float-pic-missing' }, `${tr('floatImageMissing')}${image.name === undefined ? '' : ` · ${image.name}`}`)
14638
+ : h('div', { key: `pic${index}`, className: 'iw-float-pic iw-float-pic-wait' })
14639
+ }
14333
14640
  return h('img', {
14334
14641
  key: `pic${index}`,
14335
14642
  className: 'iw-float-pic',
@@ -14566,10 +14873,6 @@ function ideFloatNotice(event) {
14566
14873
  labelKey: 'floatNoticeRetry',
14567
14874
  text: ideFloatDetail(`第 ${data.retry ?? '?'} / ${data.maxRetries ?? '?'} 次\n${data.failure?.code ?? ''} ${data.failure?.message ?? ''}`.trim()),
14568
14875
  }
14569
- case 'approval/asked':
14570
- return { labelKey: 'floatNoticeApproval', text: ideFloatDetail(`${data.toolName ?? ''}\n${data.reason ?? ''}`.trim()) }
14571
- case 'approval/decided':
14572
- return { labelKey: 'floatNoticeApprovalResult', text: String(data.outcome ?? '') }
14573
14876
  case 'approval/policy':
14574
14877
  return { labelKey: 'floatNoticeApprovalPolicy', text: String(data.policy ?? '') }
14575
14878
  case 'workspace/changes':
@@ -14722,6 +15025,33 @@ function ideFloatTranscript(entries, limit = IDE_FLOAT_MESSAGES) {
14722
15025
  }
14723
15026
  continue
14724
15027
  }
15028
+ // 审批请求自成一卡:它发生在某个工具调用「等批」期间,先把这一批收口,
15029
+ // 免得「等待审批」跑到那条命令上面去。
15030
+ if (event.type === 'approval/asked') {
15031
+ flushBatch()
15032
+ rows.push({
15033
+ key: `ap${event.seq}`,
15034
+ role: 'approval',
15035
+ text: '',
15036
+ images: [],
15037
+ tool: String(event.data?.toolName ?? ''),
15038
+ reason: String(event.data?.reason ?? ''),
15039
+ approvalId: String(event.data?.id ?? ''),
15040
+ pending: true,
15041
+ time: Number(event.time ?? 0),
15042
+ seq: event.seq,
15043
+ })
15044
+ continue
15045
+ }
15046
+ if (event.type === 'approval/decided') {
15047
+ const approvalId = String(event.data?.id ?? '')
15048
+ const settled = rows.find((row) => row.role === 'approval' && row.approvalId === approvalId)
15049
+ if (settled !== undefined) {
15050
+ settled.pending = false
15051
+ settled.outcome = String(event.data?.outcome ?? '')
15052
+ }
15053
+ continue
15054
+ }
14725
15055
  // The conversation's own question card: `ask_user_question` is a tool call,
14726
15056
  // and its answer comes back as the tool result with matching ids.
14727
15057
  if (event.type === 'tool/call' && event.data?.name === 'ask_user_question') {
@@ -14780,10 +15110,18 @@ function ideFloatTranscript(entries, limit = IDE_FLOAT_MESSAGES) {
14780
15110
  * scrolls away, once where it stays. Finished batches stay in the transcript,
14781
15111
  * folded, because they are part of the record.
14782
15112
  */
14783
- function ideFloatVisibleRows(rows, running, detail) {
15113
+ function ideFloatVisibleRows(rows, running, detail, history) {
14784
15114
  if (!Array.isArray(rows)) return []
14785
- // 还没作答的问题卡片不管在哪个位置都要露出来,否则用户永远看不到「要你选」。
15115
+ // 还没作答的问题卡片、还没决定的审批不管在哪个位置都要露出来,否则用户永远
15116
+ // 看不到「要你选 / 要你批」。
14786
15117
  const pendingQuestion = (row) => row?.role === 'question' && !(Array.isArray(row?.answers) && row.answers.length > 0)
15118
+ const pendingApproval = (row) => row?.role === 'approval' && row.pending === true
15119
+ // 用户主动往回翻(滚到顶):把整个已加载窗口里的对话铺开,否则补进来的历史会
15120
+ // 被「只画本轮」过滤掉,看起来像什么都没加载。过程行(工具批次/思考/上下文/
15121
+ // notice)仍然不画——那是对话的事。
15122
+ if (detail !== true && history === true) {
15123
+ return rows.filter((row) => row?.role !== 'step' && row?.role !== 'reasoning' && row?.role !== 'context' && row?.role !== 'notice')
15124
+ }
14787
15125
  if (detail !== true) {
14788
15126
  // The card is a status board for the current turn: what you last said, then
14789
15127
  // every line the agent printed after it. An agent narrates between Tool calls
@@ -14813,14 +15151,14 @@ function ideFloatVisibleRows(rows, running, detail) {
14813
15151
  }
14814
15152
  }
14815
15153
  rows.forEach((row, index) => {
14816
- if (pendingQuestion(row)) keep.add(index)
15154
+ if (pendingQuestion(row) || pendingApproval(row)) keep.add(index)
14817
15155
  })
14818
15156
  return [...keep].sort((left, right) => left - right).map((index) => rows[index])
14819
15157
  }
14820
15158
  const keep = new Set([lastUser])
14821
15159
  rows.forEach((row, index) => {
14822
- if (index > lastUser && (row?.role === 'assistant' || row?.role === 'files' || pendingQuestion(row))) keep.add(index)
14823
- else if (index < lastUser && pendingQuestion(row)) keep.add(index)
15160
+ if (index > lastUser && (row?.role === 'assistant' || row?.role === 'files' || row?.role === 'approval' || pendingQuestion(row))) keep.add(index)
15161
+ else if (index < lastUser && (pendingQuestion(row) || pendingApproval(row))) keep.add(index)
14824
15162
  })
14825
15163
  return [...keep].sort((left, right) => left - right).map((index) => rows[index])
14826
15164
  }
@@ -15472,8 +15810,60 @@ function ideFloatSafeUrl(url, image = false) {
15472
15810
  return ''
15473
15811
  }
15474
15812
 
15813
+ /**
15814
+ * 本地绝对路径的图片走 DSH 自己的 `api/file` 路由——对话里就是这么显示的。
15815
+ *
15816
+ * 直接把 `/tmp/x.jpg` 塞进 `<img src>` 会变成「相对当前页面」的地址,浏览器只会
15817
+ * 拿到 404 和一张裂图标(alt 文字旁边那个 ⧉)。`https?` 与 `dsh-app:` 两种部署
15818
+ * 下都能用同一个相对路由,和 DSH 客户端自己的 `fileMediaUrl` 规则一致。
15819
+ */
15820
+ function ideFloatFileUrl(path) {
15821
+ const text = String(path ?? '').trim()
15822
+ if (text === '') return ''
15823
+ // 只认绝对路径:Windows 的 `C:\x`、UNC 的 `\\host\share`、POSIX 的 `/tmp/x`。
15824
+ if (!/^(?:\/|[A-Za-z]:[\\/]|\\\\)/.test(text)) return ''
15825
+ const base = typeof document !== 'undefined' && typeof document.baseURI === 'string' ? document.baseURI : ''
15826
+ if (base === '') return ''
15827
+ if (!/^https?:/i.test(base) && !base.startsWith('dsh-app://')) return ''
15828
+ try {
15829
+ return new URL(`api/file?path=${encodeURIComponent(text)}`, base).href
15830
+ } catch (error) {
15831
+ return ''
15832
+ }
15833
+ }
15834
+
15835
+ /**
15836
+ * 一张 markdown 图:加载不出来就换成一行提示。
15837
+ *
15838
+ * 助手有时会写 `![说明](/tmp/xxx.jpg)` 指向已经不存在的文件(临时截图被清理了),
15839
+ * 浏览器只会给一枚裂图标 + alt 文字,看着像卡片坏了。这里显式说明「图片无法加载」
15840
+ * 并带上文件名,悬停给完整路径。
15841
+ */
15842
+ function IdeFloatImage(props) {
15843
+ // 一个 props 参数、不解构:测试里的 grabSource 按花括号配平取函数体,
15844
+ // 解构里的 `{ ... }` 会被当成函数结尾。
15845
+ const src = props?.src
15846
+ const alt = props?.alt
15847
+ const path = props?.path
15848
+ const tr = props?.tr
15849
+ const [failed, setFailed] = useState(false)
15850
+ if (failed === true) {
15851
+ const name = String(path ?? '').split(/[\\/]/).pop() || String(alt ?? '')
15852
+ return h('span', {
15853
+ className: 'iw-float-img-missing',
15854
+ title: path === undefined ? name : String(path),
15855
+ }, name === '' ? tr('floatImageMissing') : `${tr('floatImageMissing')} · ${name}`)
15856
+ }
15857
+ return h('img', {
15858
+ className: 'iw-float-md-img',
15859
+ src,
15860
+ alt,
15861
+ onError: () => setFailed(true),
15862
+ })
15863
+ }
15864
+
15475
15865
  /** One inline markdown run: code, bold, emphasis, strike, links, images, autolinks. */
15476
- function ideFloatInline(text, prefix = '') {
15866
+ function ideFloatInline(text, prefix = '', tr) {
15477
15867
  const nodes = []
15478
15868
  const pattern = new RegExp([
15479
15869
  '`+[^`]*`+', // inline code, any number of backticks
@@ -15509,12 +15899,21 @@ function ideFloatInline(text, prefix = '') {
15509
15899
  nodes.push(h('code', { key, className: 'iw-float-md-code' }, token.slice(ticks, -ticks).replace(/^ | $/g, '')))
15510
15900
  } else if (token.startsWith('![')) {
15511
15901
  const image = /^!\[([^\]]*)\]\(([^)]+)\)$/.exec(token)
15512
- const src = image === null ? '' : ideFloatSafeUrl(image[2], true)
15902
+ const localImage = image === null ? '' : ideFloatFileUrl(image[2])
15903
+ const src = localImage !== '' ? localImage : image === null ? '' : ideFloatSafeUrl(image[2], true)
15513
15904
  if (src === '') pushText(image === null ? token : image[1])
15514
- else nodes.push(h('img', { key, className: 'iw-float-md-img', src, alt: image[1] }))
15905
+ else nodes.push(h(IdeFloatImage, {
15906
+ key,
15907
+ src,
15908
+ alt: image[1],
15909
+ // 本地路径的图才可能「文件没了」;网络图加载失败也给同一句提示。
15910
+ path: image[2],
15911
+ tr: typeof tr === 'function' ? tr : (key) => key,
15912
+ }))
15515
15913
  } else if (token.startsWith('[')) {
15516
15914
  const link = /^\[([^\]]+)\]\(([^)]+)\)$/.exec(token)
15517
- const href = link === null ? '' : ideFloatSafeUrl(link[2])
15915
+ const localLink = link === null ? '' : ideFloatFileUrl(link[2])
15916
+ const href = localLink !== '' ? localLink : link === null ? '' : ideFloatSafeUrl(link[2])
15518
15917
  if (href === '') pushText(link === null ? token : link[1])
15519
15918
  else nodes.push(h('a', { key, className: 'iw-float-md-link', href, target: '_blank', rel: 'noreferrer' }, link[1]))
15520
15919
  } else if (token.startsWith('<http')) {
@@ -15760,19 +16159,19 @@ function IdeFloatMarkdown({ text, tr }) {
15760
16159
  return h('div', { className: 'iw-float-md' }, blocks.map((block, index) => {
15761
16160
  const key = `b${index}`
15762
16161
  if (block.type === 'code') return h(IdeFloatCodeBlock, { key, code: block.text, lang: block.lang, tr })
15763
- if (block.type === 'heading') return h('div', { key, className: `iw-float-md-h iw-float-md-h${block.level}` }, ideFloatInline(block.text, key))
16162
+ if (block.type === 'heading') return h('div', { key, className: `iw-float-md-h iw-float-md-h${block.level}` }, ideFloatInline(block.text, key, tr))
15764
16163
  if (block.type === 'hr') return h('div', { key, className: 'iw-float-md-hr' })
15765
- if (block.type === 'quote') return h('blockquote', { key, className: 'iw-float-md-quote' }, ideFloatInline(block.text, key))
16164
+ if (block.type === 'quote') return h('blockquote', { key, className: 'iw-float-md-quote' }, ideFloatInline(block.text, key, tr))
15766
16165
  if (block.type === 'table') {
15767
16166
  return h('div', { key, className: 'iw-float-md-tablewrap' }, h('table', { key: 't', className: 'iw-float-md-table' }, [
15768
16167
  h('thead', { key: 'head' }, h('tr', { key: 'row' }, block.head.map((cell, column) => h('th', {
15769
16168
  key: `c${column}`,
15770
16169
  className: cellClass(block.align[column]),
15771
- }, ideFloatInline(cell, `${key}h${column}`))))),
16170
+ }, ideFloatInline(cell, `${key}h${column}`, tr))))),
15772
16171
  h('tbody', { key: 'body' }, block.rows.map((row, rowIndex) => h('tr', { key: `r${rowIndex}` }, block.head.map((_, column) => h('td', {
15773
16172
  key: `c${column}`,
15774
16173
  className: cellClass(block.align[column]),
15775
- }, ideFloatInline(row[column] ?? '', `${key}r${rowIndex}c${column}`)))))),
16174
+ }, ideFloatInline(row[column] ?? '', `${key}r${rowIndex}c${column}`, tr)))))),
15776
16175
  ]))
15777
16176
  }
15778
16177
  if (block.type === 'ul' || block.type === 'ol') {
@@ -15786,10 +16185,10 @@ function IdeFloatMarkdown({ text, tr }) {
15786
16185
  item.task === null || item.task === undefined
15787
16186
  ? null
15788
16187
  : h('span', { key: 'check', className: 'iw-float-md-check' }, item.task === true ? '☑' : '☐'),
15789
- ...ideFloatInline(item.text.replace(/\n/g, ' '), `${key}l${itemIndex}`),
16188
+ ...ideFloatInline(item.text.replace(/\n/g, ' '), `${key}l${itemIndex}`, tr),
15790
16189
  ])))
15791
16190
  }
15792
- return h('p', { key, className: 'iw-float-md-p' }, ideFloatInline(block.text, key))
16191
+ return h('p', { key, className: 'iw-float-md-p' }, ideFloatInline(block.text, key, tr))
15793
16192
  }))
15794
16193
  }
15795
16194
 
@@ -15799,13 +16198,25 @@ function IdeFloatMarkdown({ text, tr }) {
15799
16198
  * @param props.sessions - the Client `sessions` service (retention + prompt).
15800
16199
  * @param props.modelDirectories - the model directory service the composer uses.
15801
16200
  */
15802
- function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSession, startSession, useWorkspaces, openInWorkspace, goToChat, composeText, commandList, workspaceList, skillList }) {
16201
+ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSession, startSession, useWorkspaces, openInWorkspace, goToChat, composeText, commandList, workspaceList, skillList, modeList, modeLabel }) {
15803
16202
  const tr = typeof translate === 'function' ? translate : (key) => key
15804
16203
  const state = useSyncExternalStore(store.subscribe, store.getState, store.getState)
15805
16204
  const [binding, setBinding] = useState(null)
15806
16205
  const bodyRef = useRef(null)
15807
16206
  // Whether the transcript should follow the newest line.
15808
16207
  const stickRef = useRef(true)
16208
+ // 滚到顶时往回补历史:记录「正在加载」与补完要还原的滚动高度。
16209
+ const olderRef = useRef({ busy: false, pending: false, height: 0 })
16210
+ // 「+ 新建会话」之后,不跟随时把卡片收养到新会话上(只认卡片自己发起的创建)。
16211
+ const pinnedAdoptRef = useRef(false)
16212
+ const [olderBusy, setOlderBusy] = useState(false)
16213
+ // 会话的模式(Agent 预设):DSH 表头显示的就是它,卡片只展示不改。
16214
+ const [presetId, setPresetId] = useState('')
16215
+ const [presets, setPresets] = useState([])
16216
+ // 卡片默认只画最后 200 行;用户主动往回翻时按步长放宽,别让补进来的行被裁掉。
16217
+ const [rowLimit, setRowLimit] = useState(IDE_FLOAT_MESSAGES)
16218
+ // 滚到顶 = 用户想看历史:整段对话铺开,直到发消息或切会话才回到「本轮状态板」。
16219
+ const [historyMode, setHistoryMode] = useState(false)
15809
16220
  const [entries, setEntries] = useState([])
15810
16221
  const [draft, setDraft] = useState('')
15811
16222
  const [sending, setSending] = useState(false)
@@ -15877,6 +16288,8 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
15877
16288
  code: result?.error?.code ?? 'unknown',
15878
16289
  message: result?.error?.message ?? '',
15879
16290
  })
16291
+ // 读不出来就别留一个永远转圈的骨架:标成失败,渲染成「图片无法加载」。
16292
+ setPictures((current) => (current[image.attachmentId] !== undefined ? current : { ...current, [image.attachmentId]: '' }))
15880
16293
  return
15881
16294
  }
15882
16295
  const data = result.value?.data
@@ -15904,6 +16317,110 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
15904
16317
  stickRef.current = true
15905
16318
  }, [state.floatOpen])
15906
16319
 
16320
+ // 会话的模式:投影一变就跟着变(在 DSH 里换模式,卡片立刻同步)。
16321
+ useEffect(() => {
16322
+ if (binding === null) {
16323
+ setPresetId('')
16324
+ return undefined
16325
+ }
16326
+ const projections = binding.session?.projections
16327
+ if (projections === undefined || projections === null) return undefined
16328
+ const face = typeof projections.faceOf === 'function' ? projections.faceOf('agentPreset') : undefined
16329
+ const read = () => {
16330
+ const direct = typeof projections.get === 'function' ? projections.get('agentPreset') : undefined
16331
+ const fromFace = typeof face?.getSnapshot === 'function' ? face.getSnapshot() : undefined
16332
+ const fromSession = typeof binding.session?.getSnapshot === 'function'
16333
+ ? binding.session.getSnapshot()?.projectionValues?.agentPreset
16334
+ : undefined
16335
+ setPresetId(ideFloatPresetId(direct) || ideFloatPresetId(fromFace) || ideFloatPresetId(fromSession))
16336
+ }
16337
+ read()
16338
+ const off = typeof face?.subscribe === 'function' ? face.subscribe(read) : projections.subscribeAny?.(read)
16339
+ return () => {
16340
+ if (typeof off === 'function') off()
16341
+ }
16342
+ }, [binding])
16343
+
16344
+ // 预设列表只为「自定义模式」的名字;拿不到就只显示内置模式的名字。
16345
+ useEffect(() => {
16346
+ if (typeof modeList !== 'function') return undefined
16347
+ let cancelled = false
16348
+ Promise.resolve(modeList())
16349
+ .then((result) => {
16350
+ if (cancelled) return
16351
+ if (Array.isArray(result?.value)) setPresets(result.value)
16352
+ else if (result?.error !== undefined) ideLogRecord('warn', 'float', 'presets failed', String(result.error))
16353
+ })
16354
+ .catch((error) => { if (cancelled !== true) ideLogRecord('warn', 'float', 'presets failed', error?.message ?? String(error)) })
16355
+ return () => { cancelled = true }
16356
+ }, [modeList])
16357
+
16358
+ // 不跟随时,第一次进入就把面板当前会话钉住;之后 DSH 里怎么切都不动。
16359
+ useEffect(() => {
16360
+ if (state.floatFollow !== false) return
16361
+ if (state.floatSessionId !== undefined && state.floatSessionId !== null) return
16362
+ if (typeof state.sessionId !== 'string' || state.sessionId === '') return
16363
+ store.setFloatSessionId(state.sessionId)
16364
+ }, [state.floatFollow, state.floatSessionId, state.sessionId, store])
16365
+
16366
+ // 卡片里点「+ 新建会话」:新会话属于卡片自己,不跟随时也要跟过去。
16367
+ useEffect(() => {
16368
+ if (pinnedAdoptRef.current !== true) return
16369
+ pinnedAdoptRef.current = false
16370
+ if (state.floatFollow !== false) return
16371
+ if (typeof state.sessionId !== 'string' || state.sessionId === '') return
16372
+ store.setFloatSessionId(state.sessionId)
16373
+ }, [state.sessionId, state.floatFollow, store])
16374
+
16375
+ // 滚到「更早」补一页:DSH 的会话窗口是分页的(首屏 ≥50 条消息、最多 500 条),
16376
+ // 卡片自己不请求就只能看到那一屏。补完把滚动位置往下推同样高度,视觉上停在原处。
16377
+ const loadOlderRows = async () => {
16378
+ const session = binding?.session
16379
+ const source = binding?.eventSource
16380
+ if (olderRef.current.busy) return
16381
+ const element = bodyRef.current
16382
+ const taller = () => (element === null || element === undefined ? 0 : element.scrollHeight)
16383
+ const hasMore = source?.getSnapshot()?.hasMore === true
16384
+ const canLoad = session !== undefined && session !== null && typeof session.loadOlder === 'function'
16385
+ // 已经到会话开头(或这条会话没有分页):不用请求,只把历史展开,
16386
+ // 让已经拿到的更早内容显示出来。
16387
+ if (!hasMore || !canLoad) {
16388
+ if (historyMode) return
16389
+ olderRef.current.height = taller()
16390
+ setHistoryMode(true)
16391
+ olderRef.current.pending = true
16392
+ return
16393
+ }
16394
+ olderRef.current.busy = true
16395
+ olderRef.current.height = taller()
16396
+ setOlderBusy(true)
16397
+ if (!historyMode) setHistoryMode(true)
16398
+ try {
16399
+ await session.loadOlder()
16400
+ // 窗口补进来了,但卡片只画最后 N 行;放宽上限,让补进来的行真的出现。
16401
+ setRowLimit((current) => Math.min(current + IDE_FLOAT_MESSAGES, IDE_FLOAT_MESSAGES * 10))
16402
+ olderRef.current.pending = true
16403
+ } catch (error) {
16404
+ ideLogRecord('warn', 'float', 'load older failed', error?.message ?? String(error))
16405
+ } finally {
16406
+ olderRef.current.busy = false
16407
+ setOlderBusy(false)
16408
+ }
16409
+ }
16410
+
16411
+ // 新行渲染完再量高度:把滚动条往下推「长出来的那一段」,视线不跳。
16412
+ useLayoutEffect(() => {
16413
+ const older = olderRef.current
16414
+ if (older.pending !== true) return
16415
+ const element = bodyRef.current
16416
+ if (element === null || element === undefined) return
16417
+ const grown = element.scrollHeight - older.height
16418
+ // 浏览器若已按 scroll anchoring 挪过位置,就保留它的结果,别把高度算两遍。
16419
+ if (grown > 0) element.scrollTop = Math.max(element.scrollTop, grown)
16420
+ older.height = element.scrollHeight
16421
+ older.pending = false
16422
+ })
16423
+
15907
16424
  // The transcript shows the newest line: on mount, when it comes back into
15908
16425
  // view, and after every new message. `stickRef` follows the user, so reading
15909
16426
  // older content is not yanked back; sending forces the jump.
@@ -15920,7 +16437,8 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
15920
16437
  }
15921
16438
  })
15922
16439
 
15923
- const sessionId = state.sessionId ?? ''
16440
+ const sessionId = ideFloatTargetSession(state)
16441
+ const follow = state.floatFollow !== false
15924
16442
  const open = state.floatOpen === true && state.floatEnabled !== false && state.floatClosed !== true
15925
16443
  const collapsed = state.floatCollapsed === true
15926
16444
 
@@ -15952,6 +16470,9 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
15952
16470
  useEffect(() => {
15953
16471
  if (binding === null) {
15954
16472
  setEntries([])
16473
+ setRowLimit((current) => (current === IDE_FLOAT_MESSAGES ? current : IDE_FLOAT_MESSAGES))
16474
+ olderRef.current = { busy: false, pending: false, height: 0 }
16475
+ setHistoryMode(false)
15955
16476
  return undefined
15956
16477
  }
15957
16478
  const source = binding.eventSource
@@ -15959,11 +16480,11 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
15959
16480
  const raw = source.getSnapshot()?.entries
15960
16481
  // The transcript drops Tool calls; the progress line needs them.
15961
16482
  rawEntries.current = Array.isArray(raw) ? raw : []
15962
- setEntries(ideFloatTranscript(raw))
16483
+ setEntries(ideFloatTranscript(raw, rowLimit))
15963
16484
  }
15964
16485
  read()
15965
16486
  return source.subscribe(read)
15966
- }, [binding])
16487
+ }, [binding, rowLimit])
15967
16488
 
15968
16489
  // The session directory, for the switcher in the header. The Workspace snapshot
15969
16490
  // carries the archive set, which is what keeps archived conversations out.
@@ -16105,9 +16626,11 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
16105
16626
  className: 'iw-float-menu-item iw-float-menu-new',
16106
16627
  onClick: () => {
16107
16628
  setMenu('')
16629
+ pinnedAdoptRef.current = true
16108
16630
  if (typeof startSession === 'function') startSession()
16109
16631
  },
16110
16632
  }, `+ ${tr('floatNewSession')}`),
16633
+ follow ? null : h('div', { key: 'pin', className: 'iw-float-menu-head' }, tr('floatPinnedHint')),
16111
16634
  sessionRows.length === 0
16112
16635
  ? h('div', { key: 'empty', className: 'iw-float-menu-empty' }, tr('floatSessionEmpty'))
16113
16636
  : sessionGroups.map((group) => h('div', {
@@ -16125,7 +16648,9 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
16125
16648
  title: row.cwd === '' ? row.title : row.cwd,
16126
16649
  onClick: () => {
16127
16650
  setMenu('')
16128
- if (typeof openSession === 'function') openSession(row.sessionId)
16651
+ // 不跟随:只换卡片自己的会话,不动 DSH 面板;跟随:照旧打开那个会话。
16652
+ if (!follow) store.setFloatSessionId(row.sessionId)
16653
+ else if (typeof openSession === 'function') openSession(row.sessionId)
16129
16654
  },
16130
16655
  }, [
16131
16656
  h('span', { key: 't', className: 'iw-float-menu-label' }, row.title),
@@ -16514,7 +17039,7 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
16514
17039
 
16515
17040
  // The transcript holds the conversation; the Tool log is live status pinned to
16516
17041
  // the card's footer, so it never scrolls away with the history.
16517
- const visibleEntries = ideFloatVisibleRows(entries, running, state.floatEvents === true)
17042
+ const visibleEntries = ideFloatVisibleRows(entries, running, state.floatEvents === true, historyMode)
16518
17043
 
16519
17044
  // The live line reads the RAW entries: `entries` is already folded into rows,
16520
17045
  // and the streamed deltas live only in the window (they are not rows).
@@ -16759,6 +17284,8 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
16759
17284
  const text = draft.trim()
16760
17285
  const parts = ideFloatPromptParts(text, refs, images)
16761
17286
  if (parts.length === 0 || binding === null || sending) return
17287
+ // 发新消息 = 回到实时状态板,不再停在历史视图里。
17288
+ setHistoryMode(false)
16762
17289
  // Sending means the user wants to see their own message, wherever they were.
16763
17290
  stickRef.current = true
16764
17291
  setSending(true)
@@ -16977,20 +17504,27 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
16977
17504
  width: `${box?.width ?? size.width}px`,
16978
17505
  height: `${box?.height ?? size.height}px`,
16979
17506
  fontSize: font,
17507
+ // 表头标题按工作区取色;同一个目录永远同一个色相。
17508
+ '--iw-float-hue': String(ideFloatWorkspaceHue(state.rootPath ?? '')),
16980
17509
  },
16981
17510
  }, children))
16982
17511
 
16983
17512
  if (collapsed) {
16984
17513
  // The ball is anchored to the window's bottom-right corner by CSS, so a
16985
17514
  // window resize can never leave it stranded mid-screen.
17515
+ // 收起来时审批不会自己跳出来,球上点一个告警点,别让人错过要批的东西。
17516
+ const waiting = ideFloatPendingApprovals(entries)
16986
17517
  return shell([h('button', {
16987
17518
  key: 'b',
16988
17519
  type: 'button',
16989
17520
  className: 'iw-float-ball-btn',
16990
17521
  onClick: () => store.setFloatCollapsed(false),
16991
- title: tr('floatExpand'),
16992
- 'aria-label': tr('floatExpand'),
16993
- }, 'AI')], 'iw-float-collapsed', { width: IDE_FLOAT_BALL, height: IDE_FLOAT_BALL })
17522
+ title: waiting > 0 ? tr('floatApprovalBallHint') : tr('floatExpand'),
17523
+ 'aria-label': waiting > 0 ? tr('floatApprovalBallHint') : tr('floatExpand'),
17524
+ }, [
17525
+ 'AI',
17526
+ waiting > 0 ? h('span', { key: 'dot', className: 'iw-float-ball-dot' }) : null,
17527
+ ])], 'iw-float-collapsed', { width: IDE_FLOAT_BALL, height: IDE_FLOAT_BALL })
16994
17528
  }
16995
17529
 
16996
17530
  return shell([
@@ -17005,40 +17539,45 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
17005
17539
  type: 'button',
17006
17540
  ref: titleBtnRef,
17007
17541
  className: 'iw-float-title iw-float-title-btn',
17008
- title: `${tr('floatSessions')} · ${state.rootPath ?? ''}`,
17542
+ // 悬停给完整标题 + 工作区路径:标题本身最多 20 个字。
17543
+ title: `${sessionTitle} · ${state.rootPath ?? ''}`,
17009
17544
  onClick: () => setMenu(menu === 'sessions' ? '' : 'sessions'),
17010
17545
  }, [
17011
- h('span', { key: 'text', className: 'iw-float-title iw-float-title-text' }, sessionTitle),
17546
+ h('span', { key: 'text', className: 'iw-float-title iw-float-title-text' }, ideFloatTitleText(sessionTitle)),
17012
17547
  h('span', { key: 'caret', className: 'iw-float-title-caret' }, '▾'),
17013
17548
  ]),
17014
- h('button', {
17015
- key: 'new',
17016
- type: 'button',
17017
- className: 'iw-float-new-btn',
17018
- title: tr('floatNewSession'),
17019
- 'aria-label': tr('floatNewSession'),
17020
- onClick: () => {
17021
- setMenu('')
17022
- if (typeof startSession === 'function') startSession()
17023
- },
17024
- }, '+'),
17025
- h('div', { key: 'actions', className: 'iw-float-actions' }, [
17026
- h('button', {
17027
- key: 'shrink',
17028
- type: 'button',
17029
- className: 'iw-float-icon',
17030
- title: tr('floatCollapse'),
17031
- 'aria-label': tr('floatCollapse'),
17032
- onClick: () => store.setFloatCollapsed(true),
17033
- }, '–'),
17549
+ // 右侧按钮组绝对定位,标题才能在表头里真正居中。
17550
+ h('div', { key: 'right', className: 'iw-float-head-right' }, [
17034
17551
  h('button', {
17035
- key: 'close',
17552
+ key: 'new',
17036
17553
  type: 'button',
17037
- className: 'iw-float-icon',
17038
- title: tr('floatClose'),
17039
- 'aria-label': tr('floatClose'),
17040
- onClick: () => store.setFloatClosed(true),
17041
- }, '×'),
17554
+ className: 'iw-float-new-btn',
17555
+ title: tr('floatNewSession'),
17556
+ 'aria-label': tr('floatNewSession'),
17557
+ onClick: () => {
17558
+ setMenu('')
17559
+ pinnedAdoptRef.current = true
17560
+ if (typeof startSession === 'function') startSession()
17561
+ },
17562
+ }, '+'),
17563
+ h('div', { key: 'actions', className: 'iw-float-actions' }, [
17564
+ h('button', {
17565
+ key: 'shrink',
17566
+ type: 'button',
17567
+ className: 'iw-float-icon',
17568
+ title: tr('floatCollapse'),
17569
+ 'aria-label': tr('floatCollapse'),
17570
+ onClick: () => store.setFloatCollapsed(true),
17571
+ }, '–'),
17572
+ h('button', {
17573
+ key: 'close',
17574
+ type: 'button',
17575
+ className: 'iw-float-icon',
17576
+ title: tr('floatClose'),
17577
+ 'aria-label': tr('floatClose'),
17578
+ onClick: () => store.setFloatClosed(true),
17579
+ }, '×'),
17580
+ ]),
17042
17581
  ]),
17043
17582
  ]),
17044
17583
  renderSessionsMenu(),
@@ -17052,8 +17591,12 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
17052
17591
  onScroll: (event) => {
17053
17592
  const element = event.currentTarget
17054
17593
  stickRef.current = element.scrollTop + element.clientHeight >= element.scrollHeight - 40
17594
+ // 滚到最顶再往上拉:补一页更早的历史(没有更多时是空操作)。
17595
+ if (element.scrollTop <= 4) void loadOlderRows()
17055
17596
  },
17056
- }, visibleEntries.length === 0 && running !== true
17597
+ }, [
17598
+ olderBusy ? h('div', { key: 'older', className: 'iw-float-older' }, tr('floatLoadingOlder')) : null,
17599
+ visibleEntries.length === 0 && running !== true
17057
17600
  ? h('div', { key: 'empty', className: 'iw-float-empty' }, sessionId === '' ? tr('floatNoSession') : tr('floatEmpty'))
17058
17601
  : visibleEntries.map((row) => {
17059
17602
  // One malformed event must not take the whole card down: a throw inside
@@ -17064,7 +17607,8 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
17064
17607
  ideLogRecord('warn', 'float', 'row render failed', { key: row.key, error: String(error) })
17065
17608
  return h('div', { key: row.key, className: 'iw-float-row iw-float-assistant' }, String(row.text ?? ''))
17066
17609
  }
17067
- })),
17610
+ }),
17611
+ ]),
17068
17612
  // The in-flight message renders in the transcript, exactly like the one the
17069
17613
  // conversation is printing — no separate 「正在输出」 step.
17070
17614
  streamRow === null
@@ -17282,6 +17826,11 @@ function IdeFloatingAsk({ store, sessions, modelDirectories, translate, openSess
17282
17826
  h('span', { key: 't', className: 'iw-float-perm-text' }, ideFloatPermissionLabel(permission, tr)),
17283
17827
  h(IdeChevronDownIcon, { key: 'c', size: 12 }),
17284
17828
  ]),
17829
+ presetId === '' ? null : h('span', {
17830
+ key: 'mode',
17831
+ className: 'iw-float-mode',
17832
+ title: `${tr('floatMode')}: ${ideFloatPresetName(presets, presetId, modeLabel)}`,
17833
+ }, ideFloatPresetName(presets, presetId, modeLabel)),
17285
17834
  h('span', { key: 'gap', className: 'iw-float-gap' }),
17286
17835
  efforts.length === 0 ? null : h('button', {
17287
17836
  key: 'effort',
@@ -17438,6 +17987,16 @@ function apply(ctx) {
17438
17987
  void error
17439
17988
  }
17440
17989
  const translate = ideMakeTranslator(ctx, bound)
17990
+ // 会话模式的标签:内置预设(standard/ptc/minimal/cordis)没有 name,文案在 DSH
17991
+ // 自己的 `settings.agentPreset` 命名空间里。借它的文案,和表头显示的一致。
17992
+ let presetText
17993
+ try {
17994
+ presetText = ctx.locale !== undefined && typeof ctx.locale.bind === 'function'
17995
+ ? ctx.locale.bind('settings.agentPreset')
17996
+ : undefined
17997
+ } catch (error) {
17998
+ void error
17999
+ }
17441
18000
 
17442
18001
  /**
17443
18002
  * The palette's command list.
@@ -18577,6 +19136,30 @@ function apply(ctx) {
18577
19136
  return { error: String(error?.message ?? error) }
18578
19137
  }
18579
19138
  },
19139
+ // 会话的模式 = Agent 预设;卡片只展示,切换仍在 DSH 里做。
19140
+ modeList: async () => {
19141
+ try {
19142
+ const result = await ctx.remote.agentPresets.list()
19143
+ if (result?.ok === false) return { error: result.error?.message ?? result.error?.code ?? 'failed' }
19144
+ const presets = result?.value?.presets
19145
+ return { value: Array.isArray(presets) ? presets : [] }
19146
+ } catch (error) {
19147
+ return { error: String(error?.message ?? error) }
19148
+ }
19149
+ },
19150
+ /** 内置预设的中文/英文名;返回空串表示「不是内置预设」,交给调用方兜底。 */
19151
+ modeLabel: (id) => {
19152
+ const builtin = { standard: 'Standard', ptc: 'Ptc', minimal: 'Minimal', cordis: 'Cordis' }[id]
19153
+ if (builtin === undefined) return ''
19154
+ const key = `preset${builtin}Name`
19155
+ try {
19156
+ const text = typeof presetText === 'function' ? presetText(key) : undefined
19157
+ if (typeof text === 'string' && text.trim() !== '' && text !== key) return text
19158
+ } catch (error) {
19159
+ void error
19160
+ }
19161
+ return translate(`floatMode${builtin}`)
19162
+ },
18580
19163
  workspaceList: async (sessionId, path) => {
18581
19164
  try {
18582
19165
  const result = await ctx.remote.workspaceFiles.list(sessionId, path)