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.js CHANGED
@@ -134,6 +134,16 @@ var import_react6 = require("react");
134
134
  var React = __toESM(require("react"));
135
135
 
136
136
  // ../report-ui/dist/assist-response.mjs
137
+ var REPORT_TYPES = [
138
+ "BUG",
139
+ "FEATURE_REQUEST",
140
+ "UI_IMPROVEMENT",
141
+ "PERFORMANCE",
142
+ "SECURITY",
143
+ "QUESTION",
144
+ "OTHER",
145
+ "VIDEO_SCRIPT"
146
+ ];
137
147
  var ASSIST_OFFLINE_MESSAGE = "The assistant is unavailable \u2014 write your report below and send it as normal.";
138
148
  function assistOffline() {
139
149
  return { conversationId: null, question: null, report: null, degraded: ASSIST_OFFLINE_MESSAGE };
@@ -147,7 +157,8 @@ function toAssistTurnResult(ok, body) {
147
157
  // The server words why (cap, rate limit, switched off). An hourly limit
148
158
  // keeps the assistant button for this report.
149
159
  degraded: (_a = envelope == null ? void 0 : envelope.error) != null ? _a : ASSIST_OFFLINE_MESSAGE,
150
- retryable: (envelope == null ? void 0 : envelope.retryable) === true
160
+ retryable: (envelope == null ? void 0 : envelope.retryable) === true,
161
+ ...(envelope == null ? void 0 : envelope.resendImages) === true ? { resendImages: true } : {}
151
162
  };
152
163
  }
153
164
  const d = (_b = envelope.data) != null ? _b : {};
@@ -157,13 +168,54 @@ function toAssistTurnResult(ok, body) {
157
168
  options: Array.isArray(d.options) ? d.options.filter((o) => typeof o === "string") : [],
158
169
  report: (_e = d.report) != null ? _e : null,
159
170
  title: typeof d.title === "string" && d.title.trim() ? d.title.trim() : null,
171
+ reportType: REPORT_TYPES.includes(d.reportType) ? d.reportType : null,
160
172
  duplicate: (_f = d.duplicate) != null ? _f : null,
161
173
  related: (_g = d.related) != null ? _g : null,
162
174
  solved: (_h = d.solved) != null ? _h : null,
163
175
  aboutGlitchgrab: d.aboutGlitchgrab === true,
176
+ storedImages: Array.isArray(d.storedImages) ? d.storedImages.filter((h) => typeof h === "string") : [],
164
177
  degraded: null
165
178
  };
166
179
  }
180
+ async function postJson(url, body, options = {}) {
181
+ var _a;
182
+ const headers = { "Content-Type": "application/json", ...(_a = options.headers) != null ? _a : {} };
183
+ const payload = JSON.stringify(body);
184
+ const onProgress = options.onUploadProgress;
185
+ if (onProgress && typeof XMLHttpRequest !== "undefined") {
186
+ return new Promise((resolve) => {
187
+ try {
188
+ const xhr = new XMLHttpRequest();
189
+ xhr.open("POST", url);
190
+ for (const [name, value] of Object.entries(headers)) xhr.setRequestHeader(name, value);
191
+ xhr.upload.onprogress = (e) => {
192
+ if (e.lengthComputable && e.total > 0) onProgress(Math.min(1, e.loaded / e.total));
193
+ };
194
+ xhr.upload.onload = () => onProgress(1);
195
+ xhr.onload = () => {
196
+ let parsed = null;
197
+ try {
198
+ parsed = JSON.parse(xhr.responseText);
199
+ } catch (e) {
200
+ parsed = null;
201
+ }
202
+ resolve({ ok: xhr.status >= 200 && xhr.status < 300, body: parsed });
203
+ };
204
+ xhr.onerror = () => resolve({ ok: false, body: null });
205
+ xhr.onabort = () => resolve({ ok: false, body: null });
206
+ xhr.send(payload);
207
+ } catch (e) {
208
+ resolve({ ok: false, body: null });
209
+ }
210
+ });
211
+ }
212
+ try {
213
+ const res = await fetch(url, { method: "POST", headers, body: payload });
214
+ return { ok: res.ok, body: await res.json().catch(() => null) };
215
+ } catch (e) {
216
+ return { ok: false, body: null };
217
+ }
218
+ }
167
219
 
168
220
  // src/redact.ts
169
221
  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;
@@ -915,19 +967,15 @@ async function readAttachment(file, token, baseUrl, identity) {
915
967
  return null;
916
968
  }
917
969
  }
