dsh-jira-work-overview 0.16.4 → 0.16.5

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,20 @@ 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.5] - 2026-11-24
8
+
9
+ ### Added
10
+
11
+ - **第一次用不再只看到一句失败。** 没配站点地址 / 邮箱 / 令牌时,面板在**原来显示登录失败的位置**
12
+ 直接渲染「连接 Jira」表单(站点地址 + 邮箱 + API token):缺什么填什么,已保存的字段留空沿用;
13
+ 点「保存并连接」会先拿 `/myself` 验一次再写凭据库 / 设置,成功后自动重拉列表,令牌输入框只给
14
+ 掩码提示、永远不回显。旁边保留「去配置」,直达条数 / 监视 / 通知 / 语言这些高级项。
15
+ 只有「配了但连不上」(401 / 网络 / 站点返回异常 / 凭据读不出)才继续走原来的失败提示 + 原始信息。
16
+
17
+ - **README 补了「第一次用」的截图与小节**:图由 `test/dsh-jira-shot.mjs --only panel-connect` 生成
18
+ (`docs/images/panel-connect.png` / `panel-connect.zh.png`),不讲新行为,只把「第一次打开看到什么」画出来;
19
+ 中英两份 README 都加了入口(英文在 `First-run configuration`,中文独立一节「第一次用:面板里直接填」)。
20
+
7
21
  ## [0.16.4] - 2026-11-23
8
22
 
9
23
  ### 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.5)
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
  | --- | --- | --- |
@@ -234,7 +241,7 @@ The plugin's own copy follows the DSH language setting; English and Chinese ship
234
241
  | 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
242
  | footer says "live watch disconnected" | transient transport error; it retries with backoff |
