@kangyishuai/dsh-casefile 0.4.0 → 0.4.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.
Files changed (2) hide show
  1. package/lib/service.js +19 -11
  2. package/package.json +1 -1
package/lib/service.js CHANGED
@@ -93,14 +93,7 @@ export class CasefileService extends TypertRemoteService {
93
93
  /** 会话 → 最近打开的项目(工具省略 projectId 时用)。 @type {Map<string, string>} */
94
94
  this.currentProject = new Map();
95
95
  this.accessWait = null;
96
- this.actions = createActions({
97
- store: this.store,
98
- currentProject: this.currentProject,
99
- dataRoot: this.dataRoot,
100
- onWaitChange: (state) => {
101
- this.accessWait = state;
102
- },
103
- });
96
+ this.actions = createActions(this.actionOptions());
104
97
  this.installSessions();
105
98
  this.installTools();
106
99
  this.logger.info?.(`[casefile] loaded, dataRoot=${this.dataRoot}`);
@@ -125,15 +118,30 @@ export class CasefileService extends TypertRemoteService {
125
118
  /**
126
119
  * 拿到会话服务后重建 actions(builder 需要 create/prompt/wait)。
127
120
  */
121
+ /**
122
+ * createActions 的公共选项(构造函数与 installSessions 必须共用)。
123
+ * @returns {Parameters<typeof createActions>[0]}
124
+ */
125
+ actionOptions() {
126
+ return {
127
+ store: this.store,
128
+ currentProject: this.currentProject,
129
+ dataRoot: this.dataRoot,
130
+ onWaitChange: (/** @type {any} */ state) => {
131
+ this.accessWait = state;
132
+ },
133
+ };
134
+ }
135
+
128
136
  installSessions() {
129
137
  try {
130
138
  this.ctx.inject?.(/** @type {any} */ (["sessionController"]), (/** @type {any} */ scope) => {
131
139
  const controller = scope.sessionController;
132
140
  if (!controller) return;
141
+ // 注意:这里必须和构造函数用同一份选项——漏掉 onWaitChange 会让
142
+ // 等待登录状态永远不生效(实测踩过:await-login 期间 accessState 恒为 false)。
133
143
  this.actions = createActions({
134
- store: this.store,
135
- currentProject: this.currentProject,
136
- dataRoot: this.dataRoot,
144
+ ...this.actionOptions(),
137
145
  sessions: {
138
146
  create: async (input) => {
139
147
  const created = await controller.create({ cwd: input.cwd });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kangyishuai/dsh-casefile",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Evidence-first reverse-engineering workbench on top of REA: observations become citable evidence, a handoff spec pack, and recomputable acceptance checks. No bridge, no engine.",
5
5
  "keywords": [
6
6
  "dsh",