@saltcorn/copilot 0.5.1 → 0.5.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/user-copilot.js +28 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saltcorn/copilot",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "AI assistant for building Saltcorn applications",
5
5
  "main": "index.js",
6
6
  "dependencies": {
package/user-copilot.js CHANGED
@@ -362,7 +362,14 @@ const run = async (table_id, viewname, config, state, { res, req }) => {
362
362
  onclick: `set_state_field('run_id',${run.id})`,
363
363
  class: "prevcopilotrun border p-2",
364
364
  },
365
- localeDateTime(run.started_at),
365
+ div(
366
+ { class: "d-flex justify-content-between" },
367
+ localeDateTime(run.started_at),
368
+ i({
369
+ class: "far fa-trash-alt",
370
+ onclick: `delprevrun(event, ${run.id})`,
371
+ })
372
+ ),
366
373
 
367
374
  p(
368
375
  { class: "prevrun_content" },
@@ -397,6 +404,8 @@ const run = async (table_id, viewname, config, state, { res, req }) => {
397
404
  div.interaction-segment p {margin-bottom: 0px;}
398
405
  div.interaction-segment div.card {margin-top: 0.5rem;}
399
406
  div.prevcopilotrun:hover {cursor: pointer; background-color: var(--tblr-secondary-bg-subtle, var(--bs-secondary-bg-subtle, gray));}
407
+ div.prevcopilotrun i.fa-trash-alt {display: none;}
408
+ div.prevcopilotrun:hover i.fa-trash-alt {display: block;}
400
409
  .copilot-entry .submit-button:hover { cursor: pointer}
401
410
 
402
411
  .copilot-entry .submit-button {
@@ -430,6 +439,13 @@ const run = async (table_id, viewname, config, state, { res, req }) => {
430
439
  btn.css({ width: "" }).prop("disabled", false);
431
440
  btn.removeData("old-text");
432
441
  }
442
+ function delprevrun(e, runid) {
443
+ e.preventDefault();
444
+ e.stopPropagation();
445
+ view_post('${viewname}', 'delprevrun', {run_id:runid})
446
+ $(e.target).closest(".prevcopilotrun").remove()
447
+ return false;
448
+ }
433
449
  function processExecuteResponse(res) {
434
450
  const btn = $("#exec-"+res.fcall_id)
435
451
  restore_old_button_elem($("#exec-"+res.fcall_id))
@@ -608,6 +624,16 @@ const interact = async (table_id, viewname, config, body, { req, res }) => {
608
624
  return await process_interaction(run, config, req);
609
625
  };
610
626
 
627
+ const delprevrun = async (table_id, viewname, config, body, { req, res }) => {
628
+ const { run_id } = body;
629
+ let run;
630
+
631
+ run = await WorkflowRun.findOne({ id: +run_id });
632
+ await run.delete();
633
+
634
+ return;
635
+ };
636
+
611
637
  const renderQueryInteraction = async (table, result, config, req) => {
612
638
  if (typeof result === "number")
613
639
  return wrapSegment(
@@ -907,5 +933,5 @@ module.exports = {
907
933
  get_state_fields,
908
934
  tableless: true,
909
935
  run,
910
- routes: { interact },
936
+ routes: { interact, delprevrun },
911
937
  };