918
- async function assistTurn(params, token, baseUrl) {
970
+ async function assistTurn(params, token, baseUrl, onUploadProgress) {
919
971
  const offline = assistOffline();
920
972
  try {
921
973
  const url = `${baseUrl != null ? baseUrl : DEFAULT_BASE_URL}/api/v1/ai/report-chat`;
922
- const response = await fetch(url, {
923
- method: "POST",
924
- headers: {
925
- "Content-Type": "application/json",
926
- Authorization: `Bearer ${token}`
927
- },
928
- body: JSON.stringify(params)
974
+ const response = await postJson(url, params, {
975
+ headers: { Authorization: `Bearer ${token}` },
976
+ onUploadProgress
929
977
  });
930
- return toAssistTurnResult(response.ok, await response.json().catch(() => null));
978
+ return toAssistTurnResult(response.ok, response.body);
931
979
  } catch (e) {
932
980
  return offline;
933
981
  }
@@ -2088,24 +2136,67 @@ function filesForSimilar(files, each, total) {
2088
2136
  }
2089
2137
  return picked;
2090
2138
  }
2091
- function getTypeLabel(type) {
2092
- switch (type) {
2093
- case "RATING":
2094
- return "Rating";
2095
- case "BUG":
2096
- return "Bug Report";
2097
- case "FEATURE_REQUEST":
2098
- return "Feature Request";
2099
- case "UI_IMPROVEMENT":
2100
- return "UI Improvement";
2101
- case "PERFORMANCE":
2102
- return "Performance";
2103
- case "SECURITY":
2104
- return "Security";
2105
- case "QUESTION":
2106
- return "Question";
2107
- case "OTHER":
2108
- return "Other";
2139
+ var ASSIST_IMAGE_REF_PREFIX = "gg-ref:";
2140
+ var ASSIST_IMAGE_MAX_EDGE = 1600;
2141
+ var ASSIST_IMAGE_QUALITY = 0.8;
2142
+ function pickAssistImages(all) {
2143
+ const picked = [];
2144
+ let total = 0;
2145
+ for (let i = all.length - 1; i >= 0 && picked.length < MAX_ASSIST_IMAGES; i--) {
2146
+ const image = all[i];
2147
+ if (total + image.send.length > MAX_ASSIST_IMAGE_CHARS) continue;
2148
+ picked.unshift(image);
2149
+ total += image.send.length;
2150
+ }
2151
+ return picked;
2152
+ }
2153
+ async function sha256Hex(text) {
2154
+ var _a;
2155
+ try {
2156
+ const subtle = (_a = globalThis.crypto) == null ? void 0 : _a.subtle;
2157
+ if (!subtle) return null;
2158
+ const digest = await subtle.digest("SHA-256", new TextEncoder().encode(text));
2159
+ return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, "0")).join("");
2160
+ } catch (e) {
2161
+ return null;
2162
+ }
2163
+ }
2164
+ async function toSendList(picked, stored) {
2165
+ let hasData = false;
2166
+ const screenshots = await Promise.all(
2167
+ picked.map(async (image) => {
2168
+ const hash = stored.size > 0 ? await sha256Hex(image.send) : null;
2169
+ if (hash && stored.has(hash)) return `${ASSIST_IMAGE_REF_PREFIX}${hash}`;
2170
+ hasData = true;
2171
+ return image.send;
2172
+ })
2173
+ );
2174
+ return { screenshots, hasData };
2175
+ }
2176
+ async function shrinkForAssist(dataUrl) {
2177
+ try {
2178
+ if (typeof document === "undefined" || typeof createImageBitmap !== "function") return dataUrl;
2179
+ const blob = await (await fetch(dataUrl)).blob();
2180
+ const bitmap = await createImageBitmap(blob);
2181
+ try {
2182
+ const scale = Math.min(1, ASSIST_IMAGE_MAX_EDGE / Math.max(bitmap.width, bitmap.height));
2183
+ const canvas = document.createElement("canvas");
2184
+ canvas.width = Math.max(1, Math.round(bitmap.width * scale));
2185
+ canvas.height = Math.max(1, Math.round(bitmap.height * scale));
2186
+ const ctx = canvas.getContext("2d");
2187
+ if (!ctx) return dataUrl;
2188
+ ctx.fillStyle = "#ffffff";
2189
+ ctx.fillRect(0, 0, canvas.width, canvas.height);
2190
+ ctx.imageSmoothingEnabled = true;
2191
+ ctx.imageSmoothingQuality = "high";
2192
+ ctx.drawImage(bitmap, 0, 0, canvas.width, canvas.height);
2193
+ const shrunk = canvas.toDataURL("image/jpeg", ASSIST_IMAGE_QUALITY);
2194
+ return shrunk.length < dataUrl.length ? shrunk : dataUrl;
2195
+ } finally {
2196
+ bitmap.close();
2197
+ }
2198
+ } catch (e) {
2199
+ return dataUrl;
2109
2200
  }
2110
2201
  }
2111
2202
  var CODE = /`([^`\n]+)`/y;
@@ -2587,17 +2678,6 @@ function removeChat(key, id, now = Date.now()) {
2587
2678
  write(key, next);
2588
2679
  return next;
2589
2680
  }
2590
- function pickAssistImages(all) {
2591
- const picked = [];
2592
- let total = 0;
2593
- for (let i = all.length - 1; i >= 0 && picked.length < MAX_ASSIST_IMAGES; i--) {
2594
- const shot = all[i];
2595
- if (total + shot.length > MAX_ASSIST_IMAGE_CHARS) continue;
2596
- picked.unshift(shot);
2597
- total += shot.length;
2598
- }
2599
- return picked;
2600
- }
2601
2681
  var NO_FILES = [];
2602
2682
  function pickAssistFiles(files) {
2603
2683
  const picked = [];
@@ -2785,6 +2865,14 @@ function AssistSheet({
2785
2865
  const [input, setInput] = (0, import_react3.useState)("");
2786
2866
  const [busy, setBusy] = (0, import_react3.useState)(false);
2787
2867
  const [conversationId, setConversationId] = (0, import_react3.useState)(null);
2868
+ const [uploadProgress, setUploadProgress] = (0, import_react3.useState)(null);
2869
+ const storedImagesRef = (0, import_react3.useRef)({
2870
+ conversationId: null,
2871
+ hashes: /* @__PURE__ */ new Set()
2872
+ });
2873
+ const shrunkRef = (0, import_react3.useRef)(/* @__PURE__ */ new Map());
2874
+ const shrinkingRef = (0, import_react3.useRef)(/* @__PURE__ */ new Set());
2875
+ const [, setShrunkCount] = (0, import_react3.useState)(0);
2788
2876
  const chatIdRef = (0, import_react3.useRef)(newChatId());
2789
2877
  const [savedChats, setSavedChats] = (0, import_react3.useState)(
2790
2878
  () => historyKey ? loadChats(historyKey) : []
@@ -2806,7 +2894,9 @@ function AssistSheet({
2806
2894
  const composerRef = (0, import_react3.useRef)(null);
2807
2895
  const seededRef = (0, import_react3.useRef)(false);
2808
2896
  const seedPendingRef = (0, import_react3.useRef)(false);
2897
+ const resumeAskRef = (0, import_react3.useRef)(false);
2809
2898
  const eventsRef = (0, import_react3.useRef)([]);
2899
+ const inferredTypeRef = (0, import_react3.useRef)(false);
2810
2900
  const aiDraftRef = (0, import_react3.useRef)(null);
2811
2901
  function logEvent(type, detail) {
2812
2902
  eventsRef.current.push({ type, at: Date.now(), ...detail ? { detail } : {} });
@@ -2829,13 +2919,33 @@ function AssistSheet({
2829
2919
  } catch (e) {
2830
2920
  }
2831
2921
  }
2832
- const readShots = new Set(pickAssistImages(screenshots));
2922
+ (0, import_react3.useEffect)(() => {
2923
+ for (const shot of screenshots) {
2924
+ if (shrunkRef.current.has(shot) || shrinkingRef.current.has(shot)) continue;
2925
+ shrinkingRef.current.add(shot);
2926
+ void shrinkForAssist(shot).then((copy) => {
2927
+ shrinkingRef.current.delete(shot);
2928
+ shrunkRef.current.set(shot, copy);
2929
+ setShrunkCount((n) => n + 1);
2930
+ });
2931
+ }
2932
+ }, [screenshots]);
2933
+ function assistImages() {
2934
+ return screenshots.map((original) => {
2935
+ var _a2;
2936
+ return {
2937
+ original,
2938
+ send: (_a2 = shrunkRef.current.get(original)) != null ? _a2 : original
2939
+ };
2940
+ });
2941
+ }
2942
+ const readShots = new Set(pickAssistImages(assistImages()).map((image) => image.original));
2833
2943
  const sentFiles = (0, import_react3.useMemo)(() => pickAssistFiles(files), [files]);
2834
2944
  const readFiles = new Set(sentFiles.map((f) => f.index));
2835
- function leave(type, detail) {
2945
+ function leave(type, detail, exit = onClose) {
2836
2946
  logEvent(type, detail);
2837
2947
  flushEvents();
2838
- onClose();
2948
+ exit();
2839
2949
  }
2840
2950
  (0, import_react3.useEffect)(() => {
2841
2951
  const el = scrollRef.current;
@@ -2880,6 +2990,20 @@ function AssistSheet({
2880
2990
  flushEvents();
2881
2991
  onDegrade(message, retryable);
2882
2992
  }
2993
+ function defaultTile() {
2994
+ return tiles.includes("BUG") ? "BUG" : tiles.find((x) => x !== "RATING");
2995
+ }
2996
+ function keepTypedForForm(history2) {
2997
+ if (typePicked && !inferredTypeRef.current || description.trim()) return;
2998
+ const typed = history2.filter((m) => m.role === "user").map((m) => m.content).join("\n\n");
2999
+ if (!typed) return;
3000
+ const fallback = defaultTile();
3001
+ if (fallback) {
3002
+ inferredTypeRef.current = true;
3003
+ onPickType(fallback);
3004
+ }
3005
+ onDescriptionChange(typed);
3006
+ }
2883
3007
  async function runTurn(history2, autoFile = false) {
2884
3008
  var _a2, _b, _c;
2885
3009
  const turnChat = chatIdRef.current;
@@ -2888,29 +3012,53 @@ function AssistSheet({
2888
3012
  let result;
2889
3013
  const events = takeEvents();
2890
3014
  try {
2891
- const sent = pickAssistImages(screenshots);
2892
- result = await assist({
2893
- // `kind` only on drafts, so an older server sees the exact shape it
2894
- // always did — it just learns the draft text now instead of a
2895
- // placeholder line.
2896
- messages: history2.map(
2897
- (m) => m.kind ? { role: m.role, content: m.content, kind: m.kind } : m
2898
- ),
2899
- conversationId,
2900
- screenshots: sent,
2901
- // Only when there is something: an older server then sees the body
2902
- // it always did.
2903
- ...sentFiles.length > 0 ? { files: sentFiles.map((f) => f.file) } : {},
2904
- context: {
2905
- ...context != null ? context : {},
2906
- imageSources: sent.map((shot) => pageShot && shot === pageShot ? "page" : "attached"),
2907
- // Whether this dialog can open the #366 panel at all. A hint — the
2908
- // server decides whether the model may offer it.
2909
- canReportGlitchgrab: !!onReportGlitchgrabProblem
2910
- },
2911
- events
2912
- });
3015
+ const picked = pickAssistImages(assistImages());
3016
+ const held = storedImagesRef.current;
3017
+ const stored = conversationId && held.conversationId === conversationId ? held.hashes : /* @__PURE__ */ new Set();
3018
+ const call = async (known) => {
3019
+ const { screenshots: sent, hasData } = await toSendList(picked, known);
3020
+ setUploadProgress(null);
3021
+ return assist(
3022
+ {
3023
+ // `kind` only on drafts, so an older server sees the exact shape it
3024
+ // always did — it just learns the draft text now instead of a
3025
+ // placeholder line.
3026
+ messages: history2.map(
3027
+ (m) => m.kind ? { role: m.role, content: m.content, kind: m.kind } : m
3028
+ ),
3029
+ conversationId,
3030
+ screenshots: sent,
3031
+ // Only when there is something: an older server then sees the body
3032
+ // it always did.
3033
+ ...sentFiles.length > 0 ? { files: sentFiles.map((f) => f.file) } : {},
3034
+ context: {
3035
+ ...context != null ? context : {},
3036
+ // Labelled off the originals: the page shot's copy is still the page.
3037
+ imageSources: picked.map(
3038
+ (image) => pageShot && image.original === pageShot ? "page" : "attached"
3039
+ ),
3040
+ // Whether this dialog can open the #366 panel at all. A hint — the
3041
+ // server decides whether the model may offer it.
3042
+ canReportGlitchgrab: !!onReportGlitchgrabProblem
3043
+ },
3044
+ events
3045
+ },
3046
+ hasData ? { onUploadProgress: setUploadProgress } : void 0
3047
+ );
3048
+ };
3049
+ result = await call(stored);
3050
+ if (result.resendImages) {
3051
+ storedImagesRef.current = { conversationId: null, hashes: /* @__PURE__ */ new Set() };
3052
+ result = await call(/* @__PURE__ */ new Set());
3053
+ }
3054
+ if (result.conversationId && result.storedImages) {
3055
+ storedImagesRef.current = {
3056
+ conversationId: result.conversationId,
3057
+ hashes: new Set(result.storedImages)
3058
+ };
3059
+ }
2913
3060
  } catch (e) {
3061
+ keepTypedForForm(history2);
2914
3062
  degradeKeepingEvents(
2915
3063
  events,
2916
3064
  "The assistant is unavailable \u2014 write your report below and send it as normal."
@@ -2918,9 +3066,11 @@ function AssistSheet({
2918
3066
  return;
2919
3067
  } finally {
2920
3068
  setBusy(false);
3069
+ setUploadProgress(null);
2921
3070
  }
2922
3071
  if (chatIdRef.current !== turnChat) return;
2923
3072
  if (result.degraded) {
3073
+ keepTypedForForm(history2);
2924
3074
  degradeKeepingEvents(events, result.degraded, result.retryable === true);
2925
3075
  return;
2926
3076
  }
@@ -2939,6 +3089,16 @@ function AssistSheet({
2939
3089
  return;
2940
3090
  }
2941
3091
  if (result.report) {
3092
+ let tile = currentTile;
3093
+ if (!typePicked || inferredTypeRef.current) {
3094
+ const fallback = defaultTile();
3095
+ const inferred = result.reportType && tiles.includes(result.reportType) ? result.reportType : fallback;
3096
+ if (inferred) {
3097
+ tile = inferred;
3098
+ inferredTypeRef.current = true;
3099
+ onPickType(inferred);
3100
+ }
3101
+ }
2942
3102
  onDescriptionChange(result.report);
2943
3103
  onIssueTitleChange((_b = result.title) != null ? _b : "");
2944
3104
  aiDraftRef.current = result.report;
@@ -2946,7 +3106,7 @@ function AssistSheet({
2946
3106
  setMessages([...history2, { role: "assistant", content: result.report, kind: "report" }]);
2947
3107
  setOptions([]);
2948
3108
  setPhase("draft");
2949
- if (autoFile && !attach && !(severityAsked && !severity)) {
3109
+ if (autoFile && !attach && !(showSeverity && tile === "BUG" && !severity)) {
2950
3110
  setAutoFileLeft(AUTO_FILE_SECONDS);
2951
3111
  }
2952
3112
  return;
@@ -2956,12 +3116,20 @@ function AssistSheet({
2956
3116
  setOptions((_c = result.options) != null ? _c : []);
2957
3117
  return;
2958
3118
  }
3119
+ keepTypedForForm(history2);
2959
3120
  onDegrade("The assistant had nothing to add \u2014 write your report below and send it as normal.");
2960
3121
  }
2961
3122
  (0, import_react3.useEffect)(() => {
2962
3123
  if (seededRef.current) return;
2963
3124
  seededRef.current = true;
2964
- if (!typePicked || currentTile === "RATING") return;
3125
+ if (typePicked && currentTile === "RATING") return;
3126
+ if (!typePicked) {
3127
+ if (description.trim()) {
3128
+ setPhase("chat");
3129
+ seedFromDescription();
3130
+ }
3131
+ return;
3132
+ }
2965
3133
  if (phase === "severity") {
2966
3134
  seedPendingRef.current = true;
2967
3135
  return;
@@ -2995,6 +3163,7 @@ function AssistSheet({
2995
3163
  setOptions([]);
2996
3164
  setGlitchgrabOffer(false);
2997
3165
  const underDraft = phase === "draft";
3166
+ if (phase === "type") setPhase("chat");
2998
3167
  if (underDraft) {
2999
3168
  const edited = aiDraftRef.current !== null && description.trim() !== aiDraftRef.current.trim();
3000
3169
  logEvent("keep_chatting", edited ? "after editing" : void 0);
@@ -3006,10 +3175,6 @@ function AssistSheet({
3006
3175
  setInput("");
3007
3176
  void runTurn(history2, autoFile);
3008
3177
  }
3009
- function pickType(tile) {
3010
- onPickType(tile);
3011
- setPhase(tile === "RATING" ? "rating" : needsSeverity(tile) ? "severity" : "chat");
3012
- }
3013
3178
  function withCurrentDraft(history2) {
3014
3179
  const current = description.trim();
3015
3180
  const next = [...history2];
@@ -3083,7 +3248,13 @@ function AssistSheet({
3083
3248
  }
3084
3249
  setShowChats(false);
3085
3250
  setViewingChat(null);
3251
+ resumeAskRef.current = (last == null ? void 0 : last.role) === "user";
3086
3252
  }
3253
+ (0, import_react3.useEffect)(() => {
3254
+ if (!resumeAskRef.current) return;
3255
+ resumeAskRef.current = false;
3256
+ void runTurn(messages);
3257
+ }, [messages]);
3087
3258
  function startNewChat() {
3088
3259
  flushEvents();
3089
3260
  chatIdRef.current = newChatId();
@@ -3110,7 +3281,7 @@ function AssistSheet({
3110
3281
  }
3111
3282
  const otherChats = savedChats.filter((c) => c.id !== chatIdRef.current);
3112
3283
  const resumable = (_a = otherChats.find((c) => c.status === "open" && c.messages.length > 0)) != null ? _a : null;
3113
- const empty = phase === "chat" && messages.length === 0 && !busy;
3284
+ const empty = (phase === "chat" || phase === "type") && messages.length === 0 && !busy;
3114
3285
  function renderChatList() {
3115
3286
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { "data-gg-chat-list": "", style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [
3116
3287
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
@@ -3392,7 +3563,7 @@ function AssistSheet({
3392
3563
  }
3393
3564
  ),
3394
3565
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { fontSize: "11.5px", color: t.textMuted, marginTop: "3px" }, children: [
3395
- phase === "type" ? null : reportTypeLabel,
3566
+ phase === "type" || !typePicked || inferredTypeRef.current && phase !== "draft" ? null : reportTypeLabel,
3396
3567
  phase !== "type" && severityAsked && severity ? ` \xB7 ${SEVERITY_LABELS[severity]}` : null,
3397
3568
  projectSlot ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { marginLeft: "6px" }, children: projectSlot }) : null
3398
3569
  ] })
@@ -3449,6 +3620,30 @@ function AssistSheet({
3449
3620
  },
3450
3621
  children: "Write it myself"
3451
3622
  }
3623
+ ),
3624
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3625
+ "button",
3626
+ {
3627
+ type: "button",
3628
+ "data-gg-sheet-close": "",
3629
+ onClick: () => leave("closed", `header \u2715, ${phase}`, onFinish != null ? onFinish : onClose),
3630
+ "aria-label": "Close",
3631
+ title: "Close",
3632
+ style: {
3633
+ flexShrink: 0,
3634
+ width: "32px",
3635
+ height: "32px",
3636
+ border: "none",
3637
+ borderRadius: "999px",
3638
+ background: "transparent",
3639
+ cursor: "pointer",
3640
+ display: "flex",
3641
+ alignItems: "center",
3642
+ justifyContent: "center",
3643
+ padding: 0
3644
+ },
3645
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", style: { display: "block" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M4 4L12 12M12 4L4 12", stroke: t.textMuted, strokeWidth: "2", strokeLinecap: "round" }) })
3646
+ }
3452
3647
  )
3453
3648
  ] })
3454
3649
  ]
@@ -3480,71 +3675,6 @@ function AssistSheet({
3480
3675
  minWidth: 0
3481
3676
  },
3482
3677
  children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: showChats ? "none" : "contents" }, children: [
3483
- phase === "type" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "12px" }, children: [
3484
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
3485
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Avatar, { who: "assistant", theme: t }),
3486
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3487
- "div",
3488
- {
3489
- style: {
3490
- padding: "9px 12px",
3491
- borderRadius: "12px 12px 12px 4px",
3492
- backgroundColor: t.bgSecondary,
3493
- fontSize: "13px",
3494
- lineHeight: 1.55,
3495
- maxWidth: "88%"
3496
- },
3497
- children: [
3498
- reporterName ? `Hi ${reporterName.split(" ")[0]} \u2014 w` : "W",
3499
- "hat do you want to do? Pick one and I'll take it from there."
3500
- ]
3501
- }
3502
- )
3503
- ] }),
3504
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3505
- "div",
3506
- {
3507
- style: {
3508
- display: "flex",
3509
- flexWrap: "wrap",
3510
- gap: "6px",
3511
- paddingLeft: "32px"
3512
- },
3513
- children: tiles.map((tile) => {
3514
- const rate = tile === "RATING";
3515
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3516
- "button",
3517
- {
3518
- type: "button",
3519
- "data-gg-chip": "",
3520
- "data-gg-tile": tile,
3521
- onClick: () => pickType(tile),
3522
- style: {
3523
- display: "inline-flex",
3524
- alignItems: "center",
3525
- gap: "5px",
3526
- // The rating is the only tile that isn't a report, so
3527
- // it wears the star colour the dialog's hero row uses
3528
- // rather than hiding among the report types.
3529
- border: `1px solid ${rate ? "rgba(245,158,11,0.5)" : t.inputBorder}`,
3530
- background: rate ? "rgba(245,158,11,0.08)" : "transparent",
3531
- color: rate ? "#f59e0b" : t.textMuted,
3532
- borderRadius: "999px",
3533
- // 8px vertical keeps the tap target at ~32px.
3534
- padding: "8px 12px",
3535
- fontSize: "12px",
3536
- fontWeight: rate ? 600 : 400,
3537
- fontFamily: "inherit",
3538
- cursor: "pointer"
3539
- },
3540
- children: rate ? "\u2605 Rate us" : getTypeLabel(tile)
3541
- },
3542
- tile
3543
- );
3544
- })
3545
- }
3546
- )
3547
- ] }),
3548
3678
  phase === "severity" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "12px" }, children: [
3549
3679
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
3550
3680
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Avatar, { who: "assistant", theme: t }),
@@ -3692,7 +3822,13 @@ function AssistSheet({
3692
3822
  "button",
3693
3823
  {
3694
3824
  type: "button",
3695
- onClick: () => setPhase("type"),
3825
+ onClick: () => {
3826
+ const tile = defaultTile();
3827
+ if (!tile) return;
3828
+ inferredTypeRef.current = true;
3829
+ onPickType(tile);
3830
+ setPhase("chat");
3831
+ },
3696
3832
  style: {
3697
3833
  alignSelf: "flex-start",
3698
3834
  border: "none",
@@ -3786,60 +3922,62 @@ function AssistSheet({
3786
3922
  ]
3787
3923
  }
3788
3924
  ),
3789
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
3790
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Avatar, { who: "assistant", theme: t }),
3791
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3925
+ phase !== "type" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
3926
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", gap: "8px" }, children: [
3927
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Avatar, { who: "assistant", theme: t }),
3928
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3929
+ "div",
3930
+ {
3931
+ style: {
3932
+ padding: "9px 12px",
3933
+ borderRadius: "12px 12px 12px 4px",
3934
+ backgroundColor: t.bgSecondary,
3935
+ fontSize: "13px",
3936
+ lineHeight: 1.55,
3937
+ maxWidth: "88%"
3938
+ },
3939
+ children: [
3940
+ reporterName ? `Hi ${reporterName.split(" ")[0]} \u2014 t` : "T",
3941
+ "ell me what went wrong in your own words. I can already see your screenshot and what you clicked, so skip the boring parts."
3942
+ ]
3943
+ }
3944
+ )
3945
+ ] }),
3946
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3792
3947
  "div",
3793
3948
  {
3794
3949
  style: {
3795
- padding: "9px 12px",
3796
- borderRadius: "12px 12px 12px 4px",
3797
- backgroundColor: t.bgSecondary,
3798
- fontSize: "13px",
3799
- lineHeight: 1.55,
3800
- maxWidth: "88%"
3950
+ display: "flex",
3951
+ flexWrap: "wrap",
3952
+ gap: "6px",
3953
+ paddingLeft: "32px"
3801
3954
  },
3802
- children: [
3803
- reporterName ? `Hi ${reporterName.split(" ")[0]} \u2014 t` : "T",
3804
- "ell me what went wrong in your own words. I can already see your screenshot and what you clicked, so skip the boring parts."
3805
- ]
3955
+ children: STARTERS.map((s) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3956
+ "button",
3957
+ {
3958
+ type: "button",
3959
+ "data-gg-chip": "",
3960
+ onClick: () => {
3961
+ logEvent("starter_tap", s);
3962
+ send(s);
3963
+ },
3964
+ style: {
3965
+ border: `1px solid ${t.inputBorder}`,
3966
+ background: "transparent",
3967
+ color: t.textMuted,
3968
+ borderRadius: "999px",
3969
+ padding: "6px 11px",
3970
+ fontSize: "12px",
3971
+ fontFamily: "inherit",
3972
+ cursor: "pointer"
3973
+ },
3974
+ children: s
3975
+ },
3976
+ s
3977
+ ))
3806
3978
  }
3807
3979
  )
3808
- ] }),
3809
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3810
- "div",
3811
- {
3812
- style: {
3813
- display: "flex",
3814
- flexWrap: "wrap",
3815
- gap: "6px",
3816
- paddingLeft: "32px"
3817
- },
3818
- children: STARTERS.map((s) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3819
- "button",
3820
- {
3821
- type: "button",
3822
- "data-gg-chip": "",
3823
- onClick: () => {
3824
- logEvent("starter_tap", s);
3825
- send(s);
3826
- },
3827
- style: {
3828
- border: `1px solid ${t.inputBorder}`,
3829
- background: "transparent",
3830
- color: t.textMuted,
3831
- borderRadius: "999px",
3832
- padding: "6px 11px",
3833
- fontSize: "12px",
3834
- fontFamily: "inherit",
3835
- cursor: "pointer"
3836
- },
3837
- children: s
3838
- },
3839
- s
3840
- ))
3841
- }
3842
- )
3980
+ ] })
3843
3981
  ] }),
3844
3982
  messages.map((m, i) => {
3845
3983
  const mine = m.role === "user";
@@ -4091,7 +4229,23 @@ function AssistSheet({
4091
4229
  },
4092
4230
  i
4093
4231
  )),
4094
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ThinkingClock, { color: t.textMuted })
4232
+ uploadProgress !== null && uploadProgress < 1 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4233
+ "span",
4234
+ {
4235
+ "data-gg-upload-progress": "",
4236
+ style: {
4237
+ marginLeft: "6px",
4238
+ fontSize: "12px",
4239
+ color: t.textMuted,
4240
+ fontVariantNumeric: "tabular-nums"
4241
+ },
4242
+ children: [
4243
+ "Sending your screenshot\u2026 ",
4244
+ Math.round(uploadProgress * 100),
4245
+ "%"
4246
+ ]
4247
+ }
4248
+ ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ThinkingClock, { color: t.textMuted })
4095
4249
  ]
4096
4250
  }
4097
4251
  )
@@ -4309,7 +4463,7 @@ function AssistSheet({
4309
4463
  ]
4310
4464
  }
4311
4465
  ),
4312
- !submitted && !showChats && phase !== "type" && phase !== "severity" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4466
+ !submitted && !showChats && phase !== "severity" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4313
4467
  "div",
4314
4468
  {
4315
4469
  style: {
@@ -4730,7 +4884,7 @@ function AssistSheet({
4730
4884
  sendTyped(input);
4731
4885
  }
4732
4886
  },
4733
- placeholder: phase === "draft" ? "Anything to change? Tell me here\u2026" : "Type your answer\u2026",
4887
+ 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",
4734
4888
  rows: 3,
4735
4889
  disabled: busy,
4736
4890
  autoFocus: true,
@@ -5382,6 +5536,28 @@ function isMac() {
5382
5536
  function getShortcutLabel() {
5383
5537
  return isMac() ? GLITCHGRAB_SHORTCUT_MAC : GLITCHGRAB_SHORTCUT;
5384
5538
  }
5539
+ function getTypeLabel(type) {
5540
+ switch (type) {
5541
+ case "RATING":
5542
+ return "Rating";
5543
+ case "BUG":
5544
+ return "Bug Report";
5545
+ case "FEATURE_REQUEST":
5546
+ return "Feature Request";
5547
+ case "UI_IMPROVEMENT":
5548
+ return "UI Improvement";
5549
+ case "PERFORMANCE":
5550
+ return "Performance";
5551
+ case "SECURITY":
5552
+ return "Security";
5553
+ case "QUESTION":
5554
+ return "Question";
5555
+ case "OTHER":
5556
+ return "Other";
5557
+ case "VIDEO_SCRIPT":
5558
+ return "Video script";
5559
+ }
5560
+ }
5385
5561
  var MAX_SCALE = 2;
5386
5562
  var FRAME_TIMEOUT_MS = 3e3;
5387
5563
  var GRAB_TIMEOUT_MS = FRAME_TIMEOUT_MS + 2e3;
@@ -7332,7 +7508,7 @@ function ReportDialog({
7332
7508
  gridTemplateColumns: "1fr 1fr 1fr",
7333
7509
  gap: "10px"
7334
7510
  },
7335
- children: availableTypes.map((type) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
7511
+ children: availableTypes.map((type, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
7336
7512
  "button",
7337
7513
  {
7338
7514
  type: "button",
@@ -7343,6 +7519,9 @@ function ReportDialog({
7343
7519
  setStep(2);
7344
7520
  },
7345
7521
  style: {
7522
+ // A lone last tile (7 = the team's Video script)
7523
+ // takes the whole row instead of sitting orphaned.
7524
+ gridColumn: i === availableTypes.length - 1 && availableTypes.length % 3 === 1 ? "1 / -1" : void 0,
7346
7525
  display: "flex",
7347
7526
  flexDirection: "column",
7348
7527
  alignItems: "center",
@@ -8737,7 +8916,7 @@ function ReportDialog({
8737
8916
  canReadPdf: !!readFile,
8738
8917
  onRemoveFile: (index) => setAttachments((prev) => prev.filter((_, i) => i !== index)),
8739
8918
  attachmentCount: screenshots.length + attachments.length,
8740
- context: { ...assistContext != null ? assistContext : {}, reportType },
8919
+ context: { ...assistContext != null ? assistContext : {}, ...typeChosen ? { reportType } : {} },
8741
8920
  reportTypeLabel: getTypeLabel(reportType),
8742
8921
  typePicked: typeChosen,
8743
8922
  currentTile: reportType,
@@ -8823,6 +9002,8 @@ function getPlaceholder(type, idx = 0, hasVoice = false) {
8823
9002
  return "What would you like to know?";
8824
9003
  case "OTHER":
8825
9004
  return "Tell us what's on your mind...";
9005
+ case "VIDEO_SCRIPT":
9006
+ return "Paste the script, and say which screens the video should show...";
8826
9007
  }
8827
9008
  }
8828
9009
  function getTypeIcon(type, color, size = 24) {
@@ -8933,6 +9114,16 @@ function getTypeIcon(type, color, size = 24) {
8933
9114
  strokeLinejoin: "round"
8934
9115
  }
8935
9116
  ) });
9117
+ case "VIDEO_SCRIPT":
9118
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
9119
+ "path",
9120
+ {
9121
+ 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",
9122
+ stroke: color,
9123
+ strokeWidth: "1.5",
9124
+ strokeLinejoin: "round"
9125
+ }
9126
+ ) });
8936
9127
  }
8937
9128
  }
8938
9129
 
@@ -10846,7 +11037,7 @@ function GlitchgrabProviderInner({
10846
11037
  [enhanceForDialog]
10847
11038
  );
10848
11039
  const assist = (0, import_react6.useCallback)(
10849
- async (params) => {
11040
+ async (params, options) => {
10850
11041
  var _a;
10851
11042
  const ctx = captureContext(visitedPagesRef.current);
10852
11043
  return assistTurn(
@@ -10867,7 +11058,8 @@ function GlitchgrabProviderInner({
10867
11058
  }
10868
11059
  },
10869
11060
  token,
10870
- baseUrl
11061
+ baseUrl,
11062
+ options == null ? void 0 : options.onUploadProgress
10871
11063
  );
10872
11064
  },
10873
11065
  [token, baseUrl, session]