feat(tui): workflow-start intent input box wired to StartSession.input

This commit is contained in:
2026-06-04 02:24:41 +04:00
parent fe561ada09
commit 638f57709d
5 changed files with 82 additions and 13 deletions
+34 -10
View File
@@ -243,6 +243,12 @@ func (m Model) handleInsertKey(k tea.KeyMsg) (tea.Model, tea.Cmd) {
if m.inputMode == ModeFilter {
m.inputMode = ModeRouter
}
if m.inputMode == ModeIntent {
m.wfPendingID = ""
m.wfPendingName = ""
m.clearInput()
m.inputMode = ModeRouter
}
case tea.KeyEnter:
return m.submit()
case tea.KeyBackspace:
@@ -275,6 +281,19 @@ func (m Model) handleInsertKey(k tea.KeyMsg) (tea.Model, tea.Cmd) {
return m, nil
}
// beginIntent stashes the chosen workflow and switches to a text-entry prompt for the
// freeform request. Submitting sends StartSession(id, intent); an empty line starts with no
// intent (fixed-task workflows). Esc cancels.
func (m *Model) beginIntent(wf Workflow) {
m.wfPendingID = wf.ID
m.wfPendingName = wf.ID
m.wfVisible = false
m.wfIndex = -1
m.clearInput()
m.editMode = ModeInsert
m.inputMode = ModeIntent
}
func (m *Model) enterInsert(mode InputMode) {
m.editMode = ModeInsert
m.inputMode = mode
@@ -296,11 +315,7 @@ func (m Model) normalEnter() (tea.Model, tea.Cmd) {
return m, nil
}
if m.wfVisible && m.wfIndex >= 0 && m.wfIndex < len(m.workflows) {
wf := m.workflows[m.wfIndex]
m.client.Send(protocol.StartSession(wf.ID))
m.wfVisible = false
m.wfIndex = -1
m.pendingWorkflowFocus = true
m.beginIntent(m.workflows[m.wfIndex])
return m, nil
}
if m.selectedID != "" {
@@ -537,12 +552,21 @@ func (m Model) submit() (tea.Model, tea.Cmd) {
switch ds {
case StateIdle:
// Workflow picker selection.
if m.wfIndex >= 0 && m.wfIndex < len(m.workflows) {
wf := m.workflows[m.wfIndex]
m.wfIndex = -1
m.client.Send(protocol.StartSession(wf.ID))
// Intent line for a workflow being started.
if m.wfPendingID != "" {
id := m.wfPendingID
m.client.Send(protocol.StartSession(id, text))
m.wfPendingID = ""
m.wfPendingName = ""
m.clearInput()
m.inputMode = ModeRouter
m.editMode = ModeNormal
m.pendingWorkflowFocus = true
return m, nil
}
// Workflow picker selection → prompt for the request first.
if m.wfIndex >= 0 && m.wfIndex < len(m.workflows) {
m.beginIntent(m.workflows[m.wfIndex])
return m, nil
}
// Entering an already-selected session (blank submit).