dsh-sidecard-ask 2.1.0 → 2.1.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.1
4
+
5
+ **主题:卡片记录只收侧边卡片——改发到主对话的问答不再进持久化历史。** 无 API/配置变更。
6
+
7
+ ### 修复
8
+
9
+ - **主对话承载的问答混进卡片记录**。`syncPersisted()` 一直只收 `carrier === 'side'`,但 v3 信封或
10
+ v1/v2 迁移数据里可能存在 `carrier: 'main'` 的条目(旧版本写下的),
11
+ `parseEnvelope()` 会把它当普通记录读回来并在启动时以侧边卡片回放,与主对话内容重复。
12
+ 现在读取时直接丢弃这类条目:它不写 localStorage、不进设置页的历史管理器、也不进「导出全部 .md」。
13
+ - **`sendToMain()` 成功后清理记录**。卡片改投主对话时从 durable history 删除对应 id
14
+ (`draft` 模式只是把文本放进输入框、尚未真正发出,保留记录)。
15
+
16
+ CHANGELOG 对应回归测试:`test/contract-test.mjs` 的 `main-carrier records` 段(main 提交不写盘、
17
+ 旧 payload 里的 main 条目被丢弃、`sendToMain` 删除记录)。
18
+
3
19
  ## 2.1.0
4
20
 
5
21
  **主题:跨端核查后的性能与可观测性收口——流式热路径从「每次 delta 全树重渲染」改成「只重渲染变化的卡」,
package/README.md CHANGED
@@ -713,6 +713,8 @@ node tools/compat-probe.mjs --json tools/.cache/matrix.json
713
713
  7e. 设置页勾选「完成后桌面通知」会请求通知权限;授权后切到其它标签页/窗口,作答结束时应弹系统通知。
714
714
  7f. 设置页「历史追问卡片」:可搜索、恢复到浮层、单条删除、清空;「历史卡片保存数量」设 0 后新卡片不再写盘;
715
715
  注意:**关闭浮层卡片不会删历史**(1.8.0 起历史只在管理中心删除)。
716
+ **改发到主对话(`carrier: 'main'`)的问答不算卡片记录**(2.1.1 起):它只出现在主对话里,不写
717
+ localStorage,也不出现在历史管理器与「导出全部 .md」;旧版本写进去的 main 条目在读取时丢弃。
716
718
  7g. **回答风格(1.8.0)**:设置页把「回答风格」切成「精简」并保存 → 下一次追问的答案应明显更短、
717
719
  不复述原文;切「详细」→ 应看到展开与依据。自检办法:`GET /state` 的 `config.answerStyle` 应为所选值;
718
720
  若 provider 不支持 persona,指令会内联进提示词(卡片上的 provider 行为不变)。
