dsh-plugin-sessiongraph-panel 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/client.js +57 -6
  2. package/package.json +2 -2
package/lib/client.js CHANGED
@@ -5,9 +5,15 @@
5
5
  * CJS factory 包装,靠宿主注入的 require 取 react,不引任何 npm 包(没有构建步骤、也没有
6
6
  * import 语句)。
7
7
  *
8
- * 这一个 tab 只做一件事:在 `sessiongraph` / `kernel` / `both` 之间切换「哪些会话检索工具
9
- * 对模型可见」。数据全走同源 `/dsh-plugin-sessiongraph/api/tools`,无 token、无轮询——
10
- * 值只有用户点「保存」时才会变。
8
+ * 这个 tab 管两件互不相干的事:
9
+ *
10
+ * 1. 在 `sessiongraph` / `kernel` / `both` 之间切换「哪些会话检索工具对模型可见」——存进
11
+ * `panel.json` 后由宿主侧立刻改工具表。
12
+ * 2. 开关「是否把 Codex 的历史会话也纳入索引」——同一个文件里的 `codexSync`,由**索引器**
13
+ * 在下次运行时读取(本包不持有索引器配置,所以这里只写文件、只负责显示)。
14
+ *
15
+ * 数据全走同源 `/dsh-plugin-sessiongraph/api/tools`,无 token、无轮询——值只有用户点「保存」
16
+ * 时才会变。
11
17
  */
