glitchgrab 1.62.4 → 1.63.0

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/dist/index.mjs CHANGED
@@ -860,7 +860,7 @@ async function enhanceTextOrThrow(text, token, baseUrl, screenshot, context, ide
860
860
  }
861
861
  throw new Error(unavailable);
862
862
  }
863
- async function findSimilarIssues(description, token, baseUrl, identity, files) {
863
+ async function findSimilarIssues(description, token, baseUrl, identity, files, conversationId) {
864
864
  var _a;
865
865
  try {
866
866
  const url = `${baseUrl != null ? baseUrl : DEFAULT_BASE_URL}/api/v1/reports/similar`;
@@ -873,6 +873,7 @@ async function findSimilarIssues(description, token, baseUrl, identity, files) {
873
873
  body: JSON.stringify({
874
874
  text: description,
875
875
  ...(files == null ? void 0 : files.length) ? { files } : {},
876
+ ...conversationId ? { conversationId } : {},
876
877
  ...signedFields(identity)
877
878
  })
878
879
  });
@@ -2652,16 +2653,6 @@ var STARTERS = [
2652
2653
  "I wish it could\u2026"
2653
2654
  ];
2654
2655
  var CONFIRM_OPTION = "Yes, that's it";
2655
- function isCheckBackQuestion(text) {
2656
- const t = text.trim();
2657
- 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);
2658
- }
2659
- function isAffirmativeReply(text) {
2660
- 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(
2661
- text.trim()
2662
- );
2663
- }
2664
- var AUTO_FILE_SECONDS = 3;
2665
2656
  var NARROW_QUERY = "(max-width: 640px)";
2666
2657
  function useIsNarrow() {
2667
2658
  const [narrow, setNarrow] = useState2(false);
@@ -2829,7 +2820,6 @@ function AssistSheet({
2829
2820
  const [phase, setPhase] = useState2(
2830
2821
  () => !typePicked ? "type" : currentTile === "RATING" ? "rating" : needsSeverity(currentTile) ? "severity" : "chat"
2831
2822
  );
2832
- const [autoFileLeft, setAutoFileLeft] = useState2(null);
2833
2823
  const scrollRef = useRef2(null);
2834
2824
  const draftRef = useRef2(null);
2835
2825
  const composerRef = useRef2(null);
@@ -2902,30 +2892,11 @@ function AssistSheet({
2902
2892
  el.style.height = "auto";
2903
2893
  el.style.height = `${el.scrollHeight + 2}px`;
2904
2894
  }, [input]);
2905
- useEffect2(() => {
2906
- if (autoFileLeft === null) return;
2907
- if (isSubmitting || submitted || phase !== "draft") {
2908
- setAutoFileLeft(null);
2909
- return;
2910
- }
2911
- if (autoFileLeft <= 0) {
2912
- sendDraft(true);
2913
- return;
2914
- }
2915
- const id = setTimeout(() => setAutoFileLeft((n) => n === null ? null : n - 1), 1e3);
2916
- return () => clearTimeout(id);
2917
- }, [autoFileLeft, isSubmitting, submitted, phase]);
2918
2895
  function markUp(index, shot) {
2919
2896
  if (!onAnnotateImage) return;
2920
- stopAutoFile("marked up an image");
2921
2897
  logEvent("image_markup", pageShot && shot === pageShot ? "page capture" : "attached");
2922
2898
  onAnnotateImage(index);
2923
2899
  }
2924
- function stopAutoFile(reason) {
2925
- if (autoFileLeft === null) return;
2926
- setAutoFileLeft(null);
2927
- logEvent("auto_file_stopped", reason);
2928
- }
2929
2900
  function degradeKeepingEvents(events, message, retryable) {
2930
2901
  if (events) eventsRef.current = [...events, ...eventsRef.current];
2931
2902
  flushEvents();
@@ -2945,11 +2916,10 @@ function AssistSheet({
2945
2916
  }
2946
2917
  onDescriptionChange(typed);
2947
2918
  }
2948
- async function runTurn(history2, autoFile = false) {
2919
+ async function runTurn(history2) {
2949
2920
  var _a2, _b, _c;
2950
2921
  const turnChat = chatIdRef.current;
2951
2922
  setBusy(true);
2952
- setAutoFileLeft(null);
2953
2923
  let result;
2954
2924
  const events = takeEvents();
2955
2925
  try {
@@ -3030,12 +3000,10 @@ function AssistSheet({
3030
3000
  return;
3031
3001
  }
3032
3002
  if (result.report) {
3033
- let tile = currentTile;
3034
3003
  if (!typePicked || inferredTypeRef.current) {
3035
3004
  const fallback = defaultTile();
3036
3005
  const inferred = result.reportType && tiles.includes(result.reportType) ? result.reportType : fallback;
3037
3006
  if (inferred) {
3038
- tile = inferred;
3039
3007
  inferredTypeRef.current = true;
3040
3008
  onPickType(inferred);
3041
3009
  }
@@ -3047,9 +3015,6 @@ function AssistSheet({
3047
3015
  setMessages([...history2, { role: "assistant", content: result.report, kind: "report" }]);
3048
3016
  setOptions([]);
3049
3017
  setPhase("draft");
3050
- if (autoFile && !attach && !(showSeverity && tile === "BUG" && !severity)) {
3051
- setAutoFileLeft(AUTO_FILE_SECONDS);
3052
- }
3053
3018
  return;
3054
3019
  }
3055
3020
  if (result.question) {
@@ -3092,13 +3057,7 @@ function AssistSheet({
3092
3057
  seedFromDescription();
3093
3058
  }
3094
3059
  }
3095
- function sendTyped(text) {
3096
- var _a2;
3097
- const lastAssistant = [...messages].reverse().find((m) => m.role === "assistant");
3098
- const checkingBack = options.includes(CONFIRM_OPTION) || (lastAssistant == null ? void 0 : lastAssistant.kind) !== "report" && isCheckBackQuestion((_a2 = lastAssistant == null ? void 0 : lastAssistant.content) != null ? _a2 : "");
3099
- send(text, checkingBack && isAffirmativeReply(text));
3100
- }
3101
- function send(text, autoFile = false) {
3060
+ function send(text) {
3102
3061
  const value = text.trim();
3103
3062
  if (!value || busy) return;
3104
3063
  setOptions([]);
@@ -3114,7 +3073,7 @@ function AssistSheet({
3114
3073
  const history2 = [...base, { role: "user", content: value }];
3115
3074
  setMessages(history2);
3116
3075
  setInput("");
3117
- void runTurn(history2, autoFile);
3076
+ void runTurn(history2);
3118
3077
  }
3119
3078
  function withCurrentDraft(history2) {
3120
3079
  const current = description.trim();
@@ -3127,10 +3086,9 @@ function AssistSheet({
3127
3086
  }
3128
3087
  return next;
3129
3088
  }
3130
- function sendDraft(auto = false) {
3131
- setAutoFileLeft(null);
3089
+ function sendDraft() {
3132
3090
  const edited = aiDraftRef.current !== null && description.trim() !== aiDraftRef.current.trim();
3133
- logEvent("draft_sent", auto ? "auto-filed" : edited ? "edited" : "as drafted");
3091
+ logEvent("draft_sent", edited ? "edited" : "as drafted");
3134
3092
  flushEvents();
3135
3093
  onSend();
3136
3094
  }
@@ -3173,7 +3131,6 @@ function AssistSheet({
3173
3131
  setDuplicate(null);
3174
3132
  onDuplicateChange == null ? void 0 : onDuplicateChange(null);
3175
3133
  setGlitchgrabOffer(false);
3176
- setAutoFileLeft(null);
3177
3134
  setInput("");
3178
3135
  if (chat.tile !== currentTile && tiles.includes(chat.tile)) {
3179
3136
  onPickType(chat.tile);
@@ -3206,7 +3163,6 @@ function AssistSheet({
3206
3163
  setDuplicate(null);
3207
3164
  onDuplicateChange == null ? void 0 : onDuplicateChange(null);
3208
3165
  setGlitchgrabOffer(false);
3209
- setAutoFileLeft(null);
3210
3166
  setInput("");
3211
3167
  onDescriptionChange("");
3212
3168
  onIssueTitleChange("");
@@ -3404,7 +3360,6 @@ function AssistSheet({
3404
3360
  @keyframes gg-sheet-in{from{transform:translateX(24px);opacity:0}to{transform:translateX(0);opacity:1}}
3405
3361
  @keyframes gg-sheet-up{from{transform:translateY(24px);opacity:0}to{transform:translateY(0);opacity:1}}
3406
3362
  @keyframes gg-sheet-fade{from{opacity:0}to{opacity:1}}
3407
- @keyframes gg-autofile{from{transform:scaleX(0)}to{transform:scaleX(1)}}
3408
3363
  @keyframes gg-spin{to{transform:rotate(360deg)}}
3409
3364
  @keyframes gg-dot{0%,80%,100%{transform:translateY(0);opacity:.4}40%{transform:translateY(-3px);opacity:1}}
3410
3365
  [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}
@@ -3941,11 +3896,7 @@ function AssistSheet({
3941
3896
  color: t.text,
3942
3897
  border: live ? "none" : `1px solid ${t.accent}66`
3943
3898
  },
3944
- children: live ? (
3945
- // #402: "have a read" beside a countdown reads as a
3946
- // contradiction. Say what is about to happen instead.
3947
- 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."
3948
- ) : /* @__PURE__ */ jsxs3(Fragment2, { children: [
3899
+ children: live ? "Here's your report \u2014 have a read. Nothing is sent until you send it." : /* @__PURE__ */ jsxs3(Fragment2, { children: [
3949
3900
  /* @__PURE__ */ jsx3(
3950
3901
  "span",
3951
3902
  {
@@ -4116,7 +4067,7 @@ function AssistSheet({
4116
4067
  "data-gg-option": "",
4117
4068
  onClick: () => {
4118
4069
  logEvent("option_tap", option);
4119
- send(option, option === CONFIRM_OPTION);
4070
+ send(option);
4120
4071
  },
4121
4072
  style: {
4122
4073
  border: primary ? "1px solid transparent" : `1px solid ${t.inputBorder}`,
@@ -4237,7 +4188,6 @@ function AssistSheet({
4237
4188
  if (e.key === "Enter") e.preventDefault();
4238
4189
  },
4239
4190
  onChange: (e) => {
4240
- stopAutoFile("edited the title");
4241
4191
  onIssueTitleChange(e.target.value.replace(/[\r\n]+/g, " "));
4242
4192
  },
4243
4193
  style: {
@@ -4263,7 +4213,6 @@ function AssistSheet({
4263
4213
  ref: draftRef,
4264
4214
  value: description,
4265
4215
  onChange: (e) => {
4266
- stopAutoFile("edited the draft");
4267
4216
  onDescriptionChange(e.target.value);
4268
4217
  },
4269
4218
  rows: 6,
@@ -4284,7 +4233,7 @@ function AssistSheet({
4284
4233
  }
4285
4234
  }
4286
4235
  ),
4287
- severityAsked && autoFileLeft === null && /* @__PURE__ */ jsxs3("div", { children: [
4236
+ severityAsked && /* @__PURE__ */ jsxs3("div", { children: [
4288
4237
  /* @__PURE__ */ jsxs3(
4289
4238
  "span",
4290
4239
  {
@@ -4572,7 +4521,6 @@ function AssistSheet({
4572
4521
  "aria-label": `Remove image ${i + 1}`,
4573
4522
  title: "Remove this image",
4574
4523
  onClick: () => {
4575
- stopAutoFile("changed attachments");
4576
4524
  logEvent(
4577
4525
  "image_removed",
4578
4526
  pageShot && shot === pageShot ? "page capture" : "attached"
@@ -4701,7 +4649,6 @@ function AssistSheet({
4701
4649
  "aria-label": `Remove file ${file.name}`,
4702
4650
  title: "Remove this file",
4703
4651
  onClick: () => {
4704
- stopAutoFile("changed attachments");
4705
4652
  logEvent("file_removed", read ? "read" : "not read");
4706
4653
  onRemoveFile(i);
4707
4654
  },
@@ -4784,7 +4731,6 @@ function AssistSheet({
4784
4731
  var _a2;
4785
4732
  const picked = Array.from((_a2 = e.target.files) != null ? _a2 : []);
4786
4733
  if (picked.length) {
4787
- stopAutoFile("changed attachments");
4788
4734
  const images = picked.filter((f) => f.type.startsWith("image/")).length;
4789
4735
  if (images) logEvent("image_added", String(images));
4790
4736
  if (picked.length > images) {
@@ -4816,13 +4762,12 @@ function AssistSheet({
4816
4762
  ref: composerRef,
4817
4763
  value: input,
4818
4764
  onChange: (e) => {
4819
- stopAutoFile("typing a change");
4820
4765
  setInput(e.target.value);
4821
4766
  },
4822
4767
  onKeyDown: (e) => {
4823
4768
  if (e.key === "Enter" && !e.shiftKey) {
4824
4769
  e.preventDefault();
4825
- sendTyped(input);
4770
+ send(input);
4826
4771
  }
4827
4772
  },
4828
4773
  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",
@@ -4852,7 +4797,7 @@ function AssistSheet({
4852
4797
  {
4853
4798
  type: "button",
4854
4799
  "data-gg-sheet-send": "",
4855
- onClick: () => sendTyped(input),
4800
+ onClick: () => send(input),
4856
4801
  disabled: busy || !input.trim(),
4857
4802
  "aria-label": "Send message",
4858
4803
  "data-gg-send-message": "",
@@ -4892,90 +4837,7 @@ function AssistSheet({
4892
4837
  children: validationError
4893
4838
  }
4894
4839
  ),
4895
- similarSlot ? similarSlot : autoFileLeft !== null ? (
4896
- // #402: "Yes, that's it" was the confirmation. The draft
4897
- // files itself unless they stop it — the bar shows how
4898
- // long is left, the button sends now, the × on its right
4899
- // stops it (#406). Stopping keeps the draft: Send Report
4900
- // comes back, and closing the sheet drops it.
4901
- /* @__PURE__ */ jsxs3("div", { style: { display: "flex", gap: "8px", marginTop: "8px" }, children: [
4902
- /* @__PURE__ */ jsxs3(
4903
- "button",
4904
- {
4905
- type: "button",
4906
- "data-gg-sheet-send": "",
4907
- "data-gg-auto-file": "",
4908
- onClick: () => sendDraft(),
4909
- style: {
4910
- flex: 1,
4911
- minWidth: 0,
4912
- position: "relative",
4913
- overflow: "hidden",
4914
- padding: "12px",
4915
- borderRadius: "10px",
4916
- border: "none",
4917
- backgroundColor: t.accent,
4918
- color: t.accentText,
4919
- fontSize: "14px",
4920
- fontWeight: 700,
4921
- fontFamily: "inherit",
4922
- cursor: "pointer"
4923
- },
4924
- children: [
4925
- /* @__PURE__ */ jsx3(
4926
- "span",
4927
- {
4928
- "aria-hidden": "true",
4929
- style: {
4930
- position: "absolute",
4931
- inset: 0,
4932
- backgroundColor: "rgba(255,255,255,0.22)",
4933
- transformOrigin: "left",
4934
- animation: `gg-autofile ${AUTO_FILE_SECONDS}s linear forwards`
4935
- }
4936
- }
4937
- ),
4938
- /* @__PURE__ */ jsxs3("span", { style: { position: "relative" }, children: [
4939
- "Filing in ",
4940
- autoFileLeft,
4941
- "s\u2026"
4942
- ] })
4943
- ]
4944
- }
4945
- ),
4946
- /* @__PURE__ */ jsx3(
4947
- "button",
4948
- {
4949
- type: "button",
4950
- "data-gg-stop-auto-file": "",
4951
- onClick: () => stopAutoFile("pressed stop"),
4952
- "aria-label": "Stop \u2014 don't send",
4953
- title: "Stop \u2014 don't send",
4954
- style: {
4955
- flexShrink: 0,
4956
- width: "44px",
4957
- borderRadius: "10px",
4958
- border: `1px solid ${t.inputBorder}`,
4959
- background: "transparent",
4960
- color: t.text,
4961
- display: "inline-flex",
4962
- alignItems: "center",
4963
- justifyContent: "center",
4964
- cursor: "pointer"
4965
- },
4966
- children: /* @__PURE__ */ jsx3("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx3(
4967
- "path",
4968
- {
4969
- d: "M6 6l12 12M18 6L6 18",
4970
- stroke: "currentColor",
4971
- strokeWidth: "2.25",
4972
- strokeLinecap: "round"
4973
- }
4974
- ) })
4975
- }
4976
- )
4977
- ] })
4978
- ) : /* @__PURE__ */ jsx3(
4840
+ similarSlot ? similarSlot : /* @__PURE__ */ jsx3(
4979
4841
  "button",
4980
4842
  {
4981
4843
  type: "button",
@@ -6695,8 +6557,10 @@ function ReportDialog({
6695
6557
  setIsSubmitting(true);
6696
6558
  setCheckingSimilar(true);
6697
6559
  const matches = await Promise.race([
6698
- // A PDF still being read is left out rather than waited for.
6699
- (similarFiles.length ? findSimilarIssues2(description.trim(), similarFiles) : findSimilarIssues2(description.trim())).catch(() => null),
6560
+ // A PDF still being read is left out rather than waited for. A draft
6561
+ // from the sheet names its chat, so an issue the reporter already
6562
+ // turned down there is not offered again (#697).
6563
+ (aiConversationId ? findSimilarIssues2(description.trim(), similarFiles.length ? similarFiles : void 0, aiConversationId) : similarFiles.length ? findSimilarIssues2(description.trim(), similarFiles) : findSimilarIssues2(description.trim())).catch(() => null),
6700
6564
  new Promise((resolve) => setTimeout(() => resolve(null), SIMILAR_WAIT_MS))
6701
6565
  ]);
6702
6566
  setCheckingSimilar(false);
@@ -11006,7 +10870,7 @@ function GlitchgrabProviderInner({
11006
10870
  [token, baseUrl, session]
11007
10871
  );
11008
10872
  const findSimilar = useCallback3(
11009
- (description, files) => findSimilarIssues(description, token, baseUrl, identity, files),
10873
+ (description, files, conversationId) => findSimilarIssues(description, token, baseUrl, identity, files, conversationId),
11010
10874
  [token, baseUrl, identity]
11011
10875
  );
11012
10876
  const readFile = useCallback3(