singularity-forge/web/lib/workflow-action-execution.ts
ace-pm 83feadb4e1 wip: rename gsd-parser dir + exports, fix native package.json
- packages/native/src/gsd-parser → packages/native/src/forge-parser
- Update packages/native/package.json exports: ./gsd-parser → ./forge-parser
- Update packages/native/src/index.ts imports: ./gsd-parser → ./forge-parser

Build in progress: native tsc output missing submodule dists (fd, text, image, etc).
This is a pre-existing issue with the build system, not caused by rebrand.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 14:22:21 +02:00

50 lines
1.6 KiB
TypeScript

import type { WorkspaceTerminalLine } from "./sf-workspace-store"
import { getUserMode } from "./use-user-mode"
export type SFViewName = "dashboard" | "power" | "chat" | "roadmap" | "files" | "activity" | "visualize"
export function navigateToSFView(view: SFViewName): void {
if (typeof window === "undefined") return
window.dispatchEvent(new CustomEvent("sf:navigate-view", { detail: { view } }))
}
/**
* Dispatch a workflow action command through the session command pipeline
* and navigate to the Power User Mode view.
*
* `dispatch` should be a function that sends the command through the workspace
* store (e.g. `sendCommand(buildPromptCommand(command, bridge))`), so the
* command is processed by the agent session — not just injected as raw PTY
* keystrokes.
*/
export function executeWorkflowActionInPowerMode({
dispatch,
}: {
dispatch: () => Promise<unknown>
}): void {
dispatch().catch((error) => {
console.error("[workflow-action] dispatch failed:", error)
})
const mode = getUserMode()
navigateToSFView(mode === "vibe-coder" ? "chat" : "power")
}
export function derivePendingWorkflowCommandLabel({
commandInFlight,
terminalLines,
}: {
commandInFlight: string | null
terminalLines: WorkspaceTerminalLine[]
}): string | null {
if (!commandInFlight) return null
for (let index = terminalLines.length - 1; index >= 0; index -= 1) {
const line = terminalLines[index]
if (line.type !== "input") continue
const text = line.content.trim()
if (text) return text
}
if (commandInFlight === "prompt") return "Sending command"
return `/${commandInFlight}`
}