@yuneta/gobj-ui 7.25.21 → 7.25.22

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 CHANGED
@@ -597,9 +597,15 @@ Two layout facts the browser taught this component, both worth keeping:
597
597
  session, or refused by the transport on its way out, never reaches the
598
598
  backend, so no answer will ever come back for it -- the host answers it
599
599
  itself (`C_YUI_TREEDB_TOPICS` / `C_YUI_TREEDB_GRAPH` since `7.25.21`: `i18n:
600
- "no session"`, or the transport's refusal as `error`). While a path is
601
- pending the viewer ignores every click on it, so a drill left unanswered
602
- is a dead stub for the life of the viewer.
600
+ "no session"`, or the transport's refusal as `error`). So is a drill
601
+ already SENT when the session drops: a transport answers nothing in flight
602
+ on a close, so the host keeps the paths it asked and, on the disconnect
603
+ edge (`EV_TRANSPORT_STATE` or the shell's `EV_CONNECTION_STATE`, both
604
+ `{connected: false}`), answers each one `i18n: "the connection dropped"`
605
+ (since `7.25.22`); a failure that lands after that answer is dropped with
606
+ a warning, not shown twice. While a path is pending the viewer ignores
607
+ every click on it, so a drill left unanswered is a dead stub for the life
608
+ of the viewer.
603
609
  A host that cannot read a subtree says so with the error, as
604
610
  `C_YUI_TREEDB_TOPIC_WITH_FORM` does for its schema, cell and table viewers
605
611
  since `7.25.19` (before, it declared nothing: *"Event NOT DEFINED"*):
@@ -23791,7 +23791,8 @@ var PRIVATE_DATA$6 = {
23791
23791
  schema_gobj: null,
23792
23792
  json_gobj: null,
23793
23793
  json_win: null,
23794
- json_modal: null
23794
+ json_modal: null,
23795
+ drills_in_flight: null
23795
23796
  };
23796
23797
  var __gclass__$6 = null;
23797
23798
  /******************************
@@ -23804,6 +23805,7 @@ function mt_create$6(gobj) {
23804
23805
  gobj.priv.form_writes = {};
23805
23806
  gobj.priv.reread_on_session = false;
23806
23807
  gobj.priv.conn_shell = null;
23808
+ gobj.priv.drills_in_flight = /* @__PURE__ */ new Set();
23807
23809
  build_ui$6(gobj);
23808
23810
  let subscriber = (0, _yuneta_gobj_js.gobj_read_pointer_attr)(gobj, "subscriber");
23809
23811
  if (!subscriber) subscriber = (0, _yuneta_gobj_js.gobj_parent)(gobj);
@@ -25102,6 +25104,7 @@ function close_json_viewer$1(gobj) {
25102
25104
  priv.json_gobj = null;
25103
25105
  priv.json_win = null;
25104
25106
  priv.json_modal = null;
25107
+ priv.drills_in_flight.clear();
25105
25108
  if (win && (0, _yuneta_gobj_js.is_gobj)(win)) try {
25106
25109
  if ((0, _yuneta_gobj_js.gobj_is_running)(win)) (0, _yuneta_gobj_js.gobj_stop)(win);
25107
25110
  (0, _yuneta_gobj_js.gobj_destroy)(win);
@@ -25183,7 +25186,25 @@ function request_print_tranger$1(gobj, path) {
25183
25186
  if (ret) {
25184
25187
  (0, _yuneta_gobj_js.log_error)(ret);
25185
25188
  answer_print_tranger_refused$1(gobj, path, { error: refusal_text$1(ret) });
25189
+ return;
25186
25190
  }
25191
+ if (path) priv.drills_in_flight.add(path);
25192
+ }
25193
+ /************************************************************
25194
+ * The session dropped: a drill already sent will never be answered
25195
+ * (the transport answers nothing in flight on a close), and its stub
25196
+ * would show "loading" for the life of the viewer. Answered here, so a
25197
+ * click once the session is back asks again. Idempotent: both edges of
25198
+ * one drop may arrive.
25199
+ ************************************************************/
25200
+ function answer_drills_in_flight$1(gobj) {
25201
+ let priv = gobj.priv;
25202
+ let paths = Array.from(priv.drills_in_flight);
25203
+ priv.drills_in_flight.clear();
25204
+ paths.forEach((path) => {
25205
+ (0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: transport closed, the drill '${path}' of the raw json is lost`);
25206
+ answer_print_tranger_refused$1(gobj, path, { i18n: "the connection dropped" });
25207
+ });
25187
25208
  }
