dsh-jira-work-overview 0.16.4 → 0.16.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/CHANGELOG.md CHANGED
@@ -4,6 +4,36 @@ All notable changes to **dsh-jira-work-overview** are documented here.
4
4
 
5
5
  The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). The first 25 releases were built in a single day, so the dates are real but the cadence was not: each entry lists what changed, not how long it took.
6
6
 
7
+ ## [0.16.6] - 2026-11-26
8
+
9
+ ### Changed
10
+
11
+ - **「计划」不再要求项目先绑定工作区。** 以前项目没挂工作区时点「计划」只报一句「项目还没有绑定工作区」,
12
+ 一条会话都不建;现在落点按一条顺序判定:项目已绑定的工作区 → 基座的**默认工作区**
13
+ (`workspaces.initializeDefault()`,与侧栏第一次用时初始化的是同一个),只有连默认工作区都取不到
14
+ (老基座没有工作区服务 / 调用失败)才报错并说明缺什么。host 侧(`createPlanSession`)同样兜底,
15
+ 客户端与 host 的中英文案同步改。
16
+ 为什么不能只删那句报错:DSH 的 `session.create` 在既无 `workspaceId` 又无 `cwd` 时用的是**基座的
17
+ `defaultCwd`**,不是默认工作区,所以两边都必须显式解析出默认工作区的 id。
18
+
19
+ - **README 把「计划」的落点写清楚了。** 中英两份都新增「落在哪个工作区」的判定顺序、两种落点分别长什么样、
20
+ 怎么把已经生成的计划对话挪进项目工作区(先关联、再点 `×` 归档、重新点「计划」),错误表补了
21
+ 「计划会话进了 `default-workspace`」一行;`test/README.md` 的套件说明同步。
22
+
23
+ ## [0.16.5] - 2026-11-24
24
+
25
+ ### Added
26
+
27
+ - **第一次用不再只看到一句失败。** 没配站点地址 / 邮箱 / 令牌时,面板在**原来显示登录失败的位置**
28
+ 直接渲染「连接 Jira」表单(站点地址 + 邮箱 + API token):缺什么填什么,已保存的字段留空沿用;
29
+ 点「保存并连接」会先拿 `/myself` 验一次再写凭据库 / 设置,成功后自动重拉列表,令牌输入框只给
30
+ 掩码提示、永远不回显。旁边保留「去配置」,直达条数 / 监视 / 通知 / 语言这些高级项。
31
+ 只有「配了但连不上」(401 / 网络 / 站点返回异常 / 凭据读不出)才继续走原来的失败提示 + 原始信息。
32
+
33
+ - **README 补了「第一次用」的截图与小节**:图由 `test/dsh-jira-shot.mjs --only panel-connect` 生成
34
+ (`docs/images/panel-connect.png` / `panel-connect.zh.png`),不讲新行为,只把「第一次打开看到什么」画出来;
35
+ 中英两份 README 都加了入口(英文在 `First-run configuration`,中文独立一节「第一次用:面板里直接填」)。
36
+
7
37
  ## [0.16.4] - 2026-11-23
8
38
 
9
39
  ### Fixed