@@ -842,7 +844,7 @@ node tools/compat-probe.mjs 0.1.7-rc.2 # 也可只探某个版本
842
844
  ```powershell
843
845
  # 0) 探活:唯一免鉴权的接口,只回插件版本与宿主时钟
844
846
  (Invoke-WebRequest http://127.0.0.1:8080/sidecard-ask/api/ping -UseBasicParsing).Content
845
- # → {"ok":true,"value":{"version":"2.1.0","at":1792...}} 200 = 插件宿主半已加载
847
+ # → {"ok":true,"value":{"version":"2.1.1","at":1792...}} 200 = 插件宿主半已加载
846
848
 
847
849
  # 1) 宿主接口与能力(archived 父会话检测也在这里)——需要会话
848
850
  # 在本机浏览器已登录的前提下复用会话:先 -WebSession 登录,或把浏览器的 Cookie 头带进来
package/client.js CHANGED
@@ -117,7 +117,7 @@ window.__ModuleLoader__.load({
117
117
  * the Host and the module's `api.version` both read it, so a report can
118
118
  * never claim a generation the browser is not actually running.
119
119
  */
120
- const CLIENT_VERSION = '2.1.0'
120
+ const CLIENT_VERSION = '2.1.1'
121
121
 
122
122
  /**
123
123
  * Tab kind served by the DSH native right rail (also its implementation id).
@@ -3123,7 +3123,13 @@ body[data-ds-dark-theme] .dsa-seg button[data-on="true"]:hover{
3123
3123
  * @returns {string} the file body.
3124
3124
  */
3125
3125
  function buildHistoryMarkdown(entries) {
3126
- const list = Array.isArray(entries) ? entries.filter(entry => entry !== null && typeof entry === 'object') : []
3126
+ // 主对话承载的问答不算卡片记录(2026-10-23,用户要求)——即使调用方
3127
+ // 递来一条带 `carrier: 'main'` 的旧条目,导出也不该把它当成侧边卡片。
3128
+ const list = Array.isArray(entries)
3129
+ ? entries.filter(entry => entry !== null
3130
+ && typeof entry === 'object'
3131
+ && (entry.carrier === undefined || entry.carrier === 'side'))
3132
+ : []
3127
3133
  if (list.length === 0) return ''
3128
3134
  const sections = list.map((entry, index) => {
3129
3135
  const body = buildCardMarkdown(entry)
@@ -5693,7 +5699,14 @@ body[data-ds-dark-theme] .dsa-seg button[data-on="true"]:hover{
5693
5699
  const value = JSON.parse(raw)
5694
5700
  if (value?.version !== version || !Array.isArray(value.cards)) return []
5695
5701
  return value.cards
5696
- .filter(entry => typeof entry?.id === 'string' && entry.id !== '' && typeof entry.question === 'string')
5702
+ // 主对话承载的问答不算卡片记录(2026-10-23,用户要求)。旧版本
5703
+ // 曾把 `carrier: 'main'` 的条目写进 v3/legacy 信封:读取时丢弃,
5704
+ // 磁盘上的副本等下一次写回自然消失;没有 carrier 字段的 v1/v2
5705
+ // 条目仍按侧边卡片处理(它们当时只可能来自侧边卡片)。
5706
+ .filter(entry => typeof entry?.id === 'string'
5707
+ && entry.id !== ''
5708
+ && typeof entry.question === 'string'
5709
+ && (entry.carrier === undefined || entry.carrier === 'side'))
5697
5710
  } catch { return [] }
5698
5711
  }
5699
5712
 
@@ -5756,6 +5769,9 @@ body[data-ds-dark-theme] .dsa-seg button[data-on="true"]:hover{
5756
5769
  /** Recompute the durable set from the live store and write it. */
5757
5770
  const syncPersisted = () => {
5758
5771
  const cap = historyCap()
5772
+ // 只有侧边卡片算「记录」:改发到主对话的问答由主对话自己保存,
5773
+ // 不再进 durable history(2026-10-23,用户要求)。carrier 过滤是
5774
+ // 这条边界的唯一入口,下游 writePersisted 不要再放宽。
5759
5775
  const finished = store.state.cards
5760
5776
  .filter(card => card.carrier === 'side'
5761
5777
  && (card.status === 'done' || card.status === 'stopped')
@@ -6344,6 +6360,20 @@ body[data-ds-dark-theme] .dsa-seg button[data-on="true"]:hover{
6344
6360
  error: null,
6345
6361
  streaming: null,
6346
6362
  })
6363
+ // 主对话承载的问答不算卡片记录(2026-10-23,用户要求)。这条
6364
+ // 卡片一旦改投主对话,durable history 里若还有它的副本就必须
6365
+ // 删掉,否则刷新后它会以侧边卡片的身份被恢复,和主对话重复。
6366
+ // `draft` 模式只是把文本放进输入框(还没有真正发出),保留记录。
6367
+ // cap === 0 与 deleteCard 同规则:不动已存的键,只镜像内存。
6368
+ if (result.mode !== 'draft') {
6369
+ const kept = store.state.history
6370
+ .filter(item => item.id !== card.id)
6371
+ .slice(0, historyCap())
6372
+ if (kept.length !== store.state.history.length) {
6373
+ if (historyCap() > 0) writePersisted(kept)
6374
+ store.set({ history: kept })
6375
+ }
6376
+ }
6347
6377
  toast(result.mode === 'draft' ? t('draftInserted') : t('mainSent'))
6348
6378
  } catch (error) {
6349
6379
  patchCard(card.id, {
package/index.js CHANGED
@@ -45,7 +45,7 @@ export const name = 'dsh-sidecard-ask'
45
45
  export const inject = ['webServer']
46
46
 
47
47
  /** Version of this plugin (kept in step with package.json by test/verify.mjs). */
48
- export const PLUGIN_VERSION = '2.1.0'
48
+ export const PLUGIN_VERSION = '2.1.1'
49
49
 
50
50
  /** Route prefix of the plugin's own API. */
51
51
  export const ROUTE_PREFIX = '/sidecard-ask/api'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-sidecard-ask",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "DSH 划词追问(侧边卡片作答):在聊天区与任务区选中文本就地追问,答案由独立子代理在侧边卡片里流式呈现,也可选择落回主对话。",
5
5
  "type": "module",
6
6
  "main": "index.js",