Skip to content

Commit 9991257

Browse files
committed
feat: ワークフロー実行ページに進行状況表示を追加し、useWorkflowRunフックを更新してワークフローオブジェクトを渡すように変更しました。
1 parent bf39564 commit 9991257

File tree

4 files changed

+360
-59
lines changed

4 files changed

+360
-59
lines changed

src/lib/grpc-clients.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,15 +214,15 @@ interface ImportMetaLike {
214214
const im = import.meta as unknown as ImportMetaLike;
215215

216216
// Resolve base URL in order of preference:
217-
// 1) VITE_GRPC_BASE_URL (e.g. http://localhost:50051)
217+
// 1) VITE_GRPC_BASE_URL (e.g. http://localhost:50052)
218218
// 2) window.__SAPPHILLON_GRPC_BASE__ (debug hook)
219-
// 3) fallback http://localhost:50051
219+
// 3) fallback http://localhost:50052
220220
export const BASE_URL =
221221
(im.env?.VITE_GRPC_BASE_URL as string | undefined) ||
222222
(typeof window !== "undefined" &&
223223
(window as unknown as { __SAPPHILLON_GRPC_BASE__?: string })
224224
.__SAPPHILLON_GRPC_BASE__) ||
225-
"http://localhost:50051";
225+
"http://localhost:50052";
226226

227227
// Toggle grpc-web binary/json via env (defaults to binary)
228228
const BIN_ENV = (

src/lib/workflow-progress.ts

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/**
2+
* @fileoverview Floorp 進捗ウィンドウとの通信ユーティリティ
3+
*/
4+
5+
export interface WorkflowProgressStep {
6+
id: string;
7+
functionId: string;
8+
functionName: string;
9+
status: "pending" | "running" | "completed" | "error";
10+
startedAt?: number;
11+
completedAt?: number;
12+
}
13+
14+
export interface WorkflowProgressMessage {
15+
type:
16+
| "workflow-progress-start"
17+
| "workflow-progress-update"
18+
| "workflow-progress-complete"
19+
| "workflow-progress-error";
20+
workflowId: string;
21+
workflowName?: string;
22+
steps?: WorkflowProgressStep[];
23+
currentStepIndex?: number;
24+
status?: "idle" | "running" | "completed" | "error";
25+
}
26+
27+
declare global {
28+
interface Window {
29+
OSAutomotor?: {
30+
sendWorkflowProgress: (
31+
data: WorkflowProgressMessage
32+
) => Promise<{ success: boolean; error?: string }>;
33+
};
34+
}
35+
}
36+
37+
/**
38+
* Floorp の進捗ウィンドウへメッセージを送信
39+
*/
40+
export function sendProgressMessage(message: WorkflowProgressMessage): void {
41+
if (window.OSAutomotor?.sendWorkflowProgress) {
42+
window.OSAutomotor.sendWorkflowProgress(message).catch(() => {
43+
// Ignore errors silently
44+
});
45+
}
46+
}
47+
48+
/**
49+
* プラグイン関数 ID からステップリストを生成
50+
*/
51+
export function parseWorkflowSteps(
52+
pluginFunctionIds: string[]
53+
): WorkflowProgressStep[] {
54+
return pluginFunctionIds.map((functionId, index) => ({
55+
id: `step-${index}`,
56+
functionId,
57+
functionName: functionId.split(".").pop() || functionId,
58+
status: "pending" as const,
59+
}));
60+
}
61+
62+
/**
63+
* ワークフロー実行開始を通知
64+
*/
65+
export function notifyWorkflowStart(
66+
workflowId: string,
67+
workflowName: string,
68+
steps: WorkflowProgressStep[]
69+
): void {
70+
sendProgressMessage({
71+
type: "workflow-progress-start",
72+
workflowId,
73+
workflowName,
74+
steps,
75+
currentStepIndex: 0,
76+
status: "running",
77+
});
78+
}
79+
80+
/**
81+
* ステップ進捗を通知
82+
*/
83+
export function notifyStepUpdate(
84+
workflowId: string,
85+
steps: WorkflowProgressStep[],
86+
currentStepIndex: number
87+
): void {
88+
sendProgressMessage({
89+
type: "workflow-progress-update",
90+
workflowId,
91+
steps,
92+
currentStepIndex,
93+
status: "running",
94+
});
95+
}
96+
97+
/**
98+
* ワークフロー完了を通知
99+
*/
100+
export function notifyWorkflowComplete(
101+
workflowId: string,
102+
steps: WorkflowProgressStep[]
103+
): void {
104+
sendProgressMessage({
105+
type: "workflow-progress-complete",
106+
workflowId,
107+
steps,
108+
currentStepIndex: steps.length - 1,
109+
status: "completed",
110+
});
111+
}
112+
113+
/**
114+
* ワークフローエラーを通知
115+
*/
116+
export function notifyWorkflowError(
117+
workflowId: string,
118+
steps: WorkflowProgressStep[],
119+
currentStepIndex: number
120+
): void {
121+
sendProgressMessage({
122+
type: "workflow-progress-error",
123+
workflowId,
124+
steps,
125+
currentStepIndex,
126+
status: "error",
127+
});
128+
}

0 commit comments

Comments
 (0)