12
18
  window.__ModuleLoader__.load({
13
19
  id: "dsh-plugin-sessiongraph-panel",
@@ -62,6 +68,7 @@ window.__ModuleLoader__.load({
62
68
  h1: { margin: 0, fontSize: 14, fontWeight: 600, lineHeight: 1.5, whiteSpace: "nowrap" },
63
69
  hint: { color: C.tertiary, fontSize: 12 },
64
70
  row: { display: "flex", alignItems: "center", gap: 8, flexWrap: "wrap" },
71
+ checkRow: { display: "flex", alignItems: "center", gap: 6, cursor: "pointer" },
65
72
  label: { color: C.secondary, fontSize: 12, whiteSpace: "nowrap" },
66
73
  select: {
67
74
  boxSizing: "border-box",
@@ -154,6 +161,9 @@ window.__ModuleLoader__.load({
154
161
  function SessiongraphSection() {
155
162
  const [toolSet, setToolSet] = React.useState(null);
156
163
  const [draft, setDraft] = React.useState("sessiongraph");
164
+ /** 已保存的 Codex 开关;null 表示还没读到 */
165
+ const [codex, setCodex] = React.useState(null);
166
+ const [codexDraft, setCodexDraft] = React.useState(false);
157
167
  const [available, setAvailable] = React.useState(null);
158
168
  const [error, setError] = React.useState(null);
159
169
  const [notice, setNotice] = React.useState(null);
@@ -184,6 +194,11 @@ window.__ModuleLoader__.load({
184
194
  const current = knownToolSet(data.toolSet) || "sessiongraph";
185
195
  setToolSet(current);
186
196
  setDraft(current);
197
+ // 宿主没给这个字段就当作「跟随插件默认」——索引器的默认是开,所以缺省按 true。
198
+ // 反过来(缺省 false)会让一次只改工具集的保存顺手把 Codex 关掉,那是个静默的数据损失。
199
+ const codexNow = data.codexSync !== false;
200
+ setCodex(codexNow);
201
+ setCodexDraft(codexNow);
187
202
  setLoaded(true);
188
203
  }
189
204
 
@@ -195,7 +210,7 @@ window.__ModuleLoader__.load({
195
210
  const result = await call(API + "/tools", {
196
211
  method: "POST",
197
212
  headers: { "content-type": "application/json" },
198
- body: JSON.stringify({ toolSet: draft }),
213
+ body: JSON.stringify({ toolSet: draft, codexSync: codexDraft }),
199
214
  });
200
215
  setBusy(null);
201
216
  if (!result.ok) {
@@ -204,13 +219,20 @@ window.__ModuleLoader__.load({
204
219
  }
205
220
  const data = result.data || {};
206
221
  const saved = knownToolSet(data.toolSet) || draft;
222
+ const savedCodex = data.codexSync === true;
207
223
  setToolSet(saved);
208
224
  setDraft(saved);
225
+ setCodex(savedCodex);
226
+ setCodexDraft(savedCodex);
209
227
  if (data.available) setAvailable(data.available);
210
- setNotice("已保存:" + saved + "。新值对之后创建的会话立即生效,已在跑的会话在下一步重新读取工具表。");
228
+ setNotice(
229
+ "已保存:工具集 " + saved + ";Codex 历史" + (savedCodex ? "纳入索引" : "不纳入索引") + "。"
230
+ + "工具集对之后创建的会话立即生效,已在跑的会话在下一步重新读取工具表;"
231
+ + "Codex 开关在下次索引运行时生效(下一次自动刷新或手动建索引)。",
232
+ );
211
233
  }
212
234
 
213
- const dirty = loaded && toolSet !== null && draft !== toolSet;
235
+ const dirty = loaded && (draft !== toolSet || codexDraft !== codex);
214
236
 
215
237
  const options = OPTIONS.map((option) =>
216
238
  h("option", { key: option.value, value: option.value }, option.label),
@@ -262,6 +284,34 @@ window.__ModuleLoader__.load({
262
284
  ),
263
285
  );
264
286
 
287
+ const codexBlock = h(
288
+ "div",
289
+ { style: S.block },
290
+ h(
291
+ "label",
292
+ { style: S.checkRow },
293
+ h("input", {
294
+ type: "checkbox",
295
+ checked: codexDraft === true,
296
+ disabled: busy === "save",
297
+ role: "switch",
298
+ "data-sessiongraph-codex": "",
299
+ onChange: (event) => {
300
+ setCodexDraft(event.target.checked === true);
301
+ setNotice(null);
302
+ },
303
+ }),
304
+ h("span", { style: S.label }, "同步 Codex 的历史会话"),
305
+ ),
306
+ h(
307
+ "div",
308
+ { style: S.hint },
309
+ "打开后,~/.codex 下的 rollout 日志会和 DSH 自己的会话一起进索引,"
310
+ + "用 source=codex 可以只看这一侧;关掉后下次索引运行会把这些行删掉。"
311
+ + "这个开关不会动你的 Codex 数据,只决定读不读。",
312
+ ),
313
+ );
314
+
265
315
  const notes = h(
266
316
  "div",
267
317
  { style: S.options },
@@ -280,6 +330,7 @@ window.__ModuleLoader__.load({
280
330
  "div",
281
331
  { style: S.root, "data-sessiongraph-panel": "" },
282
332
  header,
333
+ codexBlock,
283
334
  notes,
284
335
  status ? h("div", { style: S.mono }, status) : null,
285
336
  error ? h("div", { style: S.danger, role: "alert" }, error) : null,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-plugin-sessiongraph-panel",
3
- "version": "0.2.0",
4
- "description": "Settings-page panel for dsh-plugin-sessiongraph: a 会话检索 tab that switches which session-reading tools the model can see (sessiongraph / kernel / both). Browser half only — every value comes from the host's /dsh-plugin-sessiongraph/api/* routes.",
3
+ "version": "0.3.0",
4
+ "description": "Settings-page panel for dsh-plugin-sessiongraph: a 会话检索 tab that switches which session-reading tools the model can see (sessiongraph / kernel / both) and whether Codex's history joins the index. Browser half only — every value comes from the host's /dsh-plugin-sessiongraph/api/* routes.",
5
5
  "keywords": [
6
6
  "dsh",
7
7
  "dsh-plugin",