25188
25209
  /***************************************************************
25189
25210
  * The last gate before a write leaves for the yuno. The per-topic
@@ -25225,6 +25246,12 @@ function ac_mt_command_answer$2(gobj, event, kw, src) {
25225
25246
  let jv = gobj.priv.json_gobj;
25226
25247
  if (!jv || !(0, _yuneta_gobj_js.is_gobj)(jv) || (0, _yuneta_gobj_js.gobj_is_destroying)(jv)) return 0;
25227
25248
  let path = (0, _yuneta_gobj_js.kw_get_str)(gobj, kw_command, "path", "", 0);
25249
+ if (path) {
25250
+ if (!gobj.priv.drills_in_flight.delete(path) && result < 0) {
25251
+ (0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: late failure of the drill '${path}' dropped, it was already answered: ${comment || ""}`);
25252
+ return 0;
25253
+ }
25254
+ } else gobj.priv.drills_in_flight.clear();
25228
25255
  if (result < 0) {
25229
25256
  if (path) (0, _yuneta_gobj_js.gobj_send_event)(jv, "EV_SUBTREE_ERROR", {
25230
25257
  path,
@@ -25483,6 +25510,7 @@ function ac_transport_state$2(gobj, event, kw, src) {
25483
25510
  refresh_toolbar_buttons(gobj, connected);
25484
25511
  if (!connected) {
25485
25512
  gobj.priv.reread_on_session = true;
25513
+ answer_drills_in_flight$1(gobj);
25486
25514
  abandon_form_writes(gobj.priv.form_writes).forEach((w) => {
25487
25515
  (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`);
25488
25516
  answer_form_write(gobj, get_gobj_formtable(gobj, w.topic_name), w.form_write, false);
@@ -25876,6 +25904,7 @@ function ac_json_closed$1(gobj, event, kw, src) {
25876
25904
  priv.json_gobj = null;
25877
25905
  priv.json_win = null;
25878
25906
  priv.json_modal = null;
25907
+ priv.drills_in_flight.clear();
25879
25908
  if (jv && (0, _yuneta_gobj_js.is_gobj)(jv)) try {
25880
25909
  (0, _yuneta_gobj_js.gobj_stop)(jv);
25881
25910
  (0, _yuneta_gobj_js.gobj_destroy)(jv);
@@ -67468,6 +67497,7 @@ var PRIVATE_DATA$3 = {
67468
67497
  json_gobj: null,
67469
67498
  json_win: null,
67470
67499
  json_modal: null,
67500
+ drills_in_flight: null,
67471
67501
  with_treedb_tables: false,
67472
67502
  canvas_id: null,
67473
67503
  operation_mode: null,
@@ -67487,6 +67517,7 @@ var __gclass__$3 = null;
67487
67517
  ***************************************************************/
