Skip to content

Commit e20c10e

Browse files
committed
Merge branch 'add-canvas' of https://github.com/ClayPulse/pulse-editor into add-canvas
2 parents 3d44abb + 2955b3a commit e20c10e

File tree

7 files changed

+87
-66
lines changed

7 files changed

+87
-66
lines changed

package-lock.json

Lines changed: 4 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,5 @@
2626
},
2727
"devDependencies": {
2828
"@changesets/cli": "^2.29.4"
29-
},
30-
"dependencies": {
31-
"@pulse-editor/shared-utils": "^0.1.1-alpha.21"
3229
}
3330
}

web/components/extension/extension-preview.tsx

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ export default function ExtensionPreview({
7575
undefined,
7676
);
7777

78-
const [isCompatible, setIsCompatible] = useState<boolean | undefined>(
78+
const [isMFCompatible, setIsMFCompatible] = useState<boolean | undefined>(
79+
undefined,
80+
);
81+
const [isLibCompatible, setIsLibCompatible] = useState<boolean | undefined>(
7982
undefined,
8083
);
8184

@@ -100,21 +103,26 @@ export default function ExtensionPreview({
100103

101104
const remoteLibVersion =
102105
extension.config.libVersion === "unknown"
103-
? await getRemoteLibVersion(
104-
extension.remoteOrigin,
105-
extension.config.id,
106-
extension.config.version,
107-
)
108-
: extension.config.libVersion;
106+
? (
107+
await getRemoteLibVersion(
108+
extension.remoteOrigin,
109+
extension.config.id,
110+
extension.config.version,
111+
)
112+
).replace("^", "")
113+
: extension.config.libVersion.replace("^", "");
109114
setRemoteLibVersion(remoteLibVersion);
110115

111116
const mfCompatible = await checkCompatibility(
112117
hostMFVersion,
113-
hostLibVersion,
114118
remoteMFVersion,
119+
);
120+
const libCompatible = await checkCompatibility(
121+
hostLibVersion,
115122
remoteLibVersion,
116123
);
117-
setIsCompatible(mfCompatible);
124+
setIsMFCompatible(mfCompatible);
125+
setIsLibCompatible(libCompatible);
118126
}
119127

120128
fetchVersions();
@@ -175,8 +183,9 @@ export default function ExtensionPreview({
175183
<EnableCheckBox isActive={isEnabled} onPress={toggleExtension} />
176184
)}
177185

178-
{isCompatible !== undefined &&
179-
(!isCompatible ? (
186+
{isMFCompatible !== undefined &&
187+
isLibCompatible !== undefined &&
188+
(!isMFCompatible || !isLibCompatible ? (
180189
<Popover
181190
isOpen={showMFVersionInfo}
182191
onOpenChange={setShowMFVersionInfo}
@@ -196,23 +205,36 @@ export default function ExtensionPreview({
196205
setShowMFVersionInfo(false);
197206
}}
198207
>
199-
<Icon name="warning" className="text-danger!" />
208+
{!isMFCompatible ? (
209+
<Icon name="warning" className="text-danger!" />
210+
) : (
211+
<Icon name="warning" className="text-warning!" />
212+
)}
200213
</Button>
201214
</PopoverTrigger>
202215
<PopoverContent>
203216
<div className="max-w-xs">
204-
<p>
205-
This app is outdated and no longer a valid module
206-
federation app. Please update the app to the latest
207-
version. <br />
208-
Host MF version: {hostMFVersion}
209-
<br />
210-
Host lib version: {hostLibVersion}
211-
<br />
212-
App MF version: {remoteMFVersion}
213-
<br />
214-
App lib version: {remoteLibVersion}
215-
</p>
217+
{!isMFCompatible && (
218+
<p>
219+
This app is outdated and no longer a valid module
220+
federation app. Please update the app to the latest
221+
version. <br />
222+
Host MF version: {hostMFVersion}
223+
<br />
224+
App MF version: {remoteMFVersion}
225+
</p>
226+
)}
227+
{!isLibCompatible && (
228+
<p>
229+
This app's library version is outdated and may not
230+
work correctly. Please update the app to the latest
231+
version.
232+
<br />
233+
Host lib version: {hostLibVersion}
234+
<br />
235+
App lib version: {remoteLibVersion}
236+
</p>
237+
)}
216238
</div>
217239
</PopoverContent>
218240
</Popover>
@@ -241,9 +263,9 @@ export default function ExtensionPreview({
241263
<PopoverContent>
242264
<div className="max-w-xs">
243265
<p>
244-
This app's module federation version (
245-
{extension.mfVersion}) matches the host version (
246-
{hostMFVersion}). The app should work correctly.
266+
This app's module federation version ({hostMFVersion})
267+
and library version ({hostLibVersion}) match the host
268+
version. The app should work correctly.
247269
</p>
248270
</div>
249271
</PopoverContent>

web/components/interface/command-viewer.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,28 @@ export default function CommandViewer() {
4040
const [isOutputVoice, setIsOutputVoice] = useState(false);
4141
const [isWaitingAssistant, setIsWaitingAssistant] = useState(false);
4242

43+
const [args, setArgs] = useState<any>({});
44+
4345
const historyRef = useRef<HTMLDivElement>(null);
4446

4547
const runActionCallback = useCallback(
4648
async (action: ScopedAction) => {
47-
const result = await runAction(action, {});
48-
console.log("Command result:", result);
49-
addToast({
50-
color: "success",
51-
title: "Command Executed",
52-
description: `Executed command: ${action.action.name}`,
53-
});
49+
try {
50+
const result = await runAction(action, args);
51+
52+
console.log("Command result:", result);
53+
addToast({
54+
color: "success",
55+
title: "Command Executed",
56+
description: `Executed command: ${action.action.name}`,
57+
});
58+
} catch (error: any) {
59+
addToast({
60+
color: "danger",
61+
title: "Command Execution Failed",
62+
description: `Failed to execute command: ${action.action.name}. Error: ${error.message}`,
63+
});
64+
}
5465
},
5566
[runAction],
5667
);

web/lib/hooks/use-scoped-actions.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ export default function useScopedActions() {
122122
} else if (action.type === "app") {
123123
const extensions = editorContext?.persistSettings?.extensions ?? [];
124124
const ext = extensions.find((e) =>
125-
(e.config.actions ?? []).some((act) => act.name === action.action.name),
125+
(e.config.preRegisteredActions ?? []).some(
126+
(act) => act.name === action.action.name,
127+
),
126128
);
127129

128130
if (!ext) {
@@ -136,11 +138,12 @@ export default function useScopedActions() {
136138

137139
if (appInView) {
138140
// App is already in the view, execute Action in the app's context.
139-
imcContext?.polyIMC?.sendMessage(
141+
const result = await imcContext?.polyIMC?.sendMessage(
140142
ext.config.id + "-" + appInView.viewId,
141143
IMCMessageTypeEnum.EditorRunAppAction,
142144
{ name: action.action.name, args },
143145
);
146+
return result;
144147
} else {
145148
// Create an instance of the app that provides the static Action,
146149
// then execute Action in the app's context.
@@ -159,11 +162,12 @@ export default function useScopedActions() {
159162
});
160163
}
161164

162-
return await imcContext?.polyIMC?.sendMessage(
165+
const result = await imcContext?.polyIMC?.sendMessage(
163166
ext.config.id + "-" + viewId,
164167
IMCMessageTypeEnum.EditorRunAppAction,
165168
{ name: action.action.name, args },
166169
);
170+
return result;
167171
}
168172
}
169173
}
@@ -172,7 +176,7 @@ export default function useScopedActions() {
172176
extension: ExtensionApp,
173177
keyword?: string,
174178
) {
175-
const actions = extension.config.actions ?? [];
179+
const actions = extension.config.preRegisteredActions ?? [];
176180
if (keyword) {
177181
return actions.filter((action) =>
178182
action.name.toLowerCase().includes(keyword.toLowerCase().trim()),

web/lib/module-federation/version.ts

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ export async function getRemoteMFVersion(
2121
}
2222

2323
export async function getHostLibVersion(): Promise<string> {
24-
const version = packageJson.dependencies[
25-
"@pulse-editor/shared-utils"
26-
].replace("^", "");
24+
const version = packageJson.dependencies["@pulse-editor/shared-utils"];
2725
return version;
2826
}
2927

@@ -40,29 +38,21 @@ export async function getRemoteLibVersion(
4038
if (!pulseConfig) {
4139
throw new Error("Remote pulse.config.json undefined");
4240
}
43-
const libVersion = pulseConfig.libVersion.replace("^", "");
41+
const libVersion = pulseConfig.libVersion;
4442
return libVersion;
4543
}
4644

4745
export async function checkCompatibility(
48-
hostMFVersion: string,
49-
hostLibVersion: string,
50-
remoteMFVersion: string,
51-
remoteLibVersion: string,
46+
hostVersion: string,
47+
remoteVersion: string,
5248
): Promise<boolean> {
53-
if (remoteMFVersion === "unknown" || remoteLibVersion === "unknown") {
49+
if (remoteVersion === "unknown") {
5450
console.warn("Could not determine remote versions. ");
5551
return false;
5652
}
57-
if (!satisfies(remoteMFVersion, hostMFVersion)) {
53+
if (!satisfies(remoteVersion, hostVersion)) {
5854
console.warn(
59-
`Incompatible MF versions: host ${hostMFVersion}, remote ${remoteMFVersion}`,
60-
);
61-
return false;
62-
}
63-
if (!satisfies(remoteLibVersion, hostLibVersion)) {
64-
console.warn(
65-
`Incompatible lib versions: host ${hostLibVersion}, remote ${remoteLibVersion}`,
55+
`Incompatible versions: host ${hostVersion}, remote ${remoteVersion}`,
6656
);
6757
return false;
6858
}

web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@langchain/core": "^0.3.66",
2828
"@langchain/openai": "^0.6.3",
2929
"@pulse-editor/capacitor-plugin": "file:../capacitor-plugin",
30-
"@pulse-editor/shared-utils": "^0.1.1-alpha.39",
30+
"@pulse-editor/shared-utils": "^0.1.1-alpha.41",
3131
"@ricky0123/vad-web": "^0.0.28",
3232
"@vercel/analytics": "^1.5.0",
3333
"@xyflow/react": "^12.8.5",

0 commit comments

Comments
 (0)