Skip to content

Commit 8d4616c

Browse files
committed
Add running indication & improve app theme updates
1 parent da18120 commit 8d4616c

File tree

8 files changed

+64
-31
lines changed

8 files changed

+64
-31
lines changed

npm-packages/shared-utils/src/imc/inter-module-communication.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,7 @@ export class InterModuleCommunication {
7272
}
7373

7474
const message = event.data;
75-
if (
76-
process.env.NODE_ENV === "development" &&
77-
message.from !== undefined
78-
) {
75+
if (message.from !== undefined) {
7976
console.log(
8077
`Module ${this.thisWindowId} received message from module ${
8178
message.from

web/components/app-loaders/sandbox-app-loader.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export default function SandboxAppLoader({
141141
}
142142
}, [isConnected]);
143143

144-
// Send theme update to the extension
144+
// Send theme update to the extension when theme changes
145145
useEffect(() => {
146146
if (currentViewId && imcContext?.polyIMC?.hasChannel(currentViewId)) {
147147
imcContext?.polyIMC?.sendMessage(
@@ -166,7 +166,7 @@ export default function SandboxAppLoader({
166166
getHandlerMap(viewModel),
167167
);
168168
}
169-
}, [viewModel, isConnected]);
169+
}, [viewModel]);
170170

171171
function getHandlerMap(model: ViewModel) {
172172
const newMap = new Map<IMCMessageTypeEnum, ReceiverHandler>();
@@ -188,6 +188,16 @@ export default function SandboxAppLoader({
188188
if (onInitialLoaded) {
189189
onInitialLoaded();
190190
}
191+
192+
// Update with current theme
193+
// TODO: pass theme directly to app along with config when creating a new view
194+
if (currentViewId && imcContext?.polyIMC?.hasChannel(currentViewId)) {
195+
imcContext?.polyIMC?.sendMessage(
196+
currentViewId,
197+
IMCMessageTypeEnum.EditorThemeUpdate,
198+
resolvedTheme,
199+
);
200+
}
191201
},
192202
);
193203

web/components/interface/editor-toolbar.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,30 @@ export default function EditorToolbar() {
111111
return;
112112
}
113113

114+
editorContext.setEditorStates((prev) => ({
115+
...prev,
116+
runningNode: node,
117+
}));
114118
runAction(
115119
{
116120
action: selectedAction,
117121
viewId: node.id,
118122
type: "app",
119123
},
120124
{},
121-
);
125+
).then((result) => {
126+
addToast({
127+
title: "Workflow Completed",
128+
description: `The workflow has completed with result: ${JSON.stringify(
129+
result,
130+
)}`,
131+
color: "success",
132+
});
133+
editorContext?.setEditorStates((prev) => ({
134+
...prev,
135+
runningNode: undefined,
136+
}));
137+
});
122138
}}
123139
>
124140
<Icon name="play_arrow" variant="round" />

web/components/providers/imc-provider.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ export default function InterModuleCommunicationProvider({
9696
}
9797

9898
function markActionRegistered(action: Action) {
99-
console.log(`Action registered: ${action.name}`);
10099
actionRegisteredMapRef.current.set(action.name, true);
101100
if (actionRegisteredResolvePromisesRef.current[action.name]) {
102101
actionRegisteredResolvePromisesRef.current[action.name]();

web/components/views/canvas/canvas-view.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ export default function CanvasView({ config }: { config?: CanvasViewConfig }) {
203203
}),
204204
);
205205
},
206+
isRunning: false,
206207
},
207208
type: "appNode",
208209
height: appConfig.recommendedHeight ?? 360,

web/components/views/canvas/nodes/app-node/layout.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
useInternalNode,
1919
useUpdateNodeInternals,
2020
} from "@xyflow/react";
21+
import clsx from "clsx";
2122
import { useContext, useEffect, useState } from "react";
2223
import NodeHandle from "./node-handle";
2324

@@ -61,6 +62,15 @@ export default function CanvasNodeViewLayout({
6162
}));
6263
}, [node]);
6364

65+
useEffect(() => {
66+
const runningNode = editorContext?.editorStates.runningNode;
67+
if (runningNode?.id === node?.id) {
68+
setIsRunning(true);
69+
} else {
70+
setIsRunning(false);
71+
}
72+
}, [editorContext?.editorStates.runningNode]);
73+
6474
return (
6575
<div className="relative w-full h-full">
6676
{/* Control */}
@@ -171,16 +181,19 @@ export default function CanvasNodeViewLayout({
171181
/>
172182

173183
<div className="bg-content1 relative h-full w-full rounded-lg shadow-md z-10">
174-
{node?.selected || node?.dragging ? (
175-
<div className="absolute top-0 left-0 rounded-lg h-full w-full overflow-hidden selected wrapper gradient z-0" />
184+
{isRunning ? (
185+
<div className="absolute top-0 left-0 rounded-lg h-full w-full overflow-hidden running wrapper gradient z-0" />
176186
) : (
177-
isRunning && (
178-
<div className="absolute top-0 left-0 rounded-lg h-full w-full overflow-hidden running wrapper gradient z-0" />
187+
(node?.selected || node?.dragging) && (
188+
<div className="absolute top-0 left-0 rounded-lg h-full w-full overflow-hidden selected wrapper gradient z-0" />
179189
)
180190
)}
181191

182192
<div
183-
className="relative h-full w-full rounded-md overflow-hidden z-10 data-[is-dragging=true]:pointer-events-none data-[is-resizing=true]:pointer-events-none aura"
193+
className={clsx(
194+
"relative h-full w-full rounded-md overflow-hidden z-10 data-[is-dragging=true]:pointer-events-none data-[is-resizing=true]:pointer-events-none",
195+
(node?.selected || node?.dragging) && !isRunning && "aura",
196+
)}
184197
data-is-dragging={node?.dragging ? "true" : "false"}
185198
data-is-resizing={node?.resizing ? "true" : "false"}
186199
>

web/components/views/canvas/theme.css

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.react-flow__node-appNode.selected .aura {
22
box-shadow:
3-
4px 0 15px rgba(42, 138, 246, 0.3),
4-
-4px 0 15px rgba(233, 42, 103, 0.3);
3+
4px 0 18px rgba(42, 138, 246, 0.5),
4+
-4px 0 18px rgba(233, 42, 103, 0.5);
55
}
66

77
.react-flow__node-appNode .aura {
@@ -22,14 +22,14 @@
2222
.gradient:before {
2323
content: "";
2424
position: absolute;
25-
inset: -50%; /* makes it bigger than the box */
26-
border-radius: 50%; /* keep it circular */
25+
inset: -50%;
26+
border-radius: 50%;
2727
background: conic-gradient(
2828
from -160deg at 50% 50%,
29-
#e92a67 0deg,
30-
#a853ba 120deg,
31-
#2a8af6 240deg,
32-
#e92a67 360deg
29+
#ff2a6d 0deg,
30+
#b86bff 120deg,
31+
#3a9bff 240deg,
32+
#ff2a6d 360deg
3333
);
3434
z-index: -1;
3535
}
@@ -38,11 +38,11 @@
3838
content: "";
3939
background: conic-gradient(
4040
from -160deg at 50% 50%,
41-
#e92a6700 0deg,
42-
#ff0035cc 20deg,
43-
#a853ba 126deg,
44-
#2a8af6cc 232deg,
45-
#2a8af600 340deg
41+
#ff2a6d00 0deg,
42+
#ff0044dd 20deg,
43+
#b86bff 126deg,
44+
#3a9bffdd 232deg,
45+
#3a9bff00 340deg
4646
);
4747
animation: spinner 4s linear infinite;
4848
transform: rotate(0deg);
@@ -59,8 +59,3 @@
5959
outline: none;
6060
}
6161

62-
.react-flow__edge .react-flow__edge-path {
63-
stroke: url(#edge-gradient);
64-
stroke-width: 2;
65-
stroke-opacity: 0.75;
66-
}

web/lib/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ export type EditorStates = {
8787
isSideMenuOpen?: boolean;
8888
isMarketplaceOpen?: boolean;
8989

90+
// Canvas app nodes
9091
selectedNode?: Node;
92+
runningNode?: Node;
9193
};
9294

9395
/**

0 commit comments

Comments
 (0)