glitchgrab 1.64.0 → 1.65.1
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 +10 -2
- package/dist/index.js +138 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +138 -6
- package/dist/index.mjs.map +1 -1
- package/dist/server.d.mts +44 -15
- package/dist/server.d.ts +44 -15
- package/dist/server.js +22 -9
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +22 -9
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -94,6 +94,7 @@ function toAssistTurnResult(ok, body) {
|
|
|
94
94
|
// keeps the assistant button for this report.
|
|
95
95
|
degraded: (_a = envelope == null ? void 0 : envelope.error) != null ? _a : ASSIST_OFFLINE_MESSAGE,
|
|
96
96
|
retryable: (envelope == null ? void 0 : envelope.retryable) === true,
|
|
97
|
+
...(envelope == null ? void 0 : envelope.timedOut) === true ? { timedOut: true } : {},
|
|
97
98
|
...(envelope == null ? void 0 : envelope.resendImages) === true ? { resendImages: true } : {}
|
|
98
99
|
};
|
|
99
100
|
}
|
|
@@ -2720,6 +2721,8 @@ function Avatar({
|
|
|
2720
2721
|
);
|
|
2721
2722
|
}
|
|
2722
2723
|
var THINKING_SLOW_SECONDS = 20;
|
|
2724
|
+
var ASSIST_TURN_TIMEOUT_MS = 75e3;
|
|
2725
|
+
var ASSIST_UPLOAD_TIMEOUT_MS = 18e4;
|
|
2723
2726
|
function ThinkingClock({ color }) {
|
|
2724
2727
|
const [seconds, setSeconds] = useState2(0);
|
|
2725
2728
|
useEffect2(() => {
|
|
@@ -2796,6 +2799,8 @@ function AssistSheet({
|
|
|
2796
2799
|
const [messages, setMessages] = useState2([]);
|
|
2797
2800
|
const [input, setInput] = useState2("");
|
|
2798
2801
|
const [busy, setBusy] = useState2(false);
|
|
2802
|
+
const [stalled, setStalled] = useState2(null);
|
|
2803
|
+
const turnRef = useRef2(0);
|
|
2799
2804
|
const [conversationId, setConversationId] = useState2(null);
|
|
2800
2805
|
const [uploadProgress, setUploadProgress] = useState2(null);
|
|
2801
2806
|
const storedImagesRef = useRef2({
|
|
@@ -2874,6 +2879,13 @@ function AssistSheet({
|
|
|
2874
2879
|
const sentFiles = useMemo(() => pickAssistFiles(files), [files]);
|
|
2875
2880
|
const readFiles = new Set(sentFiles.map((f) => f.index));
|
|
2876
2881
|
function leave(type, detail, exit = onClose) {
|
|
2882
|
+
if (type === "write_myself" && stalled && !description.trim()) {
|
|
2883
|
+
const typed = stalled.filter((m) => m.role === "user").map((m) => m.content).join("\n\n");
|
|
2884
|
+
if (typed) {
|
|
2885
|
+
if (!typePicked) keepTypedForForm(stalled);
|
|
2886
|
+
else onDescriptionChange(typed);
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2877
2889
|
logEvent(type, detail);
|
|
2878
2890
|
flushEvents();
|
|
2879
2891
|
exit();
|
|
@@ -2919,9 +2931,23 @@ function AssistSheet({
|
|
|
2919
2931
|
async function runTurn(history2) {
|
|
2920
2932
|
var _a2, _b, _c;
|
|
2921
2933
|
const turnChat = chatIdRef.current;
|
|
2934
|
+
const turn = ++turnRef.current;
|
|
2935
|
+
const current = () => turnRef.current === turn;
|
|
2936
|
+
setStalled(null);
|
|
2922
2937
|
setBusy(true);
|
|
2923
2938
|
let result;
|
|
2924
2939
|
const events = takeEvents();
|
|
2940
|
+
let waited;
|
|
2941
|
+
let giveUp = () => {
|
|
2942
|
+
};
|
|
2943
|
+
const gaveUp = new Promise((resolve) => {
|
|
2944
|
+
giveUp = () => resolve("timeout");
|
|
2945
|
+
});
|
|
2946
|
+
const arm = (ms) => {
|
|
2947
|
+
clearTimeout(waited);
|
|
2948
|
+
waited = setTimeout(giveUp, ms);
|
|
2949
|
+
};
|
|
2950
|
+
arm(ASSIST_TURN_TIMEOUT_MS);
|
|
2925
2951
|
try {
|
|
2926
2952
|
const picked = pickAssistImages(assistImages());
|
|
2927
2953
|
const held = storedImagesRef.current;
|
|
@@ -2929,6 +2955,7 @@ function AssistSheet({
|
|
|
2929
2955
|
const call = async (known) => {
|
|
2930
2956
|
const { screenshots: sent, hasData } = await toSendList(picked, known);
|
|
2931
2957
|
setUploadProgress(null);
|
|
2958
|
+
if (hasData) arm(ASSIST_UPLOAD_TIMEOUT_MS);
|
|
2932
2959
|
return assist(
|
|
2933
2960
|
{
|
|
2934
2961
|
// `kind` only on drafts, so an older server sees the exact shape it
|
|
@@ -2954,13 +2981,37 @@ function AssistSheet({
|
|
|
2954
2981
|
},
|
|
2955
2982
|
events
|
|
2956
2983
|
},
|
|
2957
|
-
hasData ? {
|
|
2984
|
+
hasData ? {
|
|
2985
|
+
onUploadProgress: (fraction) => {
|
|
2986
|
+
if (!current()) return;
|
|
2987
|
+
setUploadProgress(fraction);
|
|
2988
|
+
if (fraction >= 1) arm(ASSIST_TURN_TIMEOUT_MS);
|
|
2989
|
+
}
|
|
2990
|
+
} : void 0
|
|
2958
2991
|
);
|
|
2959
2992
|
};
|
|
2960
|
-
|
|
2993
|
+
const first = await Promise.race([call(stored), gaveUp]);
|
|
2994
|
+
if (first === "timeout") {
|
|
2995
|
+
if (current() && chatIdRef.current === turnChat) {
|
|
2996
|
+
logEvent("turn_timeout", "sheet");
|
|
2997
|
+
setStalled(history2);
|
|
2998
|
+
}
|
|
2999
|
+
return;
|
|
3000
|
+
}
|
|
3001
|
+
result = first;
|
|
3002
|
+
if (!current()) return;
|
|
2961
3003
|
if (result.resendImages) {
|
|
2962
3004
|
storedImagesRef.current = { conversationId: null, hashes: /* @__PURE__ */ new Set() };
|
|
2963
|
-
|
|
3005
|
+
const again = await Promise.race([call(/* @__PURE__ */ new Set()), gaveUp]);
|
|
3006
|
+
if (again === "timeout") {
|
|
3007
|
+
if (current() && chatIdRef.current === turnChat) {
|
|
3008
|
+
logEvent("turn_timeout", "sheet");
|
|
3009
|
+
setStalled(history2);
|
|
3010
|
+
}
|
|
3011
|
+
return;
|
|
3012
|
+
}
|
|
3013
|
+
result = again;
|
|
3014
|
+
if (!current()) return;
|
|
2964
3015
|
}
|
|
2965
3016
|
if (result.conversationId && result.storedImages) {
|
|
2966
3017
|
storedImagesRef.current = {
|
|
@@ -2969,6 +3020,7 @@ function AssistSheet({
|
|
|
2969
3020
|
};
|
|
2970
3021
|
}
|
|
2971
3022
|
} catch (e) {
|
|
3023
|
+
if (!current()) return;
|
|
2972
3024
|
keepTypedForForm(history2);
|
|
2973
3025
|
degradeKeepingEvents(
|
|
2974
3026
|
events,
|
|
@@ -2976,10 +3028,19 @@ function AssistSheet({
|
|
|
2976
3028
|
);
|
|
2977
3029
|
return;
|
|
2978
3030
|
} finally {
|
|
2979
|
-
|
|
2980
|
-
|
|
3031
|
+
clearTimeout(waited);
|
|
3032
|
+
if (current()) {
|
|
3033
|
+
setBusy(false);
|
|
3034
|
+
setUploadProgress(null);
|
|
3035
|
+
}
|
|
3036
|
+
}
|
|
3037
|
+
if (!current() || chatIdRef.current !== turnChat) return;
|
|
3038
|
+
if (result.degraded && result.timedOut) {
|
|
3039
|
+
if (events) eventsRef.current = [...events, ...eventsRef.current];
|
|
3040
|
+
logEvent("turn_timeout", "server");
|
|
3041
|
+
setStalled(history2);
|
|
3042
|
+
return;
|
|
2981
3043
|
}
|
|
2982
|
-
if (chatIdRef.current !== turnChat) return;
|
|
2983
3044
|
if (result.degraded) {
|
|
2984
3045
|
keepTypedForForm(history2);
|
|
2985
3046
|
degradeKeepingEvents(events, result.degraded, result.retryable === true);
|
|
@@ -3060,6 +3121,7 @@ function AssistSheet({
|
|
|
3060
3121
|
function send(text) {
|
|
3061
3122
|
const value = text.trim();
|
|
3062
3123
|
if (!value || busy) return;
|
|
3124
|
+
setStalled(null);
|
|
3063
3125
|
setOptions([]);
|
|
3064
3126
|
setGlitchgrabOffer(false);
|
|
3065
3127
|
const underDraft = phase === "draft";
|
|
@@ -3124,6 +3186,7 @@ function AssistSheet({
|
|
|
3124
3186
|
var _a2;
|
|
3125
3187
|
flushEvents();
|
|
3126
3188
|
chatIdRef.current = chat.id;
|
|
3189
|
+
setStalled(null);
|
|
3127
3190
|
setMessages(chat.messages);
|
|
3128
3191
|
setConversationId(chat.conversationId);
|
|
3129
3192
|
onConversationChange == null ? void 0 : onConversationChange(chat.conversationId);
|
|
@@ -3156,6 +3219,7 @@ function AssistSheet({
|
|
|
3156
3219
|
function startNewChat() {
|
|
3157
3220
|
flushEvents();
|
|
3158
3221
|
chatIdRef.current = newChatId();
|
|
3222
|
+
setStalled(null);
|
|
3159
3223
|
setMessages([]);
|
|
3160
3224
|
setConversationId(null);
|
|
3161
3225
|
onConversationChange == null ? void 0 : onConversationChange(null);
|
|
@@ -4142,6 +4206,74 @@ function AssistSheet({
|
|
|
4142
4206
|
}
|
|
4143
4207
|
)
|
|
4144
4208
|
] }),
|
|
4209
|
+
stalled && !busy && /* @__PURE__ */ jsxs3("div", { style: { display: "flex", gap: "8px", minWidth: 0 }, role: "alert", children: [
|
|
4210
|
+
/* @__PURE__ */ jsx3(Avatar, { who: "assistant", theme: t }),
|
|
4211
|
+
/* @__PURE__ */ jsxs3(
|
|
4212
|
+
"div",
|
|
4213
|
+
{
|
|
4214
|
+
"data-gg-turn-timeout": "",
|
|
4215
|
+
style: {
|
|
4216
|
+
display: "flex",
|
|
4217
|
+
flexDirection: "column",
|
|
4218
|
+
gap: "10px",
|
|
4219
|
+
minWidth: 0,
|
|
4220
|
+
padding: "12px",
|
|
4221
|
+
borderRadius: "12px 12px 12px 4px",
|
|
4222
|
+
backgroundColor: t.bgSecondary,
|
|
4223
|
+
color: t.text,
|
|
4224
|
+
fontSize: "13px",
|
|
4225
|
+
lineHeight: 1.45
|
|
4226
|
+
},
|
|
4227
|
+
children: [
|
|
4228
|
+
/* @__PURE__ */ jsx3("span", { children: "No answer \u2014 this is taking too long. Try again, or write it yourself; what you typed comes with you." }),
|
|
4229
|
+
/* @__PURE__ */ jsxs3("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: [
|
|
4230
|
+
/* @__PURE__ */ jsx3(
|
|
4231
|
+
"button",
|
|
4232
|
+
{
|
|
4233
|
+
type: "button",
|
|
4234
|
+
"data-gg-turn-retry": "",
|
|
4235
|
+
onClick: () => {
|
|
4236
|
+
logEvent("turn_retry");
|
|
4237
|
+
void runTurn(stalled);
|
|
4238
|
+
},
|
|
4239
|
+
style: {
|
|
4240
|
+
padding: "8px 14px",
|
|
4241
|
+
borderRadius: "999px",
|
|
4242
|
+
border: "none",
|
|
4243
|
+
background: t.accent,
|
|
4244
|
+
color: t.accentText,
|
|
4245
|
+
fontSize: "12px",
|
|
4246
|
+
fontWeight: 600,
|
|
4247
|
+
fontFamily: "inherit",
|
|
4248
|
+
cursor: "pointer"
|
|
4249
|
+
},
|
|
4250
|
+
children: "Try again"
|
|
4251
|
+
}
|
|
4252
|
+
),
|
|
4253
|
+
/* @__PURE__ */ jsx3(
|
|
4254
|
+
"button",
|
|
4255
|
+
{
|
|
4256
|
+
type: "button",
|
|
4257
|
+
"data-gg-turn-write-myself": "",
|
|
4258
|
+
onClick: () => leave("write_myself", "timed out"),
|
|
4259
|
+
style: {
|
|
4260
|
+
padding: "8px 14px",
|
|
4261
|
+
borderRadius: "999px",
|
|
4262
|
+
border: `1px solid ${t.inputBorder}`,
|
|
4263
|
+
background: "transparent",
|
|
4264
|
+
color: t.textMuted,
|
|
4265
|
+
fontSize: "12px",
|
|
4266
|
+
fontFamily: "inherit",
|
|
4267
|
+
cursor: "pointer"
|
|
4268
|
+
},
|
|
4269
|
+
children: "Write it myself"
|
|
4270
|
+
}
|
|
4271
|
+
)
|
|
4272
|
+
] })
|
|
4273
|
+
]
|
|
4274
|
+
}
|
|
4275
|
+
)
|
|
4276
|
+
] }),
|
|
4145
4277
|
phase === "draft" && !submitted && /* @__PURE__ */ jsxs3(
|
|
4146
4278
|
"div",
|
|
4147
4279
|
{
|