236
243
  | 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`) |
244
+ | 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
245
  | panel says "Jira rejected this email / token pair" | 401/403 from Jira: regenerate the token; the raw response is under the hint |
239
246
  | 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
247
 
@@ -242,7 +249,7 @@ Behind a corporate proxy on Windows, DSH needs the proxy env vars it was started
242
249
 
243
250
  ## Versions and upgrades
244
251
 
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).
252
+ The current version is **0.16.5** (2026-11-24). The changelog records 39 versions (from 0.1.0); GitHub carries **14 tags / releases** (0.13.0 → 0.16.5), 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
253
 
247
254
  ### Why people still install older versions
248
255
 
@@ -277,11 +284,12 @@ The current version is **0.16.0** (2026-11-20). The changelog records 30 version
277
284
  | 0.14.0 | 2026-11-19 | feature | highlight follows **Jira's own priority order**; **first npm release** |
278
285
  | 0.15.0 | 2026-11-19 | feature | transitions update **in place**, your own changes no longer notify you, typed failure hints |
279
286
  | 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
287
  | 0.16.0 | 2026-11-20 | feature | **site-wide search**, **group by epic**, the **计划** (plan) button on every row |
288
+ | 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 |
289
+ | 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 |
290
+ | 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** |
291
+ | 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 |
292
+ | 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 |
285
293
 
286
294
  > 0.1.0–0.12.0 all happened on 2026-11-18; tags and GitHub Releases start at 0.13.0.
287
295
  > 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 +347,7 @@ Every user-visible defect, newest first (implementation detail is in the matchin
339
347
 
340
348
  1. **No sidebar entry**, or `plugin_manager` says `active` while the UI is empty → upgrade to **0.13.2 or later** and refresh.
341
349
  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.
350
+ 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
351
  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
352
 
345
353
  ## 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.5)
25
25
  plugin_manager install_bundle(target="dsh-jira-work-overview")
26
26
 
27
27
  # 2) 直接从 GitHub 装(不需要 npm 发布)
@@ -186,7 +186,11 @@ profile 里装了 `deepseek-ai/dsh-plan-mode` 就用它的 `section` 当规划
186
186
  组头的未完成数与筛选菜单都在本地重算,不再为改一个状态把几百条 issue 重新拉一遍;只有在当前列表里找不到这条时才回退整表刷新);
187
187
  失败(例如某个流转要求必填字段)把 Jira 的报错原样显示在下拉里,不静默吞掉。
188
188
 
189
- - **失败会说人话**:没配令牌 / 站点地址、凭据读不出来、令牌过期(401)、网络不通、站点返回非 JSON,
189
+ - **第一次用就是那张表单**:没配站点地址 / 邮箱 / 令牌时,面板在**原来显示失败提示的位置**直接给出
190
+ 「连接 Jira」表单(站点地址 + 邮箱 + API token),缺什么填什么,点「保存并连接」当场拉列表;
191
+ 已经保存过的字段可以留空沿用,令牌照旧只进 DSH 凭据库、提交前先用 `/myself` 验一次。
192
+ 旁边的「去配置」仍然直达完整配置弹窗(条数 / 监视 / 通知 / 语言)。
193
+ - **失败会说人话**:凭据读不出来、令牌过期(401)、网络不通、站点返回非 JSON,
190
194
  面板不再把 Host 的原始报错糊在列表位置,而是标题 + 一句「怎么办」:`去配置` 直接打开令牌弹窗、
191
195
  `重试` 重新查询;只有需要看原文的那几类(认证失败 / 网络 / 站点错误)才把原始信息以小字附在下面。
192
196
  错误类型来自 `--json` 载荷里的 `error.code`(`no_credential` / `credential_unreadable` / `no_email` /
@@ -282,6 +286,15 @@ Jira Cloud **没有**给第三方 issue 事件的 websocket / SSE 长连接(
282
286
  > 如果你更希望“毫秒级实时”,正路只有两条:让 Jira 管理员配 webhook + 内网穿透(需要公网地址),
283
287
  > 或者用 DSH 的定时任务让 agent 定时来问(每次都要跑模型,比本机轮询贵得多)。
284
288
 
289
+ ## 第一次用:面板里直接填(连接表单)
290
+
291
+ 还没配站点地址 / 邮箱 / 令牌时,打开面板看到的不是一句失败提示,而是**直接可填的「连接 Jira」表单**
292
+ (服务地址 + 账号邮箱 + API token),就占在原来失败提示的位置:缺什么填什么,点「保存并连接」当场拉列表。
293
+ 已经保存过的字段可以留空沿用(只提交你改过的值);令牌只进 DSH 凭据库,提交前先用 `/myself` 验一次,
294
+ 不然不写入。旁边的「去配置」直达完整配置弹窗(条数 / 监视 / 通知 / 语言这些高级项)。
295
+
296
+ <img src="docs/images/panel-connect.zh.png" width="1040" alt="第一次用:面板里直接是「连接 Jira」表单,含服务地址 / 账号邮箱 / API token 三个输入框与「保存并连接」「去配置」按钮">
297
+
285
298
  ## 换令牌(插件配置页)
286
299
 
287
300
  **入口(三个,内容一样)**:
@@ -496,7 +509,7 @@ Zed(`zed`)、Sublime Text(`subl`)、gedit(`gedit`)——**找到可
496
509
 
497
510
  ## 版本与升级
498
511
 
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)。
512
+ 当前版本 **0.16.5**(2026-11-24)。`CHANGELOG.md` 记了 39 个版本(0.1.0 起),GitHub 上有 **14 个 tag / Release**(0.13.0 → 0.16.5),**0.13.4 是第一个公开版本**——更早的 0.1.0–0.12.0 只存在于 `CHANGELOG.md` 与项目记录里,没有对应的提交与 tag,所以「以前的版本」= **0.13.0 及以后**。逐版的完整说明见 [CHANGELOG.md](CHANGELOG.md)。
500
513
 
501
514
  ### 为什么有人还在装以前的版本
502
515
 
@@ -531,11 +544,12 @@ Zed(`zed`)、Sublime Text(`subl`)、gedit(`gedit`)——**找到可
531
544
  | 0.14.0 | 2026-11-19 | 功能 | 高亮挂到 **Jira 自己的优先级名次**;**首次发布到 npm** |
532
545
  | 0.15.0 | 2026-11-19 | 功能 | 改状态**不再全量重拉**、自己改的状态不再通知自己、失败提示按类型 |
533
546
  | 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
547
  | 0.16.0 | 2026-11-20 | 功能 | **整站搜索**、**按 epic 分组**、任务行**「计划」**(plan 模式会话) |
548
+ | 0.16.1 | 2026-11-22 | 修复 | Windows 通知与「在文件管理器中显示」、Linux 编辑器直选、UNC 路径;三平台 CI 与发版预检;README 补计划会话图解 |
549
+ | 0.16.2 | 2026-11-23 | **修复** | 左栏工作区右键菜单的「关联 Jira 项目…」会整页消失(客户端启动竞态);新增离线套件守住 |
550
+ | 0.16.3 | 2026-11-23 | **修复** | 配置页「Jira 连接」的服务地址改成可编辑输入框(placeholder = 当前地址,写进 profile 的 Cordis patch);失败提示里的「去配置」按钮和「保存并验证」同款样式 |
551
+ | 0.16.4 | 2026-11-23 | **修复** | 全新 profile 上把邮箱、令牌、站点地址一起填好、只点「保存并验证」时地址没落盘,面板一直说没配站点地址;配置保存成功后还会自动重拉列表 |
552
+ | 0.16.5 | 2026-11-24 | 功能 | **没配置时给的是表单而不是报错**:面板直接把「连接 Jira」表单(服务地址 / 邮箱 / API token)放在原来的失败位置,已保存的字段可留空,连接成功即重拉列表 |
539
553
 
540
554
  > 0.1.0–0.12.0 这 15 个版本都发生在 2026-11-18 同一天;0.13.0 起才有 tag 与 Release。
541
555
  > 想装某个旧版本:`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 +608,7 @@ plugin_manager install_bundle(target="dsh-jira-work-overview") # 已装过则
