@adminide-stack/yantra-mobile 12.0.148-alpha.0 → 12.0.149-alpha.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/lib/features/webbuilder/WebBuilderExperience.js +38 -56
- package/lib/features/webbuilder/WebBuilderExperience.js.map +1 -1
- package/lib/features/webbuilder/buildFragments.js +4 -4
- package/lib/features/webbuilder/buildFragments.js.map +1 -1
- package/lib/features/webbuilder/components/PreviewScreen.js +28 -2
- package/lib/features/webbuilder/components/PreviewScreen.js.map +1 -1
- package/lib/features/webbuilder/components/ProjectChat.js +190 -85
- package/lib/features/webbuilder/components/ProjectChat.js.map +1 -1
- package/lib/features/webbuilder/components/ProjectSheets.js +10 -4
- package/lib/features/webbuilder/components/ProjectSheets.js.map +1 -1
- package/lib/features/webbuilder/components/PublishSheet.js +90 -14
- package/lib/features/webbuilder/components/PublishSheet.js.map +1 -1
- package/lib/features/webbuilder/components/ui.js +9 -2
- package/lib/features/webbuilder/components/ui.js.map +1 -1
- package/lib/features/webbuilder/followUps.js +19 -1
- package/lib/features/webbuilder/followUps.js.map +1 -1
- package/lib/features/webbuilder/webbuilderPrompts.js +3 -2
- package/lib/features/webbuilder/webbuilderPrompts.js.map +1 -1
- package/lib/hooks/useChatApi.js +4 -3
- package/lib/hooks/useChatApi.js.map +1 -1
- package/lib/screens/WebBuilderNative/agentBusyRetry.js +24 -0
- package/lib/screens/WebBuilderNative/agentBusyRetry.js.map +1 -0
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js +166 -44
- package/lib/screens/WebBuilderNative/useWebBuilderHost.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {useRef,useState,useCallback,useMemo,
|
|
1
|
+
import {useRef,useState,useCallback,useEffect,useMemo,useSyncExternalStore}from'react';import {useApolloClient,gql}from'@apollo/client/index.js';import {useAiCodeDeployToCloudflareMutation}from'common/graphql';import {v4}from'uuid';import AsyncStorage from'@react-native-async-storage/async-storage';import {projectInstructionsNote,readDeleteReply,readSettingsUpdateReply,parseProjectSettings}from'../../features/webbuilder/projectTools.js';import {useCdecliConnection}from'../../contexts/CdecliConnectionContext.js';import {useChatStream}from'../../hooks/useChatStream.js';import {useHostChatChannel}from'../../hooks/useHostChatChannel.js';import {useHostChatSteering}from'../../hooks/useHostChatSteering.js';import {withoutBusyRepeats,isAgentBusyReply,BUSY_RETRY_DELAYS_MS,busyRetryText}from'./agentBusyRetry.js';import {config}from'../../config/env-config.js';import {useChatMessages,subscribeRememberedHistory,historyRunningChannelIds}from'../../hooks/useChatApi.js';import {usePrerequisiteIds}from'../../hooks/usePrerequisiteIds.js';import {useCanvasSession}from'../../features/canvas/useCanvasSession.js';import {tokenClaims}from'../../features/canvas/sessionIdentity.js';import {buildsFromPosts,hasWorkflowPosts,siteNameFromRequest,titleFromPrompt,stripAgentNote,projectFromPosts,turnState,pendingWork,transcriptFromPosts,userBubbleText,displayAgentText,isGenericTitle}from'../../features/webbuilder/buildFragments.js';import {handEditsNote,savedCodeSource}from'../../features/webbuilder/codeFiles.js';import {createCodeWorkspace}from'./codeWorkspaceApi.js';import {WEBBUILDER_CHAT_SKILL,buildTriggerParams,templateRemixNote,newObjectId}from'../../features/webbuilder/workflow.js';import {useWebBuilderGallery}from'./useWebBuilderGallery.js';import {agentEditNote,agentPublishMessage}from'../../features/webbuilder/webbuilderPrompts.js';import {plainActionError}from'../../features/webbuilder/publishTools.js';import {useCodeAssistantCatalog}from'./useCodeAssistantCatalog.js';import {useConnectorTemplates}from'./useConnectorTemplates.js';import {directChannels,uploadAttachment,triggerBuild,createSandboxRouter,directSandboxRun,wakeSandbox,restoreFromSavedCopy,isNoProjectRefusal,OUTDATED_SERVER_RE}from'./webbuilderTransport.js';import {useSandboxProxyApi}from'./sandboxProxyApi.js';import {useSandboxKeepAlive}from'./useSandboxKeepAlive.js';import {pendingAskUser}from'../../features/chat/askUser.js';import {runningBuild,useRunningBuilds,markBuildDone}from'./runningBuilds.js';import {isAgentSite}from'./siteLane.js';import {undoLastChange,redoChange}from'./versionUndo.js';import {WEBBUILDER_EXPORT_ZIP_ACTION,exportZipParams,exportZipUrl}from'../../features/webbuilder/exportCode.js';import {useRestoredSandboxes,applyRestored}from'./useRestoredSandboxes.js';import {useWebBuilderJobs}from'./useWebBuilderJobs.js';var __defProp = Object.defineProperty;
|
|
2
2
|
var __defProps = Object.defineProperties;
|
|
3
3
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -69,12 +69,14 @@ const DEPLOY_WITH_DOMAIN_MUTATION = gql`
|
|
|
69
69
|
$projectName: String
|
|
70
70
|
$channelId: String
|
|
71
71
|
$customDomain: String
|
|
72
|
+
$force: Boolean
|
|
72
73
|
) {
|
|
73
74
|
aiCodeDeployToCloudflare(
|
|
74
75
|
sandboxId: $sandboxId
|
|
75
76
|
projectName: $projectName
|
|
76
77
|
channelId: $channelId
|
|
77
78
|
customDomain: $customDomain
|
|
79
|
+
force: $force
|
|
78
80
|
) {
|
|
79
81
|
success
|
|
80
82
|
message
|
|
@@ -99,7 +101,7 @@ function failureText(error) {
|
|
|
99
101
|
return "The build didn't start. Try again.";
|
|
100
102
|
}
|
|
101
103
|
function useWebBuilderHost(routeOrg) {
|
|
102
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
104
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
103
105
|
const {
|
|
104
106
|
orgName,
|
|
105
107
|
projectId: appProjectId
|
|
@@ -129,6 +131,28 @@ function useWebBuilderHost(routeOrg) {
|
|
|
129
131
|
refresh: refreshProjects,
|
|
130
132
|
upsert: upsertProject
|
|
131
133
|
} = gallery;
|
|
134
|
+
const [renames, setRenames] = useState(() => /* @__PURE__ */ new Map());
|
|
135
|
+
const renamesKey = `yantra.webbuilder.renames.${effectiveOrg || "default"}`;
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
let live = true;
|
|
138
|
+
AsyncStorage.getItem(renamesKey).then((raw) => {
|
|
139
|
+
if (!live || !raw) return;
|
|
140
|
+
const parsed = JSON.parse(raw);
|
|
141
|
+
setRenames(new Map(Object.entries(parsed).filter(([, v]) => typeof v === "string" && v.trim())));
|
|
142
|
+
}).catch(() => void 0);
|
|
143
|
+
return () => {
|
|
144
|
+
live = false;
|
|
145
|
+
};
|
|
146
|
+
}, [renamesKey]);
|
|
147
|
+
const rememberRename = useCallback((channelId, title) => {
|
|
148
|
+
setRenames((prev) => {
|
|
149
|
+
if (prev.get(channelId) === title) return prev;
|
|
150
|
+
const next = new Map(prev);
|
|
151
|
+
next.set(channelId, title);
|
|
152
|
+
AsyncStorage.setItem(renamesKey, JSON.stringify(Object.fromEntries(next))).catch(() => void 0);
|
|
153
|
+
return next;
|
|
154
|
+
});
|
|
155
|
+
}, [renamesKey]);
|
|
132
156
|
const [activeChannelId, setActiveChannelId] = useState(null);
|
|
133
157
|
const projectIds = useRef(/* @__PURE__ */ new Map());
|
|
134
158
|
const {
|
|
@@ -221,6 +245,14 @@ function useWebBuilderHost(routeOrg) {
|
|
|
221
245
|
}, [adoptAgentProject]);
|
|
222
246
|
const instructionsByChannel = useRef(/* @__PURE__ */ new Map());
|
|
223
247
|
const importedChannels = useRef(/* @__PURE__ */ new Set());
|
|
248
|
+
const lastAgentSend = useRef(null);
|
|
249
|
+
const busyTimer = useRef(null);
|
|
250
|
+
const [busyRetry, setBusyRetry] = useState(null);
|
|
251
|
+
const clearBusyRetry = useCallback(() => {
|
|
252
|
+
if (busyTimer.current) clearTimeout(busyTimer.current);
|
|
253
|
+
busyTimer.current = null;
|
|
254
|
+
setBusyRetry(null);
|
|
255
|
+
}, []);
|
|
224
256
|
const jobs = useWebBuilderJobs(effectiveOrg);
|
|
225
257
|
const agentJob = useRef(null);
|
|
226
258
|
const sendAgentTurn = useCallback((channelId, text, files, task) => {
|
|
@@ -244,6 +276,14 @@ function useWebBuilderHost(routeOrg) {
|
|
|
244
276
|
const turn2 = knowledge ? `${text}
|
|
245
277
|
|
|
246
278
|
${projectInstructionsNote(knowledge)}` : text;
|
|
279
|
+
clearBusyRetry();
|
|
280
|
+
lastAgentSend.current = {
|
|
281
|
+
channelId,
|
|
282
|
+
turn: turn2,
|
|
283
|
+
files,
|
|
284
|
+
attempt: 0,
|
|
285
|
+
handled: null
|
|
286
|
+
};
|
|
247
287
|
return chat.sendMessage(turn2, files, channelId, false, void 0, {
|
|
248
288
|
job: job == null ? void 0 : job.ref
|
|
249
289
|
});
|
|
@@ -257,7 +297,7 @@ ${projectInstructionsNote(knowledge)}` : text;
|
|
|
257
297
|
});
|
|
258
298
|
agentJob.current = null;
|
|
259
299
|
}).catch(() => void 0);
|
|
260
|
-
}, [chat, ensureChannel, jobs, ensureAdopted]);
|
|
300
|
+
}, [chat, ensureChannel, jobs, ensureAdopted, clearBusyRetry]);
|
|
261
301
|
useEffect(() => {
|
|
262
302
|
const pending = pendingAgentTurn.current;
|
|
263
303
|
if (!pending || pending.channelId !== agentChannelId) return;
|
|
@@ -514,7 +554,7 @@ ${templateRemixNote(request.template)}` : request.text,
|
|
|
514
554
|
}
|
|
515
555
|
return canFallBackToAgent(error, channelId).then((fallBack) => {
|
|
516
556
|
if (!fallBack) return;
|
|
517
|
-
const id =
|
|
557
|
+
const id = channelId;
|
|
518
558
|
agentChannels.current.add(id);
|
|
519
559
|
unsavedAgentChannels.current.add(id);
|
|
520
560
|
pendingAgentTurn.current = {
|
|
@@ -558,9 +598,12 @@ ${templateRemixNote(request.template)}` : request.text,
|
|
|
558
598
|
const historyRunning = useSyncExternalStore(subscribeRememberedHistory, historyRunningChannelIds, historyRunningChannelIds);
|
|
559
599
|
const shownProjects = useMemo(() => {
|
|
560
600
|
const runs = runningBuilds.filter((r) => !r.org || !effectiveOrg || r.org === effectiveOrg);
|
|
561
|
-
|
|
601
|
+
const named = renames.size ? projects.map((p) => renames.get(p.channelId) ? __spreadProps(__spreadValues({}, p), {
|
|
602
|
+
title: renames.get(p.channelId)
|
|
603
|
+
}) : p) : projects;
|
|
604
|
+
if (!runs.length && !historyRunning.length) return named;
|
|
562
605
|
const ids = /* @__PURE__ */ new Set([...runs.map((r) => r.channelId), ...historyRunning]);
|
|
563
|
-
const rows =
|
|
606
|
+
const rows = named.map((p) => ids.has(p.channelId) ? __spreadProps(__spreadValues({}, p), {
|
|
564
607
|
building: true
|
|
565
608
|
}) : p);
|
|
566
609
|
for (const run of runs) {
|
|
@@ -574,7 +617,7 @@ ${templateRemixNote(request.template)}` : request.text,
|
|
|
574
617
|
}
|
|
575
618
|
}
|
|
576
619
|
return rows.sort((a, b) => b.updatedAt - a.updatedAt);
|
|
577
|
-
}, [projects, runningBuilds, historyRunning, effectiveOrg]);
|
|
620
|
+
}, [projects, runningBuilds, historyRunning, effectiveOrg, renames]);
|
|
578
621
|
const pendingAsk = useMemo(() => {
|
|
579
622
|
var _a2;
|
|
580
623
|
return pendingAskUser([...streamOnSite && chat.messages.length ? chat.messages : transcriptFromPosts(posts).map((m) => ({
|
|
@@ -704,13 +747,54 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
704
747
|
visibleMessages: steeredMessages,
|
|
705
748
|
steering
|
|
706
749
|
} = useHostChatSteering(chat, userBubbleText);
|
|
707
|
-
const
|
|
750
|
+
const rawAgentMessages = useMemo(() => steeredMessages.map((m, index) => ({
|
|
708
751
|
id: `${m.role}-${index}`,
|
|
709
752
|
role: m.role,
|
|
710
753
|
// The template note is for the agent; the person sees what they typed.
|
|
711
754
|
content: m.role === "user" ? userBubbleText(m.content) : displayAgentText(m.content),
|
|
712
755
|
attachments: m.attachments
|
|
713
756
|
})).filter((m) => m.role === "user" || m.content.trim()), [steeredMessages]);
|
|
757
|
+
const busyState = useRef({
|
|
758
|
+
busy: false,
|
|
759
|
+
lastId: null,
|
|
760
|
+
channelId: null
|
|
761
|
+
});
|
|
762
|
+
busyState.current = {
|
|
763
|
+
busy: agentBusy,
|
|
764
|
+
lastId: (_h = (_g = rawAgentMessages[rawAgentMessages.length - 1]) == null ? void 0 : _g.id) != null ? _h : null,
|
|
765
|
+
channelId: agentChannelId
|
|
766
|
+
};
|
|
767
|
+
const agentMessages = useMemo(() => withoutBusyRepeats(rawAgentMessages, Boolean(busyRetry)), [rawAgentMessages, busyRetry]);
|
|
768
|
+
useEffect(() => {
|
|
769
|
+
const sent = lastAgentSend.current;
|
|
770
|
+
const last = rawAgentMessages[rawAgentMessages.length - 1];
|
|
771
|
+
if (!sent || !agentChannelId || sent.channelId !== agentChannelId || agentBusy) return;
|
|
772
|
+
if ((last == null ? void 0 : last.role) !== "assistant" || !isAgentBusyReply(last.content) || sent.handled === last.id) return;
|
|
773
|
+
sent.handled = last.id;
|
|
774
|
+
if (sent.attempt >= BUSY_RETRY_DELAYS_MS.length) return;
|
|
775
|
+
const delay = BUSY_RETRY_DELAYS_MS[sent.attempt];
|
|
776
|
+
sent.attempt += 1;
|
|
777
|
+
setBusyRetry({
|
|
778
|
+
channelId: sent.channelId,
|
|
779
|
+
attempt: sent.attempt
|
|
780
|
+
});
|
|
781
|
+
if (busyTimer.current) clearTimeout(busyTimer.current);
|
|
782
|
+
const busyReplyId = last.id;
|
|
783
|
+
busyTimer.current = setTimeout(() => {
|
|
784
|
+
busyTimer.current = null;
|
|
785
|
+
setBusyRetry(null);
|
|
786
|
+
const now = busyState.current;
|
|
787
|
+
if (now.busy || now.lastId !== busyReplyId || now.channelId !== sent.channelId) return;
|
|
788
|
+
chat.sendMessage(sent.turn, sent.files, sent.channelId, false).catch(() => void 0);
|
|
789
|
+
}, delay);
|
|
790
|
+
}, [rawAgentMessages, agentBusy, agentChannelId, chat]);
|
|
791
|
+
useEffect(() => {
|
|
792
|
+
if (lastAgentSend.current && lastAgentSend.current.channelId !== agentChannelId) {
|
|
793
|
+
lastAgentSend.current = null;
|
|
794
|
+
clearBusyRetry();
|
|
795
|
+
}
|
|
796
|
+
}, [agentChannelId, clearBusyRetry]);
|
|
797
|
+
useEffect(() => () => clearBusyRetry(), [clearBusyRetry]);
|
|
714
798
|
const withOpenRun = useCallback((rows) => {
|
|
715
799
|
if (!openRunPending || !(openRun == null ? void 0 : openRun.ask)) return rows;
|
|
716
800
|
const {
|
|
@@ -726,10 +810,11 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
726
810
|
}];
|
|
727
811
|
}, [openRunPending, openRun]);
|
|
728
812
|
const openRunStreaming = openRunPending ? (openRunState == null ? void 0 : openRunState.progress) || "Building your site\u2026" : null;
|
|
813
|
+
const retryLine = busyRetry ? busyRetryText(busyRetry.attempt) : null;
|
|
729
814
|
const hostChat = useMemo(() => agentLane ? {
|
|
730
815
|
messages: withOpenRun(agentMessages.length ? agentMessages : messages),
|
|
731
|
-
streaming: chat.response ? displayAgentText(chat.response) : openRunStreaming,
|
|
732
|
-
busy: agentBusy || openRunPending,
|
|
816
|
+
streaming: chat.response ? displayAgentText(chat.response) : retryLine || openRunStreaming,
|
|
817
|
+
busy: agentBusy || openRunPending || Boolean(busyRetry),
|
|
733
818
|
error: chat.error,
|
|
734
819
|
connected: cdecli.channelConnected,
|
|
735
820
|
ask: pendingAsk,
|
|
@@ -743,12 +828,12 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
743
828
|
connected: Boolean(token),
|
|
744
829
|
ask: pendingAsk,
|
|
745
830
|
send
|
|
746
|
-
}, [agentLane, agentMessages, steering, pendingAsk, withOpenRun, openRunStreaming, openRunPending, chat.response, agentBusy, chat.error, cdecli.channelConnected, messages, running, progress, building == null ? void 0 : building.statusText, turnError, session.ready, session.error, token, send]);
|
|
831
|
+
}, [agentLane, agentMessages, steering, busyRetry, retryLine, pendingAsk, withOpenRun, openRunStreaming, openRunPending, chat.response, agentBusy, chat.error, cdecli.channelConnected, messages, running, progress, building == null ? void 0 : building.statusText, turnError, session.ready, session.error, token, send]);
|
|
747
832
|
const recordedSandboxRef = useRef(/* @__PURE__ */ new Set());
|
|
748
833
|
const {
|
|
749
834
|
recordAgentBuild
|
|
750
835
|
} = sandboxApi;
|
|
751
|
-
const latestBuild = (
|
|
836
|
+
const latestBuild = (_i = builds[0]) != null ? _i : null;
|
|
752
837
|
useEffect(() => {
|
|
753
838
|
const channelId = activeChannelId;
|
|
754
839
|
const sandboxId = latestBuild == null ? void 0 : latestBuild.sandboxId;
|
|
@@ -787,8 +872,8 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
787
872
|
}, []);
|
|
788
873
|
const keepAlive = useSandboxKeepAlive({
|
|
789
874
|
run: token || activeChannelId ? sandboxCall : null,
|
|
790
|
-
sandboxId: (
|
|
791
|
-
live: activeChannelId !== null && Boolean((
|
|
875
|
+
sandboxId: (_j = builds[0]) == null ? void 0 : _j.sandboxId,
|
|
876
|
+
live: activeChannelId !== null && Boolean((_k = builds[0]) == null ? void 0 : _k.sandboxId),
|
|
792
877
|
onGone: markGone
|
|
793
878
|
});
|
|
794
879
|
const {
|
|
@@ -918,6 +1003,21 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
918
1003
|
return (_b2 = (_a2 = result.data) == null ? void 0 : _a2.aiCodePrePublishReview) != null ? _b2 : null;
|
|
919
1004
|
}
|
|
920
1005
|
}), [sandboxCall, apollo, activeChannelId]);
|
|
1006
|
+
const ensureProjectFor = useCallback(async (channelId, build) => {
|
|
1007
|
+
adoptedRef.current.delete(channelId);
|
|
1008
|
+
const title = (activeProject == null ? void 0 : activeProject.title) || build.title || "New site";
|
|
1009
|
+
const adopted = await ensureAdopted(channelId, title).catch(() => false);
|
|
1010
|
+
if (!adopted) return false;
|
|
1011
|
+
if (build.sandboxId) {
|
|
1012
|
+
await sandboxApi.recordAgentBuild(channelId, {
|
|
1013
|
+
sandboxId: build.sandboxId,
|
|
1014
|
+
previewUrl: build.previewUrl,
|
|
1015
|
+
title,
|
|
1016
|
+
snapshotId: build.snapshotId
|
|
1017
|
+
}).catch(() => null);
|
|
1018
|
+
}
|
|
1019
|
+
return true;
|
|
1020
|
+
}, [ensureAdopted, sandboxApi, activeProject == null ? void 0 : activeProject.title]);
|
|
921
1021
|
const projectTools = useMemo(() => ({
|
|
922
1022
|
loadSettings: async (channelId) => {
|
|
923
1023
|
var _a2, _b2;
|
|
@@ -932,6 +1032,7 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
932
1032
|
const settings = parseProjectSettings(raw);
|
|
933
1033
|
if (settings) instructionsByChannel.current.set(channelId, settings.instructions);
|
|
934
1034
|
if (settings == null ? void 0 : settings.imported) importedChannels.current.add(channelId);
|
|
1035
|
+
if ((settings == null ? void 0 : settings.title) && !isGenericTitle(settings.title)) rememberRename(channelId, settings.title);
|
|
935
1036
|
return raw;
|
|
936
1037
|
},
|
|
937
1038
|
updateSettings: async (channelId, patch) => {
|
|
@@ -948,10 +1049,7 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
948
1049
|
if (typeof patch.instructions === "string") {
|
|
949
1050
|
instructionsByChannel.current.set(channelId, patch.instructions);
|
|
950
1051
|
}
|
|
951
|
-
|
|
952
|
-
if (typeof patch.title === "string" && row) upsertProject(__spreadProps(__spreadValues({}, row), {
|
|
953
|
-
title: patch.title
|
|
954
|
-
}));
|
|
1052
|
+
if (typeof patch.title === "string" && patch.title.trim()) rememberRename(channelId, patch.title.trim());
|
|
955
1053
|
}
|
|
956
1054
|
return raw;
|
|
957
1055
|
},
|
|
@@ -989,33 +1087,51 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
989
1087
|
};
|
|
990
1088
|
},
|
|
991
1089
|
pushToGithub: async (build, repoName) => {
|
|
992
|
-
var _a2;
|
|
1090
|
+
var _a2, _b2;
|
|
993
1091
|
if (!build.sandboxId) return {
|
|
994
1092
|
ok: false,
|
|
995
1093
|
message: "Wake the preview to push to GitHub."
|
|
996
1094
|
};
|
|
997
1095
|
noteActivity();
|
|
1096
|
+
const push = () => apollo.mutate({
|
|
1097
|
+
mutation: PUSH_TO_GITHUB_MUTATION,
|
|
1098
|
+
variables: {
|
|
1099
|
+
sandboxId: build.sandboxId,
|
|
1100
|
+
repoName,
|
|
1101
|
+
channelId: activeChannelId
|
|
1102
|
+
}
|
|
1103
|
+
});
|
|
998
1104
|
try {
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
}
|
|
1105
|
+
let result = await push();
|
|
1106
|
+
const first = (_a2 = result.data) == null ? void 0 : _a2.aiCodePushToGithub;
|
|
1107
|
+
if ((first == null ? void 0 : first.success) === false && isNoProjectRefusal(first.message) && activeChannelId) {
|
|
1108
|
+
const adopted = await ensureProjectFor(activeChannelId, build);
|
|
1109
|
+
if (adopted) result = await push();
|
|
1110
|
+
}
|
|
1111
|
+
const payload = (_b2 = result.data) == null ? void 0 : _b2.aiCodePushToGithub;
|
|
1112
|
+
if (payload && payload.success !== false) {
|
|
1113
|
+
return {
|
|
1114
|
+
ok: true,
|
|
1115
|
+
message: payload.message || "Push started. Follow along in the chat."
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
console.warn("[WebBuilderNative] push refused:", payload == null ? void 0 : payload.message);
|
|
1119
|
+
if (isNoProjectRefusal(payload == null ? void 0 : payload.message)) {
|
|
1120
|
+
return {
|
|
1121
|
+
ok: false,
|
|
1122
|
+
message: "This site isn't saved as a project yet, so it can't be pushed. Try again once the AI has replied."
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
return {
|
|
1012
1126
|
ok: false,
|
|
1013
|
-
message: "The push didn't start. Try again in a moment."
|
|
1127
|
+
message: plainActionError(payload == null ? void 0 : payload.message, "The push didn't start. Try again in a moment.")
|
|
1014
1128
|
};
|
|
1015
|
-
} catch (
|
|
1129
|
+
} catch (err) {
|
|
1130
|
+
const reason = err instanceof Error ? err.message.replace(/^GraphQL error:\s*/i, "") : "";
|
|
1131
|
+
console.warn("[WebBuilderNative] push failed:", reason);
|
|
1016
1132
|
return {
|
|
1017
1133
|
ok: false,
|
|
1018
|
-
message: "The push didn't start. Check your connection and try again."
|
|
1134
|
+
message: reason && !/network|fetch|timed? ?out/i.test(reason) ? plainActionError(reason, "The push didn't start. Try again in a moment.") : "The push didn't start. Check your connection and try again."
|
|
1019
1135
|
};
|
|
1020
1136
|
}
|
|
1021
1137
|
},
|
|
@@ -1030,7 +1146,7 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
1030
1146
|
});
|
|
1031
1147
|
return (_b2 = (_a2 = result.data) == null ? void 0 : _a2.integrationConnectors) != null ? _b2 : [];
|
|
1032
1148
|
}
|
|
1033
|
-
}), [apollo,
|
|
1149
|
+
}), [apollo, rememberRename, noteActivity, activeChannelId, ensureProjectFor]);
|
|
1034
1150
|
useEffect(() => {
|
|
1035
1151
|
if (!activeChannelId) return;
|
|
1036
1152
|
projectTools.loadSettings(activeChannelId).catch(() => void 0);
|
|
@@ -1038,10 +1154,10 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
1038
1154
|
const codeApi = useMemo(() => createCodeWorkspace(sandboxCall, (edit) => {
|
|
1039
1155
|
handEditsRef.current = [...handEditsRef.current.filter((e) => e.file !== edit.file), edit];
|
|
1040
1156
|
}), [sandboxCall]);
|
|
1041
|
-
const siteLiveUrl = (
|
|
1157
|
+
const siteLiveUrl = (_l = activeProject == null ? void 0 : activeProject.liveUrl) != null ? _l : null;
|
|
1042
1158
|
const [backupRepo, setBackupRepo] = useState(null);
|
|
1043
1159
|
const readBackupRepo = sandboxApi.backupRepo;
|
|
1044
|
-
const newestBuildAt = (
|
|
1160
|
+
const newestBuildAt = (_m = builds[0]) == null ? void 0 : _m.updatedAt;
|
|
1045
1161
|
useEffect(() => {
|
|
1046
1162
|
if (!activeChannelId) return void 0;
|
|
1047
1163
|
let live = true;
|
|
@@ -1084,7 +1200,7 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
1084
1200
|
};
|
|
1085
1201
|
}, [codeApi, siteLiveUrl, siteBackupRepo]);
|
|
1086
1202
|
const [deployToCloudflare] = useAiCodeDeployToCloudflareMutation({});
|
|
1087
|
-
const publish = useCallback(async (build, projectName, customDomain) => {
|
|
1203
|
+
const publish = useCallback(async (build, projectName, customDomain, force = false) => {
|
|
1088
1204
|
var _a2;
|
|
1089
1205
|
if (!build.sandboxId || !activeChannelId) {
|
|
1090
1206
|
return {
|
|
@@ -1093,7 +1209,9 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
1093
1209
|
};
|
|
1094
1210
|
}
|
|
1095
1211
|
if (build.origin === "agent") {
|
|
1096
|
-
sendAgentTurn(activeChannelId, agentPublishMessage(build, projectName, customDomain)
|
|
1212
|
+
sendAgentTurn(activeChannelId, `${agentPublishMessage(build, projectName, customDomain, force)}
|
|
1213
|
+
|
|
1214
|
+
${agentEditNote(build)}`);
|
|
1097
1215
|
return {
|
|
1098
1216
|
ok: true
|
|
1099
1217
|
};
|
|
@@ -1104,11 +1222,13 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
1104
1222
|
projectName,
|
|
1105
1223
|
channelId: activeChannelId
|
|
1106
1224
|
};
|
|
1107
|
-
const result = customDomain ? await apollo.mutate({
|
|
1225
|
+
const result = customDomain || force ? await apollo.mutate({
|
|
1108
1226
|
mutation: DEPLOY_WITH_DOMAIN_MUTATION,
|
|
1109
|
-
variables:
|
|
1227
|
+
variables: __spreadValues(__spreadValues(__spreadValues({}, variables), customDomain ? {
|
|
1110
1228
|
customDomain
|
|
1111
|
-
})
|
|
1229
|
+
} : {}), force ? {
|
|
1230
|
+
force
|
|
1231
|
+
} : {})
|
|
1112
1232
|
}) : await deployToCloudflare({
|
|
1113
1233
|
variables
|
|
1114
1234
|
});
|
|
@@ -1117,9 +1237,11 @@ ${agentEditNote(target)}` : ""}${editsNote}`;
|
|
|
1117
1237
|
ok: true
|
|
1118
1238
|
};
|
|
1119
1239
|
console.warn("[WebBuilderNative] publish refused:", payload == null ? void 0 : payload.message);
|
|
1240
|
+
const reason = plainActionError(payload == null ? void 0 : payload.message, "");
|
|
1120
1241
|
return {
|
|
1121
1242
|
ok: false,
|
|
1122
|
-
message: "Publishing didn't start. Try again in a moment."
|
|
1243
|
+
message: reason || "Publishing didn't start. Try again in a moment.",
|
|
1244
|
+
blocked: /critical|check|blocked|secret|security/i.test(reason)
|
|
1123
1245
|
};
|
|
1124
1246
|
} catch (err) {
|
|
1125
1247
|
console.warn("[WebBuilderNative] publish failed:", err);
|