Feat v0.7.9 workflow independence #63

Merged
xcaliber merged 5 commits from feat/v0.7.9-workflow-independence into main 2026-04-02 22:31:47 +00:00
2 changed files with 20 additions and 5 deletions
Showing only changes of commit 110f128661 - Show all commits

View File

@@ -673,18 +673,27 @@ type WorkflowLandingPageData struct {
func (e *Engine) RenderWorkflow() gin.HandlerFunc {
return func(c *gin.Context) {
ctx := c.Request.Context()
entryToken := c.Param("id")
routeID := c.Param("id")
sessionID := c.GetString("session_id")
sessionName := "Visitor"
instanceName, _, _ := e.loadBranding()
// Try to load instance by entry token, then by ID
// Try to load instance — the route param may be an instance ID
// or an entry token. Also check the ?token= query param.
var inst *models.WorkflowInstance
if e.stores.Workflows != nil {
inst, _ = e.stores.Workflows.GetInstanceByToken(ctx, entryToken)
// First try: query param token (from landing page redirect)
if qToken := c.Query("token"); qToken != "" {
inst, _ = e.stores.Workflows.GetInstanceByToken(ctx, qToken)
}
// Second try: route param as entry token
if inst == nil {
inst, _ = e.stores.Workflows.GetInstance(ctx, entryToken)
inst, _ = e.stores.Workflows.GetInstanceByToken(ctx, routeID)
}
// Third try: route param as instance ID
if inst == nil {
inst, _ = e.stores.Workflows.GetInstance(ctx, routeID)
}
}
@@ -730,6 +739,12 @@ func (e *Engine) RenderWorkflow() gin.HandlerFunc {
}
}
// Resolve the actual entry token from the instance (used by JS API calls)
entryToken := ""
if inst.EntryToken != nil {
entryToken = *inst.EntryToken
}
e.Render(c, "workflow.html", PageData{
Surface: "workflow",
InstanceName: instanceName,

View File

@@ -398,7 +398,7 @@
}
window.submitForm = async function() {
if (!FORM_TPL || !FORM_TPL.fields) return;
if (!FORM_TPL || (!FORM_TPL.fields && !FORM_TPL.fieldsets)) return;
var btn = document.getElementById('formSubmitBtn');
if (btn) btn.disabled = true;