package/README.md CHANGED
@@ -21,6 +21,7 @@ Show **your** Jira work items — with their real workflow status — inside [De
21
21
  - **Live watch** — the host polls "assigned to me and not done" in the background; new assignments / status changes show a **system notification**, an **unread badge** on the sidebar entry, and a "what changed" banner with *mark as read*. The panel refreshes itself when a change arrives.
22
22
  - **Three agent tools** — `jira_my_work`, `jira_issue`, `jira_transition` (preview by default, writes only with `apply: true`).
23
23
  - **One slash command** — `/jira [--json] [--limit=<n>|0] [--lang=<tag>] [--search=<text>] [open|sprint|all | <issue key> | <JQL>]`; it renders in the command surface, so it costs no model tokens.
24
+ - **First run is the form** — with no Jira site, email or token the panel body *is* a **Connect Jira** form (site URL, email, API token) in the exact spot the failure message used to take; fill what is missing and press **Save and connect**. Already-saved fields can be left empty, and **Configure** is still one click away for fetch size, watch, notifications and language.
24
25
  - **Configure dialog** — Jira site / email / API token (token goes to the DSH credential store), fetch size, watch switch + interval, notification switch, UI language, and one-click **open `cordis.patch.yml`** (default app / system "open with" chooser / detected editors / custom app).
25
26
  - **Bilingual UI** — follows the DSH language setting (`设置 → 通用 → 语言`), live; Jira-returned text (summaries, status names, labels) is always shown verbatim.
26
27
 
@@ -37,7 +38,7 @@ Show **your** Jira work items — with their real workflow status — inside [De
37
38
  DSH installs plugins from an **installation spec** — anything `pnpm add` accepts (registry package name, git URL, tarball, absolute path). Pick one:
38
39
 
39
40
  ```bash
40
- # 1) from the npm registry (published since 0.14.0; pin a version with @0.16.0)
41
+ # 1) from the npm registry (published since 0.14.0; pin a version with @0.16.6)
41
42
  plugin_manager install_bundle(target="dsh-jira-work-overview")
42
43
 
43
44
  # 2) straight from GitHub (no npm publishing needed)
@@ -55,7 +56,13 @@ Installing adds `dsh-jira-work-overview` to your profile's bundle list and inser
55
56
 
56
57
  ## First-run configuration
57
58
 
58
- The bundled `cordis.patch.yml` deliberately contains **no site-specific values**, so nothing of the author's Jira account is shipped. Open the panel, click **配置 / Configure** in the panel header, and fill in:
59
+ The bundled `cordis.patch.yml` deliberately contains **no site-specific values**, so nothing of the author's Jira account is shipped.
60
+
61
+ **Nothing configured yet? The panel body *is* the login form.** Site URL, account email and API token show up in the exact spot where a failure hint used to be — fill what is missing and press **Save and connect**. Fields that are already saved may stay empty (the plugin submits only what you changed), and the list loads as soon as Jira accepts the pair.
62
+
63
+ <img src="docs/images/panel-connect.png" width="1040" alt="First run: the panel shows a 'Connect Jira' form with site URL, account email and API token fields plus 'Save and connect' and 'Configure' buttons">
64
+
65
+ Everything else lives in the configure dialog — click **配置 / Configure** in the panel header and fill in:
59
66
 
60
67
  | Field | Example | Required |
61
68
  | --- | --- | --- |
@@ -91,14 +98,16 @@ Prefer files? Add an override row to your profile's `cordis.patch.yml` (this is
91
98
  - Click a **status chip** on any row to move the issue; the list reloads. **Esc** closes the top-most layer (status menu → configure dialog → panel).
92
99
  - The list is **virtualized**: thousands of rows scroll smoothly because only the visible ones are in the DOM.
93
100
  - **Plan at the end of a row** (the `☰ 计划` chip) opens a *planning* conversation for that issue in the
94
- workspace the project is linked to: the new session switches to plan mode, receives the issue key, title, status and link, and is told
101
+ workspace the project is linked to (or in DSH's default Workspace when it is not linked): the new session
102
+ switches to plan mode, receives the issue key, title, status and link, and is told
95
103
  to report **only the list of changes it intends to make** — no explanations, no analysis. You approve or amend
96
104
  the plan in that conversation, and nothing is executed before you do. If the issue is too thin to plan (no
97
105
  description, no parent and no links), the session stops instead of guessing and tells you the Jira issue is
98
106
  unclear. One issue maps to one planning session: once bound the chip is highlighted, clicking it reopens the
99
107
  existing conversation (the binding lives in the volatile `planSessions` config as `ISSUE<TAB>sessionId`, and a
100
- lost binding is recovered from the `JIRA_PLAN_SESSION:<KEY>` marker in the session's first message). The button
101
- reports what is missing when the project has no linked workspace; if the profile ships
108
+ lost binding is recovered from the `JIRA_PLAN_SESSION:<KEY>` marker in the session's first message). Only
109
+ when neither the project mapping nor DSH's default Workspace can be resolved does the button report what is
110
+ missing; if the profile ships
102
111
  `deepseek-ai/dsh-plan-mode`, its `section` is the planning policy, and without it the first message carries a
103
112
  built-in one ("plan only, list the changes, execute once the user agrees").
104
113
  A planned row also carries a `×`: it archives that conversation through DSH's own workspace archive
@@ -106,10 +115,24 @@ Prefer files? Add an override row to your profile's `cordis.patch.yml` (this is
106
115
  unplanned again and the next click starts a fresh session. Archiving keeps the log — a mis-click is
107
116
  recoverable from the archive.
108
117
 
109
- ### Planning: link a workspace, then plan
118
+ ### Planning: click `☰ Plan`
119
+
120
+ The `☰ Plan` chip at the end of a row creates a **planning-mode conversation** for that issue: the new session
121
+ switches to plan mode, receives the issue key / title / status / link, and is told to report **only the list of
122
+ changes it intends to make** — no explanations, no background, no analysis. You approve or amend the plan in
123
+ that conversation, and nothing is executed before you do. If the card is too thin to plan (no summary, no
124
+ description, no parent and no links), the session stops and says the Jira issue is unclear instead of guessing.
110
125
 
111
- The `☰ Plan` chip needs the project to be linked to a workspace first — that is the step first-time users
112
- miss. Four steps, and from then on every card is one click away from a planning conversation:
126
+ **Where the conversation lands** is decided in one place, in this order:
127
+
128
+ 1. the workspace the project is linked to (sidebar → *Link Jira project…*), when there is one;
129
+ 2. otherwise DSH's **default Workspace** — the same one the sidebar initializes on first use — so an unlinked
130
+ project is no longer a dead end.
131
+
132
+ Either way the session appears in the sidebar immediately and the main view switches to it. A planned row
133
+ always reopens its existing conversation rather than creating a second one, so to file it under a project
134
+ workspace: link the project first, archive the old conversation with `×`, then click *Plan* again. Linking a
135
+ workspace to a project is a one-time four-step job:
113
136
 
114
137
  <img src="docs/images/plan-flow.png" width="1040" alt="Four steps: (1) right-click the workspace row and pick 'Link Jira project…', (2) the panel opens by itself — click the dashed project tab to link it, (3) click the '☰ Plan' chip on a row, (4) back in the panel the chip turns blue and hovering the row shows a ×">
115
138
 
@@ -120,9 +143,10 @@ miss. Four steps, and from then on every card is one click away from a planning
120
143
  to the current workspace." Candidate tabs carry a **dashed** outline — click one to link it; the header then
121
144
  reads "This workspace is linked to APP". Candidates appear only after the panel has fetched issues once, so
122
145
  hit *Refresh* if there are none.
123
- 3. **Click the `☰ Plan` chip at the end of a row**: creates a planning-mode session in that project's workspace.
124
- The first message only asks for a bullet list of the edits to make, and you agree to it in the conversation.
125
- `deepseek-ai/dsh-plan-mode` is optional — a built-in policy is used when it is absent.
146
+ 3. **Click the `☰ Plan` chip at the end of a row**: creates a planning-mode session in that project's
147
+ workspace — or in DSH's default Workspace when the project is not linked. The first message only asks for a
148
+ bullet list of the edits to make, and you agree to it in the conversation. `deepseek-ai/dsh-plan-mode` is
149
+ optional — a built-in policy is used when it is absent.
126
150
  4. **Back in the panel**: the chip turns blue (`on`) = planned. Hovering the row reveals a `×` that archives the
127
151
  session and clears the binding (recoverable from the archive).
128
152
 
@@ -134,8 +158,9 @@ The real panel, for comparison (the two planned rows near the top are outlined):
134
158
 
135
159
  | What you see | Why | What to do |
136
160
  | --- | --- | --- |
137
- | `Project APP is not linked to a workspace: link it from the sidebar first.` | The project is not linked to any workspace (or the mapping was lost) | Redo steps 1–2 above |
161
+ | `Project APP is not linked to a workspace and no default Workspace could be resolved: link it from the sidebar first.` | Neither the project mapping nor DSH's default Workspace could be resolved (workspace service unavailable / older DSH build) | Redo steps 1–2 above, or install a DSH build that provides the workspace service |
138
162
  | No candidate tabs / `No projects to link yet: open the panel once so the project list loads.` | The panel has never fetched issues successfully | Hit *Refresh*; if it still fails, set the site / email / token first |
163
+ | The planning conversation sits under *default-workspace*, not the project workspace | The project was not linked to a workspace when you clicked *Plan*, so it fell back to DSH's default Workspace | Link the project, archive the row with `×`, then click *Plan* again |
139
164
  | The workspace context menu has no *Link Jira project…* | The client half of the plugin did not register (the host row can still read active) | Reinstall the bundle and reload the page |
140
165
  | The chip stays grey and does nothing | The previous session creation has not returned yet | Wait for it; a failure shows `Could not create the planning session: …` |
141
166
  | It always reopens the same conversation | One issue maps to one planning session (by design) | Click `×` to archive it, then click *Plan* again |
@@ -234,7 +259,7 @@ The plugin's own copy follows the DSH language setting; English and Chinese ship
234
259
  | configure dialog says "Reading the token state failed: HTTP 404" | the plugin's `/api` routes were not registered (the host loaded the plugin before its connection service existed) — reload the plugin; a fixed build registers them once the service is up |
235
260
  | footer says "live watch disconnected" | transient transport error; it retries with backoff |
236
261
  | token rejected when saving | the email + token pair is wrong, or the token has no Jira access |
237
- | panel says "No Jira token yet" | nothing is configured yet: click **Configure** and paste an API token (or set `JIRA_API_TOKEN`) |
262
+ | panel body is a **Connect Jira** form | nothing is configured yet: fill site URL / email / API token and press **Save and connect** (a saved field can stay empty); the form sits where the failure hint used to be, and the token still goes straight to the DSH credential store |
238
263
  | panel says "Jira rejected this email / token pair" | 401/403 from Jira: regenerate the token; the raw response is under the hint |
239
264
  | panel says "Could not read the stored token" | the credential store returned an error rather than a value: save the token again from **Configure** |
240
265
 
@@ -242,7 +267,7 @@ Behind a corporate proxy on Windows, DSH needs the proxy env vars it was started
242
267
 
243
268
  ## Versions and upgrades
244
269
 
245
- The current version is **0.16.0** (2026-11-20). The changelog records 30 versions (from 0.1.0); GitHub carries **9 tags / releases** (0.13.0 → 0.16.0), and **0.13.4 was the first public release** — the earlier 0.1.0–0.12.0 exist only in `CHANGELOG.md` and the project notes, with no commit or tag behind them, so "an older version" means **0.13.0 or later**. Every release is described in [CHANGELOG.md](CHANGELOG.md).
270
+ The current version is **0.16.6** (2026-11-26). The changelog records 40 versions (from 0.1.0); GitHub carries **15 tags / releases** (0.13.0 → 0.16.6), and **0.13.4 was the first public release** — the earlier 0.1.0–0.12.0 exist only in `CHANGELOG.md` and the project notes, with no commit or tag behind them, so "an older version" means **0.13.0 or later**. Every release is described in [CHANGELOG.md](CHANGELOG.md).
246
271
 
247
272
  ### Why people still install older versions
248
273
 
@@ -277,11 +302,13 @@ The current version is **0.16.0** (2026-11-20). The changelog records 30 version
277
302
  | 0.14.0 | 2026-11-19 | feature | highlight follows **Jira's own priority order**; **first npm release** |
278
303
  | 0.15.0 | 2026-11-19 | feature | transitions update **in place**, your own changes no longer notify you, typed failure hints |
279
304
  | 0.15.1 | 2026-11-19 | **fix** | the four `/api` routes were never registered in a real host (404) |
280
- | 0.16.4 | 2026-11-23 | **fix** | on a fresh profile, filling email + token + site URL and clicking only **Save & verify** left the URL unsaved, so the panel always said there was no site URL; the panel now also reloads automatically after a successful save |
281
- | 0.16.3 | 2026-11-23 | **fix** | the Jira site URL is now an editable field in the config page (placeholder = current URL, saved to the profile Cordis patch); the failure hint's **Configure** button matches **Save and verify** |
282
- | 0.16.2 | 2026-11-23 | **fix** | the workspace context menu's **Link Jira project…** could vanish for a whole page (client startup race); covered by a new offline suite |
283
- | 0.16.1 | 2026-11-22 | fix | Windows notifications and *Show in file manager*, the Linux editor picker, UNC patch paths; three-OS CI and the release preflight; a planning walkthrough in both READMEs |
284
305
  | 0.16.0 | 2026-11-20 | feature | **site-wide search**, **group by epic**, the **计划** (plan) button on every row |
306
+ | 0.16.1 | 2026-11-22 | fix | Windows notifications and *Show in file manager*, the Linux editor picker, UNC patch paths; three-OS CI and the release preflight; a planning walkthrough in both READMEs |
307
+ | 0.16.2 | 2026-11-23 | **fix** | the workspace context menu's **Link Jira project…** could vanish for a whole page (client startup race); covered by a new offline suite |
308
+ | 0.16.3 | 2026-11-23 | **fix** | the Jira site URL is now an editable field in the config page (placeholder = current URL, saved to the profile Cordis patch); the failure hint's **Configure** button matches **Save and verify** |
309
+ | 0.16.4 | 2026-11-23 | **fix** | on a fresh profile, filling email + token + site URL and clicking only **Save & verify** left the URL unsaved, so the panel always said there was no site URL; the panel now also reloads automatically after a successful save |
310
+ | 0.16.5 | 2026-11-24 | feature | **nothing configured shows a form, not an error**: the panel body is the Connect Jira form (site URL / email / API token) in the old failure slot, saved fields can stay empty, and the list reloads once Jira accepts the pair |
311
+ | 0.16.6 | 2026-11-26 | feature | **`☰ Plan` works on an unlinked project too**: the planning conversation lands in the project's workspace when there is one and in DSH's default Workspace otherwise (resolved through `workspaces.initializeDefault()` client-side and `workspaceController.initializeDefault()` host-side); only when neither resolves does it fail, with copy that says so |
285
312
 
286
313
  > 0.1.0–0.12.0 all happened on 2026-11-18; tags and GitHub Releases start at 0.13.0.
287
314
  > To install an older version: `plugin_manager install_bundle(target="github:EagleSoap/dsh-jira-work-overview#v0.13.2")`, or pin the npm version with `target="dsh-jira-work-overview@0.14.0"` (the earliest version on npm is 0.14.0).
@@ -339,7 +366,7 @@ Every user-visible defect, newest first (implementation detail is in the matchin
339
366
 
340
367
  1. **No sidebar entry**, or `plugin_manager` says `active` while the UI is empty → upgrade to **0.13.2 or later** and refresh.
341
368
  2. The configure dialog reports **HTTP 404** / the badge never updates → upgrade to **0.15.1 or later**.
342
- 3. The panel says there is no token / the token was rejected / it cannot read it → use **Configure** in the hint (or at the right of the panel title); you never have to edit the profile file.
369
+ 3. **Nothing is configured yet** → the panel body is a **Connect Jira** form (site URL, email, API token); fill what is missing and press **Save and connect**. A rejected token / unreadable credential keeps the failure hint: use **Configure** there (or at the right of the panel title); you never have to edit the profile file.
343
370
  4. A raw error from `/jira` in text mode is **on purpose** — the command surface should show the real reason; the panel uses the typed `--json` hints instead.
344
371
 
345
372
  ## Security and privacy
package/README.zh.md CHANGED
@@ -21,7 +21,7 @@
21
21
  DSH 用**安装 spec** 装插件 —— 凡是 `pnpm add` 能吃的写法都行(registry 包名、git 地址、tarball、绝对路径)。选一个:
22
22
 
23
23
  ```bash
24
- # 1) 从 npm 装(0.14.0 起已发布;要钉版本就在后面写 @0.16.0)
24
+ # 1) 从 npm 装(0.14.0 起已发布;要钉版本就在后面写 @0.16.6)
25
25
  plugin_manager install_bundle(target="dsh-jira-work-overview")
26
26
 
27
27
  # 2) 直接从 GitHub 装(不需要 npm 发布)
@@ -97,20 +97,30 @@ all : assignee = currentUser() ORDER BY updated DESC
97
97
  不会出现「慢请求晚到、把新列表盖回旧范围」的闪烁;等待期间旧列表留在原位并压暗到 55%(`.jmw-body.pending`),
98
98
  新数据到达时原子替换。注意 `abort()` 只能中断「等结果」,Host 侧已经发出的 Jira 查询无法撤回。
99
99
 
100
- ### 计划会话:绑定工作区 → 点「计划」→ 敲定计划
100
+ ### 计划会话:点「计划」→ 敲定计划
101
101
 
102
- **任务行末尾的「计划」按钮**:在**该项目绑定的工作区**里新建一条会话,先用 plan 模式做任务规划,
103
- 再由你在对话里敲定或修改。第一条消息只要求它「按点列出将要执行的修改任务」,不写解释、背景或分析;
104
- 计划由你确认后才执行。这张卡信息不全(没标题 / 没描述 / 没父任务与关联)时,它会**中断**并提示
105
- 「Jira 任务不明确,无法进行任务」,同时列出缺什么,不会硬猜着往下做。
102
+ **任务行末尾的「计划」按钮**会为这张卡新建一条 **plan 模式会话**:新会话切到 plan 模式,收到任务键、
103
+ 标题、状态与链接,只被要求「按点列出将要执行的修改任务」——不写解释、背景或分析。计划由你在对话里敲定
104
+ 或修改,确认之前它不会执行任何东西。这张卡信息不全(没标题 / 没描述 / 没父任务与关联)时,它会**中断**
105
+ 并提示「Jira 任务不明确,无法进行任务」,同时列出缺什么,不会硬猜着往下做。
106
+
107
+ **落在哪个工作区**只有一条判定顺序:
108
+
109
+ 1. 项目已经绑定的工作区(左侧栏工作区那一行右键 →「关联 Jira 项目…」);
110
+ 2. 没绑(第一次用 / 映射丢了)就落在 DSH 的**默认工作区**——与侧栏第一次用时初始化的是同一个,
111
+ 不会因为「还没关联」就把按钮堵死。
112
+
113
+ 两种情况新建的会话都会立刻出现在左侧栏、并当场切到主视图。一条任务**只对应一条**计划对话:已计划的行
114
+ 再点只打开原来那条,所以想把计划会话挪进项目工作区,先关联项目,再点 `×` 归档旧的那条、重新点「计划」。
115
+ 关联一次只要四步(图解见下)。
116
+
117
+ #### 一条任务一条对话
106
118
 
107
119
  建会话用的是 DSH 自己的会话服务(`sessions.create`),所以新会话会立刻出现在侧栏、并当场切到主视图;
108
120
  `/plan` 与首条消息都按聊天框同一条路发(命令先、消息后),计划对话里的节奏和你在聊天框里开一条新会话一样。
109
- 一条任务**只对应一条**计划对话:已经计划过的任务按钮标成 `on`,再点只打开原来那条,不会又开一条。
110
121
  绑定存在插件的 volatile 配置 `planSessions` 里(一行一条 `ISSUE<TAB>sessionId`);即使换了浏览器、
111
122
  清过配置,HOST 也会按计划对话首条消息里的 `JIRA_PLAN_SESSION:<KEY>` 标记翻会话日志把它找回来。
112
- 项目没绑工作区(工作区右键 →「关联 Jira 项目…」)时,按钮会直接提示原因,不会建出半成品会话;
113
- 第一次用请照下面「四步操作」走一遍。
123
+ 只有连默认工作区都取不到(老基座没有工作区服务)时才报错,不会建出半成品会话。
114
124
  profile 里装了 `deepseek-ai/dsh-plan-mode` 就用它的 `section` 当规划口径;没装也不影响使用——
115
125
  首条消息会自带一份「只做规划、只列修改任务、敲定后再执行」的兜底口径。
116
126
 
@@ -118,8 +128,8 @@ profile 里装了 `deepseek-ai/dsh-plan-mode` 就用它的 `section` 当规划
118
128
  (依次尝试 `remote.workspace.archiveSession` / 工作区注册表 `workspaceRegistry.archiveSession` / `connection.call('workspace/archiveSession')`,与侧栏右键「归档」是同一处状态)把那条会话收进归档区,同时清掉绑定;
119
129
  归档后这一行回到未计划状态,再点「计划」是新建一条。归档不删日志,误删可以从归档区恢复。
120
130
 
121
- **四步操作(图解)**:入口是任务行末尾的「☰ 计划」,但它要求**这个项目已经挂在一个工作区**上——第一次用的人多半卡在这一步。
122
- 四步走完,之后每张卡都能一键开计划对话:
131
+ **四步操作(图解)**:入口是任务行末尾的「☰ 计划」;想让计划对话落进某个项目的工作区,就先关联一次
132
+ (不关联也能用,落在默认工作区)。四步走完,之后每张卡都能一键开计划对话:
123
133
 
124
134
  <img src="docs/images/plan-flow.zh.png" width="1040" alt="四步图解:① 左侧栏工作区右键选「关联 Jira 项目…」② 面板自动打开,点带虚线框的项目 tab 完成关联 ③ 任务行末尾点「☰ 计划」④ 回到面板按钮变蓝=已计划,行尾出现 ×">
125
135
 
@@ -128,7 +138,7 @@ profile 里装了 `deepseek-ai/dsh-plan-mode` 就用它的 `section` 当规划
128
138
  2. **点项目 tab 完成关联**:菜单点完面板会自动打开,顶部提示「点上面的项目 tab,把它关联到当前工作区。」,
129
139
  候选 tab 带**虚线框**,点哪个就把哪个挂上去;成功后面板顶部变成「当前工作区已关联 APP」。
130
140
  候选 tab 要等面板至少拉到过一次 issue 才会出现——一个候选都没有时先点「刷新」。
131
- 3. **点任务行末尾的「☰ 计划」**:在该项目绑定的工作区里新建一条 plan 模式会话,
141
+ 3. **点任务行末尾的「☰ 计划」**:在该项目绑定的工作区里(没绑定就落在默认工作区)新建一条 plan 模式会话,
132
142
  首条消息只要求它「按点列出将要执行的修改任务」,由你在对话里敲定;没装 `deepseek-ai/dsh-plan-mode`
133
143
  也能用(首条消息自带兜底口径)。
134
144
  4. **回到面板看状态**:这一行的按钮变蓝(`on`)=已计划;鼠标移到行上,按钮旁出现 `×`,
@@ -142,8 +152,9 @@ profile 里装了 `deepseek-ai/dsh-plan-mode` 就用它的 `section` 当规划
142
152
 
143
153
  | 看到什么 | 原因 | 怎么办 |
144
154
  | --- | --- | --- |
145
- | `项目 APP 还没有绑定工作区:先在左侧侧栏里把项目挂到工作区。` | 这个项目还没挂到工作区(或映射丢了) | 按上面第 1–2 步重新关联 |
155
+ | `项目 APP 没有绑定工作区,也取不到基座的默认工作区:先在左侧侧栏里把项目挂到工作区。` | 项目映射与基座的默认工作区都取不到(工作区服务不可用 / 老版本基座) | 按上面第 1–2 步重新关联,或升级到提供工作区服务的 DSH 版本 |
146
156
  | 一个候选 tab 都没有 / `没有可关联的项目:面板里先拉到过 issue 才会出现项目候选。` | 面板还没成功拉到过数据 | 先点「刷新」,必要时先在配置里补站点 / 邮箱 / 令牌 |
157
+ | 计划会话进了 `default-workspace`,不在项目工作区里 | 点「计划」时这个项目还没绑定工作区,落到了 DSH 的默认工作区 | 先关联项目,再点 `×` 归档这条,重新点「计划」 |
147
158
  | 工作区右键菜单里没有「关联 Jira 项目…」 | 客户端的插件模块没注册上(host 行显示 active 也可能如此) | 重新装插件包并刷新页面 |
148
159
  | 按钮一直是灰的,点不动 | 上一次建会话还没返回 | 等它结束;失败会显示 `创建计划对话失败:…` |
149
160
  | 打开的总是同一条对话 | 一个任务只对应一条计划对话(设计如此) | 想重开就先点 `×` 归档,再点「计划」 |
@@ -186,7 +197,11 @@ profile 里装了 `deepseek-ai/dsh-plan-mode` 就用它的 `section` 当规划
186
197
  组头的未完成数与筛选菜单都在本地重算,不再为改一个状态把几百条 issue 重新拉一遍;只有在当前列表里找不到这条时才回退整表刷新);
187
198
  失败(例如某个流转要求必填字段)把 Jira 的报错原样显示在下拉里,不静默吞掉。
188
199
 
189
- - **失败会说人话**:没配令牌 / 站点地址、凭据读不出来、令牌过期(401)、网络不通、站点返回非 JSON,
200
+ - **第一次用就是那张表单**:没配站点地址 / 邮箱 / 令牌时,面板在**原来显示失败提示的位置**直接给出
201
+ 「连接 Jira」表单(站点地址 + 邮箱 + API token),缺什么填什么,点「保存并连接」当场拉列表;
202
+ 已经保存过的字段可以留空沿用,令牌照旧只进 DSH 凭据库、提交前先用 `/myself` 验一次。
203
+ 旁边的「去配置」仍然直达完整配置弹窗(条数 / 监视 / 通知 / 语言)。
204
+ - **失败会说人话**:凭据读不出来、令牌过期(401)、网络不通、站点返回非 JSON,
190
205
  面板不再把 Host 的原始报错糊在列表位置,而是标题 + 一句「怎么办」:`去配置` 直接打开令牌弹窗、
191
206
  `重试` 重新查询;只有需要看原文的那几类(认证失败 / 网络 / 站点错误)才把原始信息以小字附在下面。
192
207
  错误类型来自 `--json` 载荷里的 `error.code`(`no_credential` / `credential_unreadable` / `no_email` /
@@ -282,6 +297,15 @@ Jira Cloud **没有**给第三方 issue 事件的 websocket / SSE 长连接(
282
297
  > 如果你更希望“毫秒级实时”,正路只有两条:让 Jira 管理员配 webhook + 内网穿透(需要公网地址),
283
298
  > 或者用 DSH 的定时任务让 agent 定时来问(每次都要跑模型,比本机轮询贵得多)。
284
299
 
300
+ ## 第一次用:面板里直接填(连接表单)
301
+
302
+ 还没配站点地址 / 邮箱 / 令牌时,打开面板看到的不是一句失败提示,而是**直接可填的「连接 Jira」表单**
303
+ (服务地址 + 账号邮箱 + API token),就占在原来失败提示的位置:缺什么填什么,点「保存并连接」当场拉列表。
304
+ 已经保存过的字段可以留空沿用(只提交你改过的值);令牌只进 DSH 凭据库,提交前先用 `/myself` 验一次,
305
+ 不然不写入。旁边的「去配置」直达完整配置弹窗(条数 / 监视 / 通知 / 语言这些高级项)。
306
+
307
+ <img src="docs/images/panel-connect.zh.png" width="1040" alt="第一次用:面板里直接是「连接 Jira」表单,含服务地址 / 账号邮箱 / API token 三个输入框与「保存并连接」「去配置」按钮">
308
+
285
309
  ## 换令牌(插件配置页)
286
310
 
287
311
  **入口(三个,内容一样)**:
@@ -496,7 +520,7 @@ Zed(`zed`)、Sublime Text(`subl`)、gedit(`gedit`)——**找到可
496
520
 
497
521
  ## 版本与升级
498
522
 
499
- 当前版本 **0.16.0**(2026-11-20)。`CHANGELOG.md` 记了 30 个版本(0.1.0 起),GitHub 上有 **9 个 tag / Release**(0.13.0 → 0.16.0),**0.13.4 是第一个公开版本**——更早的 0.1.0–0.12.0 只存在于 `CHANGELOG.md` 与项目记录里,没有对应的提交与 tag,所以「以前的版本」= **0.13.0 及以后**。逐版的完整说明见 [CHANGELOG.md](CHANGELOG.md)。
523
+ 当前版本 **0.16.6**(2026-11-26)。`CHANGELOG.md` 记了 40 个版本(0.1.0 起),GitHub 上有 **15 个 tag / Release**(0.13.0 → 0.16.6),**0.13.4 是第一个公开版本**——更早的 0.1.0–0.12.0 只存在于 `CHANGELOG.md` 与项目记录里,没有对应的提交与 tag,所以「以前的版本」= **0.13.0 及以后**。逐版的完整说明见 [CHANGELOG.md](CHANGELOG.md)。
500
524
 
501
525
  ### 为什么有人还在装以前的版本
502
526
 
@@ -531,11 +555,13 @@ Zed(`zed`)、Sublime Text(`subl`)、gedit(`gedit`)——**找到可
531
555
  | 0.14.0 | 2026-11-19 | 功能 | 高亮挂到 **Jira 自己的优先级名次**;**首次发布到 npm** |
532
556
  | 0.15.0 | 2026-11-19 | 功能 | 改状态**不再全量重拉**、自己改的状态不再通知自己、失败提示按类型 |
533
557
  | 0.15.1 | 2026-11-19 | **修复** | 四条 `/api` 路由在真宿主里没注册(404) |
534
- | 0.16.4 | 2026-11-23 | **修复** | 全新 profile 上把邮箱、令牌、站点地址一起填好、只点「保存并验证」时地址没落盘,面板一直说没配站点地址;配置保存成功后还会自动重拉列表 |
535
- | 0.16.3 | 2026-11-23 | **修复** | 配置页「Jira 连接」的服务地址改成可编辑输入框(placeholder = 当前地址,写进 profile 的 Cordis patch);失败提示里的「去配置」按钮和「保存并验证」同款样式 |
536
- | 0.16.2 | 2026-11-23 | **修复** | 左栏工作区右键菜单的「关联 Jira 项目…」会整页消失(客户端启动竞态);新增离线套件守住 |
537
- | 0.16.1 | 2026-11-22 | 修复 | Windows 通知与「在文件管理器中显示」、Linux 编辑器直选、UNC 路径;三平台 CI 与发版预检;README 补计划会话图解 |
538
558
  | 0.16.0 | 2026-11-20 | 功能 | **整站搜索**、**按 epic 分组**、任务行**「计划」**(plan 模式会话) |
559
+ | 0.16.1 | 2026-11-22 | 修复 | Windows 通知与「在文件管理器中显示」、Linux 编辑器直选、UNC 路径;三平台 CI 与发版预检;README 补计划会话图解 |
560
+ | 0.16.2 | 2026-11-23 | **修复** | 左栏工作区右键菜单的「关联 Jira 项目…」会整页消失(客户端启动竞态);新增离线套件守住 |
561
+ | 0.16.3 | 2026-11-23 | **修复** | 配置页「Jira 连接」的服务地址改成可编辑输入框(placeholder = 当前地址,写进 profile 的 Cordis patch);失败提示里的「去配置」按钮和「保存并验证」同款样式 |
562
+ | 0.16.4 | 2026-11-23 | **修复** | 全新 profile 上把邮箱、令牌、站点地址一起填好、只点「保存并验证」时地址没落盘,面板一直说没配站点地址;配置保存成功后还会自动重拉列表 |
563
+ | 0.16.5 | 2026-11-24 | 功能 | **没配置时给的是表单而不是报错**:面板直接把「连接 Jira」表单(服务地址 / 邮箱 / API token)放在原来的失败位置,已保存的字段可留空,连接成功即重拉列表 |
564
+ | 0.16.6 | 2026-11-26 | 功能 | **项目没绑工作区也能点「计划」**:绑了建在项目的工作区,没绑落到 DSH 的默认工作区(client 走 `workspaces.initializeDefault()`、host 走 `workspaceController.initializeDefault()`),只有两者都取不到才报错,文案也写明是「也取不到默认工作区」 |
539
565
 
540
566
  > 0.1.0–0.12.0 这 15 个版本都发生在 2026-11-18 同一天;0.13.0 起才有 tag 与 Release。
541
567
  > 想装某个旧版本:`plugin_manager install_bundle(target="github:EagleSoap/dsh-jira-work-overview#v0.13.2")`,或从 npm 钉版本 `target="dsh-jira-work-overview@0.14.0"`(npm 上最早的版本是 0.14.0)。
@@ -594,7 +620,7 @@ plugin_manager install_bundle(target="dsh-jira-work-overview") # 已装过则
594
620
 
595
621
  1. 左侧栏**没有入口**、或 `plugin_manager` 显示 `active` 但界面是空的 → 先升级到 **0.13.2 以上**并刷新页面。
596
622
  2. 配置页报 **HTTP 404**、角标不更新 → 升到 **0.15.1 以上**。
597
- 3. 面板提示「没有令牌 / 令牌被拒 / 读不出令牌」→ 点提示里的「去配置」(或面板标题右侧「配置」)重填;**不用改 profile 文件**。
623
+ 3. **什么都还没配** → 面板里就是「连接 Jira」表单(站点地址 / 邮箱 / API token),缺什么填什么、点「保存并连接」。令牌被拒 / 读不出令牌仍是失败提示:点提示里的「去配置」(或面板标题右侧「配置」)重填;**不用改 profile 文件**。
598
624
  4. `/jira` 文本模式返回 `kind:'error'` 的原始报错是**故意的**——命令面本来就该看到真实原因;面板专用的是 `--json` 的分类型提示。
599
625
 
600
626
  ## 测试(`test/`)
package/client.js CHANGED
@@ -93,6 +93,13 @@ window.__ModuleLoader__.load({
93
93
  return Object.prototype.hasOwnProperty.call(FAILURES, code) ? FAILURES[code] : FAILURES.unknown;
94
94
  }
95
95
 
96
+ /**
97
+ * 这几个 code 说的是「还没配好」,不是「配了但连不上」:面板把同一块位置直接换成
98
+ * 「连接 Jira」表单(站点地址 + 邮箱 + 令牌),用户当场填完就拉列表,不用先看一句失败提示
99
+ * 再自己去找配置入口。其它 code(auth / network / http…)仍走 FAILURES 的提示。
100
+ */
101
+ const CONNECT_CODES = new Set(['no_base_url', 'no_email', 'no_credential']);
102
+
96
103
  /** 条数语义的客户端归一化(与 host 侧 index.js 的 normalizeLimit 同步):
97
104
  * **0 = 不限制**,正数 clamp 到 10–5000,其它(非法 / 负数)回落到 fallback。 */
98
105
  function normalizeLimit(value, fallback = LIMIT_DEFAULT) {
@@ -189,6 +196,15 @@ window.__ModuleLoader__.load({
189
196
  failUnknownHint: '这次失败没有可归类的类型,原始信息见下方。',
190
197
  failOpenConfig: '去配置',
191
198
  failDetail: '原始信息:{message}',
199
+ // 没配站点 / 邮箱 / 令牌时,失败位置直接换成这张连接表单(三个字段都能留空沿用已保存值)。
200
+ connectTitle: '连接 Jira',
201
+ connectHint: '填上 Jira 服务地址、账号邮箱和 API token 就能拉取任务列表;已经保存过的字段可以留空沿用。',
202
+ connectTokenLabel: 'API token',
203
+ connectTokenPlaceholder: '粘贴 Jira API token',
204
+ connectTokenKeep: '已保存 {masked},留空沿用',
205
+ connectSubmit: '保存并连接',
206
+ connectSaving: '连接中…',
207
+ connectFailed: '连接失败:{message}',
192
208
  untitled: '(无摘要)',
193
209
  parent: '父 {key}',
194
210
  watch: '实时监视中',
@@ -308,7 +324,7 @@ window.__ModuleLoader__.load({
308
324
  planDropped: '{key} 的计划对话已删除',
309
325
  planDropFailed: '删除计划对话失败:{message}',
310
326
  planBusy: '该任务正在建计划对话…',
311
- planNoWorkspace: '项目 {project} 还没有绑定工作区:先在左侧侧栏里把项目挂到工作区。',
327
+ planNoWorkspace: '项目 {project} 没有绑定工作区,也取不到基座的默认工作区:先在左侧侧栏里把项目挂到工作区。',
312
328
  planFailed: '创建计划对话失败:{message}',
313
329
  planCreated: '{key} 的计划对话已创建(plan 模式)',
314
330
  planOpened: '已打开 {key} 的计划对话',
@@ -328,7 +344,7 @@ window.__ModuleLoader__.load({
328
344
  planDropped: 'Deleted the planning session for {key}',
329
345
  planDropFailed: 'Could not delete the planning session: {message}',
330
346
  planBusy: 'Creating the planning session…',
331
- planNoWorkspace: 'Project {project} is not linked to a workspace: link it from the sidebar first.',
347
+ planNoWorkspace: 'Project {project} is not linked to a workspace and no default Workspace could be resolved: link it from the sidebar first.',
332
348
  planFailed: 'Could not create the planning session: {message}',
333
349
  planCreated: 'Planning session for {key} created (plan mode)',
334
350
  planOpened: 'Opened the planning session for {key}',
@@ -425,6 +441,16 @@ window.__ModuleLoader__.load({
425
441
  failUnknownHint: 'This failure has no known type; the raw message is below.',
426
442
  failOpenConfig: 'Configure',
427
443
  failDetail: 'Raw message: {message}',
444
+ // Unconfigured site / email / token: the failure slot renders this connect form instead
445
+ // (all three fields can be left empty to keep the saved value).
446
+ connectTitle: 'Connect Jira',
447
+ connectHint: 'Enter your Jira base URL, account email and API token to load your work; leave a saved field empty to keep it.',
448
+ connectTokenLabel: 'API token',
449
+ connectTokenPlaceholder: 'Paste a Jira API token',
450
+ connectTokenKeep: 'Saved {masked} — leave empty to keep it',
451
+ connectSubmit: 'Save and connect',
452
+ connectSaving: 'Connecting…',
453
+ connectFailed: 'Connection failed: {message}',
428
454
  untitled: '(no summary)',
429
455
  parent: 'parent {key}',
430
456
  watch: 'Live watch on',
@@ -1128,7 +1154,10 @@ window.__ModuleLoader__.load({
1128
1154
 
1129
1155
  /* ------------------------------------------------ 任务 → 计划对话 */
1130
1156
  //
1131
- // 任务行后面的「计划」按钮:在项目绑定的工作区里开一个 plan 模式会话,让它先做任务规划。
1157
+ // 任务行后面的「计划」按钮:开一个 plan 模式会话,让它先做任务规划。
1158
+ // 落在哪个工作区:项目绑了工作区就建在那个工作区里;没绑(第一次用 / 映射丢了)就建在
1159
+ // 基座的**默认工作区**里(`workspaces.initializeDefault()`:与侧栏第一次用时建的是同一个),
1160
+ // 不再直接报错——按钮不该因为「还没关联」就什么都做不了。
1132
1161
  // 一个任务只对应一个计划对话(避免重复点出好几条):绑定记在 host 的 volatile 配置
1133
1162
  // planSessions 里(一行一条 `ISSUE<TAB>sessionId`),和「项目 ↔ 工作区」同一个套路——
1134
1163
  // 前端只读写、不另存。重复点击时直接打开原来那条,不再新建;本地没记(比如换了浏览器)
@@ -1237,6 +1266,34 @@ window.__ModuleLoader__.load({
1237
1266
  return '';
1238
1267
  }
1239
1268
 
1269
+ /**
1270
+ * 项目没绑工作区时的落点:基座的「默认工作区」。
1271
+ *
1272
+ * 走客户端常驻的 `workspaces` 服务(不是 `remote.workspace`:面板没在 inject 里声明遥控,
1273
+ * 硬取会抛 `cannot get property "remote.workspace" without inject`):`initializeDefault()`
1274
+ * 已经初始化过就直接返回那条,没有才按基座的目录策略建一个——与侧栏第一次用时的默认工作区
1275
+ * 是同一个,之后会话自动归到它下面。服务缺席(老基座)或调用失败时返回空串,由调用方报错。
1276
+ */
1277
+ async function defaultWorkspaceId() {
1278
+ const ctx = runtime.ctx;
1279
+ if (!ctx || typeof ctx.get !== 'function') return '';
1280
+ let workspaces;
1281
+ try {
1282
+ workspaces = ctx.get('workspaces');
1283
+ } catch {
1284
+ return '';
1285
+ }
1286
+ if (!workspaces || typeof workspaces.initializeDefault !== 'function') return '';
1287
+ try {
1288
+ const result = await workspaces.initializeDefault();
1289
+ if (result && result.ok === false) return '';
1290
+ const workspace = result?.value?.workspace ?? result?.workspace ?? result?.value ?? result;
1291
+ return String(workspace?.workspaceId ?? workspace?.id ?? '');
1292
+ } catch {
1293
+ return '';
1294
+ }
1295
+ }
1296
+
1240
1297
  /** 让新建的计划对话出现在主视图:uiWorkspace 是官方的换主视图接口。 */
1241
1298
  function openPlanSession(sessionId) {
1242
1299
  const ctx = runtime.ctx;
@@ -1323,7 +1380,8 @@ window.__ModuleLoader__.load({
1323
1380
  try {
1324
1381
  await fetchWorkspaceLinks();
1325
1382
  const project = projectOfKey(key);
1326
- const workspaceId = boundWorkspaceOf(project);
1383
+ // 绑定了就建在项目的工作区里;没绑定落默认工作区(取不到才报错)。
1384
+ const workspaceId = boundWorkspaceOf(project) || await defaultWorkspaceId();
1327
1385
  if (!workspaceId) throw new Error(t('planNoWorkspace', { project }));
1328
1386
  // 计划口径:profile 装了 plan 模式插件就用它的 section;没装时由首条消息自己带一份
1329
1387
  // (NO_POLICY_POLICY),不因为「宿主没配」就拒绝开对话。
@@ -1893,6 +1951,13 @@ window.__ModuleLoader__.load({
1893
1951
  .jmw-failure-actions{display:flex;justify-content:center;gap:8px}
1894
1952
  .jmw-failure-detail{max-width:360px;margin:14px auto 0;font-size:11px;line-height:1.5;
1895
1953
  color:var(--dsw-alias-label-tertiary,#8a8f99);white-space:pre-wrap;word-break:break-word}
1954
+ /* 还没配置时的内联「连接 Jira」表单:占的正是原来失败提示的位置,左对齐、字段竖排。 */
1955
+ .jmw-connect{max-width:420px;margin:0 auto;padding:26px 18px;text-align:left}
1956
+ .jmw-connect-title{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary,#1b1d22);margin-bottom:4px}
1957
+ .jmw-connect-hint{margin:0 0 12px;font-size:11.5px;line-height:1.6;color:var(--dsw-alias-label-secondary,#5c6270)}
1958
+ .jmw-connect-form{gap:4px}
1959
+ .jmw-connect-actions{justify-content:flex-start}
1960
+ .jmw-connect-note{margin-top:10px;font-size:11px;line-height:1.6;color:var(--dsw-alias-label-tertiary,#8a90a0)}
1896
1961
  .jmw-btn{padding:5px 14px;font:inherit;font-size:12px;color:var(--dsw-alias-label-primary,#1b1d22);cursor:pointer;
1897
1962
  background:var(--dsw-alias-interactive-bg-hover,rgba(38,49,72,.06));border:1px solid var(--dsw-alias-border-l2,rgba(0,0,0,.1));
1898
1963
  border-radius:var(--dsw-radius-sm,8px)}
@@ -2512,6 +2577,165 @@ window.__ModuleLoader__.load({
2512
2577
  return String(value).replace(/["\\\]]/g, (ch) => `\\${ch}`);
2513
2578
  }
2514
2579
 
2580
+ /* ------------------------------------------------- 未配置时的内联连接表单 */
2581
+ //
2582
+ // 第一次用时(没站点 / 没邮箱 / 没令牌),host 把失败按 code 分类送回来。这几种「还没配」
2583
+ // 不该只给一句失败提示:面板在**原来显示失败的位置**直接渲染这张表单,填完就拉列表。
2584
+ // 三个字段都能留空沿用已保存值,提交走配置页同一个 /credential 路由 —— host 会先拿
2585
+ // 邮箱 + 令牌打一次 /myself,通过了才写凭据库 / 设置(401/403 直接拒绝并把原因回给这里)。
2586
+ function ConnectForm(props) {
2587
+ const [form, setForm] = React.useState({
2588
+ // 已保存的连接信息(GET /credential):用来回填 + 判断哪一项还缺。
2589
+ origin: null,
2590
+ baseUrl: '',
2591
+ email: '',
2592
+ token: '',
2593
+ busy: false,
2594
+ error: '',
2595
+ });
2596
+
2597
+ // 进面板先读一次已保存的连接信息:只缺令牌时,用户只需要粘贴令牌再点保存。
2598
+ React.useEffect(() => {
2599
+ let alive = true;
2600
+ (async () => {
2601
+ try {
2602
+ const response = await watchFetch(CREDENTIAL_PATH, { method: 'GET', headers: { accept: 'application/json' } });
2603
+ const payload = await response.json().catch(() => null);
2604
+ if (!alive) return;
2605
+ if (payload?.ok !== true) return;
2606
+ const baseUrl = String(payload?.settings?.baseUrl ?? '');
2607
+ const email = String(payload?.email ?? '');
2608
+ setForm((prev) => ({
2609
+ ...prev,
2610
+ origin: { baseUrl, email, configured: payload?.configured === true, masked: String(payload?.masked ?? '') },
2611
+ // 状态读回来得比首屏慢:用户已经手动改过的字段不回填。
2612
+ baseUrl: prev.baseUrl || baseUrl,
2613
+ email: prev.email || email,
2614
+ }));
2615
+ } catch {
2616
+ // 读不到状态不影响手动填写(提交时 host 会给出真正的错误)。
2617
+ }
2618
+ })();
2619
+ return () => { alive = false; };
2620
+ }, []);
2621
+
2622
+ const baseUrl = form.baseUrl.trim();
2623
+ const email = form.email.trim();
2624
+ const token = form.token.trim();
2625
+ const origin = form.origin;
2626
+ // 已保存过的字段不必再填;提交时只送改过的值,空的让 host 用当前值。
2627
+ const needBaseUrl = !origin || !origin.baseUrl;
2628
+ const needEmail = !origin || !origin.email;
2629
+ const needToken = !origin || !origin.configured;
2630
+ const canSubmit = !form.busy
2631
+ && (!needBaseUrl || baseUrl !== '')
2632
+ && (!needEmail || email !== '')
2633
+ && (!needToken || token !== '');
2634
+
2635
+ const update = (field, value) => setForm((prev) => ({ ...prev, [field]: value, error: '' }));
2636
+ const onEnter = (event) => { if (event?.key === 'Enter') void submit(); };
2637
+
2638
+ async function submit() {
2639
+ if (!canSubmit) return;
2640
+ const body = {};
2641
+ if (!origin || baseUrl !== origin.baseUrl) body.baseUrl = baseUrl;
2642
+ if (!origin || email !== origin.email) body.email = email;
2643
+ if (token) body.token = token;
2644
+ setForm((prev) => ({ ...prev, busy: true, error: '' }));
2645
+ try {
2646
+ const response = await watchFetch(CREDENTIAL_PATH, {
2647
+ method: 'POST',
2648
+ headers: { accept: 'application/json', 'content-type': 'application/json' },
2649
+ body: JSON.stringify(body),
2650
+ });
2651
+ const payload = await response.json().catch(() => null);
2652
+ // host 把「邮箱 / 令牌不被接受」也回成 ok:false + error:原样显示在表单下面。
2653
+ if (payload?.ok !== true) throw new Error(payload?.error || `HTTP ${response.status}`);
2654
+ setForm((prev) => ({ ...prev, busy: false, token: '' }));
2655
+ // 保存成功 → 回到列表加载;新凭据立刻生效,不用再点「重试」。
2656
+ props?.onConnected?.();
2657
+ } catch (error) {
2658
+ setForm((prev) => ({
2659
+ ...prev,
2660
+ busy: false,
2661
+ error: t('connectFailed', { message: String(error?.message ?? error) }),
2662
+ }));
2663
+ }
2664
+ }
2665
+
2666
+ return h('div', { className: 'jmw-state jmw-connect' }, [
2667
+ h('div', { key: 'title', className: 'jmw-connect-title' }, t('connectTitle')),
2668
+ h('div', { key: 'hint', className: 'jmw-connect-hint' }, t('connectHint')),
2669
+ h('div', { key: 'form', className: 'jmw-cred-form jmw-connect-form' }, [
2670
+ h('label', { key: 'bu-label', className: 'jmw-cred-label', htmlFor: 'jmw-connect-base-url' }, t('fBaseUrl')),
2671
+ h('input', {
2672
+ key: 'bu-input',
2673
+ id: 'jmw-connect-base-url',
2674
+ className: 'jmw-cred-input',
2675
+ type: 'url',
2676
+ inputMode: 'url',
2677
+ autoComplete: 'off',
2678
+ spellCheck: false,
2679
+ placeholder: t('baseUrlPlaceholderFallback'),
2680
+ value: form.baseUrl,
2681
+ onInput: (event) => update('baseUrl', event?.target?.value ?? ''),
2682
+ onKeyDown: onEnter,
2683
+ }),
2684
+ h('label', { key: 'em-label', className: 'jmw-cred-label', htmlFor: 'jmw-connect-email' }, t('credEmailLabel')),
2685
+ h('input', {
2686
+ key: 'em-input',
2687
+ id: 'jmw-connect-email',
2688
+ className: 'jmw-cred-input',
2689
+ type: 'text',
2690
+ inputMode: 'email',
2691
+ autoComplete: 'off',
2692
+ spellCheck: false,
2693
+ placeholder: 'name@company.com',
2694
+ value: form.email,
2695
+ onInput: (event) => update('email', event?.target?.value ?? ''),
2696
+ onKeyDown: onEnter,
2697
+ }),
2698
+ h('label', { key: 'tk-label', className: 'jmw-cred-label', htmlFor: 'jmw-connect-token' }, t('connectTokenLabel')),
2699
+ h('input', {
2700
+ key: 'tk-input',
2701
+ id: 'jmw-connect-token',
2702
+ className: 'jmw-cred-input',
2703
+ type: 'password',
2704
+ autoComplete: 'off',
2705
+ spellCheck: false,
2706
+ placeholder: origin?.configured
2707
+ ? t('connectTokenKeep', { masked: origin.masked })
2708
+ : t('connectTokenPlaceholder'),
2709
+ value: form.token,
2710
+ onInput: (event) => update('token', event?.target?.value ?? ''),
2711
+ onKeyDown: onEnter,
2712
+ }),
2713
+ ]),
2714
+ h('div', { key: 'actions', className: 'jmw-cred-actions jmw-connect-actions' }, [
2715
+ h('button', {
2716
+ key: 'submit',
2717
+ type: 'button',
2718
+ // 和配置页「保存并验证」同一套按钮样式(类 + 内联兜底色)。
2719
+ className: 'jmw-cred-btn primary',
2720
+ style: BTN_PRIMARY,
2721
+ disabled: !canSubmit,
2722
+ onClick: () => { void submit(); },
2723
+ }, form.busy ? t('connectSaving') : t('connectSubmit')),
2724
+ h('button', {
2725
+ key: 'config',
2726
+ type: 'button',
2727
+ className: 'jmw-cred-btn',
2728
+ style: BTN_PLAIN,
2729
+ onClick: () => props?.onOpenConfig?.(),
2730
+ }, t('failOpenConfig')),
2731
+ ]),
2732
+ form.error ? h('div', { key: 'error', className: 'jmw-cred-msg err' }, form.error) : null,
2733
+ h('div', { key: 'note', className: 'jmw-connect-note' }, [
2734
+ h('a', { key: 'tokens', className: 'jmw-cred-link', href: TOKENS_URL, target: '_blank', rel: 'noreferrer' }, t('credTokensLink')),
2735
+ ]),
2736
+ ]);
2737
+ }
2738
+
2515
2739
  function Panel() {
2516
2740
  const state = useSnapshot();
2517
2741
  const cardRef = React.useRef(null);
@@ -2714,9 +2938,11 @@ window.__ModuleLoader__.load({
2714
2938
  let body;
2715
2939
  if (state.failure) {
2716
2940
  // 可分类的失败:标题 + 一句「怎么办」+ 按钮;原始报错只在 detail 类里以小字附在下面。
2941
+ // 「还没配置」这一类(站点 / 邮箱 / 令牌)不给失败提示:同一块位置直接换成连接表单。
2717
2942
  const meta = failureMeta(state.failure.code);
2943
+ const setup = CONNECT_CODES.has(state.failure.code);
2718
2944
  const actions = [];
2719
- if (meta.config) {
2945
+ if (!setup && meta.config) {
2720
2946
  actions.push(h('button', {
2721
2947
  key: 'config',
2722
2948
  type: 'button',
@@ -2727,20 +2953,28 @@ window.__ModuleLoader__.load({
2727
2953
  onClick: () => setCredOpen(true),
2728
2954
  }, t('failOpenConfig')));
2729
2955
  }
2730
- actions.push(h('button', {
2731
- key: 'retry',
2732
- type: 'button',
2733
- className: 'jmw-btn',
2734
- onClick: () => load(snapshot.scope),
2735
- }, t('retry')));
2736
- body = h('div', { className: 'jmw-state err jmw-failure' }, [
2737
- h('div', { key: 'title', className: 'jmw-failure-title' }, t(meta.title)),
2738
- h('div', { key: 'hint', className: 'jmw-failure-hint' }, t(meta.hint)),
2739
- h('div', { key: 'actions', className: 'jmw-failure-actions' }, actions),
2740
- meta.detail && state.failure.message
2741
- ? h('div', { key: 'detail', className: 'jmw-failure-detail' }, t('failDetail', { message: state.failure.message }))
2742
- : null,
2743
- ]);
2956
+ if (!setup) {
2957
+ actions.push(h('button', {
2958
+ key: 'retry',
2959
+ type: 'button',
2960
+ className: 'jmw-btn',
2961
+ onClick: () => load(snapshot.scope),
2962
+ }, t('retry')));
2963
+ }
2964
+ body = setup
2965
+ ? h(ConnectForm, {
2966
+ key: 'connect',
2967
+ onConnected: () => { void load(snapshot.scope); },
2968
+ onOpenConfig: () => setCredOpen(true),
2969
+ })
2970
+ : h('div', { className: 'jmw-state err jmw-failure' }, [
2971
+ h('div', { key: 'title', className: 'jmw-failure-title' }, t(meta.title)),
2972
+ h('div', { key: 'hint', className: 'jmw-failure-hint' }, t(meta.hint)),
2973
+ h('div', { key: 'actions', className: 'jmw-failure-actions' }, actions),
2974
+ meta.detail && state.failure.message
2975
+ ? h('div', { key: 'detail', className: 'jmw-failure-detail' }, t('failDetail', { message: state.failure.message }))
2976
+ : null,
2977
+ ]);
2744
2978
  } else if (state.error) {
2745
2979
  body = h('div', { className: 'jmw-state err' }, [
2746
2980
  h('div', { key: 'msg', className: 'msg' }, state.error),
Binary file
Binary file
package/index.js CHANGED
@@ -317,7 +317,7 @@ const TEXT = {
317
317
  'err.projectKey': '无效的项目键:「{project}」,应为大写字母开头的字母数字串(如 APP)。',
318
318
  'err.projectWorkspaceId': '缺少工作区 id:没法把项目挂到工作区上。',
319
319
  'err.planIssue': '无效的 issue key:「{issue}」,应形如 APP-3489。',
320
- 'err.planWorkspaceId': '缺少工作区 id:计划对话要建在项目绑定的工作区里。',
320
+ 'err.planWorkspaceId': '取不到工作区 id:项目没有绑定工作区,也取不到基座的默认工作区。',
321
321
  'err.planAction': '不支持的计划对话操作:{action}(支持 create / search / link / unlink / drop / clear)。',
322
322
  'err.planUnbound': '{key} 没有绑定计划对话:没有可归档的会话。',
323
323
  'err.planArchive': '归档计划对话失败:{message}',
@@ -520,7 +520,7 @@ const TEXT = {
520
520
  'err.projectKey': 'Invalid project key: "{project}"; expected an uppercase alphanumeric key such as APP.',
521
521
  'err.projectWorkspaceId': 'Missing workspace id: cannot link a project to a workspace.',
522
522
  'err.planIssue': 'Invalid issue key: "{issue}"; expected a key such as APP-3489.',
523
- 'err.planWorkspaceId': 'Missing workspace id: a planning session must live in the project\'s linked workspace.',
523
+ 'err.planWorkspaceId': 'No workspace id: the project has no linked workspace and no default Workspace could be resolved.',
524
524
  'err.planAction': 'Unsupported planning-session action: {action} (create / search / link / unlink / drop / clear).',
525
525
  'err.planUnbound': '{key} has no bound planning session: nothing to archive.',
526
526
  'err.planArchive': 'Could not archive the planning session: {message}',
@@ -3075,8 +3075,10 @@ function registerProjectWorkspaceRoute(ctx, jira, settings) {
3075
3075
 
3076
3076
  /* --------------------------------------------- 任务 → 计划对话 */
3077
3077
  //
3078
- // 面板任务行末尾的「计划」按钮:在项目绑定的工作区里开一条 plan 模式会话,先做任务规划,
3079
- // 由用户在对话里敲定或修改。**一个任务只对应一条计划对话**——绑定存成一串
3078
+ // 面板任务行末尾的「计划」按钮:开一条 plan 模式会话,先做任务规划,由用户在对话里敲定或修改。
3079
+ // 落点:项目绑了工作区就建在那个工作区里;没绑(第一次用 / 映射丢了)就建在基座的**默认工作区**
3080
+ // (workspace 控制器的 `initializeDefault()`,与侧栏第一次用时是同一个),只有连它都取不到才报错。
3081
+ // **一个任务只对应一条计划对话**——绑定存成一串
3080
3082
  // `ISSUE<TAB>sessionId`(Config 的 planSessions,volatile,和 projectWorkspaces 同一个存法),
3081
3083
  // 重复点击时前端先查这里,命中就只打开。
3082
3084
  //
@@ -3244,13 +3246,33 @@ async function findPlanSessionByToken(ctx, key) {
3244
3246
  return '';
3245
3247
  }
3246
3248
 
3249
+ /**
3250
+ * 项目没绑工作区时的落点:基座的「默认工作区」。
3251
+ *
3252
+ * 走 workspace 控制器自己的 `initializeDefault()`:已经初始化过就直接返回那条 durable 工作区,
3253
+ * 没有才按基座的目录策略建一个——与侧栏第一次用时的默认工作区是同一个。服务缺席(老基座)
3254
+ * 或调用失败时返回空串,由调用方报 `err.planWorkspaceId`。
3255
+ */
3256
+ async function defaultPlanWorkspaceId(ctx) {
3257
+ const controller = safeService(ctx, 'workspaceController');
3258
+ if (!controller || typeof controller.initializeDefault !== 'function') return '';
3259
+ try {
3260
+ const result = await controller.initializeDefault();
3261
+ const workspace = result?.workspace ?? result?.value?.workspace ?? result?.value ?? result;
3262
+ return String(workspace?.workspaceId ?? workspace?.id ?? '');
3263
+ } catch {
3264
+ return '';
3265
+ }
3266
+ }
3267
+
3247
3268
  /**
3248
3269
  * 建一条计划对话:工作区里新建会话 → /plan 进计划模式 → 投递首条消息。
3249
3270
  * 顺序是「先 plan 再投递」:会话是新的,命令当场生效;即便宿主把它排到第一次 step,
3250
3271
  * 也仍然排在任务消息之前。
3251
3272
  */
3252
3273
  async function createPlanSession(ctx, jira, payload, key) {
3253
- const workspaceId = String(payload?.workspaceId ?? '').trim();
3274
+ // 绑了工作区就建在项目的工作区里;没绑(第一次用 / 映射丢了)落默认工作区。
3275
+ const workspaceId = String(payload?.workspaceId ?? '').trim() || await defaultPlanWorkspaceId(ctx);
3254
3276
  if (!workspaceId) throw new Error(t('err.planWorkspaceId'));
3255
3277
  const signal = payload?.signal;
3256
3278
  const issue = await fetchPlanIssue(jira, key, signal);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-jira-work-overview",
3
- "version": "0.16.4",
3
+ "version": "0.16.6",
4
4
  "description": "Show your Jira work items and their workflow status inside DeepSeek Harness (DSH) · 在 DSH 里查看我的 Jira 工作项与完成状态",
5
5
  "license": "MIT",
6
6
  "author": "Zhaohong Fei",
package/test/README.md CHANGED
@@ -49,7 +49,7 @@ skip without `JIRA_*` credentials (no secrets are configured on purpose — this
49
49
  | `dsh-jira-bundle-id.mjs` | no | package identity: `__ModuleLoader__.load({ id })` === `package.json.name` === `cordis.patch.yml insert[].name`, no `@local/` leftovers, client half still a `{ id, factory(require) }` bundle that imports no `@deepseek-ai/*` |
50
50
  | `dsh-jira-visual.mjs` | no | rendering: grouping, collapse, project tabs, status filter, header total, priority highlight, **virtualization** (windowed DOM vs. placeholder height), **in-place status change** (no `/jira` re-fetch, local row + counts), fallback when `@tanstack/react-virtual` is missing |
51
51
  | `dsh-jira-selfwatch.mjs` | no | the watch loop's diff: someone else's status change notifies, a change **you** made (panel POST or `jira_transition`) is swallowed and its baseline advanced, a colleague changing it right afterwards still notifies, a failed write leaves no stale expectation |
52
- | `dsh-jira-plan.mjs` | no | the per-row **「计划」 button** end to end: a planning session is created in the project's linked workspace, `/plan` runs before the first message, that message carries the `JIRA_PLAN_SESSION:<KEY>` token plus the "only report the changes to make" / "stop if the issue is unclear" rules, a second click reuses the same session (local binding, then a token search through the session log), gaps are listed for a thin issue, and a missing workspace / plan-mode policy fails loudly |
52
+ | `dsh-jira-plan.mjs` | no | the per-row **「计划」 button** end to end: a planning session is created in the project's linked workspace (or in DSH's default Workspace when the project is not linked), `/plan` runs before the first message, that message carries the `JIRA_PLAN_SESSION:<KEY>` token plus the "only report the changes to make" / "stop if the issue is unclear" rules, a second click reuses the same session (local binding, then a token search through the session log), gaps are listed for a thin issue, and a workspace that cannot be resolved at all fails loudly (a missing plan-mode policy does not) |
53
53
  | `dsh-jira-workspace-menu.mjs` | no | the workspace context menu **when `contextMenus` arrives late**: the plugin waits for the service via `ctx.inject` (a single `ctx.get` at apply used to lose the 「关联 Jira 项目…」 entry for the whole page), then registers a `workspace` contribution whose entry opens the panel and reads the link mapping; also covers the older host without `ctx.inject` |
54
54
  | `dsh-jira-credential.mjs` | no | configure dialog + all six fetch routes: token/email save, verification and rejection, masked value, two-step clear, watch/language/fetch-size writes, paging (`--limit=0`, safety cap) |
55
55
  | `dsh-jira-i18n.mjs` | no | language matrix (`DSH_JIRA_LANG`, `--lang`, `?lang`, config, host preference), Jira data kept verbatim, dictionary parity (zh/en key sets), host paging assertions, the "open `cordis.patch.yml`" route |
@@ -3,10 +3,10 @@ import { prepareHostCopy, skipWhenUnavailable } from './lib-host-runtime.mjs';
3
3
  //
4
4
  // 全程不联网:Jira、DSH 的 remote / workspace / agents 服务都用桩,但**跑的是真的 index.js 与 client.js**。
5
5
  // 覆盖的正是需求本身:
6
- // 1. 点「计划」在项目绑定的工作区里建会话,/plan 先于第一条消息;
6
+ // 1. 点「计划」在项目绑定的工作区里建会话(项目没绑就落基座的默认工作区),/plan 先于第一条消息;
7
7
  // 2. 第一条消息只含「任务 + 汇报口径 + 规则」,且带 `JIRA_PLAN_SESSION:<KEY>` 标记;
8
8
  // 3. 同一张卡再点一次不再新建(本地绑定命中;清掉本地配置后靠会话日志里的标记找回);
9
- // 4. 项目没绑工作区 / 没配 plan 模式 → 明确报错,一条会话都不建;
9
+ // 4. 连默认工作区都取不到(老基座)→ 明确报错,一条会话都不建;没配 plan 模式照样能规划;
10
10
  // 5. Jira 卡信息不全 → 首条消息里带「中断并告诉用户任务不明确」的指令,规划提示里也列出缺什么。
11
11
  import { copyFileSync, mkdirSync, existsSync } from 'node:fs';
12
12
  import { fileURLToPath, pathToFileURL } from 'node:url';
@@ -46,6 +46,17 @@ const JIRA_ISSUES = {
46
46
  key: 'APP-2',
47
47
  fields: { summary: '', status: { name: 'To Do' }, issuetype: { name: 'Task' }, description: { type: 'doc', content: [] }, issuelinks: [] },
48
48
  },
49
+ 'APP-9': {
50
+ // 没绑定工作区的项目:用来验证「落到默认工作区」。
51
+ key: 'APP-9',
52
+ fields: {
53
+ summary: '导出当前筛选结果',
54
+ status: { name: 'To Do' },
55
+ issuetype: { name: 'Task' },
56
+ description: { type: 'doc', content: [{ type: 'paragraph', content: [{ type: 'text', text: '按当前筛选条件导出 CSV。' }] }] },
57
+ issuelinks: [],
58
+ },
59
+ },
49
60
  };
50
61
  const jiraCalls = [];
51
62
 
@@ -55,6 +66,9 @@ const settingsWrites = [];
55
66
  /* 「删掉计划对话」走的是基座的归档通道:记录调用,必要时模拟基座拒收。 */
56
67
  const archiveCalls = [];
57
68
  const connectionCalls = [];
69
+ /* 默认工作区(未绑定项目的落点):由 workspace 控制器提供,`false` = 老基座取不到。 */
70
+ let defaultWorkspaceAvailable = true;
71
+ const defaultWorkspaceCalls = [];
58
72
  const registryArchiveCalls = [];
59
73
  let registryArchiveRefuses = false;
60
74
  let archiveRefuses = false;
@@ -83,7 +97,21 @@ const hostCtx = {
83
97
  };
84
98
  }
85
99
  if (name === 'workspace') {
86
- return { async get(id) { return id === 'ws-uuid-1' ? { id, path: TMP, title: 'tmp' } : undefined; } };
100
+ return {
101
+ async get(id) {
102
+ if (id === 'ws-uuid-1') return { id, path: TMP, title: 'tmp' };
103
+ if (id === 'ws-default-1') return { id, path: TMP, title: 'default-workspace' };
104
+ return undefined;
105
+ },
106
+ };
107
+ }
108
+ if (name === 'workspaceController') {
109
+ return {
110
+ async initializeDefault() {
111
+ defaultWorkspaceCalls.push(true);
112
+ return defaultWorkspaceAvailable ? { workspace: { workspaceId: 'ws-default-1', path: TMP, title: 'default-workspace' } } : undefined;
113
+ },
114
+ };
87
115
  }
88
116
  if (name === 'remote') return remoteService;
89
117
  // 工作区注册表本体:服务树上的键是 `workspaceRegistry`,`archivedSessionIds` 就是它写的。
@@ -319,11 +347,21 @@ check(dropAgain.ok === false && /绑定|bound/i.test(String(dropAgain.error)), '
319
347
 
320
348
  /* ------------------------------------------------------------- 场景 5 */
321
349
 
322
- const noWorkspace = await planPayload({ action: 'create', issue: 'APP-1' });
350
+ console.log('\n场景 4(默认工作区 / 参数错误)');
351
+ // 项目没绑工作区:落到基座的默认工作区(而不是直接报错不建)。
352
+ const defaultCreate = await planPayload({ action: 'create', issue: 'APP-9' });
353
+ syncWrites();
354
+ check(defaultCreate.ok === true && Boolean(defaultCreate.sessionId), '没绑定工作区的项目在默认工作区建出计划对话', JSON.stringify({ ok: defaultCreate.ok, sessionId: defaultCreate.sessionId }));
355
+ const defaultCreateCall = [...remoteCalls].reverse().find((call) => call.call === 'create');
356
+ check(defaultCreateCall?.workspaceId === 'ws-default-1', '建会话用的是基座默认工作区 id', JSON.stringify(defaultCreateCall ?? null));
357
+ check(defaultWorkspaceCalls.length > 0, '默认工作区走 workspaceController.initializeDefault()', String(defaultWorkspaceCalls.length));
358
+ // 连默认工作区都取不到(老基座 / 服务缺席)才报错。
359
+ defaultWorkspaceAvailable = false;
360
+ const noWorkspace = await planPayload({ action: 'create', issue: 'APP-10' });
361
+ defaultWorkspaceAvailable = true;
323
362
  const badAction = await planPayload({ action: 'nope', issue: 'APP-1' });
324
363
  const badKey = await planPayload({ action: 'link', issue: 'not-a-key', sessionId: 'x' });
325
- console.log('\n场景 4(参数错误)');
326
- check(noWorkspace.ok === false && /工作区/.test(noWorkspace.error), '缺工作区 id → 明确报错', noWorkspace.error);
364
+ check(noWorkspace.ok === false && /工作区/.test(noWorkspace.error), '默认工作区也取不到 → 明确报错', noWorkspace.error);
327
365
  check(badAction.ok === false && /plan/.test(String(badAction.error)) === false && /操作|action/i.test(String(badAction.error)), '不支持的动作 → 明确报错', badAction.error);
328
366
  check(badKey.ok === false && /issue|key|APP-3489/i.test(String(badKey.error)), '非法 issue key → 明确报错', badKey.error);
329
367
 
@@ -500,6 +538,9 @@ const clientSessionsService = {
500
538
  },
501
539
  };
502
540
  const clientOpened = [];
541
+ /* 基座的默认工作区:未绑定项目的落点;设成 null 模拟老基座取不到。 */
542
+ let clientDefaultWorkspace = { workspaceId: 'ws-default-1', sessionIds: [] };
543
+ const clientDefaultWorkspaceCalls = [];
503
544
  const clientCtx = {
504
545
  get(name) {
505
546
  if (name === 'remote.commands') {
@@ -564,7 +605,16 @@ const clientCtx = {
564
605
  };
565
606
  }
566
607
  if (name === 'sessions') return clientSessionsService;
567
- if (name === 'workspaces') return { list: { getSnapshot: () => ({ items: [{ workspaceId: 'ws-uuid-1', sessionIds: ['sess-main'] }] }) } };
608
+ if (name === 'workspaces') {
609
+ // 基座的默认工作区服务:`null` = 老基座取不到(用来验证错误提示)。
610
+ return {
611
+ list: { getSnapshot: () => ({ items: [{ workspaceId: 'ws-uuid-1', sessionIds: ['sess-main'] }] }) },
612
+ async initializeDefault() {
613
+ clientDefaultWorkspaceCalls.push(true);
614
+ return { ok: true, value: { workspace: clientDefaultWorkspace } };
615
+ },
616
+ };
617
+ }
568
618
  return undefined;
569
619
  },
570
620
  on() { return () => {}; },
@@ -719,6 +769,52 @@ if (rows.length >= 2) {
719
769
  check(noPolicyText.includes('plan 模式') && noPolicyText.includes('只汇报'), '首条消息自带 plan 口径兜底', noPolicyText.split('\n').filter((line) => /plan 模式|只汇报/.test(line)).join(' / '));
720
770
  }
721
771
 
772
+ /* ------------------------------------------------ 项目没绑工作区的兜底 */
773
+ // OPS 项目不在 project-workspace 映射里(没绑工作区):点「计划」应当落到基座的默认工作区,
774
+ // 而不是弹一句「没有绑定工作区」把按钮堵死。
775
+ const pushCard = (key, project, summary) => clientListItems.push({
776
+ key, project, summary, status: 'To Do', category: 'new',
777
+ type: 'Task', priority: '', sprintId: null, sprint: '', due: '', updated: '2026-11-19',
778
+ labels: [], parent: '', parentKey: '', parentSummary: '', epicKey: '', epicSummary: '',
779
+ url: `https://example.atlassian.net/browse/${key}`,
780
+ });
781
+ const planRowOf = async (key, expected) => {
782
+ for (let i = 0; i < 120; i += 1) {
783
+ await new Promise((resolve) => setTimeout(resolve, 25));
784
+ const rows = planButtonsOf(render());
785
+ if (rows.length >= expected) {
786
+ const index = clientListItems.findIndex((row) => row.key === key);
787
+ return rows[index];
788
+ }
789
+ }
790
+ return undefined;
791
+ };
792
+ /* 面板默认停在自动选中的项目 tab 上(APP):先切到「全部项目」,新项目的卡片才画得出来。 */
793
+ const allProjectsPill = () => collectButtons(render()).find((row) => /jmw-pill/.test(String(row.props?.className ?? '')) && /全部项目|All projects/.test(collectText(row)));
794
+ allProjectsPill()?.props?.onClick?.();
795
+ pushCard('OPS-7', 'OPS', '按工单导出报表');
796
+ refreshButton()?.props?.onClick?.();
797
+ const opsRow = await planRowOf('OPS-7', 3);
798
+ check(Boolean(opsRow), '列表里出现未绑定项目的任务', String(planButtonsOf(render()).length));
799
+ const opsBefore = clientRemoteCalls.length;
800
+ await opsRow?.props?.onClick?.({ preventDefault() {}, stopPropagation() {} });
801
+ await settle(() => clientRemoteCalls.slice(opsBefore).some((call) => call.call === 'prompt'));
802
+ const opsCreate = clientRemoteCalls.slice(opsBefore).find((call) => call.call === 'create');
803
+ check(opsCreate?.workspaceId === 'ws-default-1', '项目没绑工作区 → 建在基座默认工作区', JSON.stringify(opsCreate ?? null));
804
+ check(clientDefaultWorkspaceCalls.length > 0, '默认工作区走 workspaces.initializeDefault()', String(clientDefaultWorkspaceCalls.length));
805
+
806
+ // 老基座没有默认工作区服务:这时才报错,一条会话都不建。
807
+ clientDefaultWorkspace = null;
808
+ pushCard('OPS-8', 'OPS', '按工单导出明细');
809
+ refreshButton()?.props?.onClick?.();
810
+ const opsRow2 = await planRowOf('OPS-8', 4);
811
+ check(Boolean(opsRow2), '列表里出现第二张未绑定项目的任务');
812
+ const opsBefore2 = clientRemoteCalls.length;
813
+ await opsRow2?.props?.onClick?.({ preventDefault() {}, stopPropagation() {} });
814
+ await settle(() => /没有绑定工作区/.test(collectText(render())));
815
+ check(!clientRemoteCalls.slice(opsBefore2).some((call) => call.call === 'create'), '取不到默认工作区 → 不建会话', String(clientRemoteCalls.length - opsBefore2));
816
+ check(/没有绑定工作区/.test(collectText(render())), '取不到默认工作区 → 面板给出明确原因', collectText(render()).slice(-120));
817
+
722
818
  globalThis.fetch = realFetch;
723
819
  console.log(failed === 0 ? '\n=== 计划对话测试:全部通过 ===' : `\n=== 计划对话测试:${failed} 项失败 ===`);
724
820
  process.exit(failed === 0 ? 0 : 1);
@@ -19,6 +19,7 @@
19
19
  * panel-watch.png 实时监视横幅 + 某一行展开的状态流转下拉
20
20
  * plan-flow.png 绑定工作区 → 点「计划」的四步图解(示意图,不是真截图)
21
21
  * sidebar-entry.png 左侧栏入口 + 未读角标
22
+ * panel-connect.png 第一次用(什么都没配):失败位置就是「连接 Jira」表单
22
23
  * zh 版本加 `.zh` 后缀
23
24
  */
24
25
  import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
@@ -572,6 +573,7 @@ const effects = [];
572
573
  * `options.search` —— 搜索框里的关键词(非空时命令面收到 `--search=`,回搜索命中载荷)
573
574
  * `options.workspace` —— 当前会话所在的工作区 id(面板按它自动选项目 tab)
574
575
  * `options.plans` —— 已绑定的计划对话 `{ ISSUE: sessionId }`(任务行「计划」标成 on + 多个「×」)
576
+ * `options.failCode` —— 让 `--json` 回 `ok:false` + `error.code`(面板据此渲染失败提示 / 连接表单)
575
577
  */
576
578
  async function loadClient(lang, options = {}) {
577
579
  hookStore.clear();
@@ -589,6 +591,7 @@ async function loadClient(lang, options = {}) {
589
591
  const payload = demoPayload(lang);
590
592
  const searchPayloadData = searchPayload(lang);
591
593
  const commandCalls = [];
594
+ const failCode = options.failCode ?? '';
592
595
  const plans = { sessions: { ...(options.plans ?? {}) } };
593
596
 
594
597
  const clientCtx = {
@@ -599,6 +602,11 @@ async function loadClient(lang, options = {}) {
599
602
  async execute(sessionId, line) {
600
603
  await new Promise((done) => setTimeout(done, 20));
601
604
  commandCalls.push(String(line));
605
+ // 失败载荷与真 host 同形:`--json` 不 throw,回 `ok:false` + `error:{code,message}`。
606
+ if (failCode) {
607
+ const fail = { ok: false, items: [], total: null, error: { code: failCode, message: 'Missing Jira credential: put JIRA_API_TOKEN into the DSH credential store.' } };
608
+ return { ok: true, value: { commandId: 'jira', result: { kind: 'success', text: JSON.stringify(fail) } } };
609
+ }
602
610
  // 带 `--search=` 的那次查询回搜索命中(与真 host 一样:同一份载荷形状,集合换了)。
603
611
  const searched = /--search=(.+)$/.exec(String(line));
604
612
  const data = searched && searched[1].trim() ? searchPayloadData : payload;
@@ -622,6 +630,10 @@ async function loadClient(lang, options = {}) {
622
630
  __DSH_TRANSPORT__: {
623
631
  async fetch(url, init = {}) {
624
632
  const path = String(url).split('?')[0];
633
+ // 连接表单进面板先 GET 一次已保存的连接信息;截图里是全新安装,三项都空。
634
+ if (path === '/api/jira-work-overview/credential') {
635
+ return { ok: true, status: 200, async json() { return { ok: true, configured: false, masked: '', settings: { baseUrl: '' }, email: '' }; } };
636
+ }
625
637
  if (path === '/api/jira-work-overview/transition') {
626
638
  const key = new URL(url, 'http://shot.invalid').searchParams.get('key') ?? '';
627
639
  const current = payload.items.find((row) => row.key === key)?.status ?? 'To Do';
@@ -958,6 +970,16 @@ for (const lang of LANGS) {
958
970
  shot(`panel${suffix}`, panelHtml('panel', panel), PANEL_W, PANEL_H);
959
971
  }
960
972
 
973
+ /* --- 1b) 第一次用:面板 body 就是「连接 Jira」表单(没站点 / 邮箱 / 令牌) --- */
974
+ if (WANTED('panel-connect')) {
975
+ currentEntries = {};
976
+ transport.watchState.payload = CLEAN_WATCH;
977
+ await openPanel(lang, { failCode: 'no_credential' });
978
+ await settle(160);
979
+ const panel = renderPanel();
980
+ shot(`panel-connect${suffix}`, panelHtml('panel-connect', panel), PANEL_W, PANEL_H);
981
+ }
982
+
961
983
  /* --- 2) 实时监视横幅 + 某一行的状态流转下拉 --- */
962
984
  if (WANTED('panel-watch')) {
963
985
  // 打开 APP-412 那一行的下拉:真库量到那行变高后会把后面的行整体下移,截图里同样让位。
@@ -183,6 +183,9 @@ Object.defineProperty(globalThis, 'window', {
183
183
  __DSH_TRANSPORT__: {
184
184
  async fetch(url, init) {
185
185
  const method = String(init?.method ?? 'GET').toUpperCase();
186
+ if (String(url).split('?')[0] === '/api/jira-work-overview/credential') {
187
+ return credentialFetch(String(url), init ?? {});
188
+ }
186
189
  if (String(url).split('?')[0] === '/api/jira-work-overview/transition') {
187
190
  return transitionFetch(String(url), init ?? {});
188
191
  }
@@ -230,6 +233,41 @@ async function transitionFetch(url, init) {
230
233
  return OK({ ok: true, key, current: transitionState.current, currentCategory: 'new', transitions: TRANSITIONS });
231
234
  }
232
235
 
236
+ /* --------------------------------------- 连接表单的 credential 通道 stub ----
237
+ 真校验(打 /myself、401 拒绝、写凭据库)在 dsh-jira-credential 套件里跑;这里只关心面板:
238
+ 表单回填已保存值、只提交改过的字段、保存成功后回到列表。 */
239
+ const credentialState = { configured: false, baseUrl: '', email: '', masked: '', token: '', posts: [] };
240
+ async function credentialFetch(url, init) {
241
+ const method = String(init.method ?? 'GET').toUpperCase();
242
+ await new Promise((resolve) => setTimeout(resolve, 5));
243
+ if (method === 'POST') {
244
+ const body = init.body ? JSON.parse(init.body) : {};
245
+ credentialState.posts.push(body);
246
+ if (body.baseUrl !== undefined) credentialState.baseUrl = body.baseUrl;
247
+ if (body.email !== undefined) credentialState.email = body.email;
248
+ if (body.token) {
249
+ credentialState.token = body.token;
250
+ credentialState.configured = true;
251
+ }
252
+ return OK({
253
+ ok: true,
254
+ saved: true,
255
+ configured: credentialState.configured,
256
+ masked: 'ATATT…F000',
257
+ settings: { baseUrl: credentialState.baseUrl },
258
+ email: credentialState.email,
259
+ verification: { ok: true, account: '张三' },
260
+ });
261
+ }
262
+ return OK({
263
+ ok: true,
264
+ configured: credentialState.configured,
265
+ masked: credentialState.masked,
266
+ settings: { baseUrl: credentialState.baseUrl },
267
+ email: credentialState.email,
268
+ });
269
+ }
270
+
233
271
 
234
272
  /* 站点优先级名次(GET /rest/api/3/priority 的数组下标,0 = 最高级)——host 发下来的就是这个。
235
273
  fixture 里带上它,走的就是「按 Jira 名次上底色」的主路径;H 段再单独验没有名次时的名字兜底。 */
@@ -795,59 +833,135 @@ check(
795
833
  activeFixture.current = FIXTURE;
796
834
  await pickStatus('全部状态');
797
835
 
798
- /* ---------------- I:可分类的失败 → 提示文字(不是原始报错) ----------------
799
- host 在 --json 失败时回 ok:false + error.code;面板按 code 选文案,「去配置」直达令牌弹窗,
800
- 原始 message 只在 detail 类里以小字附上(无令牌这类「一句话能解决」的不该甩一坨报错)。 */
836
+ /* ---------------- I:没配置时 → 失败位置直接换成「连接 Jira」表单 ----------------
837
+ host 在 --json 失败时回 ok:false + error.code。no_base_url / no_email / no_credential
838
+ 都是「还没配好」:面板要在同一块位置渲染登录表单(站点 + 邮箱 + 令牌),填完保存就拉列表;
839
+ 其它 code(auth / network…)仍走「提示 + 去配置 / 重试」。 */
801
840
  const clsOf = (row) => String(row.props?.className ?? '');
802
- const failureNode = (name) => collect(panel, (row) => clsOf(row) === name)[0];
803
- const failTitle = () => text(failureNode('jmw-failure-title')).trim();
804
- const failHint = () => text(failureNode('jmw-failure-hint')).trim();
841
+ const nodeOf = (name) => collect(panel, (row) => clsOf(row) === name)[0];
842
+ const failTitle = () => text(nodeOf('jmw-failure-title')).trim();
843
+ const failHint = () => text(nodeOf('jmw-failure-hint')).trim();
805
844
  const failDetails = () => collect(panel, (row) => clsOf(row) === 'jmw-failure-detail');
806
- // 失败态的按钮既可能是 .jmw-btn(重试),也可能是 .jmw-cred-btn(去配置,和配置页「保存并验证」同款)。
845
+ const connectTitle = () => text(nodeOf('jmw-connect-title')).trim();
846
+ const connectHint = () => text(nodeOf('jmw-connect-hint')).trim();
847
+ const connectInput = (field) => collect(panel, (row) => row.type === 'input' && row.props?.id === `jmw-connect-${field}`)[0];
807
848
  const isActionBtn = (row) => row.type === 'button' && /^jmw-(cred-)?btn(\s|$)/.test(clsOf(row));
808
- const failButtons = () => collect(panel, isActionBtn).map((row) => text(row).trim());
849
+ const buttonOf = (label) => collect(panel, (row) => isActionBtn(row) && text(row).trim() === label)[0];
809
850
  const refreshBtn = () => collect(panel, (row) => row.type === 'button' && row.props?.['aria-label'] === '刷新')[0];
851
+ // 迷你 React 不模拟卸载:新的失败场景要清掉上个表单的 hook 状态(真 React 由 key / 位置决定)。
852
+ const resetConnectForm = () => hookStore.delete('ConnectForm');
853
+ const flush = async (ms = 40) => { await new Promise((resolve) => setTimeout(resolve, ms)); };
810
854
 
855
+ /* 场景 1:只缺令牌(站点 / 邮箱已保存)→ 回填这两项,令牌空着不给提交。 */
811
856
  activeFailure.current = { code: 'no_credential', message: 'Missing Jira credential: put JIRA_API_TOKEN into the DSH credential store…' };
857
+ credentialState.configured = false;
858
+ credentialState.baseUrl = 'https://example.atlassian.net';
859
+ credentialState.email = 'dev@example.com';
860
+ resetConnectForm();
812
861
  refreshBtn().props.onClick();
813
862
  await settle();
814
863
  panel = renderPanel();
815
- console.log('\nI 没配令牌:标题 =', JSON.stringify(failTitle()), '| 提示 =', JSON.stringify(failHint()), '| 按钮 =', JSON.stringify(failButtons()), '| 原始报错可见 =', failDetails().length);
864
+ await flush();
865
+ panel = renderPanel();
866
+ console.log('\nI 没配令牌:标题 =', JSON.stringify(connectTitle()), '| 提示 =', JSON.stringify(connectHint()), '| 失败提示可见 =', failTitle() !== '');
867
+ check(
868
+ connectTitle() === '连接 Jira'
869
+ && connectHint().includes('API token')
870
+ && failTitle() === '' && failHint() === '' && failDetails().length === 0
871
+ && collect(panel, (row) => clsOf(row) === 'jmw-state err jmw-failure').length === 0,
872
+ 'I 没配令牌 → 失败位置换成「连接 Jira」表单(不再显示失败标题 / 原始报错)',
873
+ `${connectTitle()} / failure=${failTitle()}`,
874
+ );
875
+ check(
876
+ Boolean(connectInput('base-url')) && Boolean(connectInput('email')) && Boolean(connectInput('token')),
877
+ 'I 表单有站点地址 / 邮箱 / API token 三个输入框',
878
+ ['base-url', 'email', 'token'].map((field) => `${field}=${Boolean(connectInput(field))}`).join(' '),
879
+ );
880
+ check(
881
+ connectInput('base-url').props.value === 'https://example.atlassian.net'
882
+ && connectInput('email').props.value === 'dev@example.com'
883
+ && connectInput('token').props.value === '',
884
+ 'I 只缺令牌时回填已保存的站点与邮箱(令牌永远是空输入框)',
885
+ `${connectInput('base-url').props.value} / ${connectInput('email').props.value}`,
886
+ );
816
887
  check(
817
- failTitle() === '还没有配置 Jira 令牌'
818
- && failHint().includes('Jira API token')
819
- && failButtons().includes('去配置')
820
- && failButtons().includes('重试')
821
- && failDetails().length === 0,
822
- 'I 无令牌 → 提示文字 + 去配置 / 重试,且不显示原始报错',
823
- `${failTitle()} / ${failButtons().join(',')}`,
888
+ connectInput('token').props.placeholder === '粘贴 Jira API token' && buttonOf('保存并连接')?.props.disabled === true,
889
+ 'I 令牌为空时「保存并连接」不可点(缺什么填什么)',
890
+ `placeholder=${JSON.stringify(connectInput('token').props.placeholder)} disabled=${buttonOf('保存并连接')?.props.disabled}`,
824
891
  );
825
- const openConfig = collect(panel, (row) => isActionBtn(row) && text(row).trim() === '去配置')[0];
826
892
  check(
827
- /\bprimary\b/.test(clsOf(openConfig)) && openConfig?.props?.style?.background === '#4d6bfe'
828
- && openConfig?.props?.style?.color === '#ffffff',
829
- 'I 「去配置」用和「保存并验证」一致的按钮样式(深底白字 + primary 类)',
830
- `class=${clsOf(openConfig)} style=${JSON.stringify(openConfig?.props?.style)}`,
893
+ /\bprimary\b/.test(clsOf(buttonOf('保存并连接'))) && buttonOf('保存并连接')?.props?.style?.background === '#4d6bfe',
894
+ 'I 「保存并连接」用和配置页「保存并验证」一致的深底白字样式',
895
+ `class=${clsOf(buttonOf('保存并连接'))}`,
831
896
  );
832
- openConfig.props.onClick();
897
+
898
+ /* 去配置仍然在(轮询 / 通知 / 语言这些高级项),点开还是令牌弹窗。 */
899
+ buttonOf('去配置').props.onClick();
833
900
  panel = renderPanel();
834
901
  check(
835
902
  collect(panel, (row) => clsOf(row) === 'jmw-credmodal').length === 1,
836
- 'I 「去配置」直接打开令牌弹窗',
903
+ 'I 表单里的「去配置」照旧直达令牌弹窗',
837
904
  `jmw-credmodal=${collect(panel, (row) => clsOf(row) === 'jmw-credmodal').length}`,
838
905
  );
839
906
  keyHandlers[keyHandlers.length - 1]({ key: 'Escape', preventDefault() {} });
840
907
  panel = renderPanel();
841
908
 
842
- /* detail 类(站点 / 网络):提示之外要能看见原始 message,否则用户没法判断到底哪儿错了。 */
909
+ /* 场景 2:填令牌 → 保存并连接 → 只提交改过的字段,列表立刻回来。 */
910
+ connectInput('token').props.onInput({ target: { value: 'ATATT3xFfGF0TOKENTOKENTOKEN' } });
911
+ panel = renderPanel();
912
+ check(buttonOf('保存并连接')?.props.disabled === false, 'I 填上令牌后按钮可点(已保存的站点 / 邮箱不必重填)');
913
+ activeFailure.current = null;
914
+ const postsBefore = credentialState.posts.length;
915
+ const commandsBeforeConnect = calls.length;
916
+ buttonOf('保存并连接').props.onClick();
917
+ // 保存是异步的(POST → 成功 → 才触发列表重拉):先等 POST 回来,再等命令跑完。
918
+ await flush(80);
919
+ await settle();
920
+ panel = renderPanel();
921
+ const posted = credentialState.posts[postsBefore];
922
+ console.log('I 提交的连接信息:', JSON.stringify({ ...posted, token: posted?.token ? `${posted.token.slice(0, 6)}…` : undefined }));
923
+ check(
924
+ posted?.token === 'ATATT3xFfGF0TOKENTOKENTOKEN' && posted?.email === undefined && posted?.baseUrl === undefined,
925
+ 'I POST 只带改过的令牌(已保存的站点 / 邮箱留空沿用)',
926
+ JSON.stringify({ ...posted, token: posted?.token ? '***' : undefined }),
927
+ );
928
+ check(
929
+ calls.length > commandsBeforeConnect && rows(panel).length === FIXTURE.items.length && !connectTitle(),
930
+ 'I 保存成功后自动重拉列表(表单消失、任务行回来)',
931
+ `rows=${rows(panel).length} commands=${calls.length - commandsBeforeConnect}`,
932
+ );
933
+
934
+ /* 场景 3:首次什么都还没配(no_base_url / no_email)→ 同样是表单,不是失败提示。 */
935
+ credentialState.configured = false;
936
+ credentialState.baseUrl = '';
937
+ credentialState.email = '';
938
+ for (const code of ['no_base_url', 'no_email']) {
939
+ activeFailure.current = { code, message: `setup needed: ${code}` };
940
+ resetConnectForm();
941
+ refreshBtn().props.onClick();
942
+ await settle();
943
+ panel = renderPanel();
944
+ await flush();
945
+ panel = renderPanel();
946
+ check(
947
+ connectTitle() === '连接 Jira' && failTitle() === '' && failDetails().length === 0
948
+ && connectInput('base-url').props.value === '' && connectInput('email').props.value === '',
949
+ `I ${code} → 同一张连接表单(站点 / 邮箱都空着,等用户填)`,
950
+ `${code}: ${connectTitle()} / failure=${failTitle()}`,
951
+ );
952
+ }
953
+
954
+ /* 场景 4:凭据存在但被拒(auth)→ 仍是失败提示 + 详情;「重试」能回到列表。 */
843
955
  activeFailure.current = { code: 'auth', message: 'Jira 401 Unauthorized (/rest/api/3/search/jql):Check your email and API token' };
956
+ resetConnectForm();
844
957
  refreshBtn().props.onClick();
845
958
  await settle();
846
959
  panel = renderPanel();
847
960
  console.log('I 401:标题 =', JSON.stringify(failTitle()), '| 详情小字 =', JSON.stringify(text(failDetails()[0]).trim().slice(0, 40)));
848
961
  check(
849
- failTitle() === 'Jira 不认这组邮箱 / 令牌' && failDetails().length === 1 && text(failDetails()[0]).includes('401'),
850
- 'I 401 → 「邮箱 / 令牌不被接受」+ 原始信息收在详情里',
962
+ failTitle() === 'Jira 不认这组邮箱 / 令牌' && failDetails().length === 1 && text(failDetails()[0]).includes('401')
963
+ && !connectTitle(),
964
+ 'I 401 → 不换成表单(凭据已配,是被拒);原始信息收在详情里',
851
965
  failTitle(),
852
966
  );
853
967
  const retryBtn = collect(panel, (row) => isActionBtn(row) && text(row).trim() === '重试')[0];