594
608
 
595
609
  1. 左侧栏**没有入口**、或 `plugin_manager` 显示 `active` 但界面是空的 → 先升级到 **0.13.2 以上**并刷新页面。
596
610
  2. 配置页报 **HTTP 404**、角标不更新 → 升到 **0.15.1 以上**。
597
- 3. 面板提示「没有令牌 / 令牌被拒 / 读不出令牌」→ 点提示里的「去配置」(或面板标题右侧「配置」)重填;**不用改 profile 文件**。
611
+ 3. **什么都还没配** → 面板里就是「连接 Jira」表单(站点地址 / 邮箱 / API token),缺什么填什么、点「保存并连接」。令牌被拒 / 读不出令牌仍是失败提示:点提示里的「去配置」(或面板标题右侧「配置」)重填;**不用改 profile 文件**。
598
612
  4. `/jira` 文本模式返回 `kind:'error'` 的原始报错是**故意的**——命令面本来就该看到真实原因;面板专用的是 `--json` 的分类型提示。
599
613
 
600
614
  ## 测试(`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: '实时监视中',
@@ -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',
@@ -1893,6 +1919,13 @@ window.__ModuleLoader__.load({
1893
1919
  .jmw-failure-actions{display:flex;justify-content:center;gap:8px}
1894
1920
  .jmw-failure-detail{max-width:360px;margin:14px auto 0;font-size:11px;line-height:1.5;
1895
1921
  color:var(--dsw-alias-label-tertiary,#8a8f99);white-space:pre-wrap;word-break:break-word}
1922
+ /* 还没配置时的内联「连接 Jira」表单:占的正是原来失败提示的位置,左对齐、字段竖排。 */
1923
+ .jmw-connect{max-width:420px;margin:0 auto;padding:26px 18px;text-align:left}
1924
+ .jmw-connect-title{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary,#1b1d22);margin-bottom:4px}
1925
+ .jmw-connect-hint{margin:0 0 12px;font-size:11.5px;line-height:1.6;color:var(--dsw-alias-label-secondary,#5c6270)}
1926
+ .jmw-connect-form{gap:4px}
1927
+ .jmw-connect-actions{justify-content:flex-start}
1928
+ .jmw-connect-note{margin-top:10px;font-size:11px;line-height:1.6;color:var(--dsw-alias-label-tertiary,#8a90a0)}
1896
1929
  .jmw-btn{padding:5px 14px;font:inherit;font-size:12px;color:var(--dsw-alias-label-primary,#1b1d22);cursor:pointer;
1897
1930
  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
1931
  border-radius:var(--dsw-radius-sm,8px)}
@@ -2512,6 +2545,165 @@ window.__ModuleLoader__.load({
2512
2545
  return String(value).replace(/["\\\]]/g, (ch) => `\\${ch}`);
2513
2546
  }
2514
2547
 
2548
+ /* ------------------------------------------------- 未配置时的内联连接表单 */
2549
+ //
2550
+ // 第一次用时(没站点 / 没邮箱 / 没令牌),host 把失败按 code 分类送回来。这几种「还没配」
2551
+ // 不该只给一句失败提示:面板在**原来显示失败的位置**直接渲染这张表单,填完就拉列表。
2552
+ // 三个字段都能留空沿用已保存值,提交走配置页同一个 /credential 路由 —— host 会先拿
2553
+ // 邮箱 + 令牌打一次 /myself,通过了才写凭据库 / 设置(401/403 直接拒绝并把原因回给这里)。
2554
+ function ConnectForm(props) {
2555
+ const [form, setForm] = React.useState({
2556
+ // 已保存的连接信息(GET /credential):用来回填 + 判断哪一项还缺。
2557
+ origin: null,
2558
+ baseUrl: '',
2559
+ email: '',
2560
+ token: '',
2561
+ busy: false,
2562
+ error: '',
2563
+ });
2564
+
2565
+ // 进面板先读一次已保存的连接信息:只缺令牌时,用户只需要粘贴令牌再点保存。
2566
+ React.useEffect(() => {
2567
+ let alive = true;
2568
+ (async () => {
2569
+ try {
2570
+ const response = await watchFetch(CREDENTIAL_PATH, { method: 'GET', headers: { accept: 'application/json' } });
2571
+ const payload = await response.json().catch(() => null);
2572
+ if (!alive) return;
2573
+ if (payload?.ok !== true) return;
2574
+ const baseUrl = String(payload?.settings?.baseUrl ?? '');
2575
+ const email = String(payload?.email ?? '');
2576
+ setForm((prev) => ({
2577
+ ...prev,
2578
+ origin: { baseUrl, email, configured: payload?.configured === true, masked: String(payload?.masked ?? '') },
2579
+ // 状态读回来得比首屏慢:用户已经手动改过的字段不回填。
2580
+ baseUrl: prev.baseUrl || baseUrl,
2581
+ email: prev.email || email,
2582
+ }));
2583
+ } catch {
2584
+ // 读不到状态不影响手动填写(提交时 host 会给出真正的错误)。
2585
+ }
2586
+ })();
2587
+ return () => { alive = false; };
2588
+ }, []);
2589
+
2590
+ const baseUrl = form.baseUrl.trim();
2591
+ const email = form.email.trim();
2592
+ const token = form.token.trim();
2593
+ const origin = form.origin;
2594
+ // 已保存过的字段不必再填;提交时只送改过的值,空的让 host 用当前值。
2595
+ const needBaseUrl = !origin || !origin.baseUrl;
2596
+ const needEmail = !origin || !origin.email;
2597
+ const needToken = !origin || !origin.configured;
2598
+ const canSubmit = !form.busy
2599
+ && (!needBaseUrl || baseUrl !== '')
2600
+ && (!needEmail || email !== '')
2601
+ && (!needToken || token !== '');
2602
+
2603
+ const update = (field, value) => setForm((prev) => ({ ...prev, [field]: value, error: '' }));
2604
+ const onEnter = (event) => { if (event?.key === 'Enter') void submit(); };
2605
+
2606
+ async function submit() {
2607
+ if (!canSubmit) return;
2608
+ const body = {};
2609
+ if (!origin || baseUrl !== origin.baseUrl) body.baseUrl = baseUrl;
2610
+ if (!origin || email !== origin.email) body.email = email;
2611
+ if (token) body.token = token;
2612
+ setForm((prev) => ({ ...prev, busy: true, error: '' }));
2613
+ try {
2614
+ const response = await watchFetch(CREDENTIAL_PATH, {
2615
+ method: 'POST',
2616
+ headers: { accept: 'application/json', 'content-type': 'application/json' },
2617
+ body: JSON.stringify(body),
2618
+ });
2619
+ const payload = await response.json().catch(() => null);
2620
+ // host 把「邮箱 / 令牌不被接受」也回成 ok:false + error:原样显示在表单下面。
2621
+ if (payload?.ok !== true) throw new Error(payload?.error || `HTTP ${response.status}`);
2622
+ setForm((prev) => ({ ...prev, busy: false, token: '' }));
2623
+ // 保存成功 → 回到列表加载;新凭据立刻生效,不用再点「重试」。
2624
+ props?.onConnected?.();
2625
+ } catch (error) {
2626
+ setForm((prev) => ({
2627
+ ...prev,
2628
+ busy: false,
2629
+ error: t('connectFailed', { message: String(error?.message ?? error) }),
2630
+ }));
2631
+ }
2632
+ }
2633
+
2634
+ return h('div', { className: 'jmw-state jmw-connect' }, [
2635
+ h('div', { key: 'title', className: 'jmw-connect-title' }, t('connectTitle')),
2636
+ h('div', { key: 'hint', className: 'jmw-connect-hint' }, t('connectHint')),
2637
+ h('div', { key: 'form', className: 'jmw-cred-form jmw-connect-form' }, [
2638
+ h('label', { key: 'bu-label', className: 'jmw-cred-label', htmlFor: 'jmw-connect-base-url' }, t('fBaseUrl')),
2639
+ h('input', {
2640
+ key: 'bu-input',
2641
+ id: 'jmw-connect-base-url',
2642
+ className: 'jmw-cred-input',
2643
+ type: 'url',
2644
+ inputMode: 'url',
2645
+ autoComplete: 'off',
2646
+ spellCheck: false,
2647
+ placeholder: t('baseUrlPlaceholderFallback'),
2648
+ value: form.baseUrl,
2649
+ onInput: (event) => update('baseUrl', event?.target?.value ?? ''),
2650
+ onKeyDown: onEnter,
2651
+ }),
2652
+ h('label', { key: 'em-label', className: 'jmw-cred-label', htmlFor: 'jmw-connect-email' }, t('credEmailLabel')),
2653
+ h('input', {
2654
+ key: 'em-input',
2655
+ id: 'jmw-connect-email',
2656
+ className: 'jmw-cred-input',
2657
+ type: 'text',
2658
+ inputMode: 'email',
2659
+ autoComplete: 'off',
2660
+ spellCheck: false,
2661
+ placeholder: 'name@company.com',
2662
+ value: form.email,
2663
+ onInput: (event) => update('email', event?.target?.value ?? ''),
2664
+ onKeyDown: onEnter,
2665
+ }),
2666
+ h('label', { key: 'tk-label', className: 'jmw-cred-label', htmlFor: 'jmw-connect-token' }, t('connectTokenLabel')),
2667
+ h('input', {
2668
+ key: 'tk-input',
2669
+ id: 'jmw-connect-token',
2670
+ className: 'jmw-cred-input',
2671
+ type: 'password',
2672
+ autoComplete: 'off',
2673
+ spellCheck: false,
2674
+ placeholder: origin?.configured
2675
+ ? t('connectTokenKeep', { masked: origin.masked })
2676
+ : t('connectTokenPlaceholder'),
2677
+ value: form.token,
2678
+ onInput: (event) => update('token', event?.target?.value ?? ''),
2679
+ onKeyDown: onEnter,
2680
+ }),
2681
+ ]),
2682
+ h('div', { key: 'actions', className: 'jmw-cred-actions jmw-connect-actions' }, [
2683
+ h('button', {
2684
+ key: 'submit',
2685
+ type: 'button',
2686
+ // 和配置页「保存并验证」同一套按钮样式(类 + 内联兜底色)。
2687
+ className: 'jmw-cred-btn primary',
2688
+ style: BTN_PRIMARY,
2689
+ disabled: !canSubmit,
2690
+ onClick: () => { void submit(); },
2691
+ }, form.busy ? t('connectSaving') : t('connectSubmit')),
2692
+ h('button', {
2693
+ key: 'config',
2694
+ type: 'button',
2695
+ className: 'jmw-cred-btn',
2696
+ style: BTN_PLAIN,
2697
+ onClick: () => props?.onOpenConfig?.(),
2698
+ }, t('failOpenConfig')),
2699
+ ]),
2700
+ form.error ? h('div', { key: 'error', className: 'jmw-cred-msg err' }, form.error) : null,
2701
+ h('div', { key: 'note', className: 'jmw-connect-note' }, [
2702
+ h('a', { key: 'tokens', className: 'jmw-cred-link', href: TOKENS_URL, target: '_blank', rel: 'noreferrer' }, t('credTokensLink')),
2703
+ ]),
2704
+ ]);
2705
+ }
2706
+
2515
2707
  function Panel() {
2516
2708
  const state = useSnapshot();
2517
2709
  const cardRef = React.useRef(null);
@@ -2714,9 +2906,11 @@ window.__ModuleLoader__.load({
2714
2906
  let body;
2715
2907
  if (state.failure) {
2716
2908
  // 可分类的失败:标题 + 一句「怎么办」+ 按钮;原始报错只在 detail 类里以小字附在下面。
2909
+ // 「还没配置」这一类(站点 / 邮箱 / 令牌)不给失败提示:同一块位置直接换成连接表单。
2717
2910
  const meta = failureMeta(state.failure.code);
2911
+ const setup = CONNECT_CODES.has(state.failure.code);
2718
2912
  const actions = [];
2719
- if (meta.config) {
2913
+ if (!setup && meta.config) {
2720
2914
  actions.push(h('button', {
2721
2915
  key: 'config',
2722
2916
  type: 'button',
@@ -2727,20 +2921,28 @@ window.__ModuleLoader__.load({
2727
2921
  onClick: () => setCredOpen(true),
2728
2922
  }, t('failOpenConfig')));
2729
2923
  }
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
- ]);
2924
+ if (!setup) {
2925
+ actions.push(h('button', {
2926
+ key: 'retry',
2927
+ type: 'button',
2928
+ className: 'jmw-btn',
2929
+ onClick: () => load(snapshot.scope),
2930
+ }, t('retry')));
2931
+ }
2932
+ body = setup
2933
+ ? h(ConnectForm, {
2934
+ key: 'connect',
2935
+ onConnected: () => { void load(snapshot.scope); },
2936
+ onOpenConfig: () => setCredOpen(true),
2937
+ })
2938
+ : h('div', { className: 'jmw-state err jmw-failure' }, [
2939
+ h('div', { key: 'title', className: 'jmw-failure-title' }, t(meta.title)),
2940
+ h('div', { key: 'hint', className: 'jmw-failure-hint' }, t(meta.hint)),
2941
+ h('div', { key: 'actions', className: 'jmw-failure-actions' }, actions),
2942
+ meta.detail && state.failure.message
2943
+ ? h('div', { key: 'detail', className: 'jmw-failure-detail' }, t('failDetail', { message: state.failure.message }))
2944
+ : null,
2945
+ ]);
2744
2946
  } else if (state.error) {
2745
2947
  body = h('div', { className: 'jmw-state err' }, [
2746
2948
  h('div', { key: 'msg', className: 'msg' }, state.error),
Binary file
Binary file
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.5",
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",
@@ -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];