@christang/keel 5.100.0 → 5.101.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/README.md +1 -1
- package/assets/bootstrap/AGENTS.md +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/plugins/keel/.claude-plugin/plugin.json +1 -1
- package/plugins/keel/.codex-plugin/plugin.json +1 -1
- package/scripts/validate_plugin.py +96 -2
- package/src/core/chat/bridge.js +14 -0
- package/src/core/chat/cli.js +6 -4
- package/src/core/chat/notice.js +2 -1
- package/src/core/chat/store.js +40 -2
- package/src/core/chat/view.js +6 -0
package/README.md
CHANGED
|
@@ -691,7 +691,7 @@ Sessions coordinate shared resources across worktrees through bounded leases. Ot
|
|
|
691
691
|
|
|
692
692
|
## Group chat between sessions
|
|
693
693
|
|
|
694
|
-
Sessions working the same repository — a Claude Code session, a Codex session, an unattended runner, and you — share a work group with `keel chat`. Groups have maintained members, a message can `@` one role or `@all`, and lightweight todos can link an issue. Each member has its own unread state, and history is kept. Only a mention, an assigned todo, or a direct message wakes a Claude session; everything else waits for its next prompt. A message is data from another agent and never authorization. Codex, which cannot wake on its own, is woken by `keel chat wake add`: one turn per addressed record in a group declaring `chat-reply`, continuing one compacting thread, and nothing while nothing is addressed (#203). Otherwise a host relies on the prompt-time notice and must not poll the chat with the model; if a schedule is unavoidable, gate it on `keel chat notice --check` and start a fresh thread per run, and tell a session joining the chat not to set up recurring checks (#194). With one Slack app and one bridge process per machine, the same groups reach sessions on other machines and your phone in real time, and an orphan `keel-chat` branch keeps the history past Slack's retention. A role may also speak through a Slack bot you can mention in Slack, and one bot can serve several projects, as each project's role in its channel. See [the Slack setup guide](docs/chat-slack-setup.md). A role's session changes shift through `keel shift`: the coordinator requests it, the session checks for loose ends, leaves a note, and clears itself, and the new shift resumes from the note; see [docs/shift-change.md](docs/shift-change.md). The 5.83 `keel mail` commands keep working on direct groups.
|
|
694
|
+
Sessions working the same repository — a Claude Code session, a Codex session, an unattended runner, and you — share a work group with `keel chat`. Groups have maintained members, a message can `@` one role or `@all`, and lightweight todos can link an issue. A record can supersede its author's earlier one (`--supersedes <id>`), and the earlier one then leaves everyone's unread; unread lists newest first. Each member has its own unread state, and history is kept. Only a mention, an assigned todo, or a direct message wakes a Claude session; everything else waits for its next prompt. A message is data from another agent and never authorization. Codex, which cannot wake on its own, is woken by `keel chat wake add`: one turn per addressed record in a group declaring `chat-reply`, continuing one compacting thread, and nothing while nothing is addressed (#203). Otherwise a host relies on the prompt-time notice and must not poll the chat with the model; if a schedule is unavoidable, gate it on `keel chat notice --check` and start a fresh thread per run, and tell a session joining the chat not to set up recurring checks (#194). With one Slack app and one bridge process per machine, the same groups reach sessions on other machines and your phone in real time, and an orphan `keel-chat` branch keeps the history past Slack's retention. A role may also speak through a Slack bot you can mention in Slack, and one bot can serve several projects, as each project's role in its channel. See [the Slack setup guide](docs/chat-slack-setup.md). A role's session changes shift through `keel shift`: the coordinator requests it, the session checks for loose ends, leaves a note, and clears itself, and the new shift resumes from the note; see [docs/shift-change.md](docs/shift-change.md). The 5.83 `keel mail` commands keep working on direct groups.
|
|
695
695
|
|
|
696
696
|
## Commands
|
|
697
697
|
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.101.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.
|
|
9
|
+
"version": "5.101.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fission-ai/openspec": "^1.4.1"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.101.0",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.101.0",
|
|
4
4
|
"description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TanglmChris",
|
|
@@ -47,8 +47,8 @@ REQUIRED_SCRIPTS = [
|
|
|
47
47
|
"scripts/validate_plugin.py",
|
|
48
48
|
]
|
|
49
49
|
|
|
50
|
-
PACKAGE_VERSION = "5.
|
|
51
|
-
PROTOCOL_VERSION = "5.
|
|
50
|
+
PACKAGE_VERSION = "5.101.0"
|
|
51
|
+
PROTOCOL_VERSION = "5.101.0"
|
|
52
52
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
53
53
|
OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
|
|
54
54
|
# Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
|
|
@@ -2442,6 +2442,85 @@ def chat_scratch_group(base: Path) -> tuple[Path, Path, dict[str, str]]:
|
|
|
2442
2442
|
return rtl, verify, env
|
|
2443
2443
|
|
|
2444
2444
|
|
|
2445
|
+
def validate_chat_supersedes_scenario() -> int:
|
|
2446
|
+
"""Issue #252: a record supersedes its author's earlier one.
|
|
2447
|
+
|
|
2448
|
+
A superseded record leaves unread, so it neither wakes nor is listed; a
|
|
2449
|
+
group view marks both records; and unread and the notice list newest first.
|
|
2450
|
+
"""
|
|
2451
|
+
label = "chat-supersedes:"
|
|
2452
|
+
with tempfile.TemporaryDirectory(prefix="keel-chat-supersedes-") as raw:
|
|
2453
|
+
base = Path(raw)
|
|
2454
|
+
rtl, verify, env = chat_scratch_group(base)
|
|
2455
|
+
|
|
2456
|
+
def chat(cwd: Path, *args: str) -> subprocess.CompletedProcess[str]:
|
|
2457
|
+
return run_keel(cwd, "chat", *args, env=env)
|
|
2458
|
+
|
|
2459
|
+
def posted_id(result: subprocess.CompletedProcess[str]) -> str:
|
|
2460
|
+
return chat_json(result).get("id", "")
|
|
2461
|
+
|
|
2462
|
+
first = posted_id(chat(rtl, "post", "soc", "@verify verify owns integration", "--json"))
|
|
2463
|
+
second_run = chat(rtl, "post", "soc", "@verify design owns integration", "--supersedes", first, "--json")
|
|
2464
|
+
second = posted_id(second_run)
|
|
2465
|
+
if not first or not second:
|
|
2466
|
+
report(f"{label} the posts did not return ids: {second_run.stdout} {second_run.stderr}")
|
|
2467
|
+
return 1
|
|
2468
|
+
unread = [r.get("id") for r in chat_json(chat(verify, "unread", "--json")).get("unread", [])]
|
|
2469
|
+
if unread != [second]:
|
|
2470
|
+
report(f"{label} verify's unread is {unread!r}, not only the superseding record {second}.")
|
|
2471
|
+
return 1
|
|
2472
|
+
notice = chat_json(chat(verify, "notice", "--json")).get("notice", "")
|
|
2473
|
+
if first in notice:
|
|
2474
|
+
report(f"{label} the wake notice still lists the superseded record {first}: {notice!r}")
|
|
2475
|
+
return 1
|
|
2476
|
+
if second not in notice:
|
|
2477
|
+
report(f"{label} the wake notice does not list the superseding record {second}: {notice!r}")
|
|
2478
|
+
return 1
|
|
2479
|
+
view = chat(rtl, "soc", "--peek").stdout
|
|
2480
|
+
if f"(superseded by {second})" not in view:
|
|
2481
|
+
report(f"{label} the group view does not mark {first} superseded by {second}: {view!r}")
|
|
2482
|
+
return 1
|
|
2483
|
+
if f"(supersedes {first})" not in view:
|
|
2484
|
+
report(f"{label} the group view does not mark {second} as superseding {first}: {view!r}")
|
|
2485
|
+
return 1
|
|
2486
|
+
|
|
2487
|
+
refusals = []
|
|
2488
|
+
other = posted_id(chat(verify, "post", "soc", "verify's own note", "--json"))
|
|
2489
|
+
refusals.append(("another author's record", chat(rtl, "post", "soc", "x", "--supersedes", other), "verify"))
|
|
2490
|
+
refusals.append(("an already superseded record", chat(rtl, "post", "soc", "x", "--supersedes", first), second))
|
|
2491
|
+
gone = posted_id(chat(rtl, "post", "soc", "to retract", "--json"))
|
|
2492
|
+
chat(rtl, "retract", gone)
|
|
2493
|
+
refusals.append(("a retracted record", chat(rtl, "post", "soc", "x", "--supersedes", gone), "retracted"))
|
|
2494
|
+
chat(rtl, "group", "create", "ops", "--member", "verify")
|
|
2495
|
+
elsewhere = posted_id(chat(rtl, "post", "ops", "ops note", "--json"))
|
|
2496
|
+
refusals.append(("a record in another group", chat(rtl, "post", "soc", "x", "--supersedes", elsewhere), "ops"))
|
|
2497
|
+
for what, result, needle in refusals:
|
|
2498
|
+
if result.returncode == 0:
|
|
2499
|
+
report(f"{label} superseding {what} was accepted: {result.stdout}")
|
|
2500
|
+
return 1
|
|
2501
|
+
if needle not in result.stderr:
|
|
2502
|
+
report(f"{label} superseding {what} was refused without naming {needle!r}: {result.stderr}")
|
|
2503
|
+
return 1
|
|
2504
|
+
|
|
2505
|
+
chat(verify, "read")
|
|
2506
|
+
ordered = [posted_id(chat(rtl, "post", "soc", f"@verify step {n}", "--json")) for n in (1, 2, 3)]
|
|
2507
|
+
listed = [r.get("id") for r in chat_json(chat(verify, "unread", "--json")).get("unread", [])]
|
|
2508
|
+
if listed != list(reversed(ordered)):
|
|
2509
|
+
report(f"{label} unread is not newest first: {listed!r}, posted {ordered!r}.")
|
|
2510
|
+
return 1
|
|
2511
|
+
notice = chat_json(chat(verify, "notice", "--json")).get("notice", "")
|
|
2512
|
+
positions = [notice.find(i) for i in reversed(ordered)]
|
|
2513
|
+
if -1 in positions:
|
|
2514
|
+
report(f"{label} the wake notice does not list all three posts: {notice!r}")
|
|
2515
|
+
return 1
|
|
2516
|
+
if positions != sorted(positions):
|
|
2517
|
+
report(f"{label} the wake notice is not newest first: {notice!r}")
|
|
2518
|
+
return 1
|
|
2519
|
+
|
|
2520
|
+
report("chat-supersedes scenario passed.")
|
|
2521
|
+
return 0
|
|
2522
|
+
|
|
2523
|
+
|
|
2445
2524
|
def validate_chat_records_scenario() -> int:
|
|
2446
2525
|
"""Issue #187: todos, edits, retractions, search, and local-time display.
|
|
2447
2526
|
|
|
@@ -3112,6 +3191,8 @@ def validate_chat_bridge_outbound_scenario() -> int:
|
|
|
3112
3191
|
chat(rtl, "edit", root_id, "Clock fix is in (v2)")
|
|
3113
3192
|
gone_id = chat_json(chat(rtl, "post", "soc", "wrong group", "--json")).get("id", "")
|
|
3114
3193
|
chat(rtl, "retract", gone_id)
|
|
3194
|
+
old_rule_id = chat_json(chat(rtl, "post", "soc", "verify owns integration", "--json")).get("id", "")
|
|
3195
|
+
new_rule_id = chat_json(chat(rtl, "post", "soc", "design owns integration", "--supersedes", old_rule_id, "--json")).get("id", "")
|
|
3115
3196
|
slack.rate_limit("chat.postMessage", 1)
|
|
3116
3197
|
|
|
3117
3198
|
started = time.time()
|
|
@@ -3195,6 +3276,18 @@ def validate_chat_bridge_outbound_scenario() -> int:
|
|
|
3195
3276
|
if not any(c["params"].get("ts") == gone_ts for c in slack.calls_to("chat.delete")):
|
|
3196
3277
|
report(f"{label} the retraction did not call chat.delete.")
|
|
3197
3278
|
return 1
|
|
3279
|
+
# Issue #252: a superseded record's Slack copy says so.
|
|
3280
|
+
if not new_rule_id:
|
|
3281
|
+
report(f"{label} the superseding post returned no id.")
|
|
3282
|
+
return 1
|
|
3283
|
+
old_rule_ts = next(m["ts"] for m in slack.messages["CSOC"] if (m.get("metadata") or {}).get("event_payload", {}).get("id") == old_rule_id)
|
|
3284
|
+
marked = [c for c in slack.calls_to("chat.update") if c["params"].get("ts") == old_rule_ts]
|
|
3285
|
+
if not marked:
|
|
3286
|
+
report(f"{label} the superseded record's Slack message was never updated.")
|
|
3287
|
+
return 1
|
|
3288
|
+
if not marked[-1]["params"].get("text", "").startswith(f"(superseded by {new_rule_id})"):
|
|
3289
|
+
report(f"{label} the superseded Slack message does not open with its successor: {marked[-1]['params'].get('text')!r}")
|
|
3290
|
+
return 1
|
|
3198
3291
|
|
|
3199
3292
|
before = len(slack.calls_to("chat.postMessage"))
|
|
3200
3293
|
# launchd starts the bridge in `/`, outside every repository, so the
|
|
@@ -37641,6 +37734,7 @@ SCENARIOS: tuple = (
|
|
|
37641
37734
|
("shift-change", validate_shift_change_scenario),
|
|
37642
37735
|
("shift-without-role", validate_shift_without_role_scenario),
|
|
37643
37736
|
("resource-lock", validate_resource_lock_scenario),
|
|
37737
|
+
("chat-supersedes", validate_chat_supersedes_scenario),
|
|
37644
37738
|
("init-never-downgrades-openspec", validate_init_never_downgrades_openspec_scenario),
|
|
37645
37739
|
("native-plugin-marketplaces", validate_native_plugin_marketplaces_scenario),
|
|
37646
37740
|
("native-plugin-install-matrix", validate_native_plugin_install_matrix_scenario),
|
package/src/core/chat/bridge.js
CHANGED
|
@@ -256,6 +256,7 @@ async function postRecord(ctx, project, record, channel, direct = null) {
|
|
|
256
256
|
const sent = await call("chat.postMessage", params, direct.token);
|
|
257
257
|
writePosted(where, record.id, { channel, ts: sent.ts, thread_ts: params.thread_ts || null, as: direct.role, direct: true });
|
|
258
258
|
rememberTs(project, channel, sent.ts, record.id);
|
|
259
|
+
await markSuperseded(ctx, project, record, call);
|
|
259
260
|
return;
|
|
260
261
|
}
|
|
261
262
|
const app = roleApp(ctx, project, record.from);
|
|
@@ -281,6 +282,7 @@ async function postRecord(ctx, project, record, channel, direct = null) {
|
|
|
281
282
|
if (as) posted.as = as;
|
|
282
283
|
writePosted(where, record.id, posted);
|
|
283
284
|
rememberTs(project, channel, response.ts, record.id);
|
|
285
|
+
await markSuperseded(ctx, project, record, call);
|
|
284
286
|
// Another project on this machine that maps the same channel gets the
|
|
285
287
|
// record now, without waiting for Slack to echo it back (D16).
|
|
286
288
|
for (const other of ctx.projects) {
|
|
@@ -289,6 +291,18 @@ async function postRecord(ctx, project, record, channel, direct = null) {
|
|
|
289
291
|
}
|
|
290
292
|
}
|
|
291
293
|
|
|
294
|
+
// A record that supersedes another (#252 D5) also marks the earlier Slack
|
|
295
|
+
// message, with the token of the app that posted it, as an edit does.
|
|
296
|
+
async function markSuperseded(ctx, project, record, call) {
|
|
297
|
+
if (!record.supersedes) return;
|
|
298
|
+
const target = readPosted(project.where, record.supersedes);
|
|
299
|
+
if (!target || !target.ts) return;
|
|
300
|
+
const original = store.findRecord(project.where, record.supersedes) || {};
|
|
301
|
+
const poster = target.as ? roleApp(ctx, project, target.as) : null;
|
|
302
|
+
const text = `(superseded by ${record.id}) ${slackText(project, original, bodyText(original))}`;
|
|
303
|
+
await call("chat.update", { channel: target.channel, ts: target.ts, text }, poster ? poster.token : ctx.token);
|
|
304
|
+
}
|
|
305
|
+
|
|
292
306
|
// Every record that originated on this machine, in a mapped group, and not yet
|
|
293
307
|
// posted, in id order. The queue is derived, so it survives any restart.
|
|
294
308
|
function pendingOutbound(project) {
|
package/src/core/chat/cli.js
CHANGED
|
@@ -20,7 +20,7 @@ const USAGE = [
|
|
|
20
20
|
"keel chat group add|remove <group> <role>",
|
|
21
21
|
"keel chat group archive <group>",
|
|
22
22
|
"keel chat group list [--all] [--json] (also: keel chat list)",
|
|
23
|
-
"keel chat post <group> <text...> [--reply-to <id>] [--json] (also: keel chat <group> <text...>)",
|
|
23
|
+
"keel chat post <group> <text...> [--reply-to <id>] [--supersedes <id>] [--json] (also: keel chat <group> <text...>)",
|
|
24
24
|
"keel chat dm <role> <text...> [--json]",
|
|
25
25
|
"keel chat <group> [--since <90s|15m|2h|3d|date>] [--follow] [--peek] [--json] (view; advances your read position unless --peek)",
|
|
26
26
|
"keel chat unread [--json]",
|
|
@@ -53,6 +53,7 @@ const VALUED = {
|
|
|
53
53
|
"--set": "set",
|
|
54
54
|
"--alias": "alias",
|
|
55
55
|
"--reply-to": "replyTo",
|
|
56
|
+
"--supersedes": "supersedes",
|
|
56
57
|
"--repo": "repo",
|
|
57
58
|
"--assignee": "assignee",
|
|
58
59
|
"--issue": "issue",
|
|
@@ -259,7 +260,7 @@ function dispatch(where, options) {
|
|
|
259
260
|
case "post": {
|
|
260
261
|
const [group, ...words] = rest;
|
|
261
262
|
if (!group) throw new ChatError("keel chat post needs a group.");
|
|
262
|
-
postResult(where, store.post(where, { group, text: textFrom(words), replyTo: options.replyTo }), options.json);
|
|
263
|
+
postResult(where, store.post(where, { group, text: textFrom(words), replyTo: options.replyTo, supersedes: options.supersedes }), options.json);
|
|
263
264
|
return 0;
|
|
264
265
|
}
|
|
265
266
|
case "dm": {
|
|
@@ -270,7 +271,8 @@ function dispatch(where, options) {
|
|
|
270
271
|
}
|
|
271
272
|
case "unread": {
|
|
272
273
|
const role = store.requireRole(where);
|
|
273
|
-
|
|
274
|
+
// Newest first (#252 D3): the latest word is the one to read first.
|
|
275
|
+
const records = store.unread(where, role).reverse();
|
|
274
276
|
if (options.json) out(JSON.stringify({ role, unread: records.map(publicRecord) }));
|
|
275
277
|
else out(records.length ? records.map((r) => `${r.group} ${formatLine(r)}`).join("\n") : `keel chat: nothing unread for role \`${role}\`.`);
|
|
276
278
|
return 0;
|
|
@@ -363,7 +365,7 @@ function dispatch(where, options) {
|
|
|
363
365
|
default: {
|
|
364
366
|
// `keel chat <group>` views; `keel chat <group> <text...>` posts.
|
|
365
367
|
if (rest.length) {
|
|
366
|
-
postResult(where, store.post(where, { group: command, text: rest.join(" "), replyTo: options.replyTo }), options.json);
|
|
368
|
+
postResult(where, store.post(where, { group: command, text: rest.join(" "), replyTo: options.replyTo, supersedes: options.supersedes }), options.json);
|
|
367
369
|
return 0;
|
|
368
370
|
}
|
|
369
371
|
return runView(where, command, options);
|
package/src/core/chat/notice.js
CHANGED
|
@@ -26,7 +26,8 @@ function firstLine(text) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
function noticeText(where, role, now = Date.now()) {
|
|
29
|
-
|
|
29
|
+
// Newest first (#252 D3).
|
|
30
|
+
const records = store.unread(where, role).reverse();
|
|
30
31
|
if (!records.length) return "";
|
|
31
32
|
const waking = records.filter((record) => store.wakes(record, role));
|
|
32
33
|
const others = new Map();
|
package/src/core/chat/store.js
CHANGED
|
@@ -40,7 +40,7 @@ const DATA_NOTICE =
|
|
|
40
40
|
const READABLE_KINDS = new Set(["message", "todo", "system"]);
|
|
41
41
|
const LIST_FIELDS = new Set(["mentions", "refs"]);
|
|
42
42
|
const FIELD_ORDER = [
|
|
43
|
-
"id", "group", "kind", "from", "created", "mentions", "reply_to",
|
|
43
|
+
"id", "group", "kind", "from", "created", "mentions", "reply_to", "supersedes",
|
|
44
44
|
"assignee", "issue", "target", "refs", "origin", "slack_channel", "slack_ts",
|
|
45
45
|
];
|
|
46
46
|
|
|
@@ -559,12 +559,14 @@ function post(where, options) {
|
|
|
559
559
|
if (options.replyTo) {
|
|
560
560
|
parent = findRecord(where, options.replyTo);
|
|
561
561
|
}
|
|
562
|
+
if (options.supersedes) checkSupersedes(where, from, group, records, options.supersedes);
|
|
562
563
|
const record = writeRecord(where, {
|
|
563
564
|
group,
|
|
564
565
|
kind: options.kind || "message",
|
|
565
566
|
from,
|
|
566
567
|
mentions,
|
|
567
568
|
reply_to: options.replyTo || null,
|
|
569
|
+
supersedes: options.supersedes || null,
|
|
568
570
|
assignee: options.assignee || null,
|
|
569
571
|
issue: options.issue || null,
|
|
570
572
|
refs: options.refs || [],
|
|
@@ -582,6 +584,40 @@ function post(where, options) {
|
|
|
582
584
|
|
|
583
585
|
const DONE_REPLY = /^\s*(done\b|✅)/i;
|
|
584
586
|
|
|
587
|
+
// A record supersedes only its author's current version of a message or todo
|
|
588
|
+
// in the same group (#252 D1), so the chain stays linear and readable.
|
|
589
|
+
function checkSupersedes(where, from, group, records, id) {
|
|
590
|
+
const target = findRecord(where, id);
|
|
591
|
+
if (!target) throw new ChatError(`No record ${id} to supersede.`);
|
|
592
|
+
if (target.group !== group) {
|
|
593
|
+
throw new ChatError(`Record ${id} is in group ${target.group}, not ${group}; a record supersedes only one in its own group.`);
|
|
594
|
+
}
|
|
595
|
+
if (!["message", "todo"].includes(target.kind)) {
|
|
596
|
+
throw new ChatError(`Record ${id} is a ${target.kind}; only a message or todo can be superseded.`);
|
|
597
|
+
}
|
|
598
|
+
if (target.from !== from) {
|
|
599
|
+
throw new ChatError(`Record ${id} was written by ${target.from}; only its author may supersede it.`);
|
|
600
|
+
}
|
|
601
|
+
if (records.some((record) => record.kind === "retract" && record.target === id)) {
|
|
602
|
+
throw new ChatError(`Record ${id} was retracted; post a new record instead.`);
|
|
603
|
+
}
|
|
604
|
+
const successor = records.find((record) => record.supersedes === id);
|
|
605
|
+
if (successor) {
|
|
606
|
+
throw new ChatError(`Record ${id} is already superseded by ${successor.id}; supersede ${successor.id} instead.`);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
// Ids a later record of the same author supersedes, in one group's log.
|
|
611
|
+
function supersededIds(records) {
|
|
612
|
+
const byId = new Map(records.map((record) => [record.id, record]));
|
|
613
|
+
const ids = new Set();
|
|
614
|
+
for (const record of records) {
|
|
615
|
+
const target = record.supersedes && byId.get(record.supersedes);
|
|
616
|
+
if (target && target.from === record.from) ids.add(target.id);
|
|
617
|
+
}
|
|
618
|
+
return ids;
|
|
619
|
+
}
|
|
620
|
+
|
|
585
621
|
function isDone(where, todo) {
|
|
586
622
|
return readLog(where, todo.group).some((record) => record.kind === "done" && record.target === todo.id);
|
|
587
623
|
}
|
|
@@ -727,8 +763,10 @@ function unread(where, role) {
|
|
|
727
763
|
const state = groupState(records);
|
|
728
764
|
if (!state.exists || state.archived || !canAct(state, role)) continue;
|
|
729
765
|
const cursor = readCursor(where, role, group);
|
|
766
|
+
// A superseded record is no one's to act on (#252 D2), read or not.
|
|
767
|
+
const superseded = supersededIds(records);
|
|
730
768
|
for (const record of records) {
|
|
731
|
-
if (record.id > cursor && readable(record) && record.from !== role) result.push(record);
|
|
769
|
+
if (record.id > cursor && readable(record) && record.from !== role && !superseded.has(record.id)) result.push(record);
|
|
732
770
|
}
|
|
733
771
|
}
|
|
734
772
|
return result;
|
package/src/core/chat/view.js
CHANGED
|
@@ -63,6 +63,10 @@ function displayRecords(records) {
|
|
|
63
63
|
continue;
|
|
64
64
|
}
|
|
65
65
|
const copy = { ...record };
|
|
66
|
+
if (copy.supersedes) {
|
|
67
|
+
const old = byId.get(copy.supersedes);
|
|
68
|
+
if (old && old.from === copy.from) old.superseded_by = copy.id;
|
|
69
|
+
}
|
|
66
70
|
if (copy.kind === "done") {
|
|
67
71
|
const todo = byId.get(copy.target);
|
|
68
72
|
if (todo) todo.done = true;
|
|
@@ -79,6 +83,8 @@ function markers(record) {
|
|
|
79
83
|
parts.push(`[todo → ${record.assignee || "?"}${record.issue ? ` ${record.issue}` : ""}${record.done ? ", done" : ""}]`);
|
|
80
84
|
}
|
|
81
85
|
if (record.reply_to) parts.push(`↳ ${record.reply_to}`);
|
|
86
|
+
if (record.superseded_by) parts.push(`(superseded by ${record.superseded_by})`);
|
|
87
|
+
if (record.supersedes) parts.push(`(supersedes ${record.supersedes})`);
|
|
82
88
|
// A mention the text already spells out is not repeated; one written as an
|
|
83
89
|
// alias (`@cb`) still shows the role it resolved to (#196).
|
|
84
90
|
const text = String(record.text || "").toLowerCase();
|