mandrel 2.124.0 → 2.126.0
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/.agents/docs/agentrc-reference.json +1 -0
- package/.agents/docs/configuration.md +2 -0
- package/.agents/docs/runbooks/dispatch-board.md +199 -0
- package/.agents/docs/runbooks/dispatch.md +219 -0
- package/.agents/docs/runbooks/session-titles.md +52 -0
- package/.agents/schemas/agentrc.schema.json +60 -0
- package/.agents/scripts/acceptance-eval.js +11 -2
- package/.agents/scripts/dispatch.js +411 -0
- package/.agents/scripts/lib/child-detached.js +48 -0
- package/.agents/scripts/lib/child-exec.js +11 -0
- package/.agents/scripts/lib/config/delivery-routing.js +15 -12
- package/.agents/scripts/lib/config/temp-paths.js +26 -0
- package/.agents/scripts/lib/config-settings-schema-delivery.js +45 -0
- package/.agents/scripts/lib/dispatch/environments.js +135 -0
- package/.agents/scripts/lib/dispatch/launch-cloud.js +164 -0
- package/.agents/scripts/lib/dispatch/launch-local.js +77 -0
- package/.agents/scripts/lib/dispatch/liveness.js +21 -0
- package/.agents/scripts/lib/dispatch/record.js +54 -0
- package/.agents/scripts/lib/dispatch/status.js +329 -0
- package/.agents/scripts/lib/dispatch/targets.js +101 -0
- package/.agents/scripts/lib/dispatch/verdict.js +207 -0
- package/.agents/scripts/lib/generated/agentrc-validator.js +2 -2
- package/.agents/scripts/lib/observability/source-classifier.js +2 -0
- package/.agents/scripts/lib/orchestration/single-story-close/runner.js +2 -0
- package/.agents/scripts/lib/orchestration/story-handoff.js +6 -0
- package/.agents/scripts/lib/orchestration/story-stage-publish.js +147 -0
- package/.agents/scripts/lib/orchestration/ticketing/reads.js +2 -0
- package/.agents/scripts/lib/story-body/story-body.js +5 -2
- package/.agents/scripts/session-title.js +187 -0
- package/.agents/scripts/single-story-confirm-merge.js +7 -0
- package/.agents/scripts/single-story-init.js +3 -0
- package/.agents/workflows/helpers/audit-lens-core.md +4 -0
- package/.agents/workflows/helpers/deliver-light.md +4 -1
- package/.agents/workflows/helpers/qa-core.md +2 -0
- package/.agents/workflows/mandrel-deliver.md +7 -3
- package/.agents/workflows/mandrel-orchestrate.md +2 -0
- package/.agents/workflows/mandrel-plan.md +4 -0
- package/README.md +8 -0
- package/bin/mandrel.js +35 -13
- package/docs/CHANGELOG.md +27 -0
- package/lib/cli/dispatch.js +28 -0
- package/lib/cli/ui/accounts.js +81 -0
- package/lib/cli/ui/assignee-filter.js +91 -0
- package/lib/cli/ui/board-model.js +399 -0
- package/lib/cli/ui/board.css +578 -0
- package/lib/cli/ui/board.html +84 -0
- package/lib/cli/ui/board.js +755 -0
- package/lib/cli/ui/log-tail.js +89 -0
- package/lib/cli/ui/panel-model.js +100 -0
- package/lib/cli/ui/preferences.js +136 -0
- package/lib/cli/ui/request-guard.js +108 -0
- package/lib/cli/ui/server.js +230 -0
- package/lib/cli/ui/sources.js +258 -0
- package/lib/cli/ui/story-detail.js +99 -0
- package/lib/cli/ui.js +124 -0
- package/package.json +1 -1
package/bin/mandrel.js
CHANGED
|
@@ -13,7 +13,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
|
13
13
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
* @typedef {{ description: string, knownFlags:
|
|
16
|
+
* @typedef {{ description: string, knownFlags: string[] }} SubcommandMeta
|
|
17
17
|
* @type {Map<string, SubcommandMeta>}
|
|
18
18
|
*/
|
|
19
19
|
const SUBCOMMANDS = new Map([
|
|
@@ -21,7 +21,7 @@ const SUBCOMMANDS = new Map([
|
|
|
21
21
|
'init',
|
|
22
22
|
{
|
|
23
23
|
description: 'install and configure mandrel in the current project',
|
|
24
|
-
knownFlags:
|
|
24
|
+
knownFlags: [
|
|
25
25
|
'--assume-yes',
|
|
26
26
|
'--skip-github',
|
|
27
27
|
'--owner',
|
|
@@ -30,14 +30,14 @@ const SUBCOMMANDS = new Map([
|
|
|
30
30
|
'--project-number',
|
|
31
31
|
'--operator-handle',
|
|
32
32
|
'--dry-run',
|
|
33
|
-
]
|
|
33
|
+
],
|
|
34
34
|
},
|
|
35
35
|
],
|
|
36
36
|
[
|
|
37
37
|
'sync',
|
|
38
38
|
{
|
|
39
39
|
description: 'materialize .agents/ payload from installed package',
|
|
40
|
-
knownFlags:
|
|
40
|
+
knownFlags: ['--dry-run'],
|
|
41
41
|
},
|
|
42
42
|
],
|
|
43
43
|
[
|
|
@@ -47,7 +47,7 @@ const SUBCOMMANDS = new Map([
|
|
|
47
47
|
// No --dry-run: the projection scripts have no preview mode, and
|
|
48
48
|
// accepting the flag while syncing for real overwrote .claude/ on an
|
|
49
49
|
// operator who asked for a preview. Reject it at the dispatcher.
|
|
50
|
-
knownFlags:
|
|
50
|
+
knownFlags: [],
|
|
51
51
|
},
|
|
52
52
|
],
|
|
53
53
|
[
|
|
@@ -55,42 +55,64 @@ const SUBCOMMANDS = new Map([
|
|
|
55
55
|
{
|
|
56
56
|
description: 'regenerate .claude/agents/ from .agents/agents/',
|
|
57
57
|
// Same contract as sync-commands: no preview mode, so no --dry-run.
|
|
58
|
-
knownFlags:
|
|
58
|
+
knownFlags: [],
|
|
59
59
|
},
|
|
60
60
|
],
|
|
61
61
|
[
|
|
62
62
|
'doctor',
|
|
63
63
|
{
|
|
64
64
|
description: 'run readiness checks and report remedies',
|
|
65
|
-
knownFlags:
|
|
65
|
+
knownFlags: [],
|
|
66
66
|
},
|
|
67
67
|
],
|
|
68
68
|
[
|
|
69
69
|
'update',
|
|
70
70
|
{
|
|
71
71
|
description: 'upgrade mandrel to the newest published version',
|
|
72
|
-
knownFlags:
|
|
72
|
+
knownFlags: ['--dry-run', '--install-cmd'],
|
|
73
73
|
},
|
|
74
74
|
],
|
|
75
75
|
[
|
|
76
76
|
'migrate',
|
|
77
77
|
{
|
|
78
78
|
description: 'apply version-keyed migrations for a version range',
|
|
79
|
-
knownFlags:
|
|
79
|
+
knownFlags: ['--from', '--to', '--dry-run'],
|
|
80
80
|
},
|
|
81
81
|
],
|
|
82
82
|
[
|
|
83
83
|
'explain',
|
|
84
84
|
{
|
|
85
85
|
description: 'print resolved config values and their sources',
|
|
86
|
-
knownFlags:
|
|
86
|
+
knownFlags: ['--json'],
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
'dispatch',
|
|
91
|
+
{
|
|
92
|
+
description: 'start, resume or stop a Story in a named environment',
|
|
93
|
+
knownFlags: [
|
|
94
|
+
'--env',
|
|
95
|
+
'--resume',
|
|
96
|
+
'--stop',
|
|
97
|
+
'--status',
|
|
98
|
+
'--json',
|
|
99
|
+
'--done-limit',
|
|
100
|
+
'--dry-run',
|
|
101
|
+
],
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
'ui',
|
|
106
|
+
{
|
|
107
|
+
description: 'serve the local dispatch board on 127.0.0.1',
|
|
108
|
+
knownFlags: ['--port'],
|
|
87
109
|
},
|
|
88
110
|
],
|
|
89
111
|
[
|
|
90
112
|
'uninstall',
|
|
91
113
|
{
|
|
92
114
|
description: 'reverse a recorded install using the install ledger',
|
|
93
|
-
knownFlags:
|
|
115
|
+
knownFlags: ['--include-github', '--dry-run'],
|
|
94
116
|
},
|
|
95
117
|
],
|
|
96
118
|
]);
|
|
@@ -165,7 +187,7 @@ const UNIVERSAL_FLAGS = new Set(['--help', '-h']);
|
|
|
165
187
|
* Only flag names are checked (`--flag=value` is split).
|
|
166
188
|
*
|
|
167
189
|
* @param {string} subName
|
|
168
|
-
* @param {
|
|
190
|
+
* @param {string[]} knownFlags
|
|
169
191
|
* @param {string[]} argv
|
|
170
192
|
* @returns {string | null}
|
|
171
193
|
*/
|
|
@@ -174,7 +196,7 @@ function findUnknownFlag(subName, knownFlags, argv) {
|
|
|
174
196
|
if (!arg.startsWith('-')) continue;
|
|
175
197
|
const flagName = arg.includes('=') ? arg.slice(0, arg.indexOf('=')) : arg;
|
|
176
198
|
if (UNIVERSAL_FLAGS.has(flagName)) continue;
|
|
177
|
-
if (!knownFlags.
|
|
199
|
+
if (!knownFlags.includes(flagName)) {
|
|
178
200
|
const names = [...knownFlags].sort().join(', ');
|
|
179
201
|
const hint = names.length > 0 ? ` Known flags: ${names}\n` : '';
|
|
180
202
|
return (
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,33 @@ All notable changes to this project will be documented in this file.
|
|
|
15
15
|
-->
|
|
16
16
|
<!-- markdownlint-disable-file MD004 MD012 MD037 -->
|
|
17
17
|
|
|
18
|
+
## [2.126.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.125.0...mandrel-v2.126.0) (2026-11-19)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
* dispatch board: (1) a header multi-select assignee filter (named users… ([#6133](https://github.com/dsj1984/mandrel/issues/6133)) ([#6134](https://github.com/dsj1984/mandrel/issues/6134)) ([9335a90](https://github.com/dsj1984/mandrel/commit/9335a904d120f7b87792709514336d4092474c2a))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
* fix mandrel dispatch CLI resolving config from the package dir in consu… ([#6128](https://github.com/dsj1984/mandrel/issues/6128)) ([#6129](https://github.com/dsj1984/mandrel/issues/6129)) ([04d85d9](https://github.com/dsj1984/mandrel/commit/04d85d96ff7de50819bbea0db8eddad18379b3c8))
|
|
29
|
+
* fix story-body parser so whole-line HTML comments (the plan-story finge… ([#6131](https://github.com/dsj1984/mandrel/issues/6131)) ([#6132](https://github.com/dsj1984/mandrel/issues/6132)) ([3aa4a97](https://github.com/dsj1984/mandrel/commit/3aa4a97bbd3f6755b327be282b50de0ecae5ac00))
|
|
30
|
+
|
|
31
|
+
## [2.125.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.124.0...mandrel-v2.125.0) (2026-11-19)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
* add `mandrel ui`: a local board that shows every Story and dispatches by drag ([#6111](https://github.com/dsj1984/mandrel/issues/6111)) ([#6118](https://github.com/dsj1984/mandrel/issues/6118)) ([94cfb12](https://github.com/dsj1984/mandrel/commit/94cfb12f2ddf88f38fe63462532c9607788241d7))
|
|
37
|
+
* dispatch a Story to a named environment with `mandrel dispatch` (local launch) ([#6108](https://github.com/dsj1984/mandrel/issues/6108)) ([#6116](https://github.com/dsj1984/mandrel/issues/6116)) ([90f0576](https://github.com/dsj1984/mandrel/commit/90f05766e57a6371ae1aec6a06d86a3e6af9805c))
|
|
38
|
+
* dispatch a Story to an Anthropic cloud environment by firing a Claude routine ([#6110](https://github.com/dsj1984/mandrel/issues/6110)) ([#6117](https://github.com/dsj1984/mandrel/issues/6117)) ([d3d286c](https://github.com/dsj1984/mandrel/commit/d3d286cf24f253cd96645858b8d131820d4d37f3))
|
|
39
|
+
* dispatch board Settings: a gear icon opens per-browser board preferences, including how many Done Stories to show ([#6123](https://github.com/dsj1984/mandrel/issues/6123)) ([#6126](https://github.com/dsj1984/mandrel/issues/6126)) ([6ea0360](https://github.com/dsj1984/mandrel/commit/6ea0360e64dc9407e4929d1f8046be713e0c2772))
|
|
40
|
+
* dispatch board shows which GitHub and Claude accounts it uses, and opens Environments and Connections in the side panel from header icons ([#6122](https://github.com/dsj1984/mandrel/issues/6122)) ([#6125](https://github.com/dsj1984/mandrel/issues/6125)) ([4aecdca](https://github.com/dsj1984/mandrel/commit/4aecdca2fcd01bbac2447e4acea3e21d1e6f4acb))
|
|
41
|
+
* publish a Story's delivery stage to GitHub so remote runs show their progress ([#6109](https://github.com/dsj1984/mandrel/issues/6109)) ([#6114](https://github.com/dsj1984/mandrel/issues/6114)) ([430c8ec](https://github.com/dsj1984/mandrel/commit/430c8eca1e989cd01cc30ad02d785a80ee57b1c3))
|
|
42
|
+
* show on each dispatch-board card whether its delivery is alive and where it stands, with a detail popout per Story ([#6121](https://github.com/dsj1984/mandrel/issues/6121)) ([#6124](https://github.com/dsj1984/mandrel/issues/6124)) ([8c6e2dd](https://github.com/dsj1984/mandrel/commit/8c6e2dd1150b50985841bbd0119307330ddf0b74))
|
|
43
|
+
* title the host session with a state glyph as plan, deliver, orchestrate, audit and QA runs progress ([#6119](https://github.com/dsj1984/mandrel/issues/6119)) ([#6120](https://github.com/dsj1984/mandrel/issues/6120)) ([a0ebec9](https://github.com/dsj1984/mandrel/commit/a0ebec92ebb9364a26f98446633f2e6e603ad191))
|
|
44
|
+
|
|
18
45
|
## [2.124.0](https://github.com/dsj1984/mandrel/compare/mandrel-v2.123.0...mandrel-v2.124.0) (2026-11-17)
|
|
19
46
|
|
|
20
47
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// lib/cli/dispatch.js
|
|
2
|
+
/**
|
|
3
|
+
* `mandrel dispatch` subcommand: the operator-facing face of
|
|
4
|
+
* `.agents/scripts/dispatch.js`. Both call `runDispatch`, so they share one
|
|
5
|
+
* envelope and one set of exit codes; this module only maps the code onto
|
|
6
|
+
* the process. Config resolves from the operator's directory, not the
|
|
7
|
+
* package root, which in a consumer install sits under `node_modules/`.
|
|
8
|
+
*
|
|
9
|
+
* Injectable seams (used by tests): `exit` replaces setting
|
|
10
|
+
* `process.exitCode`; every other key is passed to `runDispatch`.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { runDispatchFromCwd as runDispatch } from '../../.agents/scripts/dispatch.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {string[]} argv
|
|
17
|
+
* @param {{ exit?: (code: number) => void } & Parameters<typeof runDispatch>[1]} [deps]
|
|
18
|
+
* @returns {Promise<void>}
|
|
19
|
+
*/
|
|
20
|
+
export default async function run(argv, deps = {}) {
|
|
21
|
+
const {
|
|
22
|
+
exit = (code) => {
|
|
23
|
+
process.exitCode = code;
|
|
24
|
+
},
|
|
25
|
+
...rest
|
|
26
|
+
} = deps;
|
|
27
|
+
exit(await runDispatch(argv, rest));
|
|
28
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// lib/cli/ui/accounts.js
|
|
2
|
+
/**
|
|
3
|
+
* Which GitHub login and Claude account the board and its local launches
|
|
4
|
+
* act as. Both probes run in parallel, the result is reused for `ttlMs`, and
|
|
5
|
+
* nothing here logs a value: account fields leave only in the response.
|
|
6
|
+
*
|
|
7
|
+
* @module cli/ui/accounts
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { runGh } from '../../../.agents/scripts/lib/gh-exec.js';
|
|
11
|
+
|
|
12
|
+
const TIMEOUT_MS = 10_000;
|
|
13
|
+
const LOGIN_RE = /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/;
|
|
14
|
+
const ACCOUNT_FIELDS = ['email', 'orgName', 'subscriptionType', 'authMethod'];
|
|
15
|
+
const FIRST_PARTY = 'firstParty';
|
|
16
|
+
|
|
17
|
+
async function githubLogin(env, runner) {
|
|
18
|
+
const r = await runGh(
|
|
19
|
+
['api', 'user', '--jq', '.login'],
|
|
20
|
+
{ env, timeout: TIMEOUT_MS },
|
|
21
|
+
runner,
|
|
22
|
+
);
|
|
23
|
+
const login = !r.error && r.status === 0 ? (r.stdout ?? '').trim() : '';
|
|
24
|
+
return LOGIN_RE.test(login)
|
|
25
|
+
? { login }
|
|
26
|
+
: { login: null, reason: 'login-unavailable' };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function parseJson(text) {
|
|
30
|
+
try {
|
|
31
|
+
return JSON.parse(text);
|
|
32
|
+
} catch {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The whitelisted account summary from `claude auth status --json`, or `null`. */
|
|
38
|
+
function accountOf(status) {
|
|
39
|
+
if (status?.loggedIn !== true) return null;
|
|
40
|
+
const account = {};
|
|
41
|
+
for (const field of ACCOUNT_FIELDS) {
|
|
42
|
+
if (typeof status[field] === 'string') account[field] = status[field];
|
|
43
|
+
}
|
|
44
|
+
const provider = status.apiProvider;
|
|
45
|
+
if (typeof provider === 'string' && provider !== FIRST_PARTY) {
|
|
46
|
+
account.apiProvider = provider;
|
|
47
|
+
}
|
|
48
|
+
return account;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function claudeAccount(runner) {
|
|
52
|
+
const r = await runner('claude', ['auth', 'status', '--json'], {
|
|
53
|
+
shell: process.platform === 'win32',
|
|
54
|
+
timeout: TIMEOUT_MS,
|
|
55
|
+
});
|
|
56
|
+
return !r.error && r.status === 0 ? accountOf(parseJson(r.stdout)) : null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @param {{ env: Record<string, string|undefined>, runner: Function,
|
|
61
|
+
* ttlMs?: number, now?: () => number }} deps
|
|
62
|
+
* @returns {() => Promise<{ github: { login: string|null, reason?: string },
|
|
63
|
+
* claude: object|null }>}
|
|
64
|
+
*/
|
|
65
|
+
export function createAccountProbe({
|
|
66
|
+
env,
|
|
67
|
+
runner,
|
|
68
|
+
ttlMs = 60_000,
|
|
69
|
+
now = Date.now,
|
|
70
|
+
}) {
|
|
71
|
+
let cached = null;
|
|
72
|
+
return () => {
|
|
73
|
+
if (cached && now() - cached.at < ttlMs) return cached.promise;
|
|
74
|
+
const promise = Promise.all([
|
|
75
|
+
githubLogin(env, runner),
|
|
76
|
+
claudeAccount(runner),
|
|
77
|
+
]).then(([github, claude]) => ({ github, claude }));
|
|
78
|
+
cached = { at: now(), promise };
|
|
79
|
+
return promise;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// lib/cli/ui/assignee-filter.js
|
|
2
|
+
/**
|
|
3
|
+
* The board's assignee filter: which people's Stories the columns show.
|
|
4
|
+
* The selection is a list of GitHub logins plus `UNASSIGNED`; an empty list
|
|
5
|
+
* shows everyone. It is saved per browser, apart from Settings, because its
|
|
6
|
+
* choices come from the board rather than a fixed set. Pure apart from the
|
|
7
|
+
* storage handed in, so it runs in the browser and under `node --test`.
|
|
8
|
+
*
|
|
9
|
+
* @module cli/ui/assignee-filter
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const FILTER_KEY = 'mandrel-board-assignees';
|
|
13
|
+
|
|
14
|
+
/** The selection value for Stories with no assignee. */
|
|
15
|
+
const UNASSIGNED = ':unassigned';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The filter's choices: Unassigned first, then every login assigned to a
|
|
19
|
+
* Story on the board, plus any still selected, sorted case-insensitively.
|
|
20
|
+
*
|
|
21
|
+
* @param {Array<{ assignees?: string[] }>} stories
|
|
22
|
+
* @param {string[]} [selected]
|
|
23
|
+
* @returns {Array<{ value: string, text: string, checked: boolean }>}
|
|
24
|
+
*/
|
|
25
|
+
export function assigneeOptions(stories, selected = []) {
|
|
26
|
+
const logins = new Set(selected.filter((v) => v !== UNASSIGNED));
|
|
27
|
+
for (const story of stories ?? []) {
|
|
28
|
+
for (const login of story.assignees ?? []) logins.add(login);
|
|
29
|
+
}
|
|
30
|
+
const sorted = [...logins].sort((a, b) =>
|
|
31
|
+
a.localeCompare(b, undefined, { sensitivity: 'base' }),
|
|
32
|
+
);
|
|
33
|
+
return [
|
|
34
|
+
{ value: UNASSIGNED, text: 'Unassigned' },
|
|
35
|
+
...sorted.map((login) => ({ value: login, text: login })),
|
|
36
|
+
].map((option) => ({ ...option, checked: selected.includes(option.value) }));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Whether `story` shows under `selected`: everyone when nothing is
|
|
41
|
+
* selected, else a Story assigned to a selected login, or an unassigned
|
|
42
|
+
* Story when Unassigned is selected.
|
|
43
|
+
*
|
|
44
|
+
* @param {{ assignees?: string[] }} story
|
|
45
|
+
* @param {string[]} selected
|
|
46
|
+
*/
|
|
47
|
+
export function matchesAssignees(story, selected) {
|
|
48
|
+
if (selected.length === 0) return true;
|
|
49
|
+
const assignees = story.assignees ?? [];
|
|
50
|
+
if (assignees.length === 0) return selected.includes(UNASSIGNED);
|
|
51
|
+
return assignees.some((login) => selected.includes(login));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The filter button's text: `Everyone`, the one choice, or a count. */
|
|
55
|
+
export function filterSummary(selected) {
|
|
56
|
+
if (selected.length === 0) return 'Everyone';
|
|
57
|
+
if (selected.length > 1) return `${selected.length} selected`;
|
|
58
|
+
return selected[0] === UNASSIGNED ? 'Unassigned' : selected[0];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** `selected` with `value` added or removed. */
|
|
62
|
+
export function toggleAssignee(selected, value, checked) {
|
|
63
|
+
const rest = selected.filter((v) => v !== value);
|
|
64
|
+
return checked ? [...rest, value] : rest;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The saved selection; anything missing or malformed is everyone.
|
|
69
|
+
*
|
|
70
|
+
* @param {Storage|null} storage
|
|
71
|
+
* @returns {string[]}
|
|
72
|
+
*/
|
|
73
|
+
export function loadAssigneeFilter(storage) {
|
|
74
|
+
try {
|
|
75
|
+
const parsed = JSON.parse(storage.getItem(FILTER_KEY));
|
|
76
|
+
return Array.isArray(parsed)
|
|
77
|
+
? parsed.filter((v) => typeof v === 'string')
|
|
78
|
+
: [];
|
|
79
|
+
} catch {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Save `selected`; a blocked store keeps it for this page only. */
|
|
85
|
+
export function saveAssigneeFilter(storage, selected) {
|
|
86
|
+
try {
|
|
87
|
+
storage.setItem(FILTER_KEY, JSON.stringify(selected));
|
|
88
|
+
} catch {
|
|
89
|
+
// Nothing to recover: everyone shows on the next load.
|
|
90
|
+
}
|
|
91
|
+
}
|