dsh-jira-work-overview 0.14.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/README.md +9 -3
- package/README.zh.md +12 -2
- package/client.js +224 -10
- package/index.js +304 -38
- package/package.json +1 -1
- package/test/README.md +2 -1
- package/test/dsh-jira-credential.mjs +25 -3
- package/test/dsh-jira-json.mjs +5 -0
- package/test/dsh-jira-selfwatch.mjs +265 -0
- package/test/dsh-jira-visual.mjs +172 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,55 @@ 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
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.15.1] - 2026-11-19
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- **四条 `/api` 路由在真宿主里根本没注册 —— 配置页「读取令牌状态失败:HTTP 404」的根因。** 插件在 `apply()`
|
|
14
|
+
里同步 `ctx.get('connection')` 取 Fetch 注册表;而 `client-connection` 的 `apply` 是异步的(先建 BrowserAuth
|
|
15
|
+
的密钥),同一个加载批里它还没 provide,`ctx.get` 只返回 `undefined`,之后也不会有人再补 —— 角标状态 / 状态流转 /
|
|
16
|
+
令牌配置 / 配置写入四条路由就这样静默丢掉(Host 侧只剩三行「这个 profile 没有 connection.fetch 服务」的 note,
|
|
17
|
+
浏览器侧 `GET /api/jira-work-overview/credential` 直接 404)。现在四条路由统一走 `ctx.inject(['connection'], …)`,
|
|
18
|
+
等服务就绪再注册(服务重建时会重跑);没有 `ctx.inject` 的老宿主 / 离线测试桩仍退回同步读取。
|
|
19
|
+
- `test/dsh-jira-credential.mjs` 的宿主桩改成真宿主的时序:加载时 `ctx.get('connection')` 返回 `undefined`,
|
|
20
|
+
只有 `inject` 回调能看到它;回调执行后必须凑满 4 条路由,否则打印 `FAIL` 并以 1 退出。这条回归以前是
|
|
21
|
+
「离线测试全绿、真机路由全 404」。
|
|
22
|
+
|
|
23
|
+
## [0.15.0] - 2026-11-19
|
|
24
|
+
|
|
25
|
+
改状态变轻了(不再为一行变化重拉整个列表),也不会再被自己的操作通知一次;面板的失败提示按类型说话。
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- **改状态后不再全量重拉列表。** 面板以前写入成功后直接 `load()`,而 `/jira --json <scope> --limit=0` 会一直翻页把
|
|
30
|
+
几百条 issue 重新拉一遍;现在就地更新那一行(状态徽标、三色状态点),并按与 host 一致的口径重算 `counts`、
|
|
31
|
+
每个 `sprints[].counts`(组头的「未完成 N / 共 M」)、状态筛选菜单(新状态按「分类 → 名字」插入同一套排序)、
|
|
32
|
+
`total` 与 `projectTotals`;状态筛选开着时改到别的状态,该行就地消失、总数减一。只有当前载荷里找不到这个
|
|
33
|
+
key(列表还没加载完 / 已被别处刷掉)才回退到整表刷新。**行不重排**:`all` 范围按 `updated DESC` 排序,
|
|
34
|
+
本地更新拿不到新的 `updated`,这条会留在原位直到下一次整表刷新。
|
|
35
|
+
- **自己改的状态不再触发通知。** 写入前后记一份期望(key → from / to / 分类,TTL 24h,写在 POST 之前以堵住轮询
|
|
36
|
+
并发窗口),下一轮后台轮询 diff 命中同一对 from → to 时静默吸收,只推进基线:不弹系统通知、不进未读角标、
|
|
37
|
+
不进「N 项新变化」横幅。面板 POST 额外捎带 `from` / `to` / `category`;`jira_transition`(`apply: true`)
|
|
38
|
+
用自己手上的 `current` 与目标状态走同一条路径。自己把 Done 的 issue 改回未完成(重新出现在「未完成」查询里)
|
|
39
|
+
也不算「新指派」。**对账只认这一对值**:同事把同一个 issue 改成别的状态照常通知;写失败立刻撤销期望。
|
|
40
|
+
- `test/dsh-jira-visual.mjs` 新增 J 段:改状态后**没有**新的 `/jira` 命令、行内徽标 / 状态点 / 组头未完成数就地变、
|
|
41
|
+
POST 带上 `from` / `to` / 分类、新状态并入筛选菜单、状态筛选下改到别的状态该行消失且总数减一。
|
|
42
|
+
- 新增离线套件 `test/dsh-jira-selfwatch.mjs`:用 fetch 桩驱动后台轮询的 diff——别人改照常通知、面板 / 工具自己改
|
|
43
|
+
静默且基线推进、同事紧接着改成别的状态仍然通知、写失败不留残影、期望表消费干净。
|
|
44
|
+
- 测试钩子 `onWatchState`(与 `onNotify` / `onOpenPatch` / `onDetectEditors` 同一套手法,配置卡片里没有这一项)
|
|
45
|
+
和 `watchState.poll()`:离线测试直接推进一轮轮询,不用等真实的 15s+ 间隔。
|
|
46
|
+
- **可分类的失败 + 对应的提示文案。** `--json`(面板专用)失败时 host 不再抛错,改为回一份形状正常的载荷带 `ok:false` 与 `error.code`:`no_credential` / `credential_unreadable` / `no_email` / `no_base_url` / `auth`(HTTP 401/403)/ `network` / `http` / `not_json` / `unknown`。面板按 code 显示标题 + 一句「怎么办」,`去配置` 直达令牌弹窗、`重试` 重新查询;只有 `auth` / `network` / `http` / `not_json` 这类需要看原文的,才把原始 message 以小字附在提示下面。类型是 host 给的稳定 code,不靠匹配报错文案(`CommandResult` 只有 `{kind,text}` 两个槽)。
|
|
47
|
+
- 凭据库读不出来与「压根没配」分成两种(`credential_unreadable` / `no_credential`):前者说明三条来源都没有值、且凭据服务本身报错,提示是「重新保存一次令牌」而不是「去配置」。
|
|
48
|
+
- 后台监视的失败也带类型(`watch.lastErrorCode`):凭据没了这类原因在页脚显示同一句提示,而不是原始报错。
|
|
49
|
+
- `test/dsh-jira-visual.mjs` 新增 I 段:无令牌 → 提示 + 「去配置」打开弹窗且原始报错不可见;401 → 标题 + 详情小字;恢复后点「重试」回到正常列表。
|
|
50
|
+
- `test/dsh-jira-json.mjs` 在 `--json` 失败时打印 `SKIP:` 并以 0 退出(以前会 JSON.parse 崩掉)。
|
|
51
|
+
|
|
52
|
+
### Changed
|
|
53
|
+
|
|
54
|
+
- 文本模式的 `/jira`(人在命令面里敲)行为没变:失败仍返回 `kind:'error'` 的原始报错 —— 命令面本来就该看到真实原因。
|
|
55
|
+
|
|
7
56
|
## [0.14.0] - 2026-11-19
|
|
8
57
|
|
|
9
58
|
高亮不再写死「`Highest` 就是最高级」,改为挂到 Jira 自己给的优先级名次上。
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Show **your** Jira work items — with their real workflow status — inside [De
|
|
|
13
13
|
## What you get
|
|
14
14
|
|
|
15
15
|
- **Rows are highlighted by Jira's own priority order** — the top two levels get a row background and a left bar (reddest = highest), read from `GET /rest/api/3/priority` rather than a hard-coded "Highest", so a site that reorders priorities or uses custom names (`P0`, `Blocker`) still gets it right. Everything below stays uncoloured. If the site does not expose that list, the panel falls back to matching the names `Highest` / `High`.
|
|
16
|
-
- **Left-sidebar panel** — one row per issue, grouped by sprint (collapsible, newest sprint first), with project tabs, a single-select **status filter**, an **accurate total** in the header, priority highlighting (see above), and a status dropdown to move an issue through its workflow.
|
|
16
|
+
- **Left-sidebar panel** — one row per issue, grouped by sprint (collapsible, newest sprint first), with project tabs, a single-select **status filter**, an **accurate total** in the header, priority highlighting (see above), and a status dropdown to move an issue through its workflow **in place** — only that row and the counts are updated, the list is not re-fetched.
|
|
17
17
|
- **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.
|
|
18
18
|
- **Three agent tools** — `jira_my_work`, `jira_issue`, `jira_transition` (preview by default, writes only with `apply: true`).
|
|
19
19
|
- **One slash command** — `/jira [--json] [--limit=<n>|0] [--lang=<tag>] [open|sprint|all | <issue key> | <JQL>]`; it renders in the command surface, so it costs no model tokens.
|
|
@@ -33,7 +33,7 @@ Show **your** Jira work items — with their real workflow status — inside [De
|
|
|
33
33
|
DSH installs plugins from an **installation spec** — anything `pnpm add` accepts (registry package name, git URL, tarball, absolute path). Pick one:
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
-
# 1) from the npm registry (published since 0.14.0; pin a version with @0.
|
|
36
|
+
# 1) from the npm registry (published since 0.14.0; pin a version with @0.15.1)
|
|
37
37
|
plugin_manager install_bundle(target="dsh-jira-work-overview")
|
|
38
38
|
|
|
39
39
|
# 2) straight from GitHub (no npm publishing needed)
|
|
@@ -107,7 +107,9 @@ Prefer files? Add an override row to your profile's `cordis.patch.yml` (this is
|
|
|
107
107
|
|
|
108
108
|
### Live watch and notifications
|
|
109
109
|
|
|
110
|
-
The host polls `assignee = currentUser() AND statusCategory != Done` every `watchIntervalMs` (default 60 s, minimum 15 s). New assignments and status changes notify; items that simply leave the open list are recorded but stay silent. The first poll only establishes a baseline.
|
|
110
|
+
The host polls `assignee = currentUser() AND statusCategory != Done` every `watchIntervalMs` (default 60 s, minimum 15 s). New assignments and status changes notify; items that simply leave the open list are recorded but stay silent. The first poll only establishes a baseline.
|
|
111
|
+
|
|
112
|
+
A status **you** changed — from the panel dropdown or `jira_transition` — is not news: the write records the expected `from → to` and the next poll silently advances its baseline instead of raising a notification, an unread badge or a banner entry. The match is on that exact pair, so a colleague changing the same issue to something else still notifies. Notifications use `osascript` on macOS, a PowerShell Toast on Windows, and `notify-send` elsewhere — silently degrading if the platform refuses.
|
|
111
113
|
|
|
112
114
|
## Configuration reference
|
|
113
115
|
|
|
@@ -150,8 +152,12 @@ The plugin's own copy follows the DSH language setting; English and Chinese ship
|
|
|
150
152
|
| `Cannot reach https://… (…): ECONNRESET` / `HTTP 000` | your machine cannot reach Jira right now (VPN/proxy/network), not a plugin bug |
|
|
151
153
|
| "No matching work items" with no error row | the query returned nothing — widen the status filter or the project tab |
|
|
152
154
|
| footer says "live watch unavailable" | the Electron shell did not expose a fetch transport; the panel/badge degrade, tools still work |
|
|
155
|
+
| 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 |
|
|
153
156
|
| footer says "live watch disconnected" | transient transport error; it retries with backoff |
|
|
154
157
|
| token rejected when saving | the email + token pair is wrong, or the token has no Jira access |
|
|
158
|
+
| panel says "No Jira token yet" | nothing is configured yet: click **Configure** and paste an API token (or set `JIRA_API_TOKEN`) |
|
|
159
|
+
| panel says "Jira rejected this email / token pair" | 401/403 from Jira: regenerate the token; the raw response is under the hint |
|
|
160
|
+
| panel says "Could not read the stored token" | the credential store returned an error rather than a value: save the token again from **Configure** |
|
|
155
161
|
|
|
156
162
|
Behind a corporate proxy on Windows, DSH needs the proxy env vars it was started with (`NODE_USE_ENV_PROXY=1`) — the plugin itself never talks to the network outside `fetch`.
|
|
157
163
|
|
package/README.zh.md
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
DSH 用**安装 spec** 装插件 —— 凡是 `pnpm add` 能吃的写法都行(registry 包名、git 地址、tarball、绝对路径)。选一个:
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
# 1) 从 npm 装(0.14.0 起已发布;要钉版本就在后面写 @0.
|
|
22
|
+
# 1) 从 npm 装(0.14.0 起已发布;要钉版本就在后面写 @0.15.1)
|
|
23
23
|
plugin_manager install_bundle(target="dsh-jira-work-overview")
|
|
24
24
|
|
|
25
25
|
# 2) 直接从 GitHub 装(不需要 npm 发布)
|
|
@@ -105,9 +105,16 @@ all : assignee = currentUser() ORDER BY updated DESC
|
|
|
105
105
|
(逾期标红;没有到期日就显示更新时间)。
|
|
106
106
|
- **改状态**:点一行的状态徽标(`状态 ▾`)会在该行下面展开一串可选状态——**这不是随便写状态名,
|
|
107
107
|
而是 Jira 工作流此刻允许的流转**,由 Host 现查 `GET /issue/{key}/transitions` 得到;当前状态带 ✓ 且不可点。
|
|
108
|
-
点一个就写入,成功后顶部出现绿色提示 `APP-4051 已改为 IN QA
|
|
108
|
+
点一个就写入,成功后顶部出现绿色提示 `APP-4051 已改为 IN QA`,**列表只在本地更新这一行**(状态徽标、状态点、
|
|
109
|
+
组头的未完成数与筛选菜单都在本地重算,不再为改一个状态把几百条 issue 重新拉一遍;只有在当前列表里找不到这条时才回退整表刷新);
|
|
109
110
|
失败(例如某个流转要求必填字段)把 Jira 的报错原样显示在下拉里,不静默吞掉。
|
|
110
111
|
|
|
112
|
+
- **失败会说人话**:没配令牌 / 站点地址、凭据读不出来、令牌过期(401)、网络不通、站点返回非 JSON,
|
|
113
|
+
面板不再把 Host 的原始报错糊在列表位置,而是标题 + 一句「怎么办」:`去配置` 直接打开令牌弹窗、
|
|
114
|
+
`重试` 重新查询;只有需要看原文的那几类(认证失败 / 网络 / 站点错误)才把原始信息以小字附在下面。
|
|
115
|
+
错误类型来自 `--json` 载荷里的 `error.code`(`no_credential` / `credential_unreadable` / `no_email` /
|
|
116
|
+
`no_base_url` / `auth` / `network` / `http` / `not_json` / `unknown`),不是靠匹配报错文案;
|
|
117
|
+
文本模式的 `/jira` 仍返回原始报错。
|
|
111
118
|
- 数据来源就是上面的 `/jira --json`:client 半边用
|
|
112
119
|
`ctx.remote.commands.execute(sessionId, '/jira --json all --limit=0 [--status=<名字>] --lang=<lang>', [])`
|
|
113
120
|
在**当前会话**上执行该命令,再解析 JSON
|
|
@@ -179,6 +186,9 @@ Jira Cloud **没有**给第三方 issue 事件的 websocket / SSE 长连接(
|
|
|
179
186
|
新增指派 / 状态变化 → 弹一条**系统通知**(macOS 用 `osascript`、Windows 用 PowerShell 的 WinRT Toast、
|
|
180
187
|
其它平台试 `notify-send`;见「平台支持」),并记进未读变化;
|
|
181
188
|
issue 离开未完成列表只记不弹(多半是刚做完,不值得打扰)。第一轮只建基线,不通知。
|
|
189
|
+
- **自己改的不打扰**:面板下拉或 `jira_transition` 写入时,Host 会先记下这次流转的「起点 → 终点」;
|
|
190
|
+
下一轮轮询命中这对值就直接推进基线,不弹通知、不进未读角标、不进横幅。对账只认这一对,
|
|
191
|
+
同事把同一个 issue 改成别的状态照样通知;写失败会立刻撤掉这份期望,不会吞掉之后别人的真变化。
|
|
182
192
|
- **面板角标**:入口按钮右上角显示未读条数;面板顶部出现「N 项新变化」横幅(列出最近几条,
|
|
183
193
|
如 `APP-4018 In Review → IN QA`)和「标记已读」按钮;面板开着时又来新变化会自动刷新列表。
|
|
184
194
|
- **通道**:Host 在 `ctx.get('connection').fetch` 上注册四条精确路由——`/api/jira-work-overview/state`
|
package/client.js
CHANGED
|
@@ -72,6 +72,27 @@ window.__ModuleLoader__.load({
|
|
|
72
72
|
const GROUP_ESTIMATE = 64;
|
|
73
73
|
const ROW_OVERSCAN = 10;
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* 失败类型 → 提示文案(host 在 `--json` 载荷的 `error.code` 里给类型,见 index.js 的 JiraError)。
|
|
77
|
+
* `config: true` = 「去配置」能解决,给一个直达按钮;`detail: true` = 提示之外还该看原始 message
|
|
78
|
+
* (站点 / 网络给的具体原因)。表里没有的 code 一律按 unknown 处理。
|
|
79
|
+
*/
|
|
80
|
+
const FAILURES = {
|
|
81
|
+
no_credential: { title: 'failCredTitle', hint: 'failCredHint', config: true },
|
|
82
|
+
credential_unreadable: { title: 'failCredUnreadableTitle', hint: 'failCredUnreadableHint', config: true, detail: true },
|
|
83
|
+
no_email: { title: 'failEmailTitle', hint: 'failEmailHint', config: true },
|
|
84
|
+
no_base_url: { title: 'failBaseUrlTitle', hint: 'failBaseUrlHint', config: true },
|
|
85
|
+
auth: { title: 'failAuthTitle', hint: 'failAuthHint', config: true, detail: true },
|
|
86
|
+
network: { title: 'failNetworkTitle', hint: 'failNetworkHint', detail: true },
|
|
87
|
+
http: { title: 'failHttpTitle', hint: 'failHttpHint', detail: true },
|
|
88
|
+
not_json: { title: 'failNotJsonTitle', hint: 'failNotJsonHint', detail: true },
|
|
89
|
+
unknown: { title: 'failUnknownTitle', hint: 'failUnknownHint', detail: true },
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
function failureMeta(code) {
|
|
93
|
+
return Object.prototype.hasOwnProperty.call(FAILURES, code) ? FAILURES[code] : FAILURES.unknown;
|
|
94
|
+
}
|
|
95
|
+
|
|
75
96
|
/** 条数语义的客户端归一化(与 host 侧 index.js 的 normalizeLimit 同步):
|
|
76
97
|
* **0 = 不限制**,正数 clamp 到 10–5000,其它(非法 / 负数)回落到 fallback。 */
|
|
77
98
|
function normalizeLimit(value, fallback = LIMIT_DEFAULT) {
|
|
@@ -121,6 +142,27 @@ window.__ModuleLoader__.load({
|
|
|
121
142
|
noSession: '先在左侧打开一个会话:命令需要在某个会话上执行。',
|
|
122
143
|
unknownCommand: '命令没有执行:/jira 未注册或语法不对。',
|
|
123
144
|
commandFailed: '命令执行失败',
|
|
145
|
+
// 可分类的失败(host 在 --json 载荷里给 error.code):只显示提示 + 按钮,原始报错收进「详情」。
|
|
146
|
+
failCredTitle: '还没有配置 Jira 令牌',
|
|
147
|
+
failCredHint: '任务列表需要 Jira API token。点「去配置」填入账号邮箱和令牌,保存后再点「重试」。',
|
|
148
|
+
failCredUnreadableTitle: '读不出凭据库里的令牌',
|
|
149
|
+
failCredUnreadableHint: 'DSH 凭据库这次没有返回令牌,任务列表暂时拿不到凭据。稍后重试,或到「配置」里重新保存一次令牌。',
|
|
150
|
+
failEmailTitle: '还缺账号邮箱',
|
|
151
|
+
failEmailHint: 'Jira 的 Basic 认证 = 邮箱 + API token,点「去配置」补上邮箱。',
|
|
152
|
+
failBaseUrlTitle: '还没有配置 Jira 站点',
|
|
153
|
+
failBaseUrlHint: '在 profile 的 cordis.patch.yml 里给这一行加上 baseUrl(例如 https://your-site.atlassian.net),或在「配置」里打开 patch 文件。',
|
|
154
|
+
failAuthTitle: 'Jira 不认这组邮箱 / 令牌',
|
|
155
|
+
failAuthHint: '令牌可能已经过期或被撤销:到 Atlassian 账号页重新生成,再到「去配置」里换成新令牌。',
|
|
156
|
+
failNetworkTitle: '连不上 Jira',
|
|
157
|
+
failNetworkHint: '检查网络 / 代理,以及 baseUrl 是否写对,然后重试。',
|
|
158
|
+
failHttpTitle: 'Jira 返回了错误',
|
|
159
|
+
failHttpHint: '站点拒绝了这次查询,原始信息见下方。',
|
|
160
|
+
failNotJsonTitle: 'Jira 返回的不是 JSON',
|
|
161
|
+
failNotJsonHint: 'baseUrl 可能指到了别的站点(或代理的登录页),先确认它指向 Jira。',
|
|
162
|
+
failUnknownTitle: '读取任务列表失败',
|
|
163
|
+
failUnknownHint: '这次失败没有可归类的类型,原始信息见下方。',
|
|
164
|
+
failOpenConfig: '去配置',
|
|
165
|
+
failDetail: '原始信息:{message}',
|
|
124
166
|
untitled: '(无摘要)',
|
|
125
167
|
parent: '父 {key}',
|
|
126
168
|
watch: '实时监视中',
|
|
@@ -264,6 +306,28 @@ window.__ModuleLoader__.load({
|
|
|
264
306
|
noSession: 'Open a session first: the command must run on one.',
|
|
265
307
|
unknownCommand: 'Command did not run: /jira unregistered or malformed.',
|
|
266
308
|
commandFailed: 'Command failed',
|
|
309
|
+
// Classified failures (host puts error.code into the --json payload): show a hint + a button,
|
|
310
|
+
// tuck the raw message into "details".
|
|
311
|
+
failCredTitle: 'No Jira token yet',
|
|
312
|
+
failCredHint: 'The task list needs a Jira API token. Open "Configure", fill in your account email and token, then hit "Retry".',
|
|
313
|
+
failCredUnreadableTitle: 'Could not read the stored token',
|
|
314
|
+
failCredUnreadableHint: 'The DSH credential store did not return the token this time. Retry in a moment, or re-save the token under "Configure".',
|
|
315
|
+
failEmailTitle: 'Account email missing',
|
|
316
|
+
failEmailHint: 'Jira Basic auth is email + API token. Open "Configure" and add the email.',
|
|
317
|
+
failBaseUrlTitle: 'No Jira site configured',
|
|
318
|
+
failBaseUrlHint: 'Add baseUrl to this plugin\'s row in the profile\'s cordis.patch.yml (for example https://your-site.atlassian.net), or open the patch file from "Configure".',
|
|
319
|
+
failAuthTitle: 'Jira rejected this email / token pair',
|
|
320
|
+
failAuthHint: 'The token may be expired or revoked: generate a new one in your Atlassian account page, then replace it under "Configure".',
|
|
321
|
+
failNetworkTitle: 'Cannot reach Jira',
|
|
322
|
+
failNetworkHint: 'Check the network / proxy and that baseUrl is right, then retry.',
|
|
323
|
+
failHttpTitle: 'Jira returned an error',
|
|
324
|
+
failHttpHint: 'The site rejected this query; the raw message is below.',
|
|
325
|
+
failNotJsonTitle: 'Jira did not return JSON',
|
|
326
|
+
failNotJsonHint: 'baseUrl may point somewhere else (or at a proxy login page) — confirm it points at Jira.',
|
|
327
|
+
failUnknownTitle: 'Could not load the task list',
|
|
328
|
+
failUnknownHint: 'This failure has no known type; the raw message is below.',
|
|
329
|
+
failOpenConfig: 'Configure',
|
|
330
|
+
failDetail: 'Raw message: {message}',
|
|
267
331
|
untitled: '(no summary)',
|
|
268
332
|
parent: 'parent {key}',
|
|
269
333
|
watch: 'Live watch on',
|
|
@@ -437,6 +501,8 @@ window.__ModuleLoader__.load({
|
|
|
437
501
|
project: 'ALL',
|
|
438
502
|
loading: false,
|
|
439
503
|
error: '',
|
|
504
|
+
/** 可分类的失败(host --json 载荷的 error 对象):{code, message};有它时不显示原始错误串。 */
|
|
505
|
+
failure: null,
|
|
440
506
|
scope: DEFAULT_SCOPE,
|
|
441
507
|
data: null,
|
|
442
508
|
collapsed: {},
|
|
@@ -698,21 +764,122 @@ window.__ModuleLoader__.load({
|
|
|
698
764
|
}
|
|
699
765
|
}
|
|
700
766
|
|
|
767
|
+
/* ------------------------------------------------- 改状态后的就地更新 */
|
|
768
|
+
//
|
|
769
|
+
// 改状态成功后不再全量重拉列表:一次 `/jira --json all --limit=0` 会把几百条 issue 重新翻页拉一遍,
|
|
770
|
+
// 对「只变了一个状态」这件事太重。Jira 那边真正变的只有 status / statusCategory / updated,
|
|
771
|
+
// 其余字段(摘要、优先级、迭代、链接)本地都已经有了,所以就地改这一行 + 重算各级计数即可。
|
|
772
|
+
// 两级计数的口径与 host 的 buildWorkListJson / groupBySprint 一致:
|
|
773
|
+
// counts = 按 statusCategory 分桶 + total;sprints[].counts = 该组 keys 的分桶。
|
|
774
|
+
|
|
775
|
+
const CATEGORY_ORDER = ['new', 'indeterminate', 'done'];
|
|
776
|
+
|
|
777
|
+
function recountItems(items) {
|
|
778
|
+
const counts = { new: 0, indeterminate: 0, done: 0 };
|
|
779
|
+
for (const item of items) {
|
|
780
|
+
if (Object.prototype.hasOwnProperty.call(counts, item?.category)) counts[item.category] += 1;
|
|
781
|
+
}
|
|
782
|
+
return { ...counts, total: items.length };
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
/** 状态筛选菜单的选项:已见过的状态一个都不能少,新增的状态插进同一套排序(分类 → 名字)。 */
|
|
786
|
+
function mergeStatusOptions(options, name, category) {
|
|
787
|
+
const rows = (Array.isArray(options) ? options : [])
|
|
788
|
+
.filter((row) => row && typeof row.name === 'string' && row.name)
|
|
789
|
+
.map((row) => ({
|
|
790
|
+
name: row.name,
|
|
791
|
+
// 已有的分类以 host 为准;只有空分类才用这次回读的值补上。
|
|
792
|
+
category: typeof row.category === 'string' && row.category ? row.category : '',
|
|
793
|
+
}));
|
|
794
|
+
if (name) {
|
|
795
|
+
const hit = rows.find((row) => row.name === name);
|
|
796
|
+
if (hit) {
|
|
797
|
+
if (!hit.category && category) hit.category = category;
|
|
798
|
+
} else {
|
|
799
|
+
rows.push({ name, category: category || '' });
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
const rank = (row) => {
|
|
803
|
+
const index = CATEGORY_ORDER.indexOf(row.category);
|
|
804
|
+
return index < 0 ? CATEGORY_ORDER.length : index;
|
|
805
|
+
};
|
|
806
|
+
return rows.sort((a, b) => (rank(a) - rank(b)) || (a.name < b.name ? -1 : (a.name > b.name ? 1 : 0)));
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/** 按 items 重算每个 sprint 分组的成员与分桶(成员消失的分组直接去掉,跟 host 一致)。 */
|
|
810
|
+
function recountSprints(sprints, items) {
|
|
811
|
+
const byKey = new Map(items.map((item) => [item.key, item]));
|
|
812
|
+
return (Array.isArray(sprints) ? sprints : [])
|
|
813
|
+
.map((group) => {
|
|
814
|
+
const keys = (Array.isArray(group?.keys) ? group.keys : []).filter((key) => byKey.has(key));
|
|
815
|
+
return { ...group, keys, counts: recountItems(keys.map((key) => byKey.get(key))) };
|
|
816
|
+
})
|
|
817
|
+
.filter((group) => group.keys.length > 0);
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* 把一次成功的流转合进当前载荷:只动这一行 + 各级计数。
|
|
822
|
+
* 返回 false 表示当前载荷里没有这条(列表还没加载完 / 已被别处刷掉),调用方退回 load()。
|
|
823
|
+
*/
|
|
824
|
+
function applyLocalStatus(key, status, category) {
|
|
825
|
+
const data = snapshot.data;
|
|
826
|
+
if (!data || !Array.isArray(data.items)) return false;
|
|
827
|
+
const at = data.items.findIndex((item) => item?.key === key);
|
|
828
|
+
if (at < 0) return false;
|
|
829
|
+
const current = data.items[at];
|
|
830
|
+
const nextStatus = status || current.status;
|
|
831
|
+
const nextCategory = category || current.category || 'unknown';
|
|
832
|
+
let items = data.items.map((item) => (item === current
|
|
833
|
+
? { ...item, status: nextStatus, category: nextCategory }
|
|
834
|
+
: item));
|
|
835
|
+
// 状态筛选开着、新状态又不再命中:跟重新查询一样,这条要从列表里消失(计数也要跟着减)。
|
|
836
|
+
const filter = typeof snapshot.status === 'string' ? snapshot.status : '';
|
|
837
|
+
const dropped = Boolean(filter && filter !== nextStatus);
|
|
838
|
+
if (dropped) items = items.filter((item) => item.key !== key);
|
|
839
|
+
const project = current.project || String(key).split('-')[0] || '';
|
|
840
|
+
let projectTotals = data.projectTotals;
|
|
841
|
+
if (dropped && data.projectTotals && typeof data.projectTotals === 'object') {
|
|
842
|
+
projectTotals = { ...data.projectTotals };
|
|
843
|
+
if (typeof projectTotals[project] === 'number') {
|
|
844
|
+
projectTotals[project] = Math.max(0, projectTotals[project] - 1);
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
patch({
|
|
848
|
+
data: {
|
|
849
|
+
...data,
|
|
850
|
+
items,
|
|
851
|
+
counts: recountItems(items),
|
|
852
|
+
sprints: recountSprints(data.sprints, items),
|
|
853
|
+
statusOptions: mergeStatusOptions(data.statusOptions, nextStatus, nextCategory),
|
|
854
|
+
total: dropped && typeof data.total === 'number' ? Math.max(0, data.total - 1) : data.total,
|
|
855
|
+
projectTotals,
|
|
856
|
+
},
|
|
857
|
+
});
|
|
858
|
+
return true;
|
|
859
|
+
}
|
|
860
|
+
|
|
701
861
|
async function applyStatus(key, row) {
|
|
702
862
|
patch({ busyKey: key });
|
|
703
863
|
patchStatuses(key, { error: '' });
|
|
864
|
+
// 面板手上就有「这次流转从哪到哪、属于哪个分类」,一并发给 host:它拿这对 from/to
|
|
865
|
+
// 在下一轮后台轮询里认出「这是我自己改的」,既不再弹通知,也不会往未读角标里加一条。
|
|
866
|
+
const from = snapshot.statuses[key]?.current ?? '';
|
|
704
867
|
try {
|
|
705
868
|
const response = await watchFetch(TRANSITION_PATH, {
|
|
706
869
|
method: 'POST',
|
|
707
870
|
headers: { accept: 'application/json', 'content-type': 'application/json' },
|
|
708
|
-
body: JSON.stringify({ key, transitionId: row.id }),
|
|
871
|
+
body: JSON.stringify({ key, transitionId: row.id, from, to: row.to, category: row.category }),
|
|
709
872
|
});
|
|
710
873
|
const payload = await response.json().catch(() => null);
|
|
711
874
|
if (payload?.ok !== true) throw new Error(payload?.error || `HTTP ${response.status}`);
|
|
712
|
-
|
|
875
|
+
const status = String(payload.status ?? '').trim() || row.to || '';
|
|
876
|
+
// 关下拉、清流转缓存(下次展开按新状态重新列);列表就地更新,不再全量重拉。
|
|
713
877
|
patch({ menuKey: '', busyKey: '', statuses: {} });
|
|
714
|
-
flash(t('statusChanged', { key, status
|
|
715
|
-
|
|
878
|
+
flash(t('statusChanged', { key, status }));
|
|
879
|
+
if (!applyLocalStatus(key, status, payload.category || row.category || '')) {
|
|
880
|
+
// 极少数情况(列表还没加载 / 这条已不在当前载荷里)才退回整表刷新。
|
|
881
|
+
await load(snapshot.scope);
|
|
882
|
+
}
|
|
716
883
|
} catch (error) {
|
|
717
884
|
patchStatuses(key, { error: t('statusFailed', { message: String(error?.message ?? error) }) });
|
|
718
885
|
patch({ busyKey: '' });
|
|
@@ -755,13 +922,13 @@ window.__ModuleLoader__.load({
|
|
|
755
922
|
const sessionId = currentSessionId();
|
|
756
923
|
if (!sessionId) {
|
|
757
924
|
cancelLoad();
|
|
758
|
-
patch({ loading: false, scope: next, error: t('noSession') });
|
|
925
|
+
patch({ loading: false, scope: next, error: t('noSession'), failure: null });
|
|
759
926
|
return;
|
|
760
927
|
}
|
|
761
928
|
const seq = cancelLoad();
|
|
762
929
|
const controller = typeof AbortController === 'function' ? new AbortController() : undefined;
|
|
763
930
|
loadController = controller;
|
|
764
|
-
patch({ loading: true, error: '', scope: next });
|
|
931
|
+
patch({ loading: true, error: '', failure: null, scope: next });
|
|
765
932
|
try {
|
|
766
933
|
// host 的 i18n 已落地:命令面也把界面语言捎过去,否则 host 渲染的文案会跟面板不一致。
|
|
767
934
|
// 面板固定发 scope(all,含已完成/已关闭);`--status=` 是单选状态筛选,空串表示不筛。
|
|
@@ -778,10 +945,16 @@ window.__ModuleLoader__.load({
|
|
|
778
945
|
const outcome = result.value.result;
|
|
779
946
|
if (!outcome || outcome.kind !== 'success') throw new Error(outcome?.text || t('commandFailed'));
|
|
780
947
|
const data = JSON.parse(outcome.text);
|
|
781
|
-
|
|
948
|
+
// host 在 --json 失败时不再 throw,而是回一份形状正常的 ok:false 载荷:这里只留
|
|
949
|
+
// error.code / message,界面按 code 给提示,不把整句报错糊在列表位置。
|
|
950
|
+
if (data && data.ok === false) {
|
|
951
|
+
patch({ data: null, failure: data.error ?? { code: 'unknown', message: '' }, error: '', loading: false });
|
|
952
|
+
return;
|
|
953
|
+
}
|
|
954
|
+
patch({ data, failure: null, error: '', loading: false });
|
|
782
955
|
} catch (error) {
|
|
783
956
|
if (seq !== loadSeq) return; // 被新请求取代 / 主动取消:不当成错误显示
|
|
784
|
-
patch({ error: String(error?.message ?? error), loading: false });
|
|
957
|
+
patch({ error: String(error?.message ?? error), failure: null, loading: false });
|
|
785
958
|
} finally {
|
|
786
959
|
if (loadController === controller) loadController = null;
|
|
787
960
|
}
|
|
@@ -1007,10 +1180,19 @@ window.__ModuleLoader__.load({
|
|
|
1007
1180
|
.jmw-state{padding:34px 18px;text-align:center;color:var(--dsw-alias-label-tertiary,#8a8f99);font-size:12px}
|
|
1008
1181
|
.jmw-state.err{color:var(--dsw-alias-label-primary,#1b1d22)}
|
|
1009
1182
|
.jmw-state .msg{margin-bottom:12px;white-space:pre-wrap;word-break:break-word}
|
|
1183
|
+
/* 可分类的失败(没配令牌 / 站点 / 网络…):一句「怎么办」+ 按钮,原始报错只在需要时以小字附上。 */
|
|
1184
|
+
.jmw-failure{padding-top:40px}
|
|
1185
|
+
.jmw-failure-title{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary,#1b1d22);margin-bottom:6px}
|
|
1186
|
+
.jmw-failure-hint{max-width:320px;margin:0 auto 14px;line-height:1.6;color:var(--dsw-alias-label-secondary,#5c6270)}
|
|
1187
|
+
.jmw-failure-actions{display:flex;justify-content:center;gap:8px}
|
|
1188
|
+
.jmw-failure-detail{max-width:360px;margin:14px auto 0;font-size:11px;line-height:1.5;
|
|
1189
|
+
color:var(--dsw-alias-label-tertiary,#8a8f99);white-space:pre-wrap;word-break:break-word}
|
|
1010
1190
|
.jmw-btn{padding:5px 14px;font:inherit;font-size:12px;color:var(--dsw-alias-label-primary,#1b1d22);cursor:pointer;
|
|
1011
1191
|
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));
|
|
1012
1192
|
border-radius:var(--dsw-radius-sm,8px)}
|
|
1013
1193
|
.jmw-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(38,49,72,.1))}
|
|
1194
|
+
.jmw-btn.primary{color:#fff;background:var(--dsw-alias-brand-primary,#4d6bfe);border-color:transparent}
|
|
1195
|
+
.jmw-btn.primary:hover{background:color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 86%,#000)}
|
|
1014
1196
|
.jmw-skel{height:13px;margin:12px 40px;border-radius:7px;
|
|
1015
1197
|
background:linear-gradient(90deg,transparent,var(--dsw-alias-interactive-bg-hover,rgba(38,49,72,.08)),transparent);
|
|
1016
1198
|
background-size:220px 100%;animation:jmw-pulse 1.1s ease-in-out infinite}
|
|
@@ -1210,7 +1392,13 @@ window.__ModuleLoader__.load({
|
|
|
1210
1392
|
if (info.supported === false) {
|
|
1211
1393
|
return h('span', { key: 'watch', className: 'warn' }, t('watchUnsupported', { reason: info.reason || '—' }));
|
|
1212
1394
|
}
|
|
1213
|
-
if (info.error)
|
|
1395
|
+
if (info.error) {
|
|
1396
|
+
// 后台监视失败也要说人话:host 把类型放在 lastErrorCode 里,命中表就用那句提示当原因,
|
|
1397
|
+
// 否则退回原始 message(协议 / 站点细节只有它说得清)。
|
|
1398
|
+
const meta = info.lastErrorCode ? failureMeta(info.lastErrorCode) : null;
|
|
1399
|
+
const message = meta ? t(meta.title) : info.error;
|
|
1400
|
+
return h('span', { key: 'watch', className: 'warn' }, t('watchError', { message }));
|
|
1401
|
+
}
|
|
1214
1402
|
if (info.enabled === false) return h('span', { key: 'watch' }, t('watchOff'));
|
|
1215
1403
|
const checked = info.checkedAt ? ` ${t('watchChecked', { time: formatTime(info.checkedAt) })}` : '';
|
|
1216
1404
|
return h('span', { key: 'watch' }, `${t('watch')}${checked}`);
|
|
@@ -1553,7 +1741,33 @@ window.__ModuleLoader__.load({
|
|
|
1553
1741
|
: null;
|
|
1554
1742
|
|
|
1555
1743
|
let body;
|
|
1556
|
-
if (state.
|
|
1744
|
+
if (state.failure) {
|
|
1745
|
+
// 可分类的失败:标题 + 一句「怎么办」+ 按钮;原始报错只在 detail 类里以小字附在下面。
|
|
1746
|
+
const meta = failureMeta(state.failure.code);
|
|
1747
|
+
const actions = [];
|
|
1748
|
+
if (meta.config) {
|
|
1749
|
+
actions.push(h('button', {
|
|
1750
|
+
key: 'config',
|
|
1751
|
+
type: 'button',
|
|
1752
|
+
className: 'jmw-btn primary',
|
|
1753
|
+
onClick: () => setCredOpen(true),
|
|
1754
|
+
}, t('failOpenConfig')));
|
|
1755
|
+
}
|
|
1756
|
+
actions.push(h('button', {
|
|
1757
|
+
key: 'retry',
|
|
1758
|
+
type: 'button',
|
|
1759
|
+
className: 'jmw-btn',
|
|
1760
|
+
onClick: () => load(snapshot.scope),
|
|
1761
|
+
}, t('retry')));
|
|
1762
|
+
body = h('div', { className: 'jmw-state err jmw-failure' }, [
|
|
1763
|
+
h('div', { key: 'title', className: 'jmw-failure-title' }, t(meta.title)),
|
|
1764
|
+
h('div', { key: 'hint', className: 'jmw-failure-hint' }, t(meta.hint)),
|
|
1765
|
+
h('div', { key: 'actions', className: 'jmw-failure-actions' }, actions),
|
|
1766
|
+
meta.detail && state.failure.message
|
|
1767
|
+
? h('div', { key: 'detail', className: 'jmw-failure-detail' }, t('failDetail', { message: state.failure.message }))
|
|
1768
|
+
: null,
|
|
1769
|
+
]);
|
|
1770
|
+
} else if (state.error) {
|
|
1557
1771
|
body = h('div', { className: 'jmw-state err' }, [
|
|
1558
1772
|
h('div', { key: 'msg', className: 'msg' }, state.error),
|
|
1559
1773
|
h('button', { key: 'retry', type: 'button', className: 'jmw-btn', onClick: () => load(snapshot.scope) }, t('retry')),
|