glitchgrab 1.62.4 → 1.62.5

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
@@ -322,13 +322,17 @@ const leads = await listLeads({ source: "demo", since: "2026-09-01" }); // GLITC
322
322
  Glitchgrab keeps, per customer, the recorded calls, a running note history and the booked next call — and WhatsApps whoever booked it 5 minutes before it is due. After each call a note of what was asked and promised appears by itself, and the next call is booked from what was said, with a reason. Read and write it from your server with the `ggc_` key:
323
323
 
324
324
  ```ts
325
- import { listFollowUps, setFollowUpBooking, dialFollowUp, addFollowUpNote } from "glitchgrab/server";
325
+ import { listFollowUps, setFollowUpBooking, dialFollowUp, addFollowUpNote, editFollowUpNote } from "glitchgrab/server";
326
326
 
327
327
  // One request for a whole list page (≤500 ids): nextCallAt, due, lastNote, noteCount, lastCall
328
328
  const rows = await listFollowUps(owners.map((o) => o.id));
329
329
 
330
330
  // The first write for a new id needs its phone
331
331
  await addFollowUpNote(owner.id, { body: "Wants WhatsApp receipts", author: "Super Admin", phone: owner.phone });
332
+ // Correct your own note (or the one written from the call)
333
+ await editFollowUpNote(owner.id, noteId, { body: "Wants WhatsApp receipts monthly", editor: "Super Admin" });
334
+ // Moving off your own store? Copy old notes with their real dates (past only, no webhook)
335
+ await addFollowUpNote(owner.id, { body: old.body, author: old.by, createdAt: old.at, editedAt: old.editedAt, editedBy: old.editedBy });
332
336
  await setFollowUpBooking(owner.id, { nextCallAt: new Date("2026-10-27T05:30:00Z"), operator: { email: "admin@you.in" } });
333
337
 
334
338
  // Rings the operator first, then the customer, from your project's Glitchgrab number — recorded
package/dist/index.js CHANGED
@@ -2711,16 +2711,6 @@ var STARTERS = [
2711
2711
  "I wish it could\u2026"
2712
2712
  ];
2713
2713
  var CONFIRM_OPTION = "Yes, that's it";
2714
- function isCheckBackQuestion(text) {
2715
- const t = text.trim();
2716
- return /^so,? you['’]?re saying\b/i.test(t) || /\b(is that right|is that correct|did i get (that|it) right|have i got (that|it) right)\s*\??\s*$/i.test(t);
2717
- }
2718
- function isAffirmativeReply(text) {
2719
- return /^(y|ya|yah|yes|yess|yeah|yep|yup|ok|okay|sure|correct|right|exactly|confirm(ed)?|that['’]?s (it|right|correct)|yes,? that['’]?s (it|right)|haan|han|ha|ho|hmm yes|👍)[\s.!👍]*$/i.test(
2720
- text.trim()
2721
- );
2722
- }
2723
- var AUTO_FILE_SECONDS = 3;
2724
2714
  var NARROW_QUERY = "(max-width: 640px)";
2725
2715
  function useIsNarrow() {
2726
2716
  const [narrow, setNarrow] = (0, import_react3.useState)(false);
@@ -2888,7 +2878,6 @@ function AssistSheet({
2888
2878
  const [phase, setPhase] = (0, import_react3.useState)(
2889
2879
  () => !typePicked ? "type" : currentTile === "RATING" ? "rating" : needsSeverity(currentTile) ? "severity" : "chat"
2890
2880
  );
2891
- const [autoFileLeft, setAutoFileLeft] = (0, import_react3.useState)(null);
2892
2881
  const scrollRef = (0, import_react3.useRef)(null);
2893
2882
  const draftRef = (0, import_react3.useRef)(null);
2894
2883
  const composerRef = (0, import_react3.useRef)(null);
@@ -2961,30 +2950,11 @@ function AssistSheet({
2961
2950
  el.style.height = "auto";
2962
2951
  el.style.height = `${el.scrollHeight + 2}px`;
2963
2952
  }, [input]);
2964
- (0, import_react3.useEffect)(() => {
2965
- if (autoFileLeft === null) return;
2966
- if (isSubmitting || submitted || phase !== "draft") {
2967
- setAutoFileLeft(null);
2968
- return;
2969
- }
2970
- if (autoFileLeft <= 0) {
2971
- sendDraft(true);
2972
- return;
2973
- }
2974
- const id = setTimeout(() => setAutoFileLeft((n) => n === null ? null : n - 1), 1e3);
2975
- return () => clearTimeout(id);
2976
- }, [autoFileLeft, isSubmitting, submitted, phase]);
2977
2953
  function markUp(index, shot) {
2978
2954
  if (!onAnnotateImage) return;
2979
- stopAutoFile("marked up an image");
2980
2955
  logEvent("image_markup", pageShot && shot === pageShot ? "page capture" : "attached");
2981
2956
  onAnnotateImage(index);
2982
2957
  }
2983
- function stopAutoFile(reason) {
2984
- if (autoFileLeft === null) return;
2985
- setAutoFileLeft(null);
2986
- logEvent("auto_file_stopped", reason);
2987
- }
2988
2958
  function degradeKeepingEvents(events, message, retryable) {
2989
2959
  if (events) eventsRef.current = [...events, ...eventsRef.current];
2990
2960
  flushEvents();
@@ -3004,11 +2974,10 @@ function AssistSheet({
3004
2974
  }
3005
2975
  onDescriptionChange(typed);
3006
2976
  }
3007
- async function runTurn(history2, autoFile = false) {
2977
+ async function runTurn(history2) {
3008
2978
  var _a2, _b, _c;
3009
2979
  const turnChat = chatIdRef.current;
3010
2980
  setBusy(true);
3011
- setAutoFileLeft(null);
3012
2981
  let result;
3013
2982
  const events = takeEvents();
3014
2983
  try {
@@ -3089,12 +3058,10 @@ function AssistSheet({
3089
3058
  return;
3090
3059
  }
3091
3060
  if (result.report) {
3092
- let tile = currentTile;
3093
3061
  if (!typePicked || inferredTypeRef.current) {
3094
3062
  const fallback = defaultTile();
3095
3063
  const inferred = result.reportType && tiles.includes(result.reportType) ? result.reportType : fallback;
3096
3064
  if (inferred) {
3097
- tile = inferred;
3098
3065
  inferredTypeRef.current = true;
3099
3066
  onPickType(inferred);
3100
3067
  }
@@ -3106,9 +3073,6 @@ function AssistSheet({
3106
3073
  setMessages([...history2, { role: "assistant", content: result.report, kind: "report" }]);
3107
3074
  setOptions([]);
3108
3075
  setPhase("draft");
3109
- if (autoFile && !attach && !(showSeverity && tile === "BUG" && !severity)) {
3110
- setAutoFileLeft(AUTO_FILE_SECONDS);
3111
- }
3112
3076
  return;
3113
3077
  }
3114
3078
  if (result.question) {
@@ -3151,13 +3115,7 @@ function AssistSheet({
3151
3115
  seedFromDescription();
3152
3116
  }
3153
3117
  }
3154
- function sendTyped(text) {
3155
- var _a2;
3156
- const lastAssistant = [...messages].reverse().find((m) => m.role === "assistant");
3157
- const checkingBack = options.includes(CONFIRM_OPTION) || (lastAssistant == null ? void 0 : lastAssistant.kind) !== "report" && isCheckBackQuestion((_a2 = lastAssistant == null ? void 0 : lastAssistant.content) != null ? _a2 : "");
3158
- send(text, checkingBack && isAffirmativeReply(text));
3159
- }
3160
- function send(text, autoFile = false) {
3118
+ function send(text) {
3161
3119
  const value = text.trim();
3162
3120
  if (!value || busy) return;
3163
3121
  setOptions([]);
@@ -3173,7 +3131,7 @@ function AssistSheet({
3173
3131
  const history2 = [...base, { role: "user", content: value }];
3174
3132
  setMessages(history2);
3175
3133
  setInput("");
3176
- void runTurn(history2, autoFile);
3134
+ void runTurn(history2);
3177
3135
  }
3178
3136
  function withCurrentDraft(history2) {
3179
3137
  const current = description.trim();
@@ -3186,10 +3144,9 @@ function AssistSheet({
3186
3144
  }
3187
3145
  return next;
3188
3146
  }
3189
- function sendDraft(auto = false) {
3190
- setAutoFileLeft(null);
3147
+ function sendDraft() {
3191
3148
  const edited = aiDraftRef.current !== null && description.trim() !== aiDraftRef.current.trim();
3192
- logEvent("draft_sent", auto ? "auto-filed" : edited ? "edited" : "as drafted");
3149
+ logEvent("draft_sent", edited ? "edited" : "as drafted");
3193
3150
  flushEvents();
3194
3151
  onSend();
3195
3152
  }
@@ -3232,7 +3189,6 @@ function AssistSheet({
3232
3189
  setDuplicate(null);
3233
3190
  onDuplicateChange == null ? void 0 : onDuplicateChange(null);
3234
3191
  setGlitchgrabOffer(false);
3235
- setAutoFileLeft(null);
3236
3192
  setInput("");
3237
3193
  if (chat.tile !== currentTile && tiles.includes(chat.tile)) {
3238
3194
  onPickType(chat.tile);
@@ -3265,7 +3221,6 @@ function AssistSheet({
3265
3221
  setDuplicate(null);
3266
3222
  onDuplicateChange == null ? void 0 : onDuplicateChange(null);
3267
3223
  setGlitchgrabOffer(false);
3268
- setAutoFileLeft(null);
3269
3224
  setInput("");
3270
3225
  onDescriptionChange("");
3271
3226
  onIssueTitleChange("");
@@ -3463,7 +3418,6 @@ function AssistSheet({
3463
3418
  @keyframes gg-sheet-in{from{transform:translateX(24px);opacity:0}to{transform:translateX(0);opacity:1}}
3464
3419
  @keyframes gg-sheet-up{from{transform:translateY(24px);opacity:0}to{transform:translateY(0);opacity:1}}
3465
3420
  @keyframes gg-sheet-fade{from{opacity:0}to{opacity:1}}
3466
- @keyframes gg-autofile{from{transform:scaleX(0)}to{transform:scaleX(1)}}
3467
3421
  @keyframes gg-spin{to{transform:rotate(360deg)}}
3468
3422
  @keyframes gg-dot{0%,80%,100%{transform:translateY(0);opacity:.4}40%{transform:translateY(-3px);opacity:1}}
3469
3423
  [data-gg-sheet-send]:focus-visible,[data-gg-chip]:focus-visible,[data-gg-assist-remove]:focus-visible,[data-gg-assist-annotate]:focus-visible,[data-gg-stop-auto-file]:focus-visible{outline:2px solid currentColor;outline-offset:2px}
@@ -4000,11 +3954,7 @@ function AssistSheet({
4000
3954
  color: t.text,
4001
3955
  border: live ? "none" : `1px solid ${t.accent}66`
4002
3956
  },
4003
- children: live ? (
4004
- // #402: "have a read" beside a countdown reads as a
4005
- // contradiction. Say what is about to happen instead.
4006
- autoFileLeft !== null ? "Here's your report \u2014 I'll file it unless you want to change something." : "Here's your report \u2014 have a read."
4007
- ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
3957
+ children: live ? "Here's your report \u2014 have a read. Nothing is sent until you send it." : /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
4008
3958
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4009
3959
  "span",
4010
3960
  {
@@ -4175,7 +4125,7 @@ function AssistSheet({
4175
4125
  "data-gg-option": "",
4176
4126
  onClick: () => {
4177
4127
  logEvent("option_tap", option);
4178
- send(option, option === CONFIRM_OPTION);
4128
+ send(option);
4179
4129
  },
4180
4130
  style: {
4181
4131
  border: primary ? "1px solid transparent" : `1px solid ${t.inputBorder}`,
@@ -4296,7 +4246,6 @@ function AssistSheet({
4296
4246
  if (e.key === "Enter") e.preventDefault();
4297
4247
  },
4298
4248
  onChange: (e) => {
4299
- stopAutoFile("edited the title");
4300
4249
  onIssueTitleChange(e.target.value.replace(/[\r\n]+/g, " "));
4301
4250
  },
4302
4251
  style: {
@@ -4322,7 +4271,6 @@ function AssistSheet({
4322
4271
  ref: draftRef,
4323
4272
  value: description,
4324
4273
  onChange: (e) => {
4325
- stopAutoFile("edited the draft");
4326
4274
  onDescriptionChange(e.target.value);
4327
4275
  },
4328
4276
  rows: 6,
@@ -4343,7 +4291,7 @@ function AssistSheet({
4343
4291
  }
4344
4292
  }
4345
4293
  ),
4346
- severityAsked && autoFileLeft === null && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
4294
+ severityAsked && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { children: [
4347
4295
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4348
4296
  "span",
4349
4297
  {
@@ -4631,7 +4579,6 @@ function AssistSheet({
4631
4579
  "aria-label": `Remove image ${i + 1}`,
4632
4580
  title: "Remove this image",
4633
4581
  onClick: () => {
4634
- stopAutoFile("changed attachments");
4635
4582
  logEvent(
4636
4583
  "image_removed",
4637
4584
  pageShot && shot === pageShot ? "page capture" : "attached"
@@ -4760,7 +4707,6 @@ function AssistSheet({
4760
4707
  "aria-label": `Remove file ${file.name}`,
4761
4708
  title: "Remove this file",
4762
4709
  onClick: () => {
4763
- stopAutoFile("changed attachments");
4764
4710
  logEvent("file_removed", read ? "read" : "not read");
4765
4711
  onRemoveFile(i);
4766
4712
  },
@@ -4843,7 +4789,6 @@ function AssistSheet({
4843
4789
  var _a2;
4844
4790
  const picked = Array.from((_a2 = e.target.files) != null ? _a2 : []);
4845
4791
  if (picked.length) {
4846
- stopAutoFile("changed attachments");
4847
4792
  const images = picked.filter((f) => f.type.startsWith("image/")).length;
4848
4793
  if (images) logEvent("image_added", String(images));
4849
4794
  if (picked.length > images) {
@@ -4875,13 +4820,12 @@ function AssistSheet({
4875
4820
  ref: composerRef,
4876
4821
  value: input,
4877
4822
  onChange: (e) => {
4878
- stopAutoFile("typing a change");
4879
4823
  setInput(e.target.value);
4880
4824
  },
4881
4825
  onKeyDown: (e) => {
4882
4826
  if (e.key === "Enter" && !e.shiftKey) {
4883
4827
  e.preventDefault();
4884
- sendTyped(input);
4828
+ send(input);
4885
4829
  }
4886
4830
  },
4887
4831
  placeholder: phase === "draft" ? "Anything to change? Tell me here\u2026" : phase === "type" ? "What went wrong, or what would you like? Type it here\u2026" : "Type your answer\u2026",
@@ -4911,7 +4855,7 @@ function AssistSheet({
4911
4855
  {
4912
4856
  type: "button",
4913
4857
  "data-gg-sheet-send": "",
4914
- onClick: () => sendTyped(input),
4858
+ onClick: () => send(input),
4915
4859
  disabled: busy || !input.trim(),
4916
4860
  "aria-label": "Send message",
4917
4861
  "data-gg-send-message": "",
@@ -4951,90 +4895,7 @@ function AssistSheet({
4951
4895
  children: validationError
4952
4896
  }
4953
4897
  ),
4954
- similarSlot ? similarSlot : autoFileLeft !== null ? (
4955
- // #402: "Yes, that's it" was the confirmation. The draft
4956
- // files itself unless they stop it — the bar shows how
4957
- // long is left, the button sends now, the × on its right
4958
- // stops it (#406). Stopping keeps the draft: Send Report
4959
- // comes back, and closing the sheet drops it.
4960
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", gap: "8px", marginTop: "8px" }, children: [
4961
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4962
- "button",
4963
- {
4964
- type: "button",
4965
- "data-gg-sheet-send": "",
4966
- "data-gg-auto-file": "",
4967
- onClick: () => sendDraft(),
4968
- style: {
4969
- flex: 1,
4970
- minWidth: 0,
4971
- position: "relative",
4972
- overflow: "hidden",
4973
- padding: "12px",
4974
- borderRadius: "10px",
4975
- border: "none",
4976
- backgroundColor: t.accent,
4977
- color: t.accentText,
4978
- fontSize: "14px",
4979
- fontWeight: 700,
4980
- fontFamily: "inherit",
4981
- cursor: "pointer"
4982
- },
4983
- children: [
4984
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4985
- "span",
4986
- {
4987
- "aria-hidden": "true",
4988
- style: {
4989
- position: "absolute",
4990
- inset: 0,
4991
- backgroundColor: "rgba(255,255,255,0.22)",
4992
- transformOrigin: "left",
4993
- animation: `gg-autofile ${AUTO_FILE_SECONDS}s linear forwards`
4994
- }
4995
- }
4996
- ),
4997
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { style: { position: "relative" }, children: [
4998
- "Filing in ",
4999
- autoFileLeft,
5000
- "s\u2026"
5001
- ] })
5002
- ]
5003
- }
5004
- ),
5005
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
5006
- "button",
5007
- {
5008
- type: "button",
5009
- "data-gg-stop-auto-file": "",
5010
- onClick: () => stopAutoFile("pressed stop"),
5011
- "aria-label": "Stop \u2014 don't send",
5012
- title: "Stop \u2014 don't send",
5013
- style: {
5014
- flexShrink: 0,
5015
- width: "44px",
5016
- borderRadius: "10px",
5017
- border: `1px solid ${t.inputBorder}`,
5018
- background: "transparent",
5019
- color: t.text,
5020
- display: "inline-flex",
5021
- alignItems: "center",
5022
- justifyContent: "center",
5023
- cursor: "pointer"
5024
- },
5025
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
5026
- "path",
5027
- {
5028
- d: "M6 6l12 12M18 6L6 18",
5029
- stroke: "currentColor",
5030
- strokeWidth: "2.25",
5031
- strokeLinecap: "round"
5032
- }
5033
- ) })
5034
- }
5035
- )
5036
- ] })
5037
- ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
4898
+ similarSlot ? similarSlot : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
5038
4899
  "button",
5039
4900
  {
5040
4901
  type: "button",