67488
67518
  function mt_create$3(gobj) {
67489
67519
  let priv = gobj.priv;
67520
+ priv.drills_in_flight = /* @__PURE__ */ new Set();
67490
67521
  let subscriber = (0, _yuneta_gobj_js.gobj_read_pointer_attr)(gobj, "subscriber");
67491
67522
  if (!subscriber) subscriber = (0, _yuneta_gobj_js.gobj_parent)(gobj);
67492
67523
  (0, _yuneta_gobj_js.gobj_subscribe_event)(gobj, null, {}, subscriber);
@@ -67645,9 +67676,13 @@ function refresh_raw_json_button(gobj, connected) {
67645
67676
  * "Raw JSON" button disables the moment the session drops and re-enables on
67646
67677
  * reconnect. The library view must not subscribe to the C_IEVENT_CLI itself
67647
67678
  * (that forwards the subscription upstream and breaks the session).
67679
+ * On the drop, the drills of the raw-json viewer still in flight are
67680
+ * answered: the transport answers nothing in flight on a close.
67648
67681
  ************************************************************/
67649
67682
  function ac_transport_state$1(gobj, event, kw, src) {
67650
- refresh_raw_json_button(gobj, !!(kw && kw.connected));
67683
+ let connected = !!(kw && kw.connected);
67684
+ refresh_raw_json_button(gobj, connected);
67685
+ if (!connected) answer_drills_in_flight(gobj);
67651
67686
  return 0;
67652
67687
  }
67653
67688
  /************************************************************
@@ -68350,6 +68385,7 @@ function close_json_viewer(gobj) {
68350
68385
  priv.json_gobj = null;
68351
68386
  priv.json_win = null;
68352
68387
  priv.json_modal = null;
68388
+ priv.drills_in_flight.clear();
68353
68389
  if (win && (0, _yuneta_gobj_js.is_gobj)(win)) try {
68354
68390
  if ((0, _yuneta_gobj_js.gobj_is_running)(win)) (0, _yuneta_gobj_js.gobj_stop)(win);
68355
68391
  (0, _yuneta_gobj_js.gobj_destroy)(win);
@@ -68417,7 +68453,25 @@ function request_print_tranger(gobj, path) {
68417
68453
  if (ret) {
68418
68454
  (0, _yuneta_gobj_js.log_error)(ret);
68419
68455
  answer_print_tranger_refused(gobj, path, { error: refusal_text(ret) });
68456
+ return;
68420
68457
  }
68458
+ if (path) priv.drills_in_flight.add(path);
68459
+ }
68460
+ /************************************************************
68461
+ * The session dropped: a drill already sent will never be answered
68462
+ * (the transport answers nothing in flight on a close), and its stub
68463
+ * would show "loading" for the life of the viewer. Answered here, so a
68464
+ * click once the session is back asks again. Idempotent: both edges of
68465
+ * one drop may arrive.
68466
+ ************************************************************/
68467
+ function answer_drills_in_flight(gobj) {
68468
+ let priv = gobj.priv;
68469
+ let paths = Array.from(priv.drills_in_flight);
68470
+ priv.drills_in_flight.clear();
68471
+ paths.forEach((path) => {
68472
+ (0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: transport closed, the drill '${path}' of the raw json is lost`);
68473
+ answer_print_tranger_refused(gobj, path, { i18n: "the connection dropped" });
68474
+ });
68421
68475
  }
68422
68476
  /************************************************************
68423
68477
  * Populate layout dropdown from child's available layouts
@@ -68795,6 +68849,12 @@ function ac_mt_command_answer$1(gobj, event, kw, src) {
68795
68849
  let jv = priv.json_gobj;
68796
68850
  if (!jv || !(0, _yuneta_gobj_js.is_gobj)(jv) || (0, _yuneta_gobj_js.gobj_is_destroying)(jv)) return 0;
68797
68851
  let path = (0, _yuneta_gobj_js.kw_get_str)(gobj, kw_command, "path", "", 0);
68852
+ if (path) {
68853
+ if (!priv.drills_in_flight.delete(path) && result < 0) {
68854
+ (0, _yuneta_gobj_js.log_warning)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: late failure of the drill '${path}' dropped, it was already answered: ${comment || ""}`);
68855
+ return 0;
68856
+ }
68857
+ } else priv.drills_in_flight.clear();
68798
68858
  if (result < 0) {
68799
68859
  if (path) (0, _yuneta_gobj_js.gobj_send_event)(jv, "EV_SUBTREE_ERROR", {
68800
68860
  path,
@@ -68981,6 +69041,7 @@ function ac_json_closed(gobj, event, kw, src) {
68981
69041
  priv.json_gobj = null;
68982
69042
  priv.json_win = null;
68983
69043
  priv.json_modal = null;
69044
+ priv.drills_in_flight.clear();
68984
69045
  if (jv && (0, _yuneta_gobj_js.is_gobj)(jv)) try {
68985
69046
  (0, _yuneta_gobj_js.gobj_stop)(jv);
68986
69047
  (0, _yuneta_gobj_js.gobj_destroy)(jv);
@@ -23786,7 +23786,8 @@ var PRIVATE_DATA$6 = {
23786
23786
  schema_gobj: null,
23787
23787
  json_gobj: null,
23788
23788
  json_win: null,
23789
- json_modal: null
23789
+ json_modal: null,
23790
+ drills_in_flight: null
23790
23791
  };
23791
23792
  var __gclass__$6 = null;
23792
23793
  /******************************
@@ -23799,6 +23800,7 @@ function mt_create$6(gobj) {
23799
23800
  gobj.priv.form_writes = {};
23800
23801
  gobj.priv.reread_on_session = false;
23801
23802
  gobj.priv.conn_shell = null;
23803
+ gobj.priv.drills_in_flight = /* @__PURE__ */ new Set();
23802
23804
  build_ui$6(gobj);
23803
23805
  let subscriber = gobj_read_pointer_attr(gobj, "subscriber");
23804
23806
  if (!subscriber) subscriber = gobj_parent(gobj);
@@ -25097,6 +25099,7 @@ function close_json_viewer$1(gobj) {
25097
25099
  priv.json_gobj = null;
25098
25100
  priv.json_win = null;
25099
25101
  priv.json_modal = null;
25102
+ priv.drills_in_flight.clear();
25100
25103
  if (win && is_gobj(win)) try {
25101
25104
  if (gobj_is_running(win)) gobj_stop(win);
25102
25105
  gobj_destroy(win);
@@ -25178,7 +25181,25 @@ function request_print_tranger$1(gobj, path) {
25178
25181
  if (ret) {
25179
25182
  log_error(ret);
25180
25183
  answer_print_tranger_refused$1(gobj, path, { error: refusal_text$1(ret) });
25184
+ return;
25181
25185
  }
25186
+ if (path) priv.drills_in_flight.add(path);
25187
+ }
25188
+ /************************************************************
25189
+ * The session dropped: a drill already sent will never be answered
25190
+ * (the transport answers nothing in flight on a close), and its stub
25191
+ * would show "loading" for the life of the viewer. Answered here, so a
25192
+ * click once the session is back asks again. Idempotent: both edges of
25193
+ * one drop may arrive.
25194
+ ************************************************************/
25195
+ function answer_drills_in_flight$1(gobj) {
25196
+ let priv = gobj.priv;
25197
+ let paths = Array.from(priv.drills_in_flight);
25198
+ priv.drills_in_flight.clear();
25199
+ paths.forEach((path) => {
25200
+ log_warning(`${gobj_short_name(gobj)}: transport closed, the drill '${path}' of the raw json is lost`);
25201
+ answer_print_tranger_refused$1(gobj, path, { i18n: "the connection dropped" });
25202
+ });
25182
25203
  }
25183
25204
  /***************************************************************
25184
25205
  * The last gate before a write leaves for the yuno. The per-topic
@@ -25220,6 +25241,12 @@ function ac_mt_command_answer$2(gobj, event, kw, src) {
25220
25241
  let jv = gobj.priv.json_gobj;
25221
25242
  if (!jv || !is_gobj(jv) || gobj_is_destroying(jv)) return 0;
25222
25243
  let path = kw_get_str(gobj, kw_command, "path", "", 0);
25244
+ if (path) {
25245
+ if (!gobj.priv.drills_in_flight.delete(path) && result < 0) {
25246
+ log_warning(`${gobj_short_name(gobj)}: late failure of the drill '${path}' dropped, it was already answered: ${comment || ""}`);
25247
+ return 0;
25248
+ }
25249
+ } else gobj.priv.drills_in_flight.clear();
25223
25250
  if (result < 0) {
25224
25251
  if (path) gobj_send_event(jv, "EV_SUBTREE_ERROR", {
25225
25252
  path,
@@ -25478,6 +25505,7 @@ function ac_transport_state$2(gobj, event, kw, src) {
25478
25505
  refresh_toolbar_buttons(gobj, connected);
25479
25506
  if (!connected) {
25480
25507
  gobj.priv.reread_on_session = true;
25508
+ answer_drills_in_flight$1(gobj);
25481
25509
  abandon_form_writes(gobj.priv.form_writes).forEach((w) => {
25482
25510
  log_warning(`${gobj_short_name(gobj)}: transport closed, the write ${w.form_write} of '${w.topic_name}' is lost`);
25483
25511
  answer_form_write(gobj, get_gobj_formtable(gobj, w.topic_name), w.form_write, false);
@@ -25871,6 +25899,7 @@ function ac_json_closed$1(gobj, event, kw, src) {
25871
25899
  priv.json_gobj = null;
25872
25900
  priv.json_win = null;
25873
25901
  priv.json_modal = null;
25902
+ priv.drills_in_flight.clear();
25874
25903
  if (jv && is_gobj(jv)) try {
25875
25904
  gobj_stop(jv);
25876
25905
  gobj_destroy(jv);
@@ -67463,6 +67492,7 @@ var PRIVATE_DATA$3 = {
67463
67492
  json_gobj: null,
67464
67493
  json_win: null,
67465
67494
  json_modal: null,
67495
+ drills_in_flight: null,
67466
67496
  with_treedb_tables: false,
67467
67497
  canvas_id: null,
67468
67498
  operation_mode: null,
@@ -67482,6 +67512,7 @@ var __gclass__$3 = null;
67482
67512
  ***************************************************************/
67483
67513
  function mt_create$3(gobj) {
67484
67514
  let priv = gobj.priv;
67515
+ priv.drills_in_flight = /* @__PURE__ */ new Set();
67485
67516
  let subscriber = gobj_read_pointer_attr(gobj, "subscriber");
67486
67517
  if (!subscriber) subscriber = gobj_parent(gobj);
67487
67518
  gobj_subscribe_event(gobj, null, {}, subscriber);
@@ -67640,9 +67671,13 @@ function refresh_raw_json_button(gobj, connected) {
67640
67671
  * "Raw JSON" button disables the moment the session drops and re-enables on
67641
67672
  * reconnect. The library view must not subscribe to the C_IEVENT_CLI itself
67642
67673
  * (that forwards the subscription upstream and breaks the session).
67674
+ * On the drop, the drills of the raw-json viewer still in flight are
67675
+ * answered: the transport answers nothing in flight on a close.
67643
67676
  ************************************************************/
67644
67677
  function ac_transport_state$1(gobj, event, kw, src) {
67645
- refresh_raw_json_button(gobj, !!(kw && kw.connected));
67678
+ let connected = !!(kw && kw.connected);
67679
+ refresh_raw_json_button(gobj, connected);
67680
+ if (!connected) answer_drills_in_flight(gobj);
67646
67681
  return 0;
67647
67682
  }
67648
67683
  /************************************************************
@@ -68345,6 +68380,7 @@ function close_json_viewer(gobj) {
68345
68380
  priv.json_gobj = null;
68346
68381
  priv.json_win = null;
68347
68382
  priv.json_modal = null;
68383
+ priv.drills_in_flight.clear();
68348
68384
  if (win && is_gobj(win)) try {
68349
68385
  if (gobj_is_running(win)) gobj_stop(win);
68350
68386
  gobj_destroy(win);
@@ -68412,7 +68448,25 @@ function request_print_tranger(gobj, path) {
68412
68448
  if (ret) {
68413
68449
  log_error(ret);
68414
68450
  answer_print_tranger_refused(gobj, path, { error: refusal_text(ret) });
68451
+ return;
68415
68452
  }
68453
+ if (path) priv.drills_in_flight.add(path);
68454
+ }
68455
+ /************************************************************
68456
+ * The session dropped: a drill already sent will never be answered
68457
+ * (the transport answers nothing in flight on a close), and its stub
68458
+ * would show "loading" for the life of the viewer. Answered here, so a
68459
+ * click once the session is back asks again. Idempotent: both edges of
68460
+ * one drop may arrive.
68461
+ ************************************************************/
68462
+ function answer_drills_in_flight(gobj) {
68463
+ let priv = gobj.priv;
68464
+ let paths = Array.from(priv.drills_in_flight);
68465
+ priv.drills_in_flight.clear();
68466
+ paths.forEach((path) => {
68467
+ log_warning(`${gobj_short_name(gobj)}: transport closed, the drill '${path}' of the raw json is lost`);
68468
+ answer_print_tranger_refused(gobj, path, { i18n: "the connection dropped" });
68469
+ });
68416
68470
  }
68417
68471
  /************************************************************
68418
68472
  * Populate layout dropdown from child's available layouts
@@ -68790,6 +68844,12 @@ function ac_mt_command_answer$1(gobj, event, kw, src) {
68790
68844
  let jv = priv.json_gobj;
68791
68845
  if (!jv || !is_gobj(jv) || gobj_is_destroying(jv)) return 0;
68792
68846
  let path = kw_get_str(gobj, kw_command, "path", "", 0);
68847
+ if (path) {
68848
+ if (!priv.drills_in_flight.delete(path) && result < 0) {
68849
+ log_warning(`${gobj_short_name(gobj)}: late failure of the drill '${path}' dropped, it was already answered: ${comment || ""}`);
68850
+ return 0;
68851
+ }
68852
+ } else priv.drills_in_flight.clear();
68793
68853
  if (result < 0) {
68794
68854
  if (path) gobj_send_event(jv, "EV_SUBTREE_ERROR", {
68795
68855
  path,
@@ -68976,6 +69036,7 @@ function ac_json_closed(gobj, event, kw, src) {
68976
69036
  priv.json_gobj = null;
68977
69037
  priv.json_win = null;
68978
69038
  priv.json_modal = null;
69039
+ priv.drills_in_flight.clear();
68979
69040
  if (jv && is_gobj(jv)) try {
68980
69041
  gobj_stop(jv);
68981
69042
  gobj_destroy(jv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.25.21",
3
+ "version": "7.25.22",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -30,7 +30,7 @@
30
30
  "devDependencies": {
31
31
  "@rollup/plugin-terser": "^1.0.0",
32
32
  "@vitest/coverage-v8": "^4.1.10",
33
- "@yuneta/gobj-js": "^7.25.7",
33
+ "@yuneta/gobj-js": "^7.25.8",
34
34
  "vite": "^8.2.1",
35
35
  "vitest": "^4.1.10"
36
36
  },
@@ -183,6 +183,7 @@ let PRIVATE_DATA = {
183
183
  json_gobj: null, /* C_YUI_JSON viewer of the raw tranger (or null) */
184
184
  json_win: null, /* C_YUI_WINDOW hosting it, desktop (or null) */
185
185
  json_modal: null, /* shell modal hosting it, mobile (or null) */
186
+ drills_in_flight: null, /* Set of the viewer's drilled paths sent, not answered */
186
187
  with_treedb_tables: false,
187
188
  canvas_id: null,
188
189
  operation_mode: null,
@@ -214,6 +215,10 @@ function mt_create(gobj)
214
215
  {
215
216
  let priv = gobj.priv;
216
217
 
218
+ /* The drills of the raw-json viewer sent and not yet answered:
219
+ * answered on the disconnect edge (answer_drills_in_flight). */
220
+ priv.drills_in_flight = new Set();
221
+
217
222
  /*
218
223
  * CHILD subscription model
219
224
  */
@@ -474,10 +479,16 @@ function refresh_raw_json_button(gobj, connected)
474
479
  * "Raw JSON" button disables the moment the session drops and re-enables on
475
480
  * reconnect. The library view must not subscribe to the C_IEVENT_CLI itself
476
481
  * (that forwards the subscription upstream and breaks the session).
482
+ * On the drop, the drills of the raw-json viewer still in flight are
483
+ * answered: the transport answers nothing in flight on a close.
477
484
  ************************************************************/
478
485
  function ac_transport_state(gobj, event, kw, src)
479
486
  {
480
- refresh_raw_json_button(gobj, !!(kw && kw.connected));
487
+ let connected = !!(kw && kw.connected);
488
+ refresh_raw_json_button(gobj, connected);
489
+ if(!connected) {
490
+ answer_drills_in_flight(gobj);
491
+ }
481
492
  return 0;
482
493
  }
483
494
 
@@ -1270,6 +1281,7 @@ function close_json_viewer(gobj)
1270
1281
  priv.json_gobj = null;
1271
1282
  priv.json_win = null;
1272
1283
  priv.json_modal = null;
1284
+ priv.drills_in_flight.clear();
1273
1285
 
1274
1286
  if(win && is_gobj(win)) {
1275
1287
  try {
@@ -1381,9 +1393,32 @@ function request_print_tranger(gobj, path)
1381
1393
  if(ret) {
1382
1394
  log_error(ret);
1383
1395
  answer_print_tranger_refused(gobj, path, {error: refusal_text(ret)});
1396
+ return;
1397
+ }
1398
+ if(path) {
1399
+ priv.drills_in_flight.add(path);
1384
1400
  }
1385
1401
  }
1386
1402
 
1403
+ /************************************************************
1404
+ * The session dropped: a drill already sent will never be answered
1405
+ * (the transport answers nothing in flight on a close), and its stub
1406
+ * would show "loading" for the life of the viewer. Answered here, so a
1407
+ * click once the session is back asks again. Idempotent: both edges of
1408
+ * one drop may arrive.
1409
+ ************************************************************/
1410
+ function answer_drills_in_flight(gobj)
1411
+ {
1412
+ let priv = gobj.priv;
1413
+ let paths = Array.from(priv.drills_in_flight);
1414
+ priv.drills_in_flight.clear();
1415
+ paths.forEach((path) => {
1416
+ log_warning(`${gobj_short_name(gobj)}: transport closed, the drill ` +
1417
+ `'${path}' of the raw json is lost`);
1418
+ answer_print_tranger_refused(gobj, path, {i18n: "the connection dropped"});
1419
+ });
1420
+ }
1421
+
1387
1422
  /************************************************************
1388
1423
  * Populate layout dropdown from child's available layouts
1389
1424
  ************************************************************/
@@ -2100,6 +2135,19 @@ function ac_mt_command_answer(gobj, event, kw, src)
2100
2135
  return 0; /* viewer closed before its answer landed: benign */
2101
2136
  }
2102
2137
  let path = kw_get_str(gobj, kw_command, "path", "", 0);
2138
+ if(path) {
2139
+ let in_flight = priv.drills_in_flight.delete(path);
2140
+ if(!in_flight && result < 0) {
2141
+ /* Already answered (the drop answered it, or the viewer
2142
+ * was refilled): a second answer would log it twice. */
2143
+ log_warning(`${gobj_short_name(gobj)}: late failure of the drill ` +
2144
+ `'${path}' dropped, it was already answered: ${comment || ""}`);
2145
+ return 0;
2146
+ }
2147
+ } else {
2148
+ /* A whole document replaces every stub the drills were for. */
2149
+ priv.drills_in_flight.clear();
2150
+ }
2103
2151
  if(result < 0) {
2104
2152
  if(path) {
2105
2153
  gobj_send_event(jv, "EV_SUBTREE_ERROR",
@@ -2411,6 +2459,7 @@ function ac_json_closed(gobj, event, kw, src)
2411
2459
  priv.json_gobj = null;
2412
2460
  priv.json_win = null;
2413
2461
  priv.json_modal = null;
2462
+ priv.drills_in_flight.clear();
2414
2463
  if(jv && is_gobj(jv)) {
2415
2464
  try {
2416
2465
  /* STOP before destroy — the viewer was STARTED in open_json_viewer
@@ -137,6 +137,7 @@ let PRIVATE_DATA = {
137
137
  json_gobj: null, /* C_YUI_JSON raw-tranger viewer (or null) */
138
138
  json_win: null, /* C_YUI_WINDOW hosting it, desktop (or null) */
139
139
  json_modal: null, /* shell modal hosting it, mobile (or null) */
140
+ drills_in_flight: null, /* Set of the viewer's drilled paths sent, not answered */
140
141
  };
141
142
 
142
143
  let __gclass__ = null;
@@ -166,6 +167,9 @@ function mt_create(gobj)
166
167
  * (reread_open_topics), never out of session. */
167
168
  gobj.priv.reread_on_session = false;
168
169
  gobj.priv.conn_shell = null; /* the shell whose EV_CONNECTION_STATE we hear */
170
+ /* The drills of the raw-json viewer sent and not yet answered:
171
+ * answered on the disconnect edge (answer_drills_in_flight). */
172
+ gobj.priv.drills_in_flight = new Set();
169
173
 
170
174
  build_ui(gobj);
171
175
 
@@ -1887,6 +1891,7 @@ function close_json_viewer(gobj)
1887
1891
  priv.json_gobj = null;
1888
1892
  priv.json_win = null;
1889
1893
  priv.json_modal = null;
1894
+ priv.drills_in_flight.clear();
1890
1895
 
1891
1896
  if(win && is_gobj(win)) {
1892
1897
  try {
@@ -2011,9 +2016,32 @@ function request_print_tranger(gobj, path)
2011
2016
  if(ret) {
2012
2017
  log_error(ret);
2013
2018
  answer_print_tranger_refused(gobj, path, {error: refusal_text(ret)});
2019
+ return;
2020
+ }
2021
+ if(path) {
2022
+ priv.drills_in_flight.add(path);
2014
2023
  }
2015
2024
  }
2016
2025
 
2026
+ /************************************************************
2027
+ * The session dropped: a drill already sent will never be answered
2028
+ * (the transport answers nothing in flight on a close), and its stub
2029
+ * would show "loading" for the life of the viewer. Answered here, so a
2030
+ * click once the session is back asks again. Idempotent: both edges of
2031
+ * one drop may arrive.
2032
+ ************************************************************/
2033
+ function answer_drills_in_flight(gobj)
2034
+ {
2035
+ let priv = gobj.priv;
2036
+ let paths = Array.from(priv.drills_in_flight);
2037
+ priv.drills_in_flight.clear();
2038
+ paths.forEach((path) => {
2039
+ log_warning(`${gobj_short_name(gobj)}: transport closed, the drill ` +
2040
+ `'${path}' of the raw json is lost`);
2041
+ answer_print_tranger_refused(gobj, path, {i18n: "the connection dropped"});
2042
+ });
2043
+ }
2044
+
2017
2045
 
2018
2046
 
2019
2047
 
@@ -2080,6 +2108,19 @@ function ac_mt_command_answer(gobj, event, kw, src)
2080
2108
  return 0; /* viewer closed before its answer landed: benign */
2081
2109
  }
2082
2110
  let path = kw_get_str(gobj, kw_command, "path", "", 0);
2111
+ if(path) {
2112
+ let in_flight = gobj.priv.drills_in_flight.delete(path);
2113
+ if(!in_flight && result < 0) {
2114
+ /* Already answered (the drop answered it, or the viewer
2115
+ * was refilled): a second answer would log it twice. */
2116
+ log_warning(`${gobj_short_name(gobj)}: late failure of the drill ` +
2117
+ `'${path}' dropped, it was already answered: ${comment || ""}`);
2118
+ return 0;
2119
+ }
2120
+ } else {
2121
+ /* A whole document replaces every stub the drills were for. */
2122
+ gobj.priv.drills_in_flight.clear();
2123
+ }
2083
2124
  if(result < 0) {
2084
2125
  if(path) {
2085
2126
  gobj_send_event(jv, "EV_SUBTREE_ERROR",
@@ -2552,12 +2593,14 @@ function ac_transport_state(gobj, event, kw, src)
2552
2593
  * the backend: its form stayed open and busy for ever. Answered
2553
2594
  * refused: the form stays open on what
2554
2595
  * was typed, and the person saves again when the session is back.
2596
+ * The same for a drill of the raw-json viewer: its stub is answered.
2555
2597
  */
2556
2598
  if(!connected) {
2557
2599
  /* What happens in the store while the session is down reaches
2558
2600
  * no table: its node events are published to nobody. Every open
2559
2601
  * table is read again when the session is back. */
2560
2602
  gobj.priv.reread_on_session = true;
2603
+ answer_drills_in_flight(gobj);
2561
2604
  abandon_form_writes(gobj.priv.form_writes).forEach((w) => {
2562
2605
  log_warning(`${gobj_short_name(gobj)}: transport closed, the write ${w.form_write} of '${w.topic_name}' is lost`);
2563
2606
  answer_form_write(
@@ -3125,6 +3168,7 @@ function ac_json_closed(gobj, event, kw, src)
3125
3168
  priv.json_gobj = null;
3126
3169
  priv.json_win = null;
3127
3170
  priv.json_modal = null;
3171
+ priv.drills_in_flight.clear();
3128
3172
  if(jv && is_gobj(jv)) {
3129
3173
  try {
3130
3174
  /* STOP before destroy — the viewer was STARTED in open_json_viewer
@@ -13,6 +13,12 @@
13
13
  * stayed on "loading" for the life of the viewer, and no click --
14
14
  * not even after the reconnect -- asked again.
15
15
  *
16
+ * Before gobj-ui 7.25.22 a drill already SENT when the session
17
+ * dropped was never answered either: the transport answers nothing
18
+ * in flight on a close, and neither host remembered what it had
19
+ * asked. Each host now keeps its drills in flight and answers them
20
+ * on the disconnect edge.
21
+ *
16
22
  * Driven through the real hosts and the real viewer on a document
17
23
  * double, with a fake transport whose state is the one the hosts
18
24
  * read and which refuses on demand.
@@ -229,4 +235,114 @@ for(const gclass of ["C_YUI_TREEDB_TOPICS", "C_YUI_TREEDB_GRAPH"]) {
229
235
  expect(logged.filter((l) => l.level === "error")).toEqual([]);
230
236
  });
231
237
  });
238
+
239
+ describe(`${gclass}: a drill in flight when the session drops is answered`, () => {
240
+
241
+ test("the drop answers the stub, and a click after the reconnect asks again", () => {
242
+ const {remote, host, viewer} = build(`${gclass}_d`, gclass);
243
+ click_stub(viewer);
244
+ expect(viewer.priv.pending.has("topics")).toBe(true);
245
+
246
+ /* The session drops before the answer: the transport never
247
+ * answers a command in flight. */
248
+ gobj_change_state(remote, "ST_DISCONNECTED");
249
+ gobj_send_event(host, "EV_TRANSPORT_STATE", {connected: false}, host);
250
+
251
+ expect(viewer.priv.pending.has("topics")).toBe(false);
252
+ expect(viewer.priv.errors.get("topics")).toEqual(
253
+ {error: "the connection dropped", is_key: true});
254
+
255
+ /* The same edge again answers nothing more. */
256
+ logged.length = 0;
257
+ gobj_send_event(host, "EV_TRANSPORT_STATE", {connected: false}, host);
258
+ expect(logged.filter((l) => l.level === "error")).toEqual([]);
259
+
260
+ gobj_change_state(remote, "ST_SESSION");
261
+ gobj_send_event(host, "EV_TRANSPORT_STATE", {connected: true}, host);
262
+ click_stub(viewer);
263
+ expect(drills()).toEqual(["topics", "topics"]);
264
+ expect(viewer.priv.pending.has("topics")).toBe(true);
265
+ });
266
+
267
+ test("a failure that lands after the drop answered is not answered twice", () => {
268
+ /* gui_agent's routing adapter answers every request in flight
269
+ * as failed on the close, and that answer can land after the
270
+ * edge that already answered the stub. */
271
+ const {remote, host, viewer} = build(`${gclass}_h`, gclass);
272
+ click_stub(viewer);
273
+ const request = commands.find((c) => c.command === "print-tranger");
274
+ gobj_change_state(remote, "ST_DISCONNECTED");
275
+ gobj_send_event(host, "EV_TRANSPORT_STATE", {connected: false}, host);
276
+
277
+ logged.length = 0;
278
+ gobj_send_event(host, "EV_MT_COMMAND_ANSWER", {
279
+ result: -1, comment: "the connection dropped", data: null,
280
+ __md_iev__: {
281
+ command_stack: [{command: "print-tranger", kw: request.kw.__md_command__}]
282
+ }
283
+ }, remote);
284
+ expect(viewer.priv.errors.get("topics")).toEqual(
285
+ {error: "the connection dropped", is_key: true});
286
+ expect(logged.filter((l) => l.level === "error")).toEqual([]);
287
+ });
288
+
289
+ test("a drill already answered is not answered again by a drop", () => {
290
+ const {remote, host, viewer} = build(`${gclass}_e`, gclass);
291
+ click_stub(viewer);
292
+ const request = commands.find((c) => c.command === "print-tranger");
293
+ gobj_send_event(host, "EV_MT_COMMAND_ANSWER", {
294
+ result: 0, comment: "", data: {a: 1, b: 2, c: 3},
295
+ __md_iev__: {
296
+ command_stack: [{command: "print-tranger", kw: request.kw.__md_command__}]
297
+ }
298
+ }, remote);
299
+ expect(viewer.priv.pending.has("topics")).toBe(false);
300
+ expect(viewer.priv.errors.has("topics")).toBe(false);
301
+
302
+ gobj_change_state(remote, "ST_DISCONNECTED");
303
+ gobj_send_event(host, "EV_TRANSPORT_STATE", {connected: false}, host);
304
+ expect(viewer.priv.errors.has("topics")).toBe(false);
305
+ expect(logged.filter((l) => l.level === "error")).toEqual([]);
306
+ });
307
+
308
+ test("a drill that failed is not answered again by a drop", () => {
309
+ const {remote, host, viewer} = build(`${gclass}_f`, gclass);
310
+ click_stub(viewer);
311
+ const request = commands.find((c) => c.command === "print-tranger");
312
+ gobj_send_event(host, "EV_MT_COMMAND_ANSWER", {
313
+ result: -1, comment: "no such path", data: null,
314
+ __md_iev__: {
315
+ command_stack: [{command: "print-tranger", kw: request.kw.__md_command__}]
316
+ }
317
+ }, remote);
318
+ expect(viewer.priv.errors.get("topics")).toEqual(
319
+ {error: "no such path", is_key: false});
320
+
321
+ gobj_change_state(remote, "ST_DISCONNECTED");
322
+ gobj_send_event(host, "EV_TRANSPORT_STATE", {connected: false}, host);
323
+ expect(viewer.priv.errors.get("topics")).toEqual(
324
+ {error: "no such path", is_key: false});
325
+ });
326
+ });
232
327
  }
328
+
329
+ /*
330
+ * wattyzer and yunovatios hear the edge from the SHELL
331
+ * (EV_CONNECTION_STATE), not from a host that forwards the transport.
332
+ */
333
+ describe("C_YUI_TREEDB_TOPICS: the shell's 'down' answers a drill in flight", () => {
334
+ test("EV_CONNECTION_STATE down answers the stub once, with its edge twin", () => {
335
+ const {remote, host, viewer} = build("topics_g", "C_YUI_TREEDB_TOPICS");
336
+ click_stub(viewer);
337
+
338
+ gobj_change_state(remote, "ST_DISCONNECTED");
339
+ gobj_send_event(host, "EV_CONNECTION_STATE", {connected: false}, host);
340
+ expect(viewer.priv.pending.has("topics")).toBe(false);
341
+ expect(viewer.priv.errors.get("topics")).toEqual(
342
+ {error: "the connection dropped", is_key: true});
343
+
344
+ const errors_after_first = logged.filter((l) => l.level === "error").length;
345
+ gobj_send_event(host, "EV_TRANSPORT_STATE", {connected: false}, host);
346
+ expect(logged.filter((l) => l.level === "error").length).toBe(errors_after_first);
347
+ });
348
+ });