@yuneta/gobj-ui 7.25.26 → 7.26.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.
@@ -23806,6 +23806,8 @@ function mt_create$6(gobj) {
23806
23806
  gobj.priv.reread_on_session = false;
23807
23807
  gobj.priv.conn_shell = null;
23808
23808
  gobj.priv.drills_in_flight = /* @__PURE__ */ new Set();
23809
+ gobj.priv.parent_rereads = /* @__PURE__ */ new Map();
23810
+ gobj.priv.reread_seq = 0;
23809
23811
  build_ui$6(gobj);
23810
23812
  let subscriber = (0, _yuneta_gobj_js.gobj_read_pointer_attr)(gobj, "subscriber");
23811
23813
  if (!subscriber) subscriber = (0, _yuneta_gobj_js.gobj_parent)(gobj);
@@ -24974,7 +24976,7 @@ function answered_record$1(data) {
24974
24976
  * Command to remote service: one node, in the shape the table
24975
24977
  * reads its topic with (TABLE_READ_OPTIONS)
24976
24978
  ************************************************************/
24977
- function treedb_get_node$1(gobj, treedb_name, topic_name, node_id) {
24979
+ function treedb_get_node$1(gobj, treedb_name, topic_name, node_id, reread_seq) {
24978
24980
  let gobj_remote_yuno = (0, _yuneta_gobj_js.gobj_read_pointer_attr)(gobj, "gobj_remote_yuno");
24979
24981
  let kw = {
24980
24982
  service: treedb_name,
@@ -24983,7 +24985,11 @@ function treedb_get_node$1(gobj, treedb_name, topic_name, node_id) {
24983
24985
  node_id,
24984
24986
  options: Object.assign({}, TABLE_READ_OPTIONS)
24985
24987
  };
24986
- kw.__md_command__ = { topic_name };
24988
+ kw.__md_command__ = {
24989
+ topic_name,
24990
+ node_id,
24991
+ reread_seq
24992
+ };
24987
24993
  let ret = (0, _yuneta_gobj_js.gobj_command)(gobj_remote_yuno, "node", kw, gobj);
24988
24994
  if (ret) {
24989
24995
  (0, _yuneta_gobj_js.log_error)(ret);
@@ -24992,6 +24998,94 @@ function treedb_get_node$1(gobj, treedb_name, topic_name, node_id) {
24992
24998
  return 0;
24993
24999
  }
24994
25000
  /************************************************************
25001
+ * Is the row of `node_id` loaded in the table of its topic?
25002
+ * A table not open, or open on other rows (a page that does
25003
+ * not hold it), shows nothing of the node: there is nothing to
25004
+ * refresh, its rows are read when they are shown.
25005
+ ************************************************************/
25006
+ function is_row_loaded(gobj, topic_name, node_id) {
25007
+ let gobj_formtable = get_gobj_formtable(gobj, topic_name);
25008
+ if (!gobj_formtable) return false;
25009
+ let tabulator = (0, _yuneta_gobj_js.gobj_read_attr)(gobj_formtable, "tabulator");
25010
+ if (!tabulator) return false;
25011
+ return !!tabulator.getRow(node_id);
25012
+ }
25013
+ /************************************************************
25014
+ * Read again a parent whose hook a link or an unlink moved
25015
+ * (ac_treedb_node_linked), ONE read in flight per parent: a
25016
+ * link that comes while it is out only marks it dirty, and
25017
+ * its answer asks once more (answer_linked_parent_reread).
25018
+ * A burst of links to one parent costs two reads of it, not
25019
+ * one per link -- each read is the parent with every child.
25020
+ * Each request carries its `seq`: only its own answer settles
25021
+ * the entry.
25022
+ ************************************************************/
25023
+ function reread_linked_parent(gobj, treedb_name, topic_name, node_id) {
25024
+ let priv = gobj.priv;
25025
+ let key = `${topic_name}\u0000${node_id}`;
25026
+ let in_flight = priv.parent_rereads.get(key);
25027
+ if (in_flight) {
25028
+ in_flight.dirty = true;
25029
+ return 0;
25030
+ }
25031
+ let seq = ++priv.reread_seq;
25032
+ priv.parent_rereads.set(key, {
25033
+ dirty: false,
25034
+ seq
25035
+ });
25036
+ let ret = treedb_get_node$1(gobj, treedb_name, topic_name, node_id, seq);
25037
+ if (ret < 0) priv.parent_rereads.delete(key);
25038
+ return ret;
25039
+ }
25040
+ /************************************************************
25041
+ * A whole read of a topic brought every row as it is now: the
25042
+ * re-reads of its parents still out have nothing to add, and
25043
+ * their answers, when they come, are not taken. It is also
25044
+ * what bounds an entry whose answer never comes on a live
25045
+ * session (a request lost by the backend): the drop clears
25046
+ * every entry (ac_transport_state), the next read of the
25047
+ * topic (its refresh, its open, the reconnect) clears its own.
25048
+ ************************************************************/
25049
+ function forget_topic_rereads(gobj, topic_name) {
25050
+ let prefix = `${topic_name}\u0000`;
25051
+ for (const key of Array.from(gobj.priv.parent_rereads.keys())) if (key.startsWith(prefix)) gobj.priv.parent_rereads.delete(key);
25052
+ }
25053
+ /************************************************************
25054
+ * The answer of a parent's re-read. It is a refresh nobody
25055
+ * asked for, so a failure is a warning, never the app's error
25056
+ * modal: a force-delete of a loaded parent publishes UNLINKED
25057
+ * per child, and the re-read reaches the backend after the
25058
+ * delete ("Node not found") -- in every open viewer.
25059
+ *
25060
+ * Only the answer of the request in flight counts: one cut by
25061
+ * a drop, or superseded by a whole read of the topic, that
25062
+ * arrives after a new request went out must neither settle
25063
+ * the new one nor update the row with older data.
25064
+ *
25065
+ * Then, if links came while it was out, the parent is read
25066
+ * once more -- when its row is still loaded.
25067
+ ************************************************************/
25068
+ function answer_linked_parent_reread(gobj, result, comment, data, kw_command) {
25069
+ let priv = gobj.priv;
25070
+ let topic_name = (0, _yuneta_gobj_js.kw_get_str)(gobj, kw_command, "topic_name", "", 0);
25071
+ let node_id = (0, _yuneta_gobj_js.kw_get_str)(gobj, kw_command, "node_id", "", 0);
25072
+ let seq = (0, _yuneta_gobj_js.kw_get_int)(gobj, kw_command, "reread_seq", 0, 0);
25073
+ let key = `${topic_name}\u0000${node_id}`;
25074
+ let in_flight = priv.parent_rereads.get(key);
25075
+ if (!in_flight || in_flight.seq !== seq) {
25076
+ if (result < 0) (0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: late failure of the re-read of the linked parent '${topic_name}^${node_id}' dropped, it was settled already (a drop, or a whole read of the topic): ${comment || ""}`);
25077
+ return 0;
25078
+ }
25079
+ priv.parent_rereads.delete(key);
25080
+ if (result < 0) (0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: the re-read of the linked parent '${topic_name}^${node_id}' failed: ${comment || ""}`);
25081
+ else {
25082
+ let gobj_formtable = get_gobj_formtable(gobj, topic_name);
25083
+ if (gobj_formtable) (0, _yuneta_gobj_js.gobj_send_event)(gobj_formtable, "EV_LOAD_NODE_UPDATED", [data], gobj);
25084
+ }
25085
+ if (in_flight.dirty && is_connected$1(gobj) && is_row_loaded(gobj, topic_name, node_id)) reread_linked_parent(gobj, (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "treedb_name"), topic_name, node_id);
25086
+ return 0;
25087
+ }
25088
+ /************************************************************
24995
25089
  * Command to remote service
24996
25090
  ************************************************************/
24997
25091
  function treedb_update_node$1(gobj, treedb_name, topic_name, record, options, form_write, created) {
@@ -25323,6 +25417,7 @@ function ac_mt_command_answer$2(gobj, event, kw, src) {
25323
25417
  }, gobj);
25324
25418
  return 0;
25325
25419
  }
25420
+ if (command === "node") return answer_linked_parent_reread(gobj, result, comment, data, kw_command);
25326
25421
  if (result < 0) {
25327
25422
  if (command === "descs") show_load_error$1(gobj, (0, i18next.t)(comment));
25328
25423
  else {
@@ -25356,18 +25451,20 @@ function ac_mt_command_answer$2(gobj, event, kw, src) {
25356
25451
  let answer = nodes_answer(data);
25357
25452
  let req_id = (0, _yuneta_gobj_js.kw_get_str)(gobj, kw_command, "req_id", "", 0);
25358
25453
  if ((0, _yuneta_gobj_js.kw_get_str)(gobj, kw_command, "purpose", "", 0) === "json") (0, _yuneta_gobj_js.gobj_send_event)(gobj_topic_form, "EV_JSON_LOADED", { rows: answer.rows }, gobj);
25359
- else if (req_id) (0, _yuneta_gobj_js.gobj_send_event)(gobj_topic_form, "EV_PAGE_LOADED", {
25360
- req_id,
25361
- rows: answer.rows,
25362
- pages: answer.pages,
25363
- total: answer.total
25364
- }, gobj);
25365
- else (0, _yuneta_gobj_js.gobj_send_event)(gobj_topic_form, "EV_LOAD_NODES", answer.rows, gobj);
25454
+ else if (req_id) {
25455
+ forget_topic_rereads(gobj, topic_name);
25456
+ (0, _yuneta_gobj_js.gobj_send_event)(gobj_topic_form, "EV_PAGE_LOADED", {
25457
+ req_id,
25458
+ rows: answer.rows,
25459
+ pages: answer.pages,
25460
+ total: answer.total
25461
+ }, gobj);
25462
+ } else {
25463
+ forget_topic_rereads(gobj, topic_name);
25464
+ (0, _yuneta_gobj_js.gobj_send_event)(gobj_topic_form, "EV_LOAD_NODES", answer.rows, gobj);
25465
+ }
25366
25466
  }
25367
25467
  break;
25368
- case "node":
25369
- (0, _yuneta_gobj_js.gobj_send_event)(get_gobj_formtable(gobj, (0, _yuneta_gobj_js.kw_get_str)(gobj, kw_command, "topic_name", "", 0)), "EV_LOAD_NODE_UPDATED", [data], gobj);
25370
- break;
25371
25468
  case "create-node":
25372
25469
  case "update-node":
25373
25470
  case "delete-node":
@@ -25541,6 +25638,7 @@ function ac_transport_state$2(gobj, event, kw, src) {
25541
25638
  refresh_toolbar_buttons(gobj, connected);
25542
25639
  if (!connected) {
25543
25640
  gobj.priv.reread_on_session = true;
25641
+ gobj.priv.parent_rereads.clear();
25544
25642
  answer_drills_in_flight$1(gobj);
25545
25643
  abandon_form_writes(gobj.priv.form_writes).forEach((w) => {
25546
25644
  (0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: transport closed, the write ${w.form_write} of '${w.topic_name}' is lost`);
@@ -25617,7 +25715,9 @@ function ac_treedb_node_updated$1(gobj, event, kw, src) {
25617
25715
  * EV_TREEDB_NODE_LINKED / EV_TREEDB_NODE_UNLINKED: the relationship
25618
25716
  * ({hook_name, parent_topic_name, child_topic_name, parent_id,
25619
25717
  * child_id, treedb_name}), not a node. The parent's hook changed and
25620
- * the event does not carry it: read the parent again.
25718
+ * the event does not carry it: read the parent again -- only when its
25719
+ * row is loaded (a table not open, or on another page, has nothing to
25720
+ * refresh), and one read in flight per parent (reread_linked_parent).
25621
25721
  ********************************************/
25622
25722
  function ac_treedb_node_linked$1(gobj, event, kw, src) {
25623
25723
  let treedb_name = (0, _yuneta_gobj_js.kw_get_str)(gobj, kw, "treedb_name", "", 0);
@@ -25628,7 +25728,8 @@ function ac_treedb_node_linked$1(gobj, event, kw, src) {
25628
25728
  (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: ${event} without parent_topic_name/parent_id`);
25629
25729
  return -1;
25630
25730
  }
25631
- return treedb_get_node$1(gobj, treedb_name, parent_topic_name, parent_id);
25731
+ if (!is_row_loaded(gobj, parent_topic_name, parent_id)) return 0;
25732
+ return reread_linked_parent(gobj, treedb_name, parent_topic_name, parent_id);
25632
25733
  }
25633
25734
  /********************************************
25634
25735
  * Remote subscription response
@@ -68811,7 +68912,7 @@ function get_nodes(gobj, topic_name) {
68811
68912
  * filtered by treedb_name alone (a {topic_name} filter would match nothing).
68812
68913
  *
68813
68914
  * NOTE: the backend only publishes them when its C_NODE service runs
68814
- * with `with_link_events` (the default since SDK 7.25.23; a v1 backend
68915
+ * with `with_link_events` (the default since SDK 7.26.0; a v1 backend
68815
68916
  * sets it off). Without it, a link/unlink is announced the
68816
68917
  * backward-compatible way — an
68817
68918
  * EV_TREEDB_NODE_UPDATED of the PARENT — which cannot move an edge here:
@@ -78978,6 +79079,15 @@ function ensure_dev_style() {
78978
79079
  background: rgba(0,0,0,0.03);
78979
79080
  }
78980
79081
  .YDEV_GROUP { display: inline-flex; align-items: center; gap: 5px; }
79082
+ /* A whole line of the bar, whose chips scroll sideways inside it: the
79083
+ window never does. min-width 0 so the flex line can be narrower than
79084
+ its content; the chips keep their size and their label on one line. */
79085
+ .YDEV_GROUP_SCROLL { flex: 1 1 100%; min-width: 0; }
79086
+ .YDEV_SCROLL {
79087
+ display: flex; align-items: center; gap: 5px; min-width: 0; flex: 1 1 auto;
79088
+ overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; padding-bottom: 2px;
79089
+ }
79090
+ .YDEV_SCROLL > * { flex: 0 0 auto; white-space: nowrap; }
78981
79091
  .YDEV_LABEL {
78982
79092
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em;
78983
79093
  opacity: 0.6; align-self: center;
@@ -79815,6 +79925,29 @@ function refresh_dev_chrome() {
79815
79925
  });
79816
79926
  update_stats();
79817
79927
  }
79928
+ function kw_shown_lines($kw, indent, out) {
79929
+ if (!$kw) return out;
79930
+ for (let $n of $kw.children) if ($n.classList.contains("TRAFFIC_ROW")) {
79931
+ let $key = $n.querySelector(".TRAFFIC_KEY");
79932
+ let key = $key ? $key.textContent : "";
79933
+ let vals = [];
79934
+ for (let $c of $n.children) {
79935
+ if ($c.classList.contains("TRAFFIC_BULLET") || $c === $key) continue;
79936
+ vals.push($c.children.length ? Array.from($c.children).map(($x) => $x.textContent).join(" ") : $c.textContent);
79937
+ }
79938
+ out.push(`${indent}• ${key} ${vals.join(" ")}`.trimEnd());
79939
+ } else if ($n.tagName === "DETAILS") {
79940
+ let $sum = $n.querySelector(":scope > summary");
79941
+ let $key = $sum ? $sum.querySelector(".TRAFFIC_NEST_KEY") : null;
79942
+ let $hint = $sum ? $sum.querySelector(".TRAFFIC_NEST_HINT_WRAP") : null;
79943
+ out.push(`${indent}${$n.open ? "▾" : "▸"} ` + `${$key ? $key.textContent : ""} ${$hint ? $hint.textContent : ""}`.trimEnd());
79944
+ if ($n.open) kw_shown_lines($n.querySelector(":scope > .TRAFFIC_KW"), indent + " ", out);
79945
+ }
79946
+ return out;
79947
+ }
79948
+ function entry_shown_lines($entry) {
79949
+ return kw_shown_lines($entry ? $entry.querySelector(":scope > .TRAFFIC_KW") : null, " ", []);
79950
+ }
79818
79951
  function traffic_to_text() {
79819
79952
  let ctx = build_filter_ctx();
79820
79953
  let out = [];
@@ -79827,6 +79960,11 @@ function traffic_to_text() {
79827
79960
  }
79828
79961
  let head = `${e.ts} ${dir_arrow(e.dir)} ${e.title ? "[" + e.title + "] " : ""}${e.event}${e.command ? " " + e.command : ""}`;
79829
79962
  out.push(head);
79963
+ if (dev_traffic_view() !== "expanded" && e.$node) {
79964
+ out.push(...entry_shown_lines(e.$node));
79965
+ out.push("");
79966
+ continue;
79967
+ }
79830
79968
  let payload = e.kw ? e.kw : e.jn;
79831
79969
  try {
79832
79970
  out.push(JSON.stringify(payload, null, 4));
@@ -80125,6 +80263,22 @@ function build_control_bar() {
80125
80263
  (0, i18next.t)(label)
80126
80264
  ], ...items]
80127
80265
  ];
80266
+ let grp_scroll = (label, items) => [
80267
+ "div",
80268
+ { class: "YDEV_GROUP YDEV_GROUP_SCROLL" },
80269
+ [[
80270
+ "span",
80271
+ {
80272
+ class: "YDEV_LABEL",
80273
+ "data-i18n": label
80274
+ },
80275
+ (0, i18next.t)(label)
80276
+ ], [
80277
+ "div",
80278
+ { class: "YDEV_SCROLL" },
80279
+ items
80280
+ ]]
80281
+ ];
80128
80282
  let sep = () => [
80129
80283
  "span",
80130
80284
  { class: "YDEV_SEP" },
@@ -80134,12 +80288,11 @@ function build_control_bar() {
80134
80288
  "div",
80135
80289
  { class: "YDEV_BAR" },
80136
80290
  [
80137
- grp("traces", [
80291
+ grp_scroll("traces", [
80138
80292
  ...trace_chips,
80139
80293
  simple_mach,
80140
80294
  traces_payload
80141
80295
  ]),
80142
- sep(),
80143
80296
  grp("output", [output_seg]),
80144
80297
  sep(),
80145
80298
  grp("view", [view_seg]),
@@ -23801,6 +23801,8 @@ function mt_create$6(gobj) {
23801
23801
  gobj.priv.reread_on_session = false;
23802
23802
  gobj.priv.conn_shell = null;
23803
23803
  gobj.priv.drills_in_flight = /* @__PURE__ */ new Set();
23804
+ gobj.priv.parent_rereads = /* @__PURE__ */ new Map();
23805
+ gobj.priv.reread_seq = 0;
23804
23806
  build_ui$6(gobj);
23805
23807
  let subscriber = gobj_read_pointer_attr(gobj, "subscriber");
23806
23808
  if (!subscriber) subscriber = gobj_parent(gobj);
@@ -24969,7 +24971,7 @@ function answered_record$1(data) {
24969
24971
  * Command to remote service: one node, in the shape the table
24970
24972
  * reads its topic with (TABLE_READ_OPTIONS)
24971
24973
  ************************************************************/
24972
- function treedb_get_node$1(gobj, treedb_name, topic_name, node_id) {
24974
+ function treedb_get_node$1(gobj, treedb_name, topic_name, node_id, reread_seq) {
24973
24975
  let gobj_remote_yuno = gobj_read_pointer_attr(gobj, "gobj_remote_yuno");
24974
24976
  let kw = {
24975
24977
  service: treedb_name,
@@ -24978,7 +24980,11 @@ function treedb_get_node$1(gobj, treedb_name, topic_name, node_id) {
24978
24980
  node_id,
24979
24981
  options: Object.assign({}, TABLE_READ_OPTIONS)
24980
24982
  };
24981
- kw.__md_command__ = { topic_name };
24983
+ kw.__md_command__ = {
24984
+ topic_name,
24985
+ node_id,
24986
+ reread_seq
24987
+ };
24982
24988
  let ret = gobj_command(gobj_remote_yuno, "node", kw, gobj);
24983
24989
  if (ret) {
24984
24990
  log_error(ret);
@@ -24987,6 +24993,94 @@ function treedb_get_node$1(gobj, treedb_name, topic_name, node_id) {
24987
24993
  return 0;
24988
24994
  }
24989
24995
  /************************************************************
24996
+ * Is the row of `node_id` loaded in the table of its topic?
24997
+ * A table not open, or open on other rows (a page that does
24998
+ * not hold it), shows nothing of the node: there is nothing to
24999
+ * refresh, its rows are read when they are shown.
25000
+ ************************************************************/
25001
+ function is_row_loaded(gobj, topic_name, node_id) {
25002
+ let gobj_formtable = get_gobj_formtable(gobj, topic_name);
25003
+ if (!gobj_formtable) return false;
25004
+ let tabulator = gobj_read_attr(gobj_formtable, "tabulator");
25005
+ if (!tabulator) return false;
25006
+ return !!tabulator.getRow(node_id);
25007
+ }
25008
+ /************************************************************
25009
+ * Read again a parent whose hook a link or an unlink moved
25010
+ * (ac_treedb_node_linked), ONE read in flight per parent: a
25011
+ * link that comes while it is out only marks it dirty, and
25012
+ * its answer asks once more (answer_linked_parent_reread).
25013
+ * A burst of links to one parent costs two reads of it, not
25014
+ * one per link -- each read is the parent with every child.
25015
+ * Each request carries its `seq`: only its own answer settles
25016
+ * the entry.
25017
+ ************************************************************/
25018
+ function reread_linked_parent(gobj, treedb_name, topic_name, node_id) {
25019
+ let priv = gobj.priv;
25020
+ let key = `${topic_name}\u0000${node_id}`;
25021
+ let in_flight = priv.parent_rereads.get(key);
25022
+ if (in_flight) {
25023
+ in_flight.dirty = true;
25024
+ return 0;
25025
+ }
25026
+ let seq = ++priv.reread_seq;
25027
+ priv.parent_rereads.set(key, {
25028
+ dirty: false,
25029
+ seq
25030
+ });
25031
+ let ret = treedb_get_node$1(gobj, treedb_name, topic_name, node_id, seq);
25032
+ if (ret < 0) priv.parent_rereads.delete(key);
25033
+ return ret;
25034
+ }
25035
+ /************************************************************
25036
+ * A whole read of a topic brought every row as it is now: the
25037
+ * re-reads of its parents still out have nothing to add, and
25038
+ * their answers, when they come, are not taken. It is also
25039
+ * what bounds an entry whose answer never comes on a live
25040
+ * session (a request lost by the backend): the drop clears
25041
+ * every entry (ac_transport_state), the next read of the
25042
+ * topic (its refresh, its open, the reconnect) clears its own.
25043
+ ************************************************************/
25044
+ function forget_topic_rereads(gobj, topic_name) {
25045
+ let prefix = `${topic_name}\u0000`;
25046
+ for (const key of Array.from(gobj.priv.parent_rereads.keys())) if (key.startsWith(prefix)) gobj.priv.parent_rereads.delete(key);
25047
+ }
25048
+ /************************************************************
25049
+ * The answer of a parent's re-read. It is a refresh nobody
25050
+ * asked for, so a failure is a warning, never the app's error
25051
+ * modal: a force-delete of a loaded parent publishes UNLINKED
25052
+ * per child, and the re-read reaches the backend after the
25053
+ * delete ("Node not found") -- in every open viewer.
25054
+ *
25055
+ * Only the answer of the request in flight counts: one cut by
25056
+ * a drop, or superseded by a whole read of the topic, that
25057
+ * arrives after a new request went out must neither settle
25058
+ * the new one nor update the row with older data.
25059
+ *
25060
+ * Then, if links came while it was out, the parent is read
25061
+ * once more -- when its row is still loaded.
25062
+ ************************************************************/
25063
+ function answer_linked_parent_reread(gobj, result, comment, data, kw_command) {
25064
+ let priv = gobj.priv;
25065
+ let topic_name = kw_get_str(gobj, kw_command, "topic_name", "", 0);
25066
+ let node_id = kw_get_str(gobj, kw_command, "node_id", "", 0);
25067
+ let seq = kw_get_int(gobj, kw_command, "reread_seq", 0, 0);
25068
+ let key = `${topic_name}\u0000${node_id}`;
25069
+ let in_flight = priv.parent_rereads.get(key);
25070
+ if (!in_flight || in_flight.seq !== seq) {
25071
+ if (result < 0) log_warning(`${gobj_short_name(gobj)}: late failure of the re-read of the linked parent '${topic_name}^${node_id}' dropped, it was settled already (a drop, or a whole read of the topic): ${comment || ""}`);
25072
+ return 0;
25073
+ }
25074
+ priv.parent_rereads.delete(key);
25075
+ if (result < 0) log_warning(`${gobj_short_name(gobj)}: the re-read of the linked parent '${topic_name}^${node_id}' failed: ${comment || ""}`);
25076
+ else {
25077
+ let gobj_formtable = get_gobj_formtable(gobj, topic_name);
25078
+ if (gobj_formtable) gobj_send_event(gobj_formtable, "EV_LOAD_NODE_UPDATED", [data], gobj);
25079
+ }
25080
+ if (in_flight.dirty && is_connected$1(gobj) && is_row_loaded(gobj, topic_name, node_id)) reread_linked_parent(gobj, gobj_read_str_attr(gobj, "treedb_name"), topic_name, node_id);
25081
+ return 0;
25082
+ }
25083
+ /************************************************************
24990
25084
  * Command to remote service
24991
25085
  ************************************************************/
24992
25086
  function treedb_update_node$1(gobj, treedb_name, topic_name, record, options, form_write, created) {
@@ -25318,6 +25412,7 @@ function ac_mt_command_answer$2(gobj, event, kw, src) {
25318
25412
  }, gobj);
25319
25413
  return 0;
25320
25414
  }
25415
+ if (command === "node") return answer_linked_parent_reread(gobj, result, comment, data, kw_command);
25321
25416
  if (result < 0) {
25322
25417
  if (command === "descs") show_load_error$1(gobj, t(comment));
25323
25418
  else {
@@ -25351,18 +25446,20 @@ function ac_mt_command_answer$2(gobj, event, kw, src) {
25351
25446
  let answer = nodes_answer(data);
25352
25447
  let req_id = kw_get_str(gobj, kw_command, "req_id", "", 0);
25353
25448
  if (kw_get_str(gobj, kw_command, "purpose", "", 0) === "json") gobj_send_event(gobj_topic_form, "EV_JSON_LOADED", { rows: answer.rows }, gobj);
25354
- else if (req_id) gobj_send_event(gobj_topic_form, "EV_PAGE_LOADED", {
25355
- req_id,
25356
- rows: answer.rows,
25357
- pages: answer.pages,
25358
- total: answer.total
25359
- }, gobj);
25360
- else gobj_send_event(gobj_topic_form, "EV_LOAD_NODES", answer.rows, gobj);
25449
+ else if (req_id) {
25450
+ forget_topic_rereads(gobj, topic_name);
25451
+ gobj_send_event(gobj_topic_form, "EV_PAGE_LOADED", {
25452
+ req_id,
25453
+ rows: answer.rows,
25454
+ pages: answer.pages,
25455
+ total: answer.total
25456
+ }, gobj);
25457
+ } else {
25458
+ forget_topic_rereads(gobj, topic_name);
25459
+ gobj_send_event(gobj_topic_form, "EV_LOAD_NODES", answer.rows, gobj);
25460
+ }
25361
25461
  }
25362
25462
  break;
25363
- case "node":
25364
- gobj_send_event(get_gobj_formtable(gobj, kw_get_str(gobj, kw_command, "topic_name", "", 0)), "EV_LOAD_NODE_UPDATED", [data], gobj);
25365
- break;
25366
25463
  case "create-node":
25367
25464
  case "update-node":
25368
25465
  case "delete-node":
@@ -25536,6 +25633,7 @@ function ac_transport_state$2(gobj, event, kw, src) {
25536
25633
  refresh_toolbar_buttons(gobj, connected);
25537
25634
  if (!connected) {
25538
25635
  gobj.priv.reread_on_session = true;
25636
+ gobj.priv.parent_rereads.clear();
25539
25637
  answer_drills_in_flight$1(gobj);
25540
25638
  abandon_form_writes(gobj.priv.form_writes).forEach((w) => {
25541
25639
  log_warning(`${gobj_short_name(gobj)}: transport closed, the write ${w.form_write} of '${w.topic_name}' is lost`);
@@ -25612,7 +25710,9 @@ function ac_treedb_node_updated$1(gobj, event, kw, src) {
25612
25710
  * EV_TREEDB_NODE_LINKED / EV_TREEDB_NODE_UNLINKED: the relationship
25613
25711
  * ({hook_name, parent_topic_name, child_topic_name, parent_id,
25614
25712
  * child_id, treedb_name}), not a node. The parent's hook changed and
25615
- * the event does not carry it: read the parent again.
25713
+ * the event does not carry it: read the parent again -- only when its
25714
+ * row is loaded (a table not open, or on another page, has nothing to
25715
+ * refresh), and one read in flight per parent (reread_linked_parent).
25616
25716
  ********************************************/
25617
25717
  function ac_treedb_node_linked$1(gobj, event, kw, src) {
25618
25718
  let treedb_name = kw_get_str(gobj, kw, "treedb_name", "", 0);
@@ -25623,7 +25723,8 @@ function ac_treedb_node_linked$1(gobj, event, kw, src) {
25623
25723
  log_error(`${gobj_short_name(gobj)}: ${event} without parent_topic_name/parent_id`);
25624
25724
  return -1;
25625
25725
  }
25626
- return treedb_get_node$1(gobj, treedb_name, parent_topic_name, parent_id);
25726
+ if (!is_row_loaded(gobj, parent_topic_name, parent_id)) return 0;
25727
+ return reread_linked_parent(gobj, treedb_name, parent_topic_name, parent_id);
25627
25728
  }
25628
25729
  /********************************************
25629
25730
  * Remote subscription response
@@ -68806,7 +68907,7 @@ function get_nodes(gobj, topic_name) {
68806
68907
  * filtered by treedb_name alone (a {topic_name} filter would match nothing).
68807
68908
  *
68808
68909
  * NOTE: the backend only publishes them when its C_NODE service runs
68809
- * with `with_link_events` (the default since SDK 7.25.23; a v1 backend
68910
+ * with `with_link_events` (the default since SDK 7.26.0; a v1 backend
68810
68911
  * sets it off). Without it, a link/unlink is announced the
68811
68912
  * backward-compatible way — an
68812
68913
  * EV_TREEDB_NODE_UPDATED of the PARENT — which cannot move an edge here:
@@ -78973,6 +79074,15 @@ function ensure_dev_style() {
78973
79074
  background: rgba(0,0,0,0.03);
78974
79075
  }
78975
79076
  .YDEV_GROUP { display: inline-flex; align-items: center; gap: 5px; }
79077
+ /* A whole line of the bar, whose chips scroll sideways inside it: the
79078
+ window never does. min-width 0 so the flex line can be narrower than
79079
+ its content; the chips keep their size and their label on one line. */
79080
+ .YDEV_GROUP_SCROLL { flex: 1 1 100%; min-width: 0; }
79081
+ .YDEV_SCROLL {
79082
+ display: flex; align-items: center; gap: 5px; min-width: 0; flex: 1 1 auto;
79083
+ overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; padding-bottom: 2px;
79084
+ }
79085
+ .YDEV_SCROLL > * { flex: 0 0 auto; white-space: nowrap; }
78976
79086
  .YDEV_LABEL {
78977
79087
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em;
78978
79088
  opacity: 0.6; align-self: center;
@@ -79810,6 +79920,29 @@ function refresh_dev_chrome() {
79810
79920
  });
79811
79921
  update_stats();
79812
79922
  }
79923
+ function kw_shown_lines($kw, indent, out) {
79924
+ if (!$kw) return out;
79925
+ for (let $n of $kw.children) if ($n.classList.contains("TRAFFIC_ROW")) {
79926
+ let $key = $n.querySelector(".TRAFFIC_KEY");
79927
+ let key = $key ? $key.textContent : "";
79928
+ let vals = [];
79929
+ for (let $c of $n.children) {
79930
+ if ($c.classList.contains("TRAFFIC_BULLET") || $c === $key) continue;
79931
+ vals.push($c.children.length ? Array.from($c.children).map(($x) => $x.textContent).join(" ") : $c.textContent);
79932
+ }
79933
+ out.push(`${indent}• ${key} ${vals.join(" ")}`.trimEnd());
79934
+ } else if ($n.tagName === "DETAILS") {
79935
+ let $sum = $n.querySelector(":scope > summary");
79936
+ let $key = $sum ? $sum.querySelector(".TRAFFIC_NEST_KEY") : null;
79937
+ let $hint = $sum ? $sum.querySelector(".TRAFFIC_NEST_HINT_WRAP") : null;
79938
+ out.push(`${indent}${$n.open ? "▾" : "▸"} ` + `${$key ? $key.textContent : ""} ${$hint ? $hint.textContent : ""}`.trimEnd());
79939
+ if ($n.open) kw_shown_lines($n.querySelector(":scope > .TRAFFIC_KW"), indent + " ", out);
79940
+ }
79941
+ return out;
79942
+ }
79943
+ function entry_shown_lines($entry) {
79944
+ return kw_shown_lines($entry ? $entry.querySelector(":scope > .TRAFFIC_KW") : null, " ", []);
79945
+ }
79813
79946
  function traffic_to_text() {
79814
79947
  let ctx = build_filter_ctx();
79815
79948
  let out = [];
@@ -79822,6 +79955,11 @@ function traffic_to_text() {
79822
79955
  }
79823
79956
  let head = `${e.ts} ${dir_arrow(e.dir)} ${e.title ? "[" + e.title + "] " : ""}${e.event}${e.command ? " " + e.command : ""}`;
79824
79957
  out.push(head);
79958
+ if (dev_traffic_view() !== "expanded" && e.$node) {
79959
+ out.push(...entry_shown_lines(e.$node));
79960
+ out.push("");
79961
+ continue;
79962
+ }
79825
79963
  let payload = e.kw ? e.kw : e.jn;
79826
79964
  try {
79827
79965
  out.push(JSON.stringify(payload, null, 4));
@@ -80120,6 +80258,22 @@ function build_control_bar() {
80120
80258
  t(label)
80121
80259
  ], ...items]
80122
80260
  ];
80261
+ let grp_scroll = (label, items) => [
80262
+ "div",
80263
+ { class: "YDEV_GROUP YDEV_GROUP_SCROLL" },
80264
+ [[
80265
+ "span",
80266
+ {
80267
+ class: "YDEV_LABEL",
80268
+ "data-i18n": label
80269
+ },
80270
+ t(label)
80271
+ ], [
80272
+ "div",
80273
+ { class: "YDEV_SCROLL" },
80274
+ items
80275
+ ]]
80276
+ ];
80123
80277
  let sep = () => [
80124
80278
  "span",
80125
80279
  { class: "YDEV_SEP" },
@@ -80129,12 +80283,11 @@ function build_control_bar() {
80129
80283
  "div",
80130
80284
  { class: "YDEV_BAR" },
80131
80285
  [
80132
- grp("traces", [
80286
+ grp_scroll("traces", [
80133
80287
  ...trace_chips,
80134
80288
  simple_mach,
80135
80289
  traces_payload
80136
80290
  ]),
80137
- sep(),
80138
80291
  grp("output", [output_seg]),
80139
80292
  sep(),
80140
80293
  grp("view", [view_seg]),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.25.26",
3
+ "version": "7.26.1",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -31,7 +31,7 @@
31
31
  "@rollup/plugin-terser": "^1.0.0",
32
32
  "@vitest/coverage-v8": "^4.1.10",
33
33
  "@yuneta/gobj-js": "^7.25.8",
34
- "vite": "^8.3.1",
34
+ "vite": "^8.3.3",
35
35
  "vitest": "^4.1.10"
36
36
  },
37
37
  "peerDependencies": {
@@ -1890,7 +1890,7 @@ function get_nodes(gobj, topic_name)
1890
1890
  * filtered by treedb_name alone (a {topic_name} filter would match nothing).
1891
1891
  *
1892
1892
  * NOTE: the backend only publishes them when its C_NODE service runs
1893
- * with `with_link_events` (the default since SDK 7.25.23; a v1 backend
1893
+ * with `with_link_events` (the default since SDK 7.26.0; a v1 backend
1894
1894
  * sets it off). Without it, a link/unlink is announced the
1895
1895
  * backward-compatible way — an
1896
1896
  * EV_TREEDB_NODE_UPDATED of the PARENT — which cannot move an edge here:
@@ -170,6 +170,12 @@ function mt_create(gobj)
170
170
  /* The drills of the raw-json viewer sent and not yet answered:
171
171
  * answered on the disconnect edge (answer_drills_in_flight). */
172
172
  gobj.priv.drills_in_flight = new Set();
173
+ /* The parents re-read because a link moved their hook, by
174
+ * "<topic>\u0000<id>", each with `dirty` when another link came
175
+ * while its read was out, and the `seq` of its request: an
176
+ * answer of another request is not its (reread_linked_parent). */
177
+ gobj.priv.parent_rereads = new Map();
178
+ gobj.priv.reread_seq = 0;
173
179
 
174
180
  build_ui(gobj);
175
181
 
@@ -1495,7 +1501,7 @@ function subscribe_treedb(gobj, topic_name)
1495
1501
 
1496
1502
  /*
1497
1503
  * A link/unlink changes the hook of the PARENT, and a backend with
1498
- * `with_link_events` (the default since SDK 7.25.23) tells it as the
1504
+ * `with_link_events` (the default since SDK 7.26.0) tells it as the
1499
1505
  * relationship, with no `topic_name`: the parent's topic is
1500
1506
  * `parent_topic_name`. The child's row moves on its own UPDATED.
1501
1507
  */
@@ -1683,7 +1689,7 @@ function answered_record(data)
1683
1689
  * Command to remote service: one node, in the shape the table
1684
1690
  * reads its topic with (TABLE_READ_OPTIONS)
1685
1691
  ************************************************************/
1686
- function treedb_get_node(gobj, treedb_name, topic_name, node_id)
1692
+ function treedb_get_node(gobj, treedb_name, topic_name, node_id, reread_seq)
1687
1693
  {
1688
1694
  let gobj_remote_yuno = gobj_read_pointer_attr(gobj, "gobj_remote_yuno");
1689
1695
  let kw = {
@@ -1696,6 +1702,8 @@ function treedb_get_node(gobj, treedb_name, topic_name, node_id)
1696
1702
 
1697
1703
  kw.__md_command__ = { // Data to be returned
1698
1704
  topic_name: topic_name,
1705
+ node_id: node_id,
1706
+ reread_seq: reread_seq
1699
1707
  };
1700
1708
 
1701
1709
  let ret = gobj_command(
@@ -1711,6 +1719,129 @@ function treedb_get_node(gobj, treedb_name, topic_name, node_id)
1711
1719
  return 0;
1712
1720
  }
1713
1721
 
1722
+ /************************************************************
1723
+ * Is the row of `node_id` loaded in the table of its topic?
1724
+ * A table not open, or open on other rows (a page that does
1725
+ * not hold it), shows nothing of the node: there is nothing to
1726
+ * refresh, its rows are read when they are shown.
1727
+ ************************************************************/
1728
+ function is_row_loaded(gobj, topic_name, node_id)
1729
+ {
1730
+ let gobj_formtable = get_gobj_formtable(gobj, topic_name);
1731
+ if(!gobj_formtable) {
1732
+ return false;
1733
+ }
1734
+ let tabulator = gobj_read_attr(gobj_formtable, "tabulator");
1735
+ if(!tabulator) {
1736
+ return false;
1737
+ }
1738
+ return !!tabulator.getRow(node_id);
1739
+ }
1740
+
1741
+ /************************************************************
1742
+ * Read again a parent whose hook a link or an unlink moved
1743
+ * (ac_treedb_node_linked), ONE read in flight per parent: a
1744
+ * link that comes while it is out only marks it dirty, and
1745
+ * its answer asks once more (answer_linked_parent_reread).
1746
+ * A burst of links to one parent costs two reads of it, not
1747
+ * one per link -- each read is the parent with every child.
1748
+ * Each request carries its `seq`: only its own answer settles
1749
+ * the entry.
1750
+ ************************************************************/
1751
+ function reread_linked_parent(gobj, treedb_name, topic_name, node_id)
1752
+ {
1753
+ let priv = gobj.priv;
1754
+ let key = `${topic_name}\u0000${node_id}`;
1755
+ let in_flight = priv.parent_rereads.get(key);
1756
+ if(in_flight) {
1757
+ in_flight.dirty = true;
1758
+ return 0;
1759
+ }
1760
+ let seq = ++priv.reread_seq;
1761
+ priv.parent_rereads.set(key, {dirty: false, seq: seq});
1762
+ let ret = treedb_get_node(gobj, treedb_name, topic_name, node_id, seq);
1763
+ if(ret < 0) {
1764
+ priv.parent_rereads.delete(key); // Error already logged
1765
+ }
1766
+ return ret;
1767
+ }
1768
+
1769
+ /************************************************************
1770
+ * A whole read of a topic brought every row as it is now: the
1771
+ * re-reads of its parents still out have nothing to add, and
1772
+ * their answers, when they come, are not taken. It is also
1773
+ * what bounds an entry whose answer never comes on a live
1774
+ * session (a request lost by the backend): the drop clears
1775
+ * every entry (ac_transport_state), the next read of the
1776
+ * topic (its refresh, its open, the reconnect) clears its own.
1777
+ ************************************************************/
1778
+ function forget_topic_rereads(gobj, topic_name)
1779
+ {
1780
+ let prefix = `${topic_name}\u0000`;
1781
+ for(const key of Array.from(gobj.priv.parent_rereads.keys())) {
1782
+ if(key.startsWith(prefix)) {
1783
+ gobj.priv.parent_rereads.delete(key);
1784
+ }
1785
+ }
1786
+ }
1787
+
1788
+ /************************************************************
1789
+ * The answer of a parent's re-read. It is a refresh nobody
1790
+ * asked for, so a failure is a warning, never the app's error
1791
+ * modal: a force-delete of a loaded parent publishes UNLINKED
1792
+ * per child, and the re-read reaches the backend after the
1793
+ * delete ("Node not found") -- in every open viewer.
1794
+ *
1795
+ * Only the answer of the request in flight counts: one cut by
1796
+ * a drop, or superseded by a whole read of the topic, that
1797
+ * arrives after a new request went out must neither settle
1798
+ * the new one nor update the row with older data.
1799
+ *
1800
+ * Then, if links came while it was out, the parent is read
1801
+ * once more -- when its row is still loaded.
1802
+ ************************************************************/
1803
+ function answer_linked_parent_reread(gobj, result, comment, data, kw_command)
1804
+ {
1805
+ let priv = gobj.priv;
1806
+ let topic_name = kw_get_str(gobj, kw_command, "topic_name", "", 0);
1807
+ let node_id = kw_get_str(gobj, kw_command, "node_id", "", 0);
1808
+ let seq = kw_get_int(gobj, kw_command, "reread_seq", 0, 0);
1809
+ let key = `${topic_name}\u0000${node_id}`;
1810
+ let in_flight = priv.parent_rereads.get(key);
1811
+ if(!in_flight || in_flight.seq !== seq) {
1812
+ if(result < 0) {
1813
+ log_warning(`${gobj_short_name(gobj)}: late failure of the re-read of ` +
1814
+ `the linked parent '${topic_name}^${node_id}' dropped, it was ` +
1815
+ `settled already (a drop, or a whole read of the topic): ${comment || ""}`);
1816
+ }
1817
+ return 0;
1818
+ }
1819
+ priv.parent_rereads.delete(key);
1820
+
1821
+ if(result < 0) {
1822
+ log_warning(`${gobj_short_name(gobj)}: the re-read of the linked parent ` +
1823
+ `'${topic_name}^${node_id}' failed: ${comment || ""}`);
1824
+ } else {
1825
+ /* A table closed while the read was out has no row to update. */
1826
+ let gobj_formtable = get_gobj_formtable(gobj, topic_name);
1827
+ if(gobj_formtable) {
1828
+ gobj_send_event(
1829
+ gobj_formtable,
1830
+ "EV_LOAD_NODE_UPDATED",
1831
+ [data],
1832
+ gobj
1833
+ );
1834
+ }
1835
+ }
1836
+
1837
+ if(in_flight.dirty && is_connected(gobj) && is_row_loaded(gobj, topic_name, node_id)) {
1838
+ reread_linked_parent(
1839
+ gobj, gobj_read_str_attr(gobj, "treedb_name"), topic_name, node_id
1840
+ ); // Error already logged
1841
+ }
1842
+ return 0;
1843
+ }
1844
+
1714
1845
  /************************************************************
1715
1846
  * Command to remote service
1716
1847
  ************************************************************/
@@ -2252,6 +2383,15 @@ function ac_mt_command_answer(gobj, event, kw, src)
2252
2383
  return 0;
2253
2384
  }
2254
2385
 
2386
+ /*
2387
+ * A parent re-read because a link or an unlink moved its hook
2388
+ * (ac_treedb_node_linked). Before the generic error path: its
2389
+ * failure is a warning, never the app-wide modal.
2390
+ */
2391
+ if(command === "node") {
2392
+ return answer_linked_parent_reread(gobj, result, comment, data, kw_command);
2393
+ }
2394
+
2255
2395
  if(result < 0) {
2256
2396
  if(command === "descs") {
2257
2397
  /* The schema couldn't load (not a treedb, no authz for it, backend
@@ -2346,6 +2486,7 @@ function ac_mt_command_answer(gobj, event, kw, src)
2346
2486
  gobj
2347
2487
  );
2348
2488
  } else if(req_id) {
2489
+ forget_topic_rereads(gobj, topic_name); // the rows a table shows, read now
2349
2490
  gobj_send_event(
2350
2491
  gobj_topic_form,
2351
2492
  "EV_PAGE_LOADED",
@@ -2358,6 +2499,7 @@ function ac_mt_command_answer(gobj, event, kw, src)
2358
2499
  gobj
2359
2500
  );
2360
2501
  } else {
2502
+ forget_topic_rereads(gobj, topic_name);
2361
2503
  gobj_send_event(
2362
2504
  gobj_topic_form,
2363
2505
  "EV_LOAD_NODES",
@@ -2368,19 +2510,6 @@ function ac_mt_command_answer(gobj, event, kw, src)
2368
2510
  }
2369
2511
  break;
2370
2512
 
2371
- case "node":
2372
- /*
2373
- * A parent re-read because a link or an unlink moved its hook
2374
- * (ac_treedb_node_linked): an update of its row.
2375
- */
2376
- gobj_send_event(
2377
- get_gobj_formtable(gobj, kw_get_str(gobj, kw_command, "topic_name", "", 0)),
2378
- "EV_LOAD_NODE_UPDATED",
2379
- [data],
2380
- gobj
2381
- );
2382
- break;
2383
-
2384
2513
  case "create-node":
2385
2514
  case "update-node":
2386
2515
  case "delete-node":
@@ -2679,6 +2808,7 @@ function ac_transport_state(gobj, event, kw, src)
2679
2808
  * no table: its node events are published to nobody. Every open
2680
2809
  * table is read again when the session is back. */
2681
2810
  gobj.priv.reread_on_session = true;
2811
+ gobj.priv.parent_rereads.clear(); /* the reconnect reads every open table */
2682
2812
  answer_drills_in_flight(gobj);
2683
2813
  abandon_form_writes(gobj.priv.form_writes).forEach((w) => {
2684
2814
  log_warning(`${gobj_short_name(gobj)}: transport closed, the write ${w.form_write} of '${w.topic_name}' is lost`);
@@ -2802,7 +2932,9 @@ function ac_treedb_node_updated(gobj, event, kw, src)
2802
2932
  * EV_TREEDB_NODE_LINKED / EV_TREEDB_NODE_UNLINKED: the relationship
2803
2933
  * ({hook_name, parent_topic_name, child_topic_name, parent_id,
2804
2934
  * child_id, treedb_name}), not a node. The parent's hook changed and
2805
- * the event does not carry it: read the parent again.
2935
+ * the event does not carry it: read the parent again -- only when its
2936
+ * row is loaded (a table not open, or on another page, has nothing to
2937
+ * refresh), and one read in flight per parent (reread_linked_parent).
2806
2938
  ********************************************/
2807
2939
  function ac_treedb_node_linked(gobj, event, kw, src)
2808
2940
  {
@@ -2818,7 +2950,11 @@ function ac_treedb_node_linked(gobj, event, kw, src)
2818
2950
  return -1;
2819
2951
  }
2820
2952
 
2821
- return treedb_get_node(gobj, treedb_name, parent_topic_name, parent_id); // Error already logged
2953
+ if(!is_row_loaded(gobj, parent_topic_name, parent_id)) {
2954
+ return 0;
2955
+ }
2956
+
2957
+ return reread_linked_parent(gobj, treedb_name, parent_topic_name, parent_id); // Error already logged
2822
2958
  }
2823
2959
 
2824
2960
  /********************************************
@@ -11,11 +11,24 @@
11
11
  * Copyright (c) 2026, ArtGins.
12
12
  * All Rights Reserved.
13
13
  ***********************************************************************/
14
- import {describe, test, expect, beforeAll, beforeEach} from "vitest";
14
+ import {describe, test, expect, beforeAll, beforeEach, vi} from "vitest";
15
15
  import {install_dom_double} from "../test/dom_double.js";
16
16
 
17
17
  install_dom_double();
18
18
 
19
+ /* The app-wide error modal: what it is asked to show is asserted. */
20
+ const shown = vi.hoisted(() => []);
21
+ vi.mock("./shell_modals.js", async (importOriginal) => {
22
+ const original = await importOriginal();
23
+ return {
24
+ ...original,
25
+ yui_shell_show_error: (shell, message) => {
26
+ shown.push(message);
27
+ return {close() {}};
28
+ },
29
+ };
30
+ });
31
+
19
32
  const gobj_js = await import("@yuneta/gobj-js");
20
33
  const {
21
34
  SDATA, SDATA_END, data_type_t, event_flag_t,
@@ -104,6 +117,7 @@ beforeAll(() => {
104
117
  [
105
118
  SDATA(data_type_t.DTP_STRING, "topic_name", 0, "", "topic"),
106
119
  SDATA(data_type_t.DTP_BOOLEAN, "with_remote_paging", 0, false, "pulls its pages"),
120
+ SDATA(data_type_t.DTP_POINTER, "tabulator", 0, null, "the table: only getRow() is read"),
107
121
  SDATA_END()
108
122
  ],
109
123
  {}, 0, 0, 0, 0
@@ -139,6 +153,7 @@ beforeEach(() => {
139
153
  commands.length = 0;
140
154
  loaded.length = 0;
141
155
  updated.length = 0;
156
+ shown.length = 0;
142
157
  });
143
158
 
144
159
  function build(name)
@@ -162,9 +177,13 @@ function build(name)
162
177
  for(const topic of ["users", "roles"]) {
163
178
  /* Named as the view names its forms: the answer of a `nodes`
164
179
  * finds its table by that name. */
180
+ /* The ids of the rows the table holds: what a link reads
181
+ * again is a parent whose row is loaded. */
182
+ const rows = new Set();
165
183
  forms[topic] = gobj_create(`${name}_topics?${topic}`, "C_YUI_TREEDB_TOPIC_WITH_FORM",
166
- {topic_name: topic}, topics);
184
+ {topic_name: topic, tabulator: {getRow: (id) => (rows.has(id)? {id}: false)}}, topics);
167
185
  forms[topic].priv_topic = topic;
186
+ forms[topic].rows = rows;
168
187
  }
169
188
  /* What the start of a shell with no routes says is the fixture's,
170
189
  * not the behaviour under test: the check starts here. */
@@ -523,7 +542,7 @@ describe("what the drop hid is read again on the reconnect", () => {
523
542
  });
524
543
 
525
544
  /*
526
- * SDK 7.25.23 turns `with_link_events` on by default: a link or an unlink
545
+ * SDK 7.26.0 turns `with_link_events` on by default: a link or an unlink
527
546
  * no longer arrives as the parent's EV_TREEDB_NODE_UPDATED, but as the
528
547
  * relationship, which carries no node. The parent's row (its hook column)
529
548
  * must still move: the view reads the parent again.
@@ -532,8 +551,9 @@ describe("a link told as EV_TREEDB_NODE_LINKED / UNLINKED", () => {
532
551
 
533
552
  for(const event of ["EV_TREEDB_NODE_LINKED", "EV_TREEDB_NODE_UNLINKED"]) {
534
553
  test(`${event} re-reads the parent and updates its row`, () => {
535
- const {shell, topics} = build(`tl_${event}`);
554
+ const {shell, topics, forms} = build(`tl_${event}`);
536
555
  yui_shell_set_connection_state(shell, true);
556
+ forms.roles.rows.add("admin");
537
557
 
538
558
  gobj_send_event(topics, event, {
539
559
  treedb_name: "treedb_test",
@@ -572,4 +592,210 @@ describe("a link told as EV_TREEDB_NODE_LINKED / UNLINKED", () => {
572
592
  expect(commands.filter((c) => c.command === "node")).toEqual([]);
573
593
  expect(errors()).toEqual([]);
574
594
  });
595
+
596
+ /*
597
+ * Each read of a parent is the parent with every child. A burst of
598
+ * links to one parent (a bulk link, an import) must not cost one read
599
+ * per link per open view: one read in flight per parent, and one more
600
+ * when links came while it was out.
601
+ */
602
+ function link(topics, parent_id, child_id)
603
+ {
604
+ gobj_send_event(topics, "EV_TREEDB_NODE_LINKED", {
605
+ treedb_name: "treedb_test",
606
+ hook_name: "users",
607
+ parent_topic_name: "roles",
608
+ parent_id: parent_id,
609
+ child_topic_name: "users",
610
+ child_id: child_id
611
+ }, remote);
612
+ }
613
+
614
+ function node_reads()
615
+ {
616
+ return commands.filter((c) => c.command === "node");
617
+ }
618
+
619
+ test("a burst of links to one loaded parent: at most two reads", () => {
620
+ const {shell, topics, forms} = build("tl_burst");
621
+ yui_shell_set_connection_state(shell, true);
622
+ forms.roles.rows.add("admin");
623
+
624
+ for(let i = 0; i < 50; i++) {
625
+ link(topics, "admin", `user${i}`);
626
+ }
627
+ expect(node_reads().length).toBe(1);
628
+
629
+ /* The first answer: links came while it was out, one more read. */
630
+ gobj_send_event(topics, "EV_MT_COMMAND_ANSWER",
631
+ answer_ok(node_reads()[0], {id: "admin"}), remote);
632
+ expect(node_reads().length).toBe(2);
633
+
634
+ /* The second: nothing came meanwhile, the burst is over. */
635
+ gobj_send_event(topics, "EV_MT_COMMAND_ANSWER",
636
+ answer_ok(node_reads()[1], {id: "admin"}), remote);
637
+ expect(node_reads().length).toBe(2);
638
+ expect(updated.length).toBe(2);
639
+
640
+ /* A link after the burst reads again. */
641
+ link(topics, "admin", "late");
642
+ expect(node_reads().length).toBe(3);
643
+ expect(errors()).toEqual([]);
644
+ });
645
+
646
+ test("a link to a parent not loaded reads nothing", () => {
647
+ const {shell, topics, forms} = build("tl_unloaded");
648
+ yui_shell_set_connection_state(shell, true);
649
+ forms.roles.rows.add("other");
650
+
651
+ link(topics, "admin", "alice");
652
+ expect(node_reads()).toEqual([]);
653
+ expect(errors()).toEqual([]);
654
+ });
655
+
656
+ test("a link to a parent of a topic with no table reads nothing", () => {
657
+ const {shell, topics} = build("tl_notable");
658
+ yui_shell_set_connection_state(shell, true);
659
+ gobj_send_event(topics, "EV_TREEDB_NODE_LINKED", {
660
+ treedb_name: "treedb_test",
661
+ hook_name: "items",
662
+ parent_topic_name: "groups",
663
+ parent_id: "g1",
664
+ child_topic_name: "items",
665
+ child_id: "i1"
666
+ }, remote);
667
+ expect(node_reads()).toEqual([]);
668
+ expect(errors()).toEqual([]);
669
+ });
670
+
671
+ test("a drop abandons the read in flight: the next link reads again", () => {
672
+ const {shell, topics, forms} = build("tl_drop");
673
+ yui_shell_set_connection_state(shell, true);
674
+ forms.roles.rows.add("admin");
675
+ link(topics, "admin", "alice");
676
+ link(topics, "admin", "bob");
677
+ expect(node_reads().length).toBe(1);
678
+
679
+ gobj_change_state(remote, "ST_DISCONNECTED");
680
+ gobj_send_event(topics, "EV_TRANSPORT_STATE", {connected: false}, topics);
681
+ /* The adapter settles the read it had in flight: no second read
682
+ * out of session, no modal. */
683
+ gobj_send_event(topics, "EV_MT_COMMAND_ANSWER", {
684
+ result: -1, comment: "the session closed", data: null, __md_iev__: {
685
+ command_stack: [{command: "node", kw: node_reads()[0].kw.__md_command__}]
686
+ }
687
+ }, remote);
688
+ expect(node_reads().length).toBe(1);
689
+
690
+ gobj_change_state(remote, "ST_SESSION");
691
+ gobj_send_event(topics, "EV_TRANSPORT_STATE", {connected: true}, topics);
692
+ link(topics, "admin", "carol");
693
+ expect(node_reads().length).toBe(2);
694
+ expect(errors()).toEqual([]);
695
+ expect(shown).toEqual([]);
696
+ });
697
+
698
+ function failed_read(request, comment)
699
+ {
700
+ return {result: -1, comment: comment, data: null, __md_iev__: {
701
+ command_stack: [{command: "node", kw: request.kw.__md_command__}]
702
+ }};
703
+ }
704
+
705
+ function warnings()
706
+ {
707
+ return logged.filter((l) => l.level === "warning").map((l) => l.msg);
708
+ }
709
+
710
+ /*
711
+ * A force-delete of a loaded parent publishes UNLINKED per child, and
712
+ * the re-read reaches the backend after the delete: "Node not found".
713
+ * A refresh nobody asked for: a warning, never the app-wide modal.
714
+ */
715
+ test("a re-read that fails while connected: a warning, no modal, settled", () => {
716
+ const {shell, topics, forms} = build("tl_fail");
717
+ yui_shell_set_connection_state(shell, true);
718
+ forms.roles.rows.add("admin");
719
+ link(topics, "admin", "alice");
720
+ link(topics, "admin", "bob"); /* dirty */
721
+ expect(node_reads().length).toBe(1);
722
+
723
+ /* The row is gone meanwhile: the dirty entry asks nothing more. */
724
+ forms.roles.rows.delete("admin");
725
+ gobj_send_event(topics, "EV_MT_COMMAND_ANSWER",
726
+ failed_read(node_reads()[0], "Node not found"), remote);
727
+ expect(shown).toEqual([]);
728
+ expect(errors()).toEqual([]);
729
+ expect(warnings().some((m) => m.includes("re-read of the linked parent") &&
730
+ m.includes("Node not found"))).toBe(true);
731
+ expect(node_reads().length).toBe(1);
732
+ expect(updated).toEqual([]);
733
+
734
+ /* Settled: the next link of a loaded parent reads again. */
735
+ forms.roles.rows.add("admin");
736
+ link(topics, "admin", "carol");
737
+ expect(node_reads().length).toBe(2);
738
+ });
739
+
740
+ /*
741
+ * A read cut by a drop answers -1 LATE, after the reconnect and after
742
+ * a new read of the same parent went out: it is not the new read's
743
+ * answer, and settles nothing of it.
744
+ */
745
+ test("a late failure of a read cut by a drop does not settle the new read", () => {
746
+ const {shell, topics, forms} = build("tl_late");
747
+ yui_shell_set_connection_state(shell, true);
748
+ forms.roles.rows.add("admin");
749
+ link(topics, "admin", "alice");
750
+ const first = node_reads()[0];
751
+
752
+ gobj_change_state(remote, "ST_DISCONNECTED");
753
+ gobj_send_event(topics, "EV_TRANSPORT_STATE", {connected: false}, topics);
754
+ gobj_change_state(remote, "ST_SESSION");
755
+ gobj_send_event(topics, "EV_TRANSPORT_STATE", {connected: true}, topics);
756
+
757
+ link(topics, "admin", "bob");
758
+ expect(node_reads().length).toBe(2);
759
+ const second = node_reads()[1];
760
+
761
+ gobj_send_event(topics, "EV_MT_COMMAND_ANSWER",
762
+ failed_read(first, "the session closed"), remote);
763
+ expect(shown).toEqual([]);
764
+ expect(errors()).toEqual([]);
765
+
766
+ /* The second read is still the one in flight: a link only marks it. */
767
+ link(topics, "admin", "carol");
768
+ expect(node_reads().length).toBe(2);
769
+
770
+ gobj_send_event(topics, "EV_MT_COMMAND_ANSWER",
771
+ answer_ok(second, {id: "admin"}), remote);
772
+ expect(updated).toEqual([{topic: "roles", rows: [{id: "admin"}]}]);
773
+ expect(node_reads().length).toBe(3); /* dirty: one more */
774
+ });
775
+
776
+ /*
777
+ * A whole read of the topic brings every row as it is now: a re-read
778
+ * still out is moot, its late answer is not taken (older data), and
779
+ * the parent is free to be read on the next link -- which is also
780
+ * what releases an entry whose answer never comes.
781
+ */
782
+ test("a whole read of the topic settles its re-reads still out", () => {
783
+ const {shell, topics, forms} = build("tl_whole");
784
+ yui_shell_set_connection_state(shell, true);
785
+ forms.roles.rows.add("admin");
786
+ link(topics, "admin", "alice");
787
+ const lost = node_reads()[0];
788
+
789
+ gobj_send_event(topics, "EV_MT_COMMAND_ANSWER",
790
+ nodes_answer_of("roles", [{id: "admin"}]), remote);
791
+
792
+ link(topics, "admin", "bob");
793
+ expect(node_reads().length).toBe(2);
794
+
795
+ gobj_send_event(topics, "EV_MT_COMMAND_ANSWER",
796
+ answer_ok(lost, {id: "admin", stale: true}), remote);
797
+ expect(updated).toEqual([]);
798
+ expect(errors()).toEqual([]);
799
+ expect(shown).toEqual([]);
800
+ });
575
801
  });
package/src/yui_dev.js CHANGED
@@ -419,6 +419,15 @@ function ensure_dev_style()
419
419
  background: rgba(0,0,0,0.03);
420
420
  }
421
421
  .YDEV_GROUP { display: inline-flex; align-items: center; gap: 5px; }
422
+ /* A whole line of the bar, whose chips scroll sideways inside it: the
423
+ window never does. min-width 0 so the flex line can be narrower than
424
+ its content; the chips keep their size and their label on one line. */
425
+ .YDEV_GROUP_SCROLL { flex: 1 1 100%; min-width: 0; }
426
+ .YDEV_SCROLL {
427
+ display: flex; align-items: center; gap: 5px; min-width: 0; flex: 1 1 auto;
428
+ overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; padding-bottom: 2px;
429
+ }
430
+ .YDEV_SCROLL > * { flex: 0 0 auto; white-space: nowrap; }
422
431
  .YDEV_LABEL {
423
432
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em;
424
433
  opacity: 0.6; align-self: center;
@@ -1411,10 +1420,62 @@ function refresh_dev_chrome()
1411
1420
  update_stats();
1412
1421
  }
1413
1422
 
1423
+ /* The payload of a FOLDED entry as text, the way it is on screen: one line
1424
+ * per row, a closed branch as its one-line summary (`data {places: […], …}`)
1425
+ * and only an OPENED branch with its content, four characters further in.
1426
+ *
1427
+ * Read from the painted DOM and not from the payload, because whether a
1428
+ * branch is open lives only there. It is the copy a person wants to paste
1429
+ * somewhere: the folded view exists because a list-map answer is 1.4 MB,
1430
+ * and the copy used to be that 1.4 MB laid out whatever the screen said.
1431
+ * The browser console copies what it shows, and so does this now. */
1432
+ function kw_shown_lines($kw, indent, out)
1433
+ {
1434
+ if(!$kw) {
1435
+ return out;
1436
+ }
1437
+ for(let $n of $kw.children) {
1438
+ if($n.classList.contains('TRAFFIC_ROW')) {
1439
+ let $key = $n.querySelector('.TRAFFIC_KEY');
1440
+ let key = $key ? $key.textContent : '';
1441
+ let vals = [];
1442
+ for(let $c of $n.children) {
1443
+ if($c.classList.contains('TRAFFIC_BULLET') || $c === $key) {
1444
+ continue;
1445
+ }
1446
+ vals.push($c.children.length ?
1447
+ Array.from($c.children).map(($x) => $x.textContent).join(' ') :
1448
+ $c.textContent);
1449
+ }
1450
+ out.push(`${indent}• ${key} ${vals.join(' ')}`.trimEnd());
1451
+ } else if($n.tagName === 'DETAILS') {
1452
+ let $sum = $n.querySelector(':scope > summary');
1453
+ let $key = $sum ? $sum.querySelector('.TRAFFIC_NEST_KEY') : null;
1454
+ let $hint = $sum ? $sum.querySelector('.TRAFFIC_NEST_HINT_WRAP') : null;
1455
+ out.push(`${indent}${$n.open ? '▾' : '▸'} ` +
1456
+ `${$key ? $key.textContent : ''} ${$hint ? $hint.textContent : ''}`.trimEnd());
1457
+ if($n.open) {
1458
+ kw_shown_lines($n.querySelector(':scope > .TRAFFIC_KW'), indent + ' ', out);
1459
+ }
1460
+ }
1461
+ }
1462
+ return out;
1463
+ }
1464
+
1465
+ /* A painted folded entry as the lines of its payload. Exported for its
1466
+ test. */
1467
+ function entry_shown_lines($entry)
1468
+ {
1469
+ let $kw = $entry ? $entry.querySelector(':scope > .TRAFFIC_KW') : null;
1470
+ return kw_shown_lines($kw, ' ', []);
1471
+ }
1472
+
1414
1473
  /* Serialize the currently-visible (filtered) traffic to plain text:
1415
1474
  * one header line per entry (time · direction · title · event/command)
1416
- * followed by its pretty-printed payload. Honours the active filters and
1417
- * search so the copy matches exactly what is on screen. */
1475
+ * followed by its payload AS THE VIEW SHOWS IT -- folded, what is on
1476
+ * screen (entry_shown_lines()); laid out, the whole payload. Honours the
1477
+ * active filters and search so the copy matches exactly what is on
1478
+ * screen. */
1418
1479
  function traffic_to_text()
1419
1480
  {
1420
1481
  let ctx = build_filter_ctx();
@@ -1433,6 +1494,11 @@ function traffic_to_text()
1433
1494
  `${e.title ? "[" + e.title + "] " : ""}${e.event}` +
1434
1495
  `${e.command ? " " + e.command : ""}`;
1435
1496
  out.push(head);
1497
+ if(dev_traffic_view() !== "expanded" && e.$node) {
1498
+ out.push(...entry_shown_lines(e.$node));
1499
+ out.push("");
1500
+ continue;
1501
+ }
1436
1502
  let payload = e.kw ? e.kw : e.jn;
1437
1503
  try {
1438
1504
  out.push(JSON.stringify(payload, null, 4));
@@ -1672,10 +1738,18 @@ function build_control_bar()
1672
1738
 
1673
1739
  let grp = (label, items) => ['div', {class: 'YDEV_GROUP'},
1674
1740
  [['span', {class: 'YDEV_LABEL', 'data-i18n': label}, t(label)], ...items]];
1741
+ /* A row too long for the window scrolls ON ITS OWN: the label stays,
1742
+ the chips run in a strip with its own horizontal scroll. The TRACES
1743
+ row did not fit and pushed the whole window into scrolling sideways,
1744
+ the log with it. */
1745
+ let grp_scroll = (label, items) => ['div', {class: 'YDEV_GROUP YDEV_GROUP_SCROLL'}, [
1746
+ ['span', {class: 'YDEV_LABEL', 'data-i18n': label}, t(label)],
1747
+ ['div', {class: 'YDEV_SCROLL'}, items],
1748
+ ]];
1675
1749
  let sep = () => ['span', {class: 'YDEV_SEP'}, ''];
1676
1750
 
1677
1751
  return createElement2(['div', {class: 'YDEV_BAR'}, [
1678
- grp('traces', [...trace_chips, simple_mach, traces_payload]), sep(),
1752
+ grp_scroll('traces', [...trace_chips, simple_mach, traces_payload]),
1679
1753
  grp('output', [output_seg]), sep(),
1680
1754
  grp('view', [view_seg]), expand_grp, sep(),
1681
1755
  grp('show', dir_chips), sep(),
@@ -1867,4 +1941,6 @@ export {
1867
1941
  the stylesheet below is a template literal, so one backtick in a CSS
1868
1942
  comment stops the whole module from parsing. */
1869
1943
  object_preview, object_preview_parts,
1944
+ /* And the copy of the folded view, with the renderer it reads. */
1945
+ entry_shown_lines, render_detailed,
1870
1946
  };
@@ -0,0 +1,61 @@
1
+ /***********************************************************************
2
+ * yui_dev_copy.test.js
3
+ *
4
+ * What "copy" of the Developer window puts on the clipboard in
5
+ * the FOLDED view: the payload as it is on screen -- a closed
6
+ * branch as its one-line summary, an opened one with its
7
+ * content -- and not the whole payload laid out, which for a
8
+ * list-map answer was 1.4 MB of text.
9
+ *
10
+ * The summary has no blanks after the commas because the screen
11
+ * has none: createElement2 trims every text node, the preview's
12
+ * ", " tokens included. The copy is what is seen.
13
+ *
14
+ * Copyright (c) 2026, ArtGins.
15
+ * All Rights Reserved.
16
+ ***********************************************************************/
17
+ import {describe, it, expect, beforeAll} from "vitest";
18
+ import {install_dom_double} from "../test/dom_double.js";
19
+
20
+ let entry_shown_lines;
21
+ let render_detailed;
22
+
23
+ beforeAll(async () => {
24
+ install_dom_double();
25
+ ({entry_shown_lines, render_detailed} = await import("./yui_dev.js"));
26
+ });
27
+
28
+ function painted(kw)
29
+ {
30
+ return render_detailed({
31
+ kind: "traffic", dir: "in", event: "EV_MT_COMMAND_ANSWER",
32
+ title: "central_yuno", ts: "09:04:11.914", size: 1473431, kw: kw,
33
+ });
34
+ }
35
+
36
+ describe("entry_shown_lines", () => {
37
+ it("copies a closed branch as its one-line summary", () => {
38
+ const $e = painted({
39
+ result: 0,
40
+ comment: "db_history_ce^1620: 524 nodos",
41
+ data: {places: [1, 2, 3], families: [4], devices: [5, 6]},
42
+ });
43
+ expect(entry_shown_lines($e)).toEqual([
44
+ " • result: 0",
45
+ " • comment: db_history_ce^1620: 524 nodos",
46
+ " ▸ data {places:[…],families:[…],devices:[…]}",
47
+ ]);
48
+ });
49
+
50
+ it("copies an OPENED branch with its content, four characters in", () => {
51
+ const $e = painted({result: 0, data: {count: 2, rows: [7, 8]}});
52
+ const $details = $e.querySelector("details");
53
+ $details.open = true;
54
+ expect(entry_shown_lines($e)).toEqual([
55
+ " • result: 0",
56
+ " ▾ data {count:2,rows:[…]}",
57
+ " • count: 2",
58
+ " ▸ rows [2]",
59
+ ]);
60
+ });
61
+ });