diff --git a/changelog.d/5826-delete-one-segment.added.md b/changelog.d/5826-delete-one-segment.added.md new file mode 100644 index 0000000000..14ec4fb102 --- /dev/null +++ b/changelog.d/5826-delete-one-segment.added.md @@ -0,0 +1,7 @@ +- **`Message.delete_segments` can remove one segment.** Pass `occurrence=i` to delete only the + i-th segment of that id, numbered as `field()` and `count_segments()` number it; it returns 1, or 0 + when that occurrence is absent. The `results_relay` porting template now uses it to drop a + cancelled OBX (with its NTE, PRT and Z rows) and edits the rest in place, so a feed copied from it keeps + every OBX field, escape and the OBX-to-OBR grouping. Before, the template rebuilt each OBX from a + fixed subset of fields joined by hand, and every OBX was re-inserted under the first OBR. + (`BACKLOG #5826`) diff --git a/changelog.d/5829-tee-relay-bounds.fixed.md b/changelog.d/5829-tee-relay-bounds.fixed.md new file mode 100644 index 0000000000..d7793d61e2 --- /dev/null +++ b/changelog.d/5829-tee-relay-bounds.fixed.md @@ -0,0 +1,6 @@ +- **The tee relay refuses a Corepoint attempt count or shadow-queue bound below one.** + `--corepoint-attempts` and `--mefor-queue-max` (and the matching `RelayConfig` fields) now take + only a positive integer, where one attempt means no retry, and a bad value stops the relay before + any listener binds. Before, zero attempts would have let the relay ACK an Epic message and then + fail without forwarding it or tripping fail-closed, and a bound of zero or less would have made + the shadow queue unbounded. (`BACKLOG #5829`) diff --git a/changelog.d/5848-harness-detail-replay-open-failure.fixed.md b/changelog.d/5848-harness-detail-replay-open-failure.fixed.md new file mode 100644 index 0000000000..9f79b33dc3 --- /dev/null +++ b/changelog.d/5848-harness-detail-replay-open-failure.fixed.md @@ -0,0 +1,7 @@ +- **The harness message detail panel no longer acts on, or shows, the previous message while a new + one opens.** Selecting a row now clears the panel and withdraws Replay and Show body until that + message's open lands. Before, Replay pressed in that window would replay the previously shown + message. An open that fails with an error other than an API error is now reported and clears the + panel, where before it left the previous message on screen with nothing said. A row selected + while Replay's step-up prompt is open is kept: the refresh after the replay no longer reopens the + replayed message over it. diff --git a/changelog.d/5849-harness-a5-tcp-listener-port.fixed.md b/changelog.d/5849-harness-a5-tcp-listener-port.fixed.md new file mode 100644 index 0000000000..6ff1fafc61 --- /dev/null +++ b/changelog.d/5849-harness-a5-tcp-listener-port.fixed.md @@ -0,0 +1,3 @@ +- **The harness acceptance A5 probe now reports the raw-TCP listener port.** Row A5 names the MLLP, + DICOM, TCP and API listeners, but the probe reported bindability only for MLLP, DICOM and API. It + now also reports TCP port 2580, the default of the harness's `IB_Harness_TCP` inbound. diff --git a/docs/DANGEROUS-FUNCTIONALITY.md b/docs/DANGEROUS-FUNCTIONALITY.md index d75b3f9a03..7024a0728e 100644 --- a/docs/DANGEROUS-FUNCTIONALITY.md +++ b/docs/DANGEROUS-FUNCTIONALITY.md @@ -861,6 +861,7 @@ the patterns cannot see, found by reading the code. The scan's limits include at | It takes the first line of hover text it built, for a menu title. That text can carry words from the engine's reply, which `engineClient.ts` already parsed. | `statusBar.ts` | | It splits what the MessageFoundry command line and git printed into lines, to put a time stamp on each for the "MessageFoundry Checks" output. It reads nothing out of them. | `checksLog.ts` | | It reads the characters of the Test Bench Debug program's text, which the extension holds itself, to name the program's file by a checksum (BACKLOG #5409) | `testBenchDebugProgram.ts` | +| It lower-cases the first letter of a promote notification sentence, which always starts with its own words | `promoteOutcome.ts` | **Extension files that parse text the patterns cannot see.** diff --git a/docs/TEE-RELAY.md b/docs/TEE-RELAY.md index 5f8221d9ea..c8f549df09 100644 --- a/docs/TEE-RELAY.md +++ b/docs/TEE-RELAY.md @@ -76,10 +76,11 @@ transformed/routed output against Corepoint's — without MEFOR delivering to re (`AE`/`AR`) **does not propagate back to Epic** — Epic sees the relay, not Corepoint. That's why the relay **logs every NAK** (see below). Corepoint still NAKs internally; transport failures are surfaced via the fail-closed shutdown. -* **Fail-closed.** On a Corepoint **transport** failure (unreachable, after `--corepoint-attempts` quick - retries), the relay **stops accepting on Listener A and drops live Epic connections** so Epic sees the - outage and queues/retries on its side. It does **not** exit (so it can't crash-loop against a down - Corepoint) — **restart it once Corepoint is healthy.** A message in flight at the instant of the failure +* **Fail-closed.** On a Corepoint **transport** failure (unreachable on every one of the + `--corepoint-attempts` tries, which count the first try, so `1` means no retry), the relay **stops + accepting on Listener A and drops live Epic connections** so Epic sees the outage and + queues/retries on its side. It does **not** exit (so it can't crash-loop against a down Corepoint) + — **restart it once Corepoint is healthy.** A message in flight at the instant of the failure may be `AA`'d-but-undelivered; the shutdown bounds further loss and Epic's resend/queue covers the rest. (This is a simple fail-closed relay, **not** durable store-and-forward — by design.) * **Shadow leg is decoupled.** The MEFOR copy goes through a bounded in-memory queue drained by its own @@ -110,9 +111,10 @@ python -m tee run --listen-epic :6661 --corepoint corehost:5000 --mefor meforhos python -m tee naks --db ./tee.db ``` -Useful flags: `--corepoint-attempts` / `--corepoint-retry-delay` (quick retries before tripping -fail-closed), `--connect-timeout` / `--send-timeout`, `--max-frame-bytes` (frame-size DoS cap), -`--mefor-queue-max` (shadow buffer bound), `--capture-bodies` (persist full bodies — **test data only**), +Useful flags: `--corepoint-attempts` (tries before tripping fail-closed, a positive integer; see +*Fail-closed* above) / `--corepoint-retry-delay` (seconds between tries), `--connect-timeout` / +`--send-timeout`, `--max-frame-bytes` (frame-size DoS cap), `--mefor-queue-max` (shadow buffer +bound, a positive integer), `--capture-bodies` (persist full bodies — **test data only**), `-y/--yes` (skip the test-data-only confirmation for an unattended/service start), `--log-level`, `--stop-grace` (default 30 seconds). On shutdown the relay stops ACKing new messages, then gives messages it has already ACKed up to the grace to finish their Corepoint and MEFOR legs, then gives diff --git a/docs/USER-GUIDE.md b/docs/USER-GUIDE.md index 340ffc5110..e8bbe0d82a 100644 --- a/docs/USER-GUIDE.md +++ b/docs/USER-GUIDE.md @@ -447,9 +447,9 @@ Routers and Handlers work against the mutable HL7 `Message` in [messagefoundry/p - **Peek a field** — `msg["PID-3"]` / `msg.field("OBX-3.1", occurrence=i)`; convenience properties `msg.message_code` (MSH-9.1), `msg.trigger_event` (MSH-9.2), `msg.control_id` (MSH-10). - **Iterate repetitions / segments** — `msg.repetitions("PID-3")` walks a `~`-list; `msg.count_segments("OBX")` plus `field(occurrence=…)` walks repeating segments. -- **Mutate** — `msg["MSH-4"] = value` / `msg.set(path, value, occurrence=…, repetition=…)`; rebuild a repeating block with `msg.delete_segments("OBX")` + `msg.add_segment(line, index=…)` + `msg.add_repetition(...)`. +- **Mutate** — `msg["MSH-4"] = value` / `msg.set(path, value, occurrence=…, repetition=…)`; drop one repeating segment with `msg.delete_segments("OBX", occurrence=i)` (walk the occurrences back to front), or rebuild a whole block with `msg.delete_segments("OBX")` + `msg.add_segment(line, index=…)` + `msg.add_repetition(...)`. - **Copy a value you read into a whole field with `msg.set_data`, never `msg.set`.** A read of a component or subcomponent, such as `msg.field("PID-3.1")`, is decoded: escaped `^`, `~` and `&` come back as plain characters. `msg.set("PV1-19", msg.field("PID-3.1"))` then writes them into a whole field as live structure, so the sender would choose the components and repetitions of a field you wrote. `msg.set_data("PV1-19", msg.field("PID-3.1") or "")` writes the value as data, and `copy_field` and `split_field` do that for you. `msg.set` on a whole field is still right for text you wrote yourself, such as `msg.set("PV1-19", "A^B")`. `messagefoundry check` flags the unsafe shape as `leaf-to-whole-field` where it can see both paths as literals ([ADR 0206](adr/0206-an-hl7-write-or-re-encode-never-lets-data-become-structure.md)). On an X12 message, `set_data` refuses the component separator in a whole element, so a value holding one raises there. Write each component on its own path, or keep `set` if you mean the separator as structure. Editing such a `set` line's path or value in the Steps view turns it into `set_data`, so change it as text. -- **Read MSH separators** — never hardcode `|^~\&`. The repeating-segment rebuild in [samples/results_relay/results_relay.py](../samples/results_relay/results_relay.py) reads them from MSH-1/MSH-2 (its `_separators` helper) before joining components. +- **Read MSH separators** — never hardcode `|^~\&`. Better still, edit through `Message` so you never join delimiters at all: [samples/results_relay/results_relay.py](../samples/results_relay/results_relay.py) drops, remaps and renumbers OBX segments in place, keeping every field, escape and the OBX-to-OBR grouping. - **Re-encode** — `msg.encode()` (or just pass `msg` to a `Send`, which encodes for you). A non-HL7 inbound (`content_type` other than `hl7v2`) delivers a `RawMessage` instead — read `.raw` / `.text` / `.json()` / `.xml()` (the XML accessor is XXE-safe via defusedxml: DOCTYPE, external-entity, and billion-laughs payloads raise) and `Send` a built string. For cross-field business-rule checks beyond what schema validation catches, compose the primitives in `parsing/consistency.py`, as [samples/consistency/validated_adt.py](../samples/consistency/validated_adt.py) does (raise `ConsistencyError` → dead-letter, or `return None` → filter). The three validation tiers are laid out in [HL7-VALIDATION.md](HL7-VALIDATION.md). diff --git a/harness/_console_widgets.py b/harness/_console_widgets.py index b6415bf569..9859f0cde9 100644 --- a/harness/_console_widgets.py +++ b/harness/_console_widgets.py @@ -19,6 +19,8 @@ from __future__ import annotations import html +import logging +import traceback from collections.abc import Callable from dataclasses import dataclass from datetime import datetime @@ -50,6 +52,8 @@ from messagefoundry.apiclient import ApiError, EngineClient, StepUpRequired from messagefoundry.parsing import HL7PeekError, parse_tree +_log = logging.getLogger(__name__) + #: Shared "error red" for inline error text — the message-detail error, the auth dialogs' #: error labels, and the heart's stopped state — so the palette can't drift across modules. #: Carried over from the retired console theme so there is a single source of truth for this colour. @@ -292,10 +296,30 @@ def load(self, message_id: str) -> None: # an in-flight one (rapid row clicks / replay), so a stale result is dropped in _apply. self._open_seq += 1 self._pending_id = message_id - # No Show body until this open lands: a press now would fetch the previous message's body. - self._show_body.setEnabled(False) + # Nothing is open until this open lands. The previous message leaves the screen now, and + # Show body or Replay pressed meanwhile would act on it, so both go too (BACKLOG #5848). + self._reset("Opening the message...") open_seq = self._open_seq - self._runner.submit(lambda: self._fetch(message_id, open_seq), on_done=self._apply) + self._runner.submit( + lambda: self._fetch(message_id, open_seq), + on_done=self._apply, + on_error=lambda exc: self._open_raised(message_id, open_seq, exc), + ) + + def _open_raised(self, message_id: str, open_seq: int, exc: BaseException) -> None: + """The open raised something other than ApiError. The client wraps transport errors in + ApiError, so this is a contract break, such as a closed client or a decode bug: log it and + take _apply's error path, which drops it if a newer open superseded it. Its text can quote + message fields (a decode error names its input), so no level logs the text: WARNING carries + the type name, and DEBUG the traceback's frames without the message.""" + _log.warning("message detail open raised %s", type(exc).__name__) + _log.debug( + "message detail open raised %s at:\n%s", + type(exc).__name__, + "".join(traceback.format_tb(exc.__traceback__)), + ) + error = f"the message could not be opened: {type(exc).__name__}" + self._apply(_DetailSnapshot(message_id, open_seq, None, error)) def stop(self) -> None: """Stop the background runner (call on window close) so a late result can't touch dead widgets.""" @@ -409,14 +433,19 @@ def _apply_body(self, snap: _BodySnapshot) -> None: self._raw.setPlainText(snap.raw.replace("\r", "\n")) def _on_replay(self) -> None: - if self._message_id is None: - return + # Read once: replay() can open a step-up prompt whose nested event loop runs a load() or + # clear(). That newer selection wins, so the refresh below runs only if none did. + message_id = self._message_id + if message_id is None: + return # nothing open, or a newer load() is still in flight + open_seq = self._open_seq try: - self._client.replay(self._message_id) + self._client.replay(message_id) except ApiError as exc: self.error.emit(str(exc)) return - self.load(self._message_id) # refresh detail (status/events updated) + if open_seq == self._open_seq: + self.load(message_id) # refresh detail (status/events updated) self.changed.emit() diff --git a/harness/acceptance/probes.py b/harness/acceptance/probes.py index b26a49adfa..f4ecfc0e32 100644 --- a/harness/acceptance/probes.py +++ b/harness/acceptance/probes.py @@ -30,8 +30,11 @@ _log = logging.getLogger(__name__) -#: Default listener ports referenced by section A5 (informational bindability check). -_DEFAULT_PORTS: dict[str, int] = {"MLLP": 2575, "DICOM": 11112, "API": 8765} +#: Fixed reference ports for section A5 (informational bindability check), one entry per listener +#: the A5 row names (BACKLOG #5849). Each is a stock default, not what a given deployment binds, +#: which depends on its config and --env. TCP is the default of ``IB_Harness_TCP``, the raw-TCP +#: inbound in ``harness/config/tcp_x12.py`` (endpoint ``tcp_in``); a test pins the two together. +_DEFAULT_PORTS: dict[str, int] = {"MLLP": 2575, "DICOM": 11112, "TCP": 2580, "API": 8765} class _ChainCut(Exception): diff --git a/ide/media/stepsWebview.js b/ide/media/stepsWebview.js index d4c7cbb822..2ca094bbf1 100644 --- a/ide/media/stepsWebview.js +++ b/ide/media/stepsWebview.js @@ -52,6 +52,9 @@ // moveTo, so an arrow move rides the verified cross-suite engine path. function stepsCtxRows() { return Array.from(document.querySelectorAll('li.row')).map((el) => ({ + // The page holds every Handler and Router of the module; a row names its own, as the model's + // RowDropContext does (BACKLOG #5830). + handler: el.dataset.handler, lineStart: Number(el.dataset.lineStart), lineEnd: Number(el.dataset.lineEnd), nesting: Number(el.dataset.nesting), @@ -106,9 +109,9 @@ function buildDropSlots(rws) { const bySuite = new Map(); for (const r of rws) { const l = bySuite.get(r.suite); if (l) { l.push(r); } else { bySuite.set(r.suite, [r]); } } - const root = rws.find((r) => r.nesting === 0); + // Every function's top-level suite, in document order (BACKLOG #5840). + const roots = Array.from(new Set(rws.filter((r) => r.nesting === 0).map((r) => r.suite))); const slots = []; - if (!root) { return slots; } const cont = (r) => r.control === 'elif' || r.control === 'else'; const emit = (suiteId) => { const ch = bySuite.get(suiteId) || []; @@ -126,10 +129,30 @@ } } }; - emit(root.suite); + for (const s of roots) { emit(s); } return slots; } - function walkMove(rws, blockStartLine, direction) { + // Mirror of stepsModel.resolveInsertAnchor (BACKLOG #5839): an insert AFTER an if/elif/else/for + // header is requested BEFORE the block's first body row, since right after the header line, at the + // header's indent, the engine's re-parse refuses it. Any other anchor and position is unchanged. + function resolveInsertAnchor(rws, anchorLineStart, position) { + const anchor = rws.find((r) => r.lineStart === anchorLineStart); + if (!anchor) { return null; } + const isHeader = anchor.kind === 'control' && anchor.control !== undefined && anchor.control !== 'raise'; + if (position !== 'after' || !isHeader) { return { anchor, position }; } + const bodySuite = String(anchor.lineStart); + // A blank-only body row is skipped: the engine would take the header's indent from it. + const first = rws.find((r) => r.suite === bodySuite && (r.expectSrc === undefined ? 'x' : r.expectSrc).trim() !== ''); + return first ? { anchor: first, position: 'before' } : null; + } + function walkMove(allRws, blockStartLine, direction) { + // Walk only the moving row's own function, told apart by its root suite (def line), never by name: + // a Router and a Handler may share one (BACKLOG #5830). + const at = allRws.findIndex((r) => r.lineStart === blockStartLine); + if (at < 0) { return null; } + let root = ''; + const roots = allRws.map((r) => (r.nesting === 0 ? (root = r.suite) : root)); + const rws = allRws.filter((_r, i) => roots[i] === roots[at]); const mi = rws.findIndex((r) => r.lineStart === blockStartLine); if (mi < 0) { return null; } const m = rws[mi]; @@ -536,16 +559,26 @@ function pasteSelected() { const clip = getClipboard(); if (!clip || !selected) { return; } // empty clipboard / no selection → friendly no-op - vscode.postMessage({ + // A paste on an if/elif/else/for header lands as the block's first statement (BACKLOG #5839), so + // the anchor moves to the body's first row and the resolved position rides along. Any other anchor + // posts no position and the provider derives it, as before. + // Only a control header can move, so a leaf paste skips the row sweep. + const res = selected.kind === 'control' ? resolveInsertAnchor(stepsCtxRows(), selected.lineStart, 'after') : null; + // resolveInsertAnchor turns an 'after' into a 'before' only when it moved the anchor into a body. + const moved = res !== null && res.position === 'before'; + const at = moved ? res.anchor : selected; + const msg = { command: 'paste', - handler: selected.handler, - lineStart: selected.lineStart, - lineEnd: selected.lineEnd, - kind: selected.kind, - expectSrc: selected.expectSrc, + handler: at.handler, + lineStart: at.lineStart, + lineEnd: at.lineEnd, + kind: at.kind, + expectSrc: at.expectSrc, block: clip.source, text: 'MessageFoundry: pasted ' + (clip.label || 'the steps') + '.', - }); + }; + if (moved) { msg.position = res.position; } + vscode.postMessage(msg); } for (const el of rows) { @@ -750,23 +783,10 @@ if (sel.value === '' || !selected) { return; } // ADR 0104 fan-out: insert BEFORE a terminal return / scaffold footer (no dead code), AFTER a // mid-body append send or any other step. - const position = selected.isReturn ? 'before' : 'after'; - // Remember what to select after the insert re-projects (the new neighbour of the anchor row). - vscode.setState(Object.assign({}, vscode.getState() || {}, { - selectAfterInsert: { handler: selected.handler, anchorExpectSrc: selected.expectSrc, position }, - })); - vscode.postMessage({ - command: 'insertItem', - itemId: sel.value, - // Pass the isReturn-aware position (a mid-body append → after, a return/footer → before) so the - // provider does not have to re-derive it from `kind` alone (which can't tell an append from a return). - position: position, - handler: selected.handler, - lineStart: selected.lineStart, - lineEnd: selected.lineEnd, - expectSrc: selected.expectSrc, - kind: selected.kind, - }); + // Pass the isReturn-aware position (a mid-body append → after, a return/footer → before) so the + // provider does not have to re-derive it from `kind` alone (which can't tell an append from a return). + const opt = sel.selectedOptions && sel.selectedOptions[0]; + menuInsert(sel.value, selected.isReturn ? 'before' : 'after', !!(opt && opt.dataset.anchor === 'if_chain')); }); // Filter: hide rows that don't match the query (segment / field path / action / Send target). Pure client- @@ -790,17 +810,26 @@ // pure stepsModel.contextMenuEnablement (unit-tested there). Copy/Cut/Paste stay keyboard-served (they // are deliberately NOT in this menu). Dispatch helpers use the currently `selected` row. These post to // the SAME provider handlers, so the byte-stable lens-rewrite path + F7 stale guard are unchanged. - function menuInsert(itemId, position) { + // Shared by the toolbar Add and the menu's Insert before / after. `clause` marks an Else / Else If + // item (data-anchor="if_chain"), whose anchor must stay the if/elif row it extends; every other item + // goes through resolveInsertAnchor, so "after a header" lands as the block's first statement. + function menuInsert(itemId, position, clause) { if (!selected || !itemId || (position !== 'before' && position !== 'after')) { return; } - // Remember which row to re-select after the insert re-projects (the new neighbour of the anchor), - // exactly as the toolbar Add does — the position drives before/after neighbour selection. + let at = selected; + if (!clause) { + const res = resolveInsertAnchor(stepsCtxRows(), selected.lineStart, position); + // No body row to anchor on: send the request as asked, and the engine's refusal is shown. + if (res) { at = res.anchor; position = res.position; } + } + // Remember which row to re-select after the insert re-projects (the new neighbour of the anchor); + // the position drives before/after neighbour selection. vscode.setState(Object.assign({}, vscode.getState() || {}, { - selectAfterInsert: { handler: selected.handler, anchorExpectSrc: selected.expectSrc, position: position }, + selectAfterInsert: { handler: at.handler, anchorExpectSrc: at.expectSrc, position: position }, })); vscode.postMessage({ command: 'insertItem', itemId: itemId, position: position, - handler: selected.handler, lineStart: selected.lineStart, lineEnd: selected.lineEnd, - expectSrc: selected.expectSrc, kind: selected.kind, + handler: at.handler, lineStart: at.lineStart, lineEnd: at.lineEnd, + expectSrc: at.expectSrc, kind: at.kind, }); } function menuDelete() { @@ -864,6 +893,9 @@ if (!el) { return; } el.disabled = !!disabled; // A disabled Insert parent must also suppress its submenu (belt-and-suspenders with openSubmenu). + // Only the PARENT decides that: an item inside the submenu shares the same .ctx-sub, and + // letting it toggle the class would hide the whole submenu whenever its last item is greyed. + if (!el.classList.contains('ctx-parent')) { return; } const sub = el.closest('.ctx-sub'); if (sub) { sub.classList.toggle('ctx-disabled', !!disabled); } } @@ -878,7 +910,8 @@ const ls = Number(el.dataset.lineStart); const ctxRows = stepsCtxRows(); // Mirrors stepsModel.contextMenuEnablement: Insert before always; Insert after suppressed on a - // terminal RETURN / scaffold footer (dead code after the return) but ALLOWED on a mid-body append + // terminal RETURN / scaffold footer / Router route row (data-is-return, so dead code after the + // return) but ALLOWED on a mid-body append // send (ADR 0104); Delete only on an editable action/lookup/send row; ↑/↓ per walk. for (const p of insertParents) { setDisabled(p, p.dataset.sub === 'after' && isReturn); @@ -896,15 +929,18 @@ // ADR 0104 fan-out: "Add destination" only on a real send row (never the `return []` filter). setDisabled(addDestItem, !(kind === 'send' && el.dataset.filtered !== 'true')); // ADR 0106: Else / Else If (data-anchor="if_chain") only apply to an if-chain anchor (an if/elif row). - const isIfChain = kind === 'control' && (control === 'if' || control === 'elif'); - for (const c of menu.querySelectorAll('.ctx-item[data-anchor="if_chain"]')) { - setDisabled(c, !isIfChain); - } // ADR 0076 Amendment D: grey every Add item outside the enclosing element's role, so a Router's // menu offers routing constructs only and the engine's refusal is never met as an error toast. + // The menu is shared by every row, so each item's state is set afresh on every open, enabling + // what this row allows as well as greying what it does not (BACKLOG #5842). + // A statement inserted BEFORE an elif/else header would land at the clause keyword's indent and + // split the if-chain, which the engine refuses; a Comment there is accepted, so only it stays. + const isIfChain = kind === 'control' && (control === 'if' || control === 'elif'); + const continuation = kind === 'control' && (control === 'elif' || control === 'else'); const rowRole = el.dataset.role || 'handler'; for (const c of menu.querySelectorAll('.ctx-item[data-item-id]')) { - if (!inRole(c, rowRole)) { setDisabled(c, true); } + setDisabled(c, (c.dataset.anchor === 'if_chain' && !isIfChain) || !inRole(c, rowRole) || + (continuation && c.dataset.position === 'before' && c.dataset.itemId !== 'comment')); } // Mirror isRowMovable: a code row (and an elif/else header) is NOT movable, even though walkMove // finds an adjacent slot for it (it is draggable only as a drag-interception marker). Gate the @@ -967,7 +1003,7 @@ const item = ev.target.closest('.ctx-item'); if (!item || item.disabled) { return; } const cmd = item.dataset.cmd; - if (cmd === 'insert') { menuInsert(item.dataset.itemId, item.dataset.position); } + if (cmd === 'insert') { menuInsert(item.dataset.itemId, item.dataset.position, item.dataset.anchor === 'if_chain'); } else if (cmd === 'deleteRow') { menuDelete(); } else if (cmd === 'addDestination') { menuAddDestination(); } else if (cmd === 'moveUp') { menuMove('up'); } @@ -1022,7 +1058,7 @@ } // ---- TEST-ONLY EXPORT HOOK (BACKLOG #1758; master test plan 13-steps-editor.md §S2 step 3) -------- - // The ten functions above MIRROR pure, unit-tested helpers in ide/src/stepsModel.ts (the declared + // The mirrored functions above (steps-mirror.test.ts lists them in MIRRORED) MIRROR pure, unit-tested helpers in ide/src/stepsModel.ts (the declared // source of truth) because this script is loaded into a `default-src 'none'` webview and cannot // import across that boundary. The differential suite (ide/src/test/suite/steps-mirror.test.ts) loads // THIS FILE under jsdom and asserts every mirror agrees with its model counterpart, so a drift shows @@ -1047,6 +1083,7 @@ clipLabel: clipLabel, buildDropSlots: buildDropSlots, walkMove: walkMove, + resolveInsertAnchor: resolveInsertAnchor, canDrop: canDrop, scopeLabel: scopeLabel, resolveDrop: resolveDrop, diff --git a/ide/src/alertEditor.ts b/ide/src/alertEditor.ts index ab2e467676..26b5620f15 100644 --- a/ide/src/alertEditor.ts +++ b/ide/src/alertEditor.ts @@ -12,7 +12,7 @@ import * as vscode from "vscode"; import { runJson, serviceConfig, workspaceDir, writerPathSetting } from "./cli"; import { STARTUP_BANNERS, openChannel, postToWebview } from "./webviewMessaging"; -import { alertEditorScript } from "./alertEditorWebview"; +import { ALERT_COOLDOWN_MAX_DAYS, ALERT_COOLDOWN_MAX_SECONDS, alertEditorScript } from "./alertEditorWebview"; const EVENT_TYPES = [ "any", @@ -217,8 +217,8 @@ function formHtml(webview: vscode.Webview): string {
-
-
Re-alert interval for matching events; blank = global default.
+
+
Re-alert interval for matching events, more than 0 and at most ${ALERT_COOLDOWN_MAX_DAYS} days; blank = global default.