feat(tui): workflow-start intent input box wired to StartSession.input
This commit is contained in:
@@ -213,9 +213,14 @@ func ChatInput(sessionID, text, mode string) []byte {
|
||||
return encode("ChatInput", map[string]any{"sessionId": sessionID, "text": text, "mode": mode})
|
||||
}
|
||||
|
||||
// StartSession launches a workflow-backed session.
|
||||
func StartSession(workflowID string) []byte {
|
||||
return encode("StartSession", map[string]any{"workflowId": workflowID, "config": nil})
|
||||
// StartSession launches a workflow-backed session. input is the optional freeform request
|
||||
// seeded into the decision journal; pass "" for fixed-task workflows (e.g. healthcheck).
|
||||
func StartSession(workflowID, input string) []byte {
|
||||
msg := map[string]any{"workflowId": workflowID, "config": nil}
|
||||
if input != "" {
|
||||
msg["input"] = input
|
||||
}
|
||||
return encode("StartSession", msg)
|
||||
}
|
||||
|
||||
// CancelSession cancels a running session.
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package protocol
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func decodeFrame(t *testing.T, b []byte) map[string]any {
|
||||
t.Helper()
|
||||
var m map[string]any
|
||||
if err := json.Unmarshal(b, &m); err != nil {
|
||||
t.Fatalf("unmarshal: %v", err)
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
func TestStartSessionOmitsEmptyInput(t *testing.T) {
|
||||
m := decodeFrame(t, StartSession("healthcheck", ""))
|
||||
if m["workflowId"] != "healthcheck" {
|
||||
t.Fatalf("unexpected frame: %+v", m)
|
||||
}
|
||||
if _, present := m["input"]; present {
|
||||
t.Fatalf("empty input must be omitted, got: %+v", m)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStartSessionCarriesIntent(t *testing.T) {
|
||||
m := decodeFrame(t, StartSession("role_pipeline", "add an auth layer to the account service"))
|
||||
if m["input"] != "add an auth layer to the account service" {
|
||||
t.Fatalf("intent not carried: %+v", m)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user