@cnzgray/dsh-mattpocock-workflow 0.4.0 → 0.5.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/lib/client.js +267 -66
- package/lib/index.js +1155 -440
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -184,6 +184,7 @@ var zh = {
|
|
|
184
184
|
"refresh.action": "\u5237\u65B0",
|
|
185
185
|
"refresh.busy": "\u5237\u65B0\u4E2D\u2026",
|
|
186
186
|
"refresh.full": "\u5168\u91CF\u5237\u65B0",
|
|
187
|
+
"refresh.title": "\u5237\u65B0\uFF08Shift+\u70B9\u51FB\uFF1A\u5FFD\u7565\u672C\u5730\u7F13\u5B58\u5168\u91CF\u91CD\u62C9\uFF09",
|
|
187
188
|
"tickets.loaded": "\u5DF2\u52A0\u8F7D {loaded} / \u5171 {total}",
|
|
188
189
|
"tickets.loadedCapped": "\uFF0C\u5DF2\u8FBE\u4E0A\u9650",
|
|
189
190
|
"tickets.emptyRepo": "\u8FD9\u4E2A\u4ED3\u5E93\u8FD8\u6CA1\u6709\u5DE5\u5355\u3002",
|
|
@@ -303,6 +304,7 @@ var zh = {
|
|
|
303
304
|
"error.rpcBadResponse": "\u5BBF\u4E3B\u8FD4\u56DE\u7684\u54CD\u5E94\u683C\u5F0F\u4E0D\u6B63\u786E\u3002",
|
|
304
305
|
"error.rpcNetworkFailed": "\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25\uFF1A{detail}",
|
|
305
306
|
"error.snapshotNoWorkspace": "\u5F53\u524D\u4F1A\u8BDD\u6CA1\u6709\u5DE5\u4F5C\u533A\u76EE\u5F55\uFF0C\u65E0\u6CD5\u8BFB\u53D6\u5DE5\u5355\u3002",
|
|
307
|
+
"error.deltaWithoutBase": "\u5237\u65B0\u56DE\u5305\u7F3A\u5C11\u57FA\u51C6\u5FEB\u7167\uFF0C\u5DF2\u4FDD\u7559\u5F53\u524D\u6570\u636E\u3002",
|
|
306
308
|
"error.openEnvCheck": "\u67E5\u770B\u73AF\u5883\u68C0\u67E5",
|
|
307
309
|
"env.summary": "\u73AF\u5883\u68C0\u67E5 {pass}/{total}",
|
|
308
310
|
"env.recheck": "\u91CD\u65B0\u68C0\u67E5",
|
|
@@ -656,6 +658,7 @@ var en = {
|
|
|
656
658
|
"refresh.action": "Refresh",
|
|
657
659
|
"refresh.busy": "Refreshing\u2026",
|
|
658
660
|
"refresh.full": "Full refresh",
|
|
661
|
+
"refresh.title": "Refresh (Shift+click: refetch all, ignoring the local store)",
|
|
659
662
|
"tickets.loaded": "Loaded {loaded} of {total}",
|
|
660
663
|
"tickets.loadedCapped": " (limit reached)",
|
|
661
664
|
"tickets.emptyRepo": "This repository has no tickets yet.",
|
|
@@ -775,6 +778,7 @@ var en = {
|
|
|
775
778
|
"error.rpcBadResponse": "The host returned a malformed response.",
|
|
776
779
|
"error.rpcNetworkFailed": "Network request failed: {detail}",
|
|
777
780
|
"error.snapshotNoWorkspace": "This session has no workspace directory; cannot read tickets.",
|
|
781
|
+
"error.deltaWithoutBase": "The refresh payload has no base snapshot; kept the current data.",
|
|
778
782
|
"error.openEnvCheck": "Check environment",
|
|
779
783
|
"env.summary": "Environment check {pass}/{total}",
|
|
780
784
|
"env.recheck": "Recheck",
|
|
@@ -1326,6 +1330,8 @@ var ERROR_CODES = {
|
|
|
1326
1330
|
fetchFailed: "fetch-failed",
|
|
1327
1331
|
/** 编号不存在或工单已被删除。 */
|
|
1328
1332
|
ticketNotFound: "ticket-not-found",
|
|
1333
|
+
/** 后端拒绝了请求(限流);携带服务端要求的重试等待时按它退避。 */
|
|
1334
|
+
rateLimited: "rate-limited",
|
|
1329
1335
|
/** 当前后端不提供所请求的详情或写能力。 */
|
|
1330
1336
|
capabilityUnsupported: "capability-unsupported",
|
|
1331
1337
|
invalidParams: "invalid-params",
|
|
@@ -1351,8 +1357,12 @@ function createPanelClient(t2, fetchImpl = defaultFetch) {
|
|
|
1351
1357
|
get: (workspaceRoot) => call(fetchImpl, t2, RPC_METHODS.snapshotGet, { workspaceRoot }, isSnapshotResult),
|
|
1352
1358
|
more: (workspaceRoot) => call(fetchImpl, t2, RPC_METHODS.snapshotMore, { workspaceRoot }, isSnapshotResult),
|
|
1353
1359
|
refresh: (workspaceRoot, options) => {
|
|
1354
|
-
const params =
|
|
1355
|
-
|
|
1360
|
+
const params = {
|
|
1361
|
+
workspaceRoot,
|
|
1362
|
+
...options?.full === true ? { full: true } : {},
|
|
1363
|
+
...options?.ifVersion === void 0 ? {} : { ifVersion: options.ifVersion }
|
|
1364
|
+
};
|
|
1365
|
+
return call(fetchImpl, t2, RPC_METHODS.snapshotRefresh, params, isSnapshotRefreshResult);
|
|
1356
1366
|
},
|
|
1357
1367
|
cache: (workspaceRoot, options) => {
|
|
1358
1368
|
const params = options?.clear === true ? { workspaceRoot, clear: true, confirm: SNAPSHOT_CLEAR_CONFIRMATION } : { workspaceRoot };
|
|
@@ -1360,11 +1370,11 @@ function createPanelClient(t2, fetchImpl = defaultFetch) {
|
|
|
1360
1370
|
},
|
|
1361
1371
|
resolveBlockers: (workspaceRoot) => call(fetchImpl, t2, RPC_METHODS.snapshotResolveBlockers, { workspaceRoot }, isSnapshotResult),
|
|
1362
1372
|
envCheck: (workspaceRoot) => call(fetchImpl, t2, RPC_METHODS.envCheck, { workspaceRoot }, isEnvCheckResult),
|
|
1363
|
-
getDetail: (workspaceRoot, ref, number) => call(
|
|
1373
|
+
getDetail: (workspaceRoot, ref, number, repository) => call(
|
|
1364
1374
|
fetchImpl,
|
|
1365
1375
|
t2,
|
|
1366
1376
|
RPC_METHODS.ticketGet,
|
|
1367
|
-
{ workspaceRoot, ref, number },
|
|
1377
|
+
{ workspaceRoot, ref, number, ...repository === void 0 ? {} : { repository } },
|
|
1368
1378
|
isTicketDetailResult
|
|
1369
1379
|
),
|
|
1370
1380
|
updateTicket: (workspaceRoot, ref, number, patch) => call(
|
|
@@ -1433,6 +1443,23 @@ function isRpcResult(value, isPayload) {
|
|
|
1433
1443
|
function isSnapshotResult(value) {
|
|
1434
1444
|
return isRpcResult(value, isWorkspaceSnapshot);
|
|
1435
1445
|
}
|
|
1446
|
+
function isSnapshotRefreshResult(value) {
|
|
1447
|
+
return isRpcResult(value, isSnapshotRefreshResultPayload);
|
|
1448
|
+
}
|
|
1449
|
+
function isSnapshotRefreshResultPayload(value) {
|
|
1450
|
+
if (!isObject(value)) return false;
|
|
1451
|
+
if (typeof value.kind !== "string") return false;
|
|
1452
|
+
if (value.kind === "full") {
|
|
1453
|
+
return "snapshot" in value && isWorkspaceSnapshot(value.snapshot);
|
|
1454
|
+
}
|
|
1455
|
+
if (value.kind === "not-modified") {
|
|
1456
|
+
return typeof value.version === "number" && typeof value.checkedAt === "number";
|
|
1457
|
+
}
|
|
1458
|
+
if (value.kind === "changes") {
|
|
1459
|
+
return typeof value.version === "number" && typeof value.fetchedAt === "number" && Array.isArray(value.tickets) && value.tickets.every(hasTicketFilterFields) && isStringArray(value.removed) && typeof value.metrics === "object" && value.metrics !== null && (value.viewer === null || typeof value.viewer === "string") && typeof value.total === "number" && typeof value.loaded === "number" && typeof value.windowLimit === "number" && typeof value.blockersFinalized === "boolean";
|
|
1460
|
+
}
|
|
1461
|
+
return false;
|
|
1462
|
+
}
|
|
1436
1463
|
function isWorkspaceSnapshot(value) {
|
|
1437
1464
|
if (typeof value !== "object" || value === null) return false;
|
|
1438
1465
|
if (!("backend" in value) || typeof value.backend !== "string") return false;
|
|
@@ -1448,6 +1475,9 @@ function isWorkspaceSnapshot(value) {
|
|
|
1448
1475
|
if (!("hierarchy" in value) || !(value.hierarchy === "native" || value.hierarchy === "convention" || value.hierarchy === "none")) {
|
|
1449
1476
|
return false;
|
|
1450
1477
|
}
|
|
1478
|
+
if (!("libraryVersion" in value) || !(value.libraryVersion === null || typeof value.libraryVersion === "number")) {
|
|
1479
|
+
return false;
|
|
1480
|
+
}
|
|
1451
1481
|
if (!("tickets" in value) || !Array.isArray(value.tickets)) return false;
|
|
1452
1482
|
if (!value.tickets.every(hasTicketFilterFields)) return false;
|
|
1453
1483
|
if (!("metrics" in value) || typeof value.metrics !== "object" || value.metrics === null) {
|
|
@@ -3014,11 +3044,19 @@ function blockerItems(ticket, tickets) {
|
|
|
3014
3044
|
}
|
|
3015
3045
|
return items;
|
|
3016
3046
|
}
|
|
3017
|
-
|
|
3018
|
-
|
|
3047
|
+
var BLOCKER_REF = /^(?:([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+))?#(\d+)$/;
|
|
3048
|
+
function parseBlockerRef(ref) {
|
|
3049
|
+
const match = BLOCKER_REF.exec(ref);
|
|
3019
3050
|
if (match === null) return null;
|
|
3020
|
-
const number = Number.parseInt(match[
|
|
3021
|
-
|
|
3051
|
+
const number = Number.parseInt(match[2] ?? "", 10);
|
|
3052
|
+
if (!Number.isSafeInteger(number)) return null;
|
|
3053
|
+
return { repository: match[1] ?? null, number };
|
|
3054
|
+
}
|
|
3055
|
+
function blockerNumber(ref) {
|
|
3056
|
+
return parseBlockerRef(ref)?.number ?? null;
|
|
3057
|
+
}
|
|
3058
|
+
function blockerRepository(ref) {
|
|
3059
|
+
return parseBlockerRef(ref)?.repository ?? null;
|
|
3022
3060
|
}
|
|
3023
3061
|
function findSnapshotTicket(tickets, ref) {
|
|
3024
3062
|
return tickets?.find((ticket) => ticket.ref === ref) ?? null;
|
|
@@ -3116,7 +3154,7 @@ function useDetailNavigation(workspaceRoot) {
|
|
|
3116
3154
|
setNavigation({
|
|
3117
3155
|
open: {
|
|
3118
3156
|
workspaceRoot,
|
|
3119
|
-
target: { ref: ticket.ref, number: ticket.number, ticket }
|
|
3157
|
+
target: { ref: ticket.ref, number: ticket.number, ticket, repository: null }
|
|
3120
3158
|
},
|
|
3121
3159
|
stack: []
|
|
3122
3160
|
});
|
|
@@ -3133,7 +3171,8 @@ function useDetailNavigation(workspaceRoot) {
|
|
|
3133
3171
|
target: {
|
|
3134
3172
|
ref,
|
|
3135
3173
|
number: row?.number ?? blockerNumber(ref),
|
|
3136
|
-
ticket: row
|
|
3174
|
+
ticket: row,
|
|
3175
|
+
repository: blockerRepository(ref)
|
|
3137
3176
|
}
|
|
3138
3177
|
},
|
|
3139
3178
|
stack: [...current.stack, from]
|
|
@@ -5951,11 +5990,33 @@ async function loadSnapshot(target, mode) {
|
|
|
5951
5990
|
const quiet = mode === "auto" && target.hasData.current;
|
|
5952
5991
|
if (!quiet) target.setPhase(mode === "get" ? "loading" : "refreshing");
|
|
5953
5992
|
target.setError(null);
|
|
5954
|
-
|
|
5993
|
+
if (mode === "get") {
|
|
5994
|
+
const result2 = await target.client.get(target.workspaceRoot);
|
|
5995
|
+
if (current !== target.sequence.current) return null;
|
|
5996
|
+
if (!result2.ok) return applyFailure(target, mode, quiet, result2.error);
|
|
5997
|
+
const root2 = target.workspaceRoot;
|
|
5998
|
+
return quiet ? applyQuiet(target, root2, current, result2.result) : applyLoaded(target, root2, current, result2.result);
|
|
5999
|
+
}
|
|
6000
|
+
const held = target.latest.current?.libraryVersion;
|
|
6001
|
+
const result = await target.client.refresh(target.workspaceRoot, {
|
|
6002
|
+
...mode === "refresh-full" ? { full: true } : {},
|
|
6003
|
+
...held === null || held === void 0 ? {} : { ifVersion: held }
|
|
6004
|
+
});
|
|
5955
6005
|
if (current !== target.sequence.current) return null;
|
|
5956
6006
|
if (!result.ok) return applyFailure(target, mode, quiet, result.error);
|
|
5957
6007
|
const root = target.workspaceRoot;
|
|
5958
|
-
|
|
6008
|
+
const payload = result.result;
|
|
6009
|
+
if (payload.kind === "not-modified") {
|
|
6010
|
+
return applyNotModified(target, root, current, quiet, payload.checkedAt);
|
|
6011
|
+
}
|
|
6012
|
+
const snapshot = payload.kind === "full" ? payload.snapshot : mergeChanges(target, payload);
|
|
6013
|
+
if (snapshot === null) {
|
|
6014
|
+
return applyFailure(target, mode, quiet, {
|
|
6015
|
+
code: "fetch-failed",
|
|
6016
|
+
message: target.t("error.deltaWithoutBase")
|
|
6017
|
+
});
|
|
6018
|
+
}
|
|
6019
|
+
return quiet ? applyQuiet(target, root, current, snapshot) : applyLoaded(target, root, current, snapshot);
|
|
5959
6020
|
}
|
|
5960
6021
|
async function loadMoreSnapshot(target, running) {
|
|
5961
6022
|
if (target.workspaceRoot === void 0 || running.current) return null;
|
|
@@ -5994,6 +6055,42 @@ function applyFailure(target, mode, quiet, error) {
|
|
|
5994
6055
|
if (!quiet) target.setPhase("ready");
|
|
5995
6056
|
return null;
|
|
5996
6057
|
}
|
|
6058
|
+
async function applyNotModified(target, root, current, quiet, checkedAt) {
|
|
6059
|
+
const base = target.latest.current;
|
|
6060
|
+
target.setRefreshError(null);
|
|
6061
|
+
if (!quiet) target.setPhase("ready");
|
|
6062
|
+
if (base === null) return null;
|
|
6063
|
+
const verified = {
|
|
6064
|
+
...base,
|
|
6065
|
+
source: "live",
|
|
6066
|
+
stale: false,
|
|
6067
|
+
refreshError: null,
|
|
6068
|
+
fetchedAt: checkedAt
|
|
6069
|
+
};
|
|
6070
|
+
return applyQuiet(target, root, current, verified);
|
|
6071
|
+
}
|
|
6072
|
+
function mergeChanges(target, changes) {
|
|
6073
|
+
const base = target.latest.current;
|
|
6074
|
+
if (base === null) return null;
|
|
6075
|
+
const byRef = new Map(base.tickets.map((ticket) => [ticket.ref, ticket]));
|
|
6076
|
+
for (const ref of changes.removed) byRef.delete(ref);
|
|
6077
|
+
for (const row of changes.tickets) byRef.set(row.ref, row);
|
|
6078
|
+
return {
|
|
6079
|
+
...base,
|
|
6080
|
+
tickets: [...byRef.values()],
|
|
6081
|
+
metrics: changes.metrics,
|
|
6082
|
+
viewer: changes.viewer,
|
|
6083
|
+
total: changes.total,
|
|
6084
|
+
loaded: changes.loaded,
|
|
6085
|
+
windowLimit: changes.windowLimit,
|
|
6086
|
+
fetchedAt: changes.fetchedAt,
|
|
6087
|
+
libraryVersion: changes.version,
|
|
6088
|
+
source: "live",
|
|
6089
|
+
stale: false,
|
|
6090
|
+
refreshError: null,
|
|
6091
|
+
blockersFinalized: changes.blockersFinalized
|
|
6092
|
+
};
|
|
6093
|
+
}
|
|
5997
6094
|
async function applyQuiet(target, root, current, result) {
|
|
5998
6095
|
let settled = result;
|
|
5999
6096
|
if (!settled.blockersFinalized) {
|
|
@@ -7240,8 +7337,41 @@ async function copyText2(text, t2) {
|
|
|
7240
7337
|
}
|
|
7241
7338
|
}
|
|
7242
7339
|
|
|
7340
|
+
// src/client/detail-cache.ts
|
|
7341
|
+
var DETAIL_CACHE_PER_WORKSPACE = 100;
|
|
7342
|
+
var DETAIL_CACHE_WORKSPACES = 5;
|
|
7343
|
+
function detailCacheDecision(hit, currentUpdatedAt) {
|
|
7344
|
+
if (hit !== null && currentUpdatedAt !== void 0 && hit.updatedAt === currentUpdatedAt) {
|
|
7345
|
+
return "hit";
|
|
7346
|
+
}
|
|
7347
|
+
return hit !== null ? "stale" : "miss";
|
|
7348
|
+
}
|
|
7349
|
+
var caches = /* @__PURE__ */ new Map();
|
|
7350
|
+
function readDetailCache(workspaceRoot, ref) {
|
|
7351
|
+
return caches.get(workspaceRoot)?.get(ref) ?? null;
|
|
7352
|
+
}
|
|
7353
|
+
function writeDetailCache(workspaceRoot, detail) {
|
|
7354
|
+
let cache = caches.get(workspaceRoot);
|
|
7355
|
+
if (cache === void 0) {
|
|
7356
|
+
while (caches.size >= DETAIL_CACHE_WORKSPACES) {
|
|
7357
|
+
const oldest = caches.keys().next().value;
|
|
7358
|
+
if (oldest === void 0) break;
|
|
7359
|
+
caches.delete(oldest);
|
|
7360
|
+
}
|
|
7361
|
+
cache = /* @__PURE__ */ new Map();
|
|
7362
|
+
caches.set(workspaceRoot, cache);
|
|
7363
|
+
}
|
|
7364
|
+
cache.delete(detail.ref);
|
|
7365
|
+
cache.set(detail.ref, { detail, updatedAt: detail.updatedAt });
|
|
7366
|
+
while (cache.size > DETAIL_CACHE_PER_WORKSPACE) {
|
|
7367
|
+
const oldest = cache.keys().next().value;
|
|
7368
|
+
if (oldest === void 0) break;
|
|
7369
|
+
cache.delete(oldest);
|
|
7370
|
+
}
|
|
7371
|
+
}
|
|
7372
|
+
|
|
7243
7373
|
// src/client/ticket-detail-hooks.ts
|
|
7244
|
-
function useDetailRequest(client, workspaceRoot, ref, number) {
|
|
7374
|
+
function useDetailRequest(client, workspaceRoot, ref, number, repository, currentUpdatedAt) {
|
|
7245
7375
|
const [detail, setDetail] = React26.useState(null);
|
|
7246
7376
|
const [error, setError] = React26.useState(null);
|
|
7247
7377
|
const [phase, setPhase] = React26.useState("loading");
|
|
@@ -7251,45 +7381,43 @@ function useDetailRequest(client, workspaceRoot, ref, number) {
|
|
|
7251
7381
|
const readId = React26.useRef(0);
|
|
7252
7382
|
const readRunning = React26.useRef(false);
|
|
7253
7383
|
React26.useEffect(() => {
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
7263
|
-
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
7267
|
-
|
|
7268
|
-
|
|
7269
|
-
setError(result.error);
|
|
7270
|
-
setPhase("error");
|
|
7384
|
+
return startDetailLoad({
|
|
7385
|
+
client,
|
|
7386
|
+
workspaceRoot,
|
|
7387
|
+
ref,
|
|
7388
|
+
number,
|
|
7389
|
+
repository,
|
|
7390
|
+
currentUpdatedAt,
|
|
7391
|
+
attempt,
|
|
7392
|
+
readId,
|
|
7393
|
+
readRunning,
|
|
7394
|
+
setDetail,
|
|
7395
|
+
setError,
|
|
7396
|
+
setPhase,
|
|
7397
|
+
setRefreshing,
|
|
7398
|
+
setRefreshError
|
|
7271
7399
|
});
|
|
7272
|
-
|
|
7273
|
-
active = false;
|
|
7274
|
-
readId.current += 1;
|
|
7275
|
-
};
|
|
7276
|
-
}, [client, workspaceRoot, ref, number, attempt]);
|
|
7400
|
+
}, [client, workspaceRoot, ref, number, repository, attempt, currentUpdatedAt]);
|
|
7277
7401
|
const refresh = () => {
|
|
7278
7402
|
if (readRunning.current) return;
|
|
7279
7403
|
readRunning.current = true;
|
|
7280
7404
|
const current = readId.current + 1;
|
|
7281
7405
|
readId.current = current;
|
|
7282
7406
|
setRefreshing(true);
|
|
7283
|
-
void client.getDetail(workspaceRoot, ref, number).then((result) => {
|
|
7407
|
+
void client.getDetail(workspaceRoot, ref, number, repository ?? void 0).then((result) => {
|
|
7284
7408
|
if (readId.current !== current) return;
|
|
7285
7409
|
readRunning.current = false;
|
|
7286
7410
|
setRefreshing(false);
|
|
7287
|
-
|
|
7288
|
-
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
|
|
7292
|
-
|
|
7411
|
+
applyDetailRead({
|
|
7412
|
+
workspaceRoot,
|
|
7413
|
+
result,
|
|
7414
|
+
cached: true,
|
|
7415
|
+
setDetail,
|
|
7416
|
+
setPhase,
|
|
7417
|
+
setError,
|
|
7418
|
+
setRefreshError
|
|
7419
|
+
});
|
|
7420
|
+
if (result.ok) setRefreshError(null);
|
|
7293
7421
|
});
|
|
7294
7422
|
};
|
|
7295
7423
|
return {
|
|
@@ -7299,12 +7427,86 @@ function useDetailRequest(client, workspaceRoot, ref, number) {
|
|
|
7299
7427
|
reload: () => {
|
|
7300
7428
|
setAttempt((value) => value + 1);
|
|
7301
7429
|
},
|
|
7302
|
-
replace:
|
|
7430
|
+
replace: (next) => {
|
|
7431
|
+
writeDetailCache(workspaceRoot, next);
|
|
7432
|
+
setDetail(next);
|
|
7433
|
+
},
|
|
7303
7434
|
refresh,
|
|
7304
7435
|
refreshing,
|
|
7305
7436
|
refreshError
|
|
7306
7437
|
};
|
|
7307
7438
|
}
|
|
7439
|
+
function startDetailLoad(target) {
|
|
7440
|
+
const {
|
|
7441
|
+
client,
|
|
7442
|
+
workspaceRoot,
|
|
7443
|
+
ref,
|
|
7444
|
+
number,
|
|
7445
|
+
repository,
|
|
7446
|
+
currentUpdatedAt,
|
|
7447
|
+
readId,
|
|
7448
|
+
readRunning,
|
|
7449
|
+
setDetail,
|
|
7450
|
+
setError,
|
|
7451
|
+
setPhase,
|
|
7452
|
+
setRefreshing,
|
|
7453
|
+
setRefreshError
|
|
7454
|
+
} = target;
|
|
7455
|
+
let active = true;
|
|
7456
|
+
readId.current += 1;
|
|
7457
|
+
readRunning.current = false;
|
|
7458
|
+
setError(null);
|
|
7459
|
+
setRefreshing(false);
|
|
7460
|
+
setRefreshError(null);
|
|
7461
|
+
const hit = readDetailCache(workspaceRoot, ref);
|
|
7462
|
+
const decision = detailCacheDecision(hit, currentUpdatedAt);
|
|
7463
|
+
if (decision === "hit") {
|
|
7464
|
+
if (hit !== null) setDetail(hit.detail);
|
|
7465
|
+
setPhase("ready");
|
|
7466
|
+
return () => {
|
|
7467
|
+
active = false;
|
|
7468
|
+
readId.current += 1;
|
|
7469
|
+
};
|
|
7470
|
+
}
|
|
7471
|
+
if (decision === "stale") {
|
|
7472
|
+
if (hit !== null) setDetail(hit.detail);
|
|
7473
|
+
setPhase("ready");
|
|
7474
|
+
} else {
|
|
7475
|
+
setDetail(null);
|
|
7476
|
+
setPhase("loading");
|
|
7477
|
+
}
|
|
7478
|
+
void client.getDetail(workspaceRoot, ref, number, repository ?? void 0).then((result) => {
|
|
7479
|
+
if (!active) return;
|
|
7480
|
+
applyDetailRead({
|
|
7481
|
+
workspaceRoot,
|
|
7482
|
+
result,
|
|
7483
|
+
cached: decision !== "miss",
|
|
7484
|
+
setDetail,
|
|
7485
|
+
setPhase,
|
|
7486
|
+
setError,
|
|
7487
|
+
setRefreshError
|
|
7488
|
+
});
|
|
7489
|
+
});
|
|
7490
|
+
return () => {
|
|
7491
|
+
active = false;
|
|
7492
|
+
readId.current += 1;
|
|
7493
|
+
};
|
|
7494
|
+
}
|
|
7495
|
+
function applyDetailRead(options) {
|
|
7496
|
+
const { result } = options;
|
|
7497
|
+
if (result.ok) {
|
|
7498
|
+
writeDetailCache(options.workspaceRoot, result.result);
|
|
7499
|
+
options.setDetail(result.result);
|
|
7500
|
+
options.setPhase("ready");
|
|
7501
|
+
return;
|
|
7502
|
+
}
|
|
7503
|
+
if (options.cached) {
|
|
7504
|
+
options.setRefreshError(result.error);
|
|
7505
|
+
return;
|
|
7506
|
+
}
|
|
7507
|
+
options.setError(result.error);
|
|
7508
|
+
options.setPhase("error");
|
|
7509
|
+
}
|
|
7308
7510
|
function useTicketMutation(client, options) {
|
|
7309
7511
|
const [busy, setBusy] = React26.useState(false);
|
|
7310
7512
|
const [error, setError] = React26.useState(null);
|
|
@@ -7327,10 +7529,17 @@ function useTicketMutation(client, options) {
|
|
|
7327
7529
|
return;
|
|
7328
7530
|
}
|
|
7329
7531
|
const [fresh, snapshot] = await Promise.all([
|
|
7330
|
-
client.getDetail(
|
|
7532
|
+
client.getDetail(
|
|
7533
|
+
options.workspaceRoot,
|
|
7534
|
+
options.ref,
|
|
7535
|
+
options.number,
|
|
7536
|
+
options.repository ?? void 0
|
|
7537
|
+
),
|
|
7331
7538
|
client.refresh(options.workspaceRoot)
|
|
7332
7539
|
]);
|
|
7333
|
-
if (snapshot.ok
|
|
7540
|
+
if (snapshot.ok && snapshot.result.kind === "full") {
|
|
7541
|
+
options.onSnapshot(snapshot.result.snapshot);
|
|
7542
|
+
}
|
|
7334
7543
|
if (!fresh.ok) {
|
|
7335
7544
|
setError(fresh.error);
|
|
7336
7545
|
return;
|
|
@@ -10843,13 +11052,14 @@ function TicketDetailView(props) {
|
|
|
10843
11052
|
}
|
|
10844
11053
|
function useDetailViewState(props) {
|
|
10845
11054
|
const { client, workspaceRoot } = props;
|
|
10846
|
-
const { ref, number, ticket } = props.target;
|
|
10847
|
-
const
|
|
11055
|
+
const { ref, number, repository, ticket } = props.target;
|
|
11056
|
+
const { current: currentTicket, updateFromSnapshot } = useCurrentTicket(ref, ticket);
|
|
11057
|
+
const updatedAt = currentTicket?.updatedAt;
|
|
11058
|
+
const request = useDetailRequest(client, workspaceRoot, ref, number, repository, updatedAt);
|
|
10848
11059
|
const loadAttachment = React29.useMemo(
|
|
10849
11060
|
() => createAttachmentLoader(client, workspaceRoot),
|
|
10850
11061
|
[client, workspaceRoot]
|
|
10851
11062
|
);
|
|
10852
|
-
const { current: currentTicket, updateFromSnapshot } = useCurrentTicket(ref, ticket);
|
|
10853
11063
|
const blockers = blockerItems(currentTicket, props.snapshotTickets);
|
|
10854
11064
|
const canExpandBlockers = currentTicket !== null && currentTicket.skillActionReason === "blocked" && blockers.length > 0;
|
|
10855
11065
|
const [expandedRef, setExpandedRef] = React29.useState(null);
|
|
@@ -10861,6 +11071,7 @@ function useDetailViewState(props) {
|
|
|
10861
11071
|
workspaceRoot,
|
|
10862
11072
|
ref,
|
|
10863
11073
|
number,
|
|
11074
|
+
repository,
|
|
10864
11075
|
onUpdated: request.replace,
|
|
10865
11076
|
onSnapshot: updateFromSnapshot
|
|
10866
11077
|
});
|
|
@@ -11701,12 +11912,6 @@ function Footer(props) {
|
|
|
11701
11912
|
|
|
11702
11913
|
// src/client/tickets-header.tsx
|
|
11703
11914
|
var React36 = __toESM(require("react"), 1);
|
|
11704
|
-
var SECONDARY_BUTTON_STYLE = {
|
|
11705
|
-
...BUTTON_STYLE,
|
|
11706
|
-
padding: "2px 6px",
|
|
11707
|
-
fontSize: 12,
|
|
11708
|
-
color: COLORS.secondary
|
|
11709
|
-
};
|
|
11710
11915
|
var REFRESH_ERROR_STYLE2 = {
|
|
11711
11916
|
color: COLORS.error,
|
|
11712
11917
|
fontSize: 12,
|
|
@@ -11740,22 +11945,18 @@ function TicketsHeader(props) {
|
|
|
11740
11945
|
"data-testid": "refresh",
|
|
11741
11946
|
"data-hover": "soft",
|
|
11742
11947
|
disabled: props.busy,
|
|
11743
|
-
|
|
11948
|
+
title: t2("refresh.title"),
|
|
11949
|
+
onClick: (event) => {
|
|
11950
|
+
if (event.shiftKey) {
|
|
11951
|
+
props.onRefreshFull();
|
|
11952
|
+
return;
|
|
11953
|
+
}
|
|
11954
|
+
props.onRefresh();
|
|
11955
|
+
},
|
|
11744
11956
|
style: { ...REFRESH_BUTTON_STYLE, opacity: props.busy ? 0.6 : 1 }
|
|
11745
11957
|
},
|
|
11746
11958
|
/* @__PURE__ */ React36.createElement(RefreshIcon, null),
|
|
11747
11959
|
props.busy ? t2("refresh.busy") : t2("refresh.action")
|
|
11748
|
-
), /* @__PURE__ */ React36.createElement(
|
|
11749
|
-
"button",
|
|
11750
|
-
{
|
|
11751
|
-
type: "button",
|
|
11752
|
-
"data-testid": "refresh-full",
|
|
11753
|
-
"data-hover": "soft",
|
|
11754
|
-
disabled: props.busy,
|
|
11755
|
-
onClick: props.onRefreshFull,
|
|
11756
|
-
style: { ...SECONDARY_BUTTON_STYLE, opacity: props.busy ? 0.6 : 1 }
|
|
11757
|
-
},
|
|
11758
|
-
t2("refresh.full")
|
|
11759
11960
|
)));
|
|
11760
11961
|
}
|
|
11761
11962
|
function SourceBadge2(props) {
|