glitchgrab 1.62.0 → 1.62.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.
package/dist/index.mjs CHANGED
@@ -70,6 +70,16 @@ import {
70
70
  import * as React from "react";
71
71
 
72
72
  // ../report-ui/dist/assist-response.mjs
73
+ var REPORT_TYPES = [
74
+ "BUG",
75
+ "FEATURE_REQUEST",
76
+ "UI_IMPROVEMENT",
77
+ "PERFORMANCE",
78
+ "SECURITY",
79
+ "QUESTION",
80
+ "OTHER",
81
+ "VIDEO_SCRIPT"
82
+ ];
73
83
  var ASSIST_OFFLINE_MESSAGE = "The assistant is unavailable \u2014 write your report below and send it as normal.";
74
84
  function assistOffline() {
75
85
  return { conversationId: null, question: null, report: null, degraded: ASSIST_OFFLINE_MESSAGE };
@@ -83,7 +93,8 @@ function toAssistTurnResult(ok, body) {
83
93
  // The server words why (cap, rate limit, switched off). An hourly limit
84
94
  // keeps the assistant button for this report.
85
95
  degraded: (_a = envelope == null ? void 0 : envelope.error) != null ? _a : ASSIST_OFFLINE_MESSAGE,
86
- retryable: (envelope == null ? void 0 : envelope.retryable) === true
96
+ retryable: (envelope == null ? void 0 : envelope.retryable) === true,
97
+ ...(envelope == null ? void 0 : envelope.resendImages) === true ? { resendImages: true } : {}
87
98
  };
88
99
  }
89
100
  const d = (_b = envelope.data) != null ? _b : {};
@@ -93,13 +104,54 @@ function toAssistTurnResult(ok, body) {
93
104
  options: Array.isArray(d.options) ? d.options.filter((o) => typeof o === "string") : [],
94
105
  report: (_e = d.report) != null ? _e : null,
95
106
  title: typeof d.title === "string" && d.title.trim() ? d.title.trim() : null,
107
+ reportType: REPORT_TYPES.includes(d.reportType) ? d.reportType : null,
96
108
  duplicate: (_f = d.duplicate) != null ? _f : null,
97
109
  related: (_g = d.related) != null ? _g : null,
98
110
  solved: (_h = d.solved) != null ? _h : null,
99
111
  aboutGlitchgrab: d.aboutGlitchgrab === true,
112
+ storedImages: Array.isArray(d.storedImages) ? d.storedImages.filter((h) => typeof h === "string") : [],
100
113
  degraded: null
101
114
  };
102
115
  }
116
+ async function postJson(url, body, options = {}) {
117
+ var _a;
118
+ const headers = { "Content-Type": "application/json", ...(_a = options.headers) != null ? _a : {} };
119
+ const payload = JSON.stringify(body);
120
+ const onProgress = options.onUploadProgress;
121
+ if (onProgress && typeof XMLHttpRequest !== "undefined") {
122
+ return new Promise((resolve) => {
123
+ try {
124
+ const xhr = new XMLHttpRequest();
125
+ xhr.open("POST", url);
126
+ for (const [name, value] of Object.entries(headers)) xhr.setRequestHeader(name, value);
127
+ xhr.upload.onprogress = (e) => {
128
+ if (e.lengthComputable && e.total > 0) onProgress(Math.min(1, e.loaded / e.total));
129
+ };
130
+ xhr.upload.onload = () => onProgress(1);
131
+ xhr.onload = () => {
132
+ let parsed = null;
133
+ try {
134
+ parsed = JSON.parse(xhr.responseText);
135
+ } catch (e) {
136
+ parsed = null;
137
+ }
138
+ resolve({ ok: xhr.status >= 200 && xhr.status < 300, body: parsed });
139
+ };
140
+ xhr.onerror = () => resolve({ ok: false, body: null });
141
+ xhr.onabort = () => resolve({ ok: false, body: null });
142
+ xhr.send(payload);
143
+ } catch (e) {
144
+ resolve({ ok: false, body: null });
145
+ }
146
+ });
147
+ }
148
+ try {
149
+ const res = await fetch(url, { method: "POST", headers, body: payload });
150
+ return { ok: res.ok, body: await res.json().catch(() => null) };
151
+ } catch (e) {
152
+ return { ok: false, body: null };
153
+ }
154
+ }
103
155
 
104
156
  // src/redact.ts
105
157
  var SENSITIVE_KEY_RE = /(pass|pwd|secret|token|auth|session|cookie|credential|apikey|api_key|access_key|private|signature|otp|pin|cvv|card|ssn|aadhaar|pan)/i;
@@ -851,19 +903,15 @@ async function readAttachment(file, token, baseUrl, identity) {
851
903
  return null;
852
904
  }
853
905
  }
854
- async function assistTurn(params, token, baseUrl) {
906
+ async function assistTurn(params, token, baseUrl, onUploadProgress) {
855
907
  const offline = assistOffline();
856
908
  try {
857
909
  const url = `${baseUrl != null ? baseUrl : DEFAULT_BASE_URL}/api/v1/ai/report-chat`;
858
- const response = await fetch(url, {
859
- method: "POST",
860
- headers: {
861
- "Content-Type": "application/json",
862
- Authorization: `Bearer ${token}`
863
- },
864
- body: JSON.stringify(params)
910
+ const response = await postJson(url, params, {
911
+ headers: { Authorization: `Bearer ${token}` },
912
+ onUploadProgress
865
913
  });
866
- return toAssistTurnResult(response.ok, await response.json().catch(() => null));
914
+ return toAssistTurnResult(response.ok, response.body);
867
915
  } catch (e) {
868
916
  return offline;
869
917
  }
@@ -2029,24 +2077,67 @@ function filesForSimilar(files, each, total) {
2029
2077
  }
2030
2078
  return picked;
2031
2079
  }
2032
- function getTypeLabel(type) {
2033
- switch (type) {
2034
- case "RATING":
2035
- return "Rating";
2036
- case "BUG":
2037
- return "Bug Report";
2038
- case "FEATURE_REQUEST":
2039
- return "Feature Request";
2040
- case "UI_IMPROVEMENT":
2041
- return "UI Improvement";
2042
- case "PERFORMANCE":
2043
- return "Performance";
2044
- case "SECURITY":
2045
- return "Security";
2046
- case "QUESTION":
2047
- return "Question";
2048
- case "OTHER":
2049
- return "Other";
2080
+ var ASSIST_IMAGE_REF_PREFIX = "gg-ref:";
2081
+ var ASSIST_IMAGE_MAX_EDGE = 1600;
2082
+ var ASSIST_IMAGE_QUALITY = 0.8;
2083
+ function pickAssistImages(all) {
2084
+ const picked = [];
2085
+ let total = 0;
2086
+ for (let i = all.length - 1; i >= 0 && picked.length < MAX_ASSIST_IMAGES; i--) {
2087
+ const image = all[i];
2088
+ if (total + image.send.length > MAX_ASSIST_IMAGE_CHARS) continue;
2089
+ picked.unshift(image);
2090
+ total += image.send.length;
2091
+ }
2092
+ return picked;
2093
+ }
2094
+ async function sha256Hex(text) {
2095
+ var _a;
2096
+ try {
2097
+ const subtle = (_a = globalThis.crypto) == null ? void 0 : _a.subtle;
2098
+ if (!subtle) return null;
2099
+ const digest = await subtle.digest("SHA-256", new TextEncoder().encode(text));
2100
+ return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("");
2101
+ } catch (e) {
2102
+ return null;
2103
+ }
2104
+ }
2105
+ async function toSendList(picked, stored) {
2106
+ let hasData = false;
2107
+ const screenshots = await Promise.all(
2108
+ picked.map(async (image) => {
2109
+ const hash = stored.size > 0 ? await sha256Hex(image.send) : null;
2110
+ if (hash && stored.has(hash)) return `${ASSIST_IMAGE_REF_PREFIX}${hash}`;
2111
+ hasData = true;
2112
+ return image.send;
2113
+ })
2114
+ );
2115
+ return { screenshots, hasData };
2116
+ }
2117
+ async function shrinkForAssist(dataUrl) {
2118
+ try {
2119
+ if (typeof document === "undefined" || typeof createImageBitmap !== "function") return dataUrl;
2120
+ const blob = await (await fetch(dataUrl)).blob();
2121
+ const bitmap = await createImageBitmap(blob);
2122
+ try {
2123
+ const scale = Math.min(1, ASSIST_IMAGE_MAX_EDGE / Math.max(bitmap.width, bitmap.height));
2124
+ const canvas = document.createElement("canvas");
2125
+ canvas.width = Math.max(1, Math.round(bitmap.width * scale));
2126
+ canvas.height = Math.max(1, Math.round(bitmap.height * scale));
2127
+ const ctx = canvas.getContext("2d");
2128
+ if (!ctx) return dataUrl;
2129
+ ctx.fillStyle = "#ffffff";
2130
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
2131
+ ctx.imageSmoothingEnabled = true;
2132
+ ctx.imageSmoothingQuality = "high";
2133
+ ctx.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
2134
+ const shrunk = canvas.toDataURL("image/jpeg", ASSIST_IMAGE_QUALITY);
2135
+ return shrunk.length < dataUrl.length ? shrunk : dataUrl;
2136
+ } finally {
2137
+ bitmap.close();
2138
+ }
2139
+ } catch (e) {
2140
+ return dataUrl;
2050
2141
  }
2051
2142
  }
2052
2143
  var CODE = /`([^`\n]+)`/y;
@@ -2528,17 +2619,6 @@ function removeChat(key, id, now = Date.now()) {
2528
2619
  write(key, next);
2529
2620
  return next;
2530
2621
  }
2531
- function pickAssistImages(all) {
2532
- const picked = [];
2533
- let total = 0;
2534
- for (let i = all.length - 1; i >= 0 && picked.length < MAX_ASSIST_IMAGES; i--) {
2535
- const shot = all[i];
2536
- if (total + shot.length > MAX_ASSIST_IMAGE_CHARS) continue;
2537
- picked.unshift(shot);
2538
- total += shot.length;
2539
- }
2540
- return picked;
2541
- }
2542
2622
  var NO_FILES = [];
2543
2623
  function pickAssistFiles(files) {
2544
2624
  const picked = [];
@@ -2726,6 +2806,14 @@ function AssistSheet({
2726
2806
  const [input, setInput] = useState2("");
2727
2807
  const [busy, setBusy] = useState2(false);
2728
2808
  const [conversationId, setConversationId] = useState2(null);
2809
+ const [uploadProgress, setUploadProgress] = useState2(null);
2810
+ const storedImagesRef = useRef2({
2811
+ conversationId: null,
2812
+ hashes: /* @__PURE__ */ new Set()
2813
+ });
2814
+ const shrunkRef = useRef2(/* @__PURE__ */ new Map());
2815
+ const shrinkingRef = useRef2(/* @__PURE__ */ new Set());
2816
+ const [, setShrunkCount] = useState2(0);
2729
2817
  const chatIdRef = useRef2(newChatId());
2730
2818
  const [savedChats, setSavedChats] = useState2(
2731
2819
  () => historyKey ? loadChats(historyKey) : []
@@ -2747,7 +2835,9 @@ function AssistSheet({
2747
2835
  const composerRef = useRef2(null);
2748
2836
  const seededRef = useRef2(false);
2749
2837
  const seedPendingRef = useRef2(false);
2838
+ const resumeAskRef = useRef2(false);
2750
2839
  const eventsRef = useRef2([]);
2840
+ const inferredTypeRef = useRef2(false);
2751
2841
  const aiDraftRef = useRef2(null);
2752
2842
  function logEvent(type, detail) {
2753
2843
  eventsRef.current.push({ type, at: Date.now(), ...detail ? { detail } : {} });
@@ -2770,13 +2860,33 @@ function AssistSheet({
2770
2860
  } catch (e) {
2771
2861
  }
2772
2862
  }
2773
- const readShots = new Set(pickAssistImages(screenshots));
2863
+ useEffect2(() => {
2864
+ for (const shot of screenshots) {
2865
+ if (shrunkRef.current.has(shot) || shrinkingRef.current.has(shot)) continue;
2866
+ shrinkingRef.current.add(shot);
2867
+ void shrinkForAssist(shot).then((copy) => {
2868
+ shrinkingRef.current.delete(shot);
2869
+ shrunkRef.current.set(shot, copy);
2870
+ setShrunkCount((n) => n + 1);
2871
+ });
2872
+ }
2873
+ }, [screenshots]);
2874
+ function assistImages() {
2875
+ return screenshots.map((original) => {
2876
+ var _a2;
2877
+ return {
2878
+ original,
2879
+ send: (_a2 = shrunkRef.current.get(original)) != null ? _a2 : original
2880
+ };
2881
+ });
2882
+ }
2883
+ const readShots = new Set(pickAssistImages(assistImages()).map((image) => image.original));
2774
2884
  const sentFiles = useMemo(() => pickAssistFiles(files), [files]);
2775
2885
  const readFiles = new Set(sentFiles.map((f) => f.index));
2776
- function leave(type, detail) {
2886
+ function leave(type, detail, exit = onClose) {
2777
2887
  logEvent(type, detail);
2778
2888
  flushEvents();
2779
- onClose();
2889
+ exit();
2780
2890
  }
2781
2891
  useEffect2(() => {
2782
2892
  const el = scrollRef.current;
@@ -2821,6 +2931,20 @@ function AssistSheet({
2821
2931
  flushEvents();
2822
2932
  onDegrade(message, retryable);
2823
2933
  }
2934
+ function defaultTile() {
2935
+ return tiles.includes("BUG") ? "BUG" : tiles.find((x) => x !== "RATING");
2936
+ }
2937
+ function keepTypedForForm(history2) {
2938
+ if (typePicked && !inferredTypeRef.current || description.trim()) return;
2939
+ const typed = history2.filter((m) => m.role === "user").map((m) => m.content).join("\n\n");
2940
+ if (!typed) return;
2941
+ const fallback = defaultTile();
2942
+ if (fallback) {
2943
+ inferredTypeRef.current = true;
2944
+ onPickType(fallback);
2945
+ }
2946
+ onDescriptionChange(typed);
2947
+ }
2824
2948
  async function runTurn(history2, autoFile = false) {
2825
2949
  var _a2, _b, _c;
2826
2950
  const turnChat = chatIdRef.current;
@@ -2829,29 +2953,53 @@ function AssistSheet({
2829
2953
  let result;
2830
2954
  const events = takeEvents();
2831
2955
  try {
2832
- const sent = pickAssistImages(screenshots);
2833
- result = await assist({
2834
- // `kind` only on drafts, so an older server sees the exact shape it
2835
- // always did — it just learns the draft text now instead of a
2836
- // placeholder line.
2837
- messages: history2.map(
2838
- (m) => m.kind ? { role: m.role, content: m.content, kind: m.kind } : m
2839
- ),
2840
- conversationId,
2841
- screenshots: sent,
2842
- // Only when there is something: an older server then sees the body
2843
- // it always did.
2844
- ...sentFiles.length > 0 ? { files: sentFiles.map((f) => f.file) } : {},
2845
- context: {
2846
- ...context != null ? context : {},
2847
- imageSources: sent.map((shot) => pageShot && shot === pageShot ? "page" : "attached"),
2848
- // Whether this dialog can open the #366 panel at all. A hint — the
2849
- // server decides whether the model may offer it.
2850
- canReportGlitchgrab: !!onReportGlitchgrabProblem
2851
- },
2852
- events
2853
- });
2956
+ const picked = pickAssistImages(assistImages());
2957
+ const held = storedImagesRef.current;
2958
+ const stored = conversationId && held.conversationId === conversationId ? held.hashes : /* @__PURE__ */ new Set();
2959
+ const call = async (known) => {
2960
+ const { screenshots: sent, hasData } = await toSendList(picked, known);
2961
+ setUploadProgress(null);
2962
+ return assist(
2963
+ {
2964
+ // `kind` only on drafts, so an older server sees the exact shape it
2965
+ // always did — it just learns the draft text now instead of a
2966
+ // placeholder line.
2967
+ messages: history2.map(
2968
+ (m) => m.kind ? { role: m.role, content: m.content, kind: m.kind } : m
2969
+ ),
2970
+ conversationId,
2971
+ screenshots: sent,
2972
+ // Only when there is something: an older server then sees the body
2973
+ // it always did.
2974
+ ...sentFiles.length > 0 ? { files: sentFiles.map((f) => f.file) } : {},
2975
+ context: {
2976
+ ...context != null ? context : {},
2977
+ // Labelled off the originals: the page shot's copy is still the page.
2978
+ imageSources: picked.map(
2979
+ (image) => pageShot && image.original === pageShot ? "page" : "attached"
2980
+ ),
2981
+ // Whether this dialog can open the #366 panel at all. A hint — the
2982
+ // server decides whether the model may offer it.
2983
+ canReportGlitchgrab: !!onReportGlitchgrabProblem
2984
+ },
2985
+ events
2986
+ },
2987
+ hasData ? { onUploadProgress: setUploadProgress } : void 0
2988
+ );
2989
+ };
2990
+ result = await call(stored);
2991
+ if (result.resendImages) {
2992
+ storedImagesRef.current = { conversationId: null, hashes: /* @__PURE__ */ new Set() };
2993
+ result = await call(/* @__PURE__ */ new Set());
2994
+ }
2995
+ if (result.conversationId && result.storedImages) {
2996
+ storedImagesRef.current = {
2997
+ conversationId: result.conversationId,
2998
+ hashes: new Set(result.storedImages)
2999
+ };
3000
+ }
2854
3001
  } catch (e) {
3002
+ keepTypedForForm(history2);
2855
3003
  degradeKeepingEvents(
2856
3004
  events,
2857
3005
  "The assistant is unavailable \u2014 write your report below and send it as normal."
@@ -2859,9 +3007,11 @@ function AssistSheet({
2859
3007
  return;
2860
3008
  } finally {
2861
3009
  setBusy(false);
3010
+ setUploadProgress(null);
2862
3011
  }
2863
3012
  if (chatIdRef.current !== turnChat) return;
2864
3013
  if (result.degraded) {
3014
+ keepTypedForForm(history2);
2865
3015
  degradeKeepingEvents(events, result.degraded, result.retryable === true);
2866
3016
  return;
2867
3017
  }
@@ -2880,6 +3030,16 @@ function AssistSheet({
2880
3030
  return;
2881
3031
  }
2882
3032
  if (result.report) {
3033
+ let tile = currentTile;
3034
+ if (!typePicked || inferredTypeRef.current) {
3035
+ const fallback = defaultTile();
3036
+ const inferred = result.reportType && tiles.includes(result.reportType) ? result.reportType : fallback;
3037
+ if (inferred) {
3038
+ tile = inferred;
3039
+ inferredTypeRef.current = true;
3040
+ onPickType(inferred);
3041
+ }
3042
+ }
2883
3043
  onDescriptionChange(result.report);
2884
3044
  onIssueTitleChange((_b = result.title) != null ? _b : "");
2885
3045
  aiDraftRef.current = result.report;
@@ -2887,7 +3047,7 @@ function AssistSheet({
2887
3047
  setMessages([...history2, { role: "assistant", content: result.report, kind: "report" }]);
2888
3048
  setOptions([]);
2889
3049
  setPhase("draft");
2890
- if (autoFile && !attach && !(severityAsked && !severity)) {
3050
+ if (autoFile && !attach && !(showSeverity && tile === "BUG" && !severity)) {
2891
3051
  setAutoFileLeft(AUTO_FILE_SECONDS);
2892
3052
  }
2893
3053
  return;
@@ -2897,12 +3057,20 @@ function AssistSheet({
2897
3057
  setOptions((_c = result.options) != null ? _c : []);
2898
3058
  return;
2899
3059
  }
3060
+ keepTypedForForm(history2);
2900
3061
  onDegrade("The assistant had nothing to add \u2014 write your report below and send it as normal.");
2901
3062
  }
2902
3063
  useEffect2(() => {
2903
3064
  if (seededRef.current) return;
2904
3065
  seededRef.current = true;
2905
- if (!typePicked || currentTile === "RATING") return;
3066
+ if (typePicked && currentTile === "RATING") return;
3067
+ if (!typePicked) {
3068
+ if (description.trim()) {
3069
+ setPhase("chat");
3070
+ seedFromDescription();
3071
+ }
3072
+ return;
3073
+ }
2906
3074
  if (phase === "severity") {
2907
3075
  seedPendingRef.current = true;
2908
3076
  return;
@@ -2936,6 +3104,7 @@ function AssistSheet({
2936
3104
  setOptions([]);
2937
3105
  setGlitchgrabOffer(false);
2938
3106
  const underDraft = phase === "draft";
3107
+ if (phase === "type") setPhase("chat");
2939
3108
  if (underDraft) {
2940
3109
  const edited = aiDraftRef.current !== null && description.trim() !== aiDraftRef.current.trim();
2941
3110
  logEvent("keep_chatting", edited ? "after editing" : void 0);
@@ -2947,10 +3116,6 @@ function AssistSheet({
2947
3116
  setInput("");
2948
3117
  void runTurn(history2, autoFile);
2949
3118
  }
2950
- function pickType(tile) {
2951
- onPickType(tile);
2952
- setPhase(tile === "RATING" ? "rating" : needsSeverity(tile) ? "severity" : "chat");
2953
- }
2954
3119
  function withCurrentDraft(history2) {
2955
3120
  const current = description.trim();
2956
3121
  const next = [...history2];
@@ -3024,7 +3189,13 @@ function AssistSheet({
3024
3189
  }
3025
3190
  setShowChats(false);
3026
3191
  setViewingChat(null);
3192
+ resumeAskRef.current = (last == null ? void 0 : last.role) === "user";
3027
3193
  }
3194
+ useEffect2(() => {
3195
+ if (!resumeAskRef.current) return;
3196
+ resumeAskRef.current = false;
3197
+ void runTurn(messages);
3198
+ }, [messages]);
3028
3199
  function startNewChat() {
3029
3200
  flushEvents();
3030
3201
  chatIdRef.current = newChatId();
@@ -3051,7 +3222,7 @@ function AssistSheet({
3051
3222
  }
3052
3223
  const otherChats = savedChats.filter((c) => c.id !== chatIdRef.current);
3053
3224
  const resumable = (_a = otherChats.find((c) => c.status === "open" && c.messages.length > 0)) != null ? _a : null;
3054
- const empty = phase === "chat" && messages.length === 0 && !busy;
3225
+ const empty = (phase === "chat" || phase === "type") && messages.length === 0 && !busy;
3055
3226
  function renderChatList() {
3056
3227
  return /* @__PURE__ */ jsxs3("div", { "data-gg-chat-list": "", style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [
3057
3228
  /* @__PURE__ */ jsxs3("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
@@ -3333,7 +3504,7 @@ function AssistSheet({
3333
3504
  }
3334
3505
  ),
3335
3506
  /* @__PURE__ */ jsxs3("div", { style: { fontSize: "11.5px", color: t.textMuted, marginTop: "3px" }, children: [
3336
- phase === "type" ? null : reportTypeLabel,
3507
+ phase === "type" || !typePicked || inferredTypeRef.current && phase !== "draft" ? null : reportTypeLabel,
3337
3508
  phase !== "type" && severityAsked && severity ? ` \xB7 ${SEVERITY_LABELS[severity]}` : null,
3338
3509
  projectSlot ? /* @__PURE__ */ jsx3("span", { style: { marginLeft: "6px" }, children: projectSlot }) : null
3339
3510
  ] })
@@ -3390,6 +3561,30 @@ function AssistSheet({
3390
3561
  },
3391
3562
  children: "Write it myself"
3392
3563
  }
3564
+ ),
3565
+ /* @__PURE__ */ jsx3(
3566
+ "button",
3567
+ {
3568
+ type: "button",
3569
+ "data-gg-sheet-close": "",
3570
+ onClick: () => leave("closed", `header \u2715, ${phase}`, onFinish != null ? onFinish : onClose),
3571
+ "aria-label": "Close",
3572
+ title: "Close",
3573
+ style: {
3574
+ flexShrink: 0,
3575
+ width: "32px",
3576
+ height: "32px",
3577
+ border: "none",
3578
+ borderRadius: "999px",
3579
+ background: "transparent",
3580
+ cursor: "pointer",
3581
+ display: "flex",
3582
+ alignItems: "center",
3583
+ justifyContent: "center",
3584
+ padding: 0
3585
+ },
3586
+ children: /* @__PURE__ */ jsx3("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", style: { display: "block" }, children: /* @__PURE__ */ jsx3("path", { d: "M4 4L12 12M12 4L4 12", stroke: t.textMuted, strokeWidth: "2", strokeLinecap: "round" }) })
3587
+ }
3393
3588
  )
3394
3589
  ] })
3395
3590
  ]
@@ -3421,71 +3616,6 @@ function AssistSheet({
3421
3616
  minWidth: 0
3422
3617
  },
3423
3618
  children: /* @__PURE__ */ jsxs3("div", { style: { display: showChats ? "none" : "contents" }, children: [
3424
- phase === "type" && /* @__PURE__ */ jsxs3("div", { style: { display: "flex", flexDirection: "column", gap: "12px" }, children: [
3425
- /* @__PURE__ */ jsxs3("div", { style: { display: "flex", gap: "8px" }, children: [
3426
- /* @__PURE__ */ jsx3(Avatar, { who: "assistant", theme: t }),
3427
- /* @__PURE__ */ jsxs3(
3428
- "div",
3429
- {
3430
- style: {
3431
- padding: "9px 12px",
3432
- borderRadius: "12px 12px 12px 4px",
3433
- backgroundColor: t.bgSecondary,
3434
- fontSize: "13px",
3435
- lineHeight: 1.55,
3436
- maxWidth: "88%"
3437
- },
3438
- children: [
3439
- reporterName ? `Hi ${reporterName.split(" ")[0]} \u2014 w` : "W",
3440
- "hat do you want to do? Pick one and I'll take it from there."
3441
- ]
3442
- }
3443
- )
3444
- ] }),
3445
- /* @__PURE__ */ jsx3(
3446
- "div",
3447
- {
3448
- style: {
3449
- display: "flex",
3450
- flexWrap: "wrap",
3451
- gap: "6px",
3452
- paddingLeft: "32px"
3453
- },
3454
- children: tiles.map((tile) => {
3455
- const rate = tile === "RATING";
3456
- return /* @__PURE__ */ jsx3(
3457
- "button",
3458
- {
3459
- type: "button",
3460
- "data-gg-chip": "",
3461
- "data-gg-tile": tile,
3462
- onClick: () => pickType(tile),
3463
- style: {
3464
- display: "inline-flex",
3465
- alignItems: "center",
3466
- gap: "5px",
3467
- // The rating is the only tile that isn't a report, so
3468
- // it wears the star colour the dialog's hero row uses
3469
- // rather than hiding among the report types.
3470
- border: `1px solid ${rate ? "rgba(245,158,11,0.5)" : t.inputBorder}`,
3471
- background: rate ? "rgba(245,158,11,0.08)" : "transparent",
3472
- color: rate ? "#f59e0b" : t.textMuted,
3473
- borderRadius: "999px",
3474
- // 8px vertical keeps the tap target at ~32px.
3475
- padding: "8px 12px",
3476
- fontSize: "12px",
3477
- fontWeight: rate ? 600 : 400,
3478
- fontFamily: "inherit",
3479
- cursor: "pointer"
3480
- },
3481
- children: rate ? "\u2605 Rate us" : getTypeLabel(tile)
3482
- },
3483
- tile
3484
- );
3485
- })
3486
- }
3487
- )
3488
- ] }),
3489
3619
  phase === "severity" && /* @__PURE__ */ jsxs3("div", { style: { display: "flex", flexDirection: "column", gap: "12px" }, children: [
3490
3620
  /* @__PURE__ */ jsxs3("div", { style: { display: "flex", gap: "8px" }, children: [
3491
3621
  /* @__PURE__ */ jsx3(Avatar, { who: "assistant", theme: t }),
@@ -3633,7 +3763,13 @@ function AssistSheet({
3633
3763
  "button",
3634
3764
  {
3635
3765
  type: "button",
3636
- onClick: () => setPhase("type"),
3766
+ onClick: () => {
3767
+ const tile = defaultTile();
3768
+ if (!tile) return;
3769
+ inferredTypeRef.current = true;
3770
+ onPickType(tile);
3771
+ setPhase("chat");
3772
+ },
3637
3773
  style: {
3638
3774
  alignSelf: "flex-start",
3639
3775
  border: "none",
@@ -3727,60 +3863,62 @@ function AssistSheet({
3727
3863
  ]
3728
3864
  }
3729
3865
  ),
3730
- /* @__PURE__ */ jsxs3("div", { style: { display: "flex", gap: "8px" }, children: [
3731
- /* @__PURE__ */ jsx3(Avatar, { who: "assistant", theme: t }),
3732
- /* @__PURE__ */ jsxs3(
3866
+ phase !== "type" && /* @__PURE__ */ jsxs3(Fragment2, { children: [
3867
+ /* @__PURE__ */ jsxs3("div", { style: { display: "flex", gap: "8px" }, children: [
3868
+ /* @__PURE__ */ jsx3(Avatar, { who: "assistant", theme: t }),
3869
+ /* @__PURE__ */ jsxs3(
3870
+ "div",
3871
+ {
3872
+ style: {
3873
+ padding: "9px 12px",
3874
+ borderRadius: "12px 12px 12px 4px",
3875
+ backgroundColor: t.bgSecondary,
3876
+ fontSize: "13px",
3877
+ lineHeight: 1.55,
3878
+ maxWidth: "88%"
3879
+ },
3880
+ children: [
3881
+ reporterName ? `Hi ${reporterName.split(" ")[0]} \u2014 t` : "T",
3882
+ "ell me what went wrong in your own words. I can already see your screenshot and what you clicked, so skip the boring parts."
3883
+ ]
3884
+ }
3885
+ )
3886
+ ] }),
3887
+ /* @__PURE__ */ jsx3(
3733
3888
  "div",
3734
3889
  {
3735
3890
  style: {
3736
- padding: "9px 12px",
3737
- borderRadius: "12px 12px 12px 4px",
3738
- backgroundColor: t.bgSecondary,
3739
- fontSize: "13px",
3740
- lineHeight: 1.55,
3741
- maxWidth: "88%"
3891
+ display: "flex",
3892
+ flexWrap: "wrap",
3893
+ gap: "6px",
3894
+ paddingLeft: "32px"
3742
3895
  },
3743
- children: [
3744
- reporterName ? `Hi ${reporterName.split(" ")[0]} \u2014 t` : "T",
3745
- "ell me what went wrong in your own words. I can already see your screenshot and what you clicked, so skip the boring parts."
3746
- ]
3896
+ children: STARTERS.map((s) => /* @__PURE__ */ jsx3(
3897
+ "button",
3898
+ {
3899
+ type: "button",
3900
+ "data-gg-chip": "",
3901
+ onClick: () => {
3902
+ logEvent("starter_tap", s);
3903
+ send(s);
3904
+ },
3905
+ style: {
3906
+ border: `1px solid ${t.inputBorder}`,
3907
+ background: "transparent",
3908
+ color: t.textMuted,
3909
+ borderRadius: "999px",
3910
+ padding: "6px 11px",
3911
+ fontSize: "12px",
3912
+ fontFamily: "inherit",
3913
+ cursor: "pointer"
3914
+ },
3915
+ children: s
3916
+ },
3917
+ s
3918
+ ))
3747
3919
  }
3748
3920
  )
3749
- ] }),
3750
- /* @__PURE__ */ jsx3(
3751
- "div",
3752
- {
3753
- style: {
3754
- display: "flex",
3755
- flexWrap: "wrap",
3756
- gap: "6px",
3757
- paddingLeft: "32px"
3758
- },
3759
- children: STARTERS.map((s) => /* @__PURE__ */ jsx3(
3760
- "button",
3761
- {
3762
- type: "button",
3763
- "data-gg-chip": "",
3764
- onClick: () => {
3765
- logEvent("starter_tap", s);
3766
- send(s);
3767
- },
3768
- style: {
3769
- border: `1px solid ${t.inputBorder}`,
3770
- background: "transparent",
3771
- color: t.textMuted,
3772
- borderRadius: "999px",
3773
- padding: "6px 11px",
3774
- fontSize: "12px",
3775
- fontFamily: "inherit",
3776
- cursor: "pointer"
3777
- },
3778
- children: s
3779
- },
3780
- s
3781
- ))
3782
- }
3783
- )
3921
+ ] })
3784
3922
  ] }),
3785
3923
  messages.map((m, i) => {
3786
3924
  const mine = m.role === "user";
@@ -4032,7 +4170,23 @@ function AssistSheet({
4032
4170
  },
4033
4171
  i
4034
4172
  )),
4035
- /* @__PURE__ */ jsx3(ThinkingClock, { color: t.textMuted })
4173
+ uploadProgress !== null && uploadProgress < 1 ? /* @__PURE__ */ jsxs3(
4174
+ "span",
4175
+ {
4176
+ "data-gg-upload-progress": "",
4177
+ style: {
4178
+ marginLeft: "6px",
4179
+ fontSize: "12px",
4180
+ color: t.textMuted,
4181
+ fontVariantNumeric: "tabular-nums"
4182
+ },
4183
+ children: [
4184
+ "Sending your screenshot\u2026 ",
4185
+ Math.round(uploadProgress * 100),
4186
+ "%"
4187
+ ]
4188
+ }
4189
+ ) : /* @__PURE__ */ jsx3(ThinkingClock, { color: t.textMuted })
4036
4190
  ]
4037
4191
  }
4038
4192
  )
@@ -4250,7 +4404,7 @@ function AssistSheet({
4250
4404
  ]
4251
4405
  }
4252
4406
  ),
4253
- !submitted && !showChats && phase !== "type" && phase !== "severity" && /* @__PURE__ */ jsxs3(
4407
+ !submitted && !showChats && phase !== "severity" && /* @__PURE__ */ jsxs3(
4254
4408
  "div",
4255
4409
  {
4256
4410
  style: {
@@ -4671,7 +4825,7 @@ function AssistSheet({
4671
4825
  sendTyped(input);
4672
4826
  }
4673
4827
  },
4674
- placeholder: phase === "draft" ? "Anything to change? Tell me here\u2026" : "Type your answer\u2026",
4828
+ 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",
4675
4829
  rows: 3,
4676
4830
  disabled: busy,
4677
4831
  autoFocus: true,
@@ -5323,6 +5477,28 @@ function isMac() {
5323
5477
  function getShortcutLabel() {
5324
5478
  return isMac() ? GLITCHGRAB_SHORTCUT_MAC : GLITCHGRAB_SHORTCUT;
5325
5479
  }
5480
+ function getTypeLabel(type) {
5481
+ switch (type) {
5482
+ case "RATING":
5483
+ return "Rating";
5484
+ case "BUG":
5485
+ return "Bug Report";
5486
+ case "FEATURE_REQUEST":
5487
+ return "Feature Request";
5488
+ case "UI_IMPROVEMENT":
5489
+ return "UI Improvement";
5490
+ case "PERFORMANCE":
5491
+ return "Performance";
5492
+ case "SECURITY":
5493
+ return "Security";
5494
+ case "QUESTION":
5495
+ return "Question";
5496
+ case "OTHER":
5497
+ return "Other";
5498
+ case "VIDEO_SCRIPT":
5499
+ return "Video script";
5500
+ }
5501
+ }
5326
5502
  var MAX_SCALE = 2;
5327
5503
  var FRAME_TIMEOUT_MS = 3e3;
5328
5504
  var GRAB_TIMEOUT_MS = FRAME_TIMEOUT_MS + 2e3;
@@ -7273,7 +7449,7 @@ function ReportDialog({
7273
7449
  gridTemplateColumns: "1fr 1fr 1fr",
7274
7450
  gap: "10px"
7275
7451
  },
7276
- children: availableTypes.map((type) => /* @__PURE__ */ jsxs5(
7452
+ children: availableTypes.map((type, i) => /* @__PURE__ */ jsxs5(
7277
7453
  "button",
7278
7454
  {
7279
7455
  type: "button",
@@ -7284,6 +7460,9 @@ function ReportDialog({
7284
7460
  setStep(2);
7285
7461
  },
7286
7462
  style: {
7463
+ // A lone last tile (7 = the team's Video script)
7464
+ // takes the whole row instead of sitting orphaned.
7465
+ gridColumn: i === availableTypes.length - 1 && availableTypes.length % 3 === 1 ? "1 / -1" : void 0,
7287
7466
  display: "flex",
7288
7467
  flexDirection: "column",
7289
7468
  alignItems: "center",
@@ -8678,7 +8857,7 @@ function ReportDialog({
8678
8857
  canReadPdf: !!readFile,
8679
8858
  onRemoveFile: (index) => setAttachments((prev) => prev.filter((_, i) => i !== index)),
8680
8859
  attachmentCount: screenshots.length + attachments.length,
8681
- context: { ...assistContext != null ? assistContext : {}, reportType },
8860
+ context: { ...assistContext != null ? assistContext : {}, ...typeChosen ? { reportType } : {} },
8682
8861
  reportTypeLabel: getTypeLabel(reportType),
8683
8862
  typePicked: typeChosen,
8684
8863
  currentTile: reportType,
@@ -8764,6 +8943,8 @@ function getPlaceholder(type, idx = 0, hasVoice = false) {
8764
8943
  return "What would you like to know?";
8765
8944
  case "OTHER":
8766
8945
  return "Tell us what's on your mind...";
8946
+ case "VIDEO_SCRIPT":
8947
+ return "Paste the script, and say which screens the video should show...";
8767
8948
  }
8768
8949
  }
8769
8950
  function getTypeIcon(type, color, size = 24) {
@@ -8874,6 +9055,16 @@ function getTypeIcon(type, color, size = 24) {
8874
9055
  strokeLinejoin: "round"
8875
9056
  }
8876
9057
  ) });
9058
+ case "VIDEO_SCRIPT":
9059
+ return /* @__PURE__ */ jsx5("svg", { ...props, children: /* @__PURE__ */ jsx5(
9060
+ "path",
9061
+ {
9062
+ d: "M3 7a2 2 0 012-2h9a2 2 0 012 2v10a2 2 0 01-2 2H5a2 2 0 01-2-2V7zM16 10l5-3v10l-5-3",
9063
+ stroke: color,
9064
+ strokeWidth: "1.5",
9065
+ strokeLinejoin: "round"
9066
+ }
9067
+ ) });
8877
9068
  }
8878
9069
  }
8879
9070
 
@@ -10787,7 +10978,7 @@ function GlitchgrabProviderInner({
10787
10978
  [enhanceForDialog]
10788
10979
  );
10789
10980
  const assist = useCallback3(
10790
- async (params) => {
10981
+ async (params, options) => {
10791
10982
  var _a;
10792
10983
  const ctx = captureContext(visitedPagesRef.current);
10793
10984
  return assistTurn(
@@ -10808,7 +10999,8 @@ function GlitchgrabProviderInner({
10808
10999
  }
10809
11000
  },
10810
11001
  token,
10811
- baseUrl
11002
+ baseUrl,
11003
+ options == null ? void 0 : options.onUploadProgress
10812
11004
  );
10813
11005
  },
10814
11006
  [token, baseUrl, session]