Honor explicit follow-up questions after a submitted work choice

Why: A fresh question referencing an earlier result could be mistaken for a duplicate background request.

Evidence: The new English-summary reference regression failed with the old receipt branch and passes with the explicit-reference distinction.

Impact: Deduplicate inferred pending choices while allowing explicit new requests to use the saved result.

Refs: feature/workbench-flow-completion review P1
This commit is contained in:
2026-10-15 07:14:17 +00:00
parent aed45d7f31
commit 0f4ca18957
2 changed files with 20 additions and 1 deletions
+2 -1
View File
@@ -292,6 +292,7 @@ func materialPurposeRequest(text string) bool {
}
func (m *Manager) bindWorkContext(conv core.Conversation, msg core.Message, ref *WorkReference, runIDs ...core.ID) (string, error) {
inferred := ref == nil
if ref == nil {
ref = m.directWorkReference(conv, messageText(msg))
}
@@ -304,7 +305,7 @@ func (m *Manager) bindWorkContext(conv core.Conversation, msg core.Message, ref
return "", err
}
if d := card.Work.Decision; d != nil && materialPurposeRequest(messageText(msg)) {
if d.State == "dispatching" || d.State == "submitted" {
if inferred && (d.State == "dispatching" || d.State == "submitted") {
return workReceiptPrefix + card.ID, nil
}
if d.State == "open" || d.State == "deferred" {
+18
View File
@@ -169,6 +169,24 @@ func TestDirectMaterialSummaryUsesExistingForegroundOnly(t *testing.T) {
}
}
func TestExplicitWorkReferenceAllowsNewSummaryAfterPreviousChoice(t *testing.T) {
c, card := completedMaterialWork(t)
_, err := c.mgr.WorkCardAction(c.run.Owner, card.ID, "work.submit", core.WorkCardAction{ResultVersion: 1, SelectedIDs: []string{"summary"}})
if err != nil {
t.Fatal(err)
}
waitBackgroundIdle(t, c)
conv, err := c.mgr.st.GetConversation(c.run.Owner, c.run.ConversationID)
if err != nil {
t.Fatal(err)
}
msg := core.Message{Parts: []core.Part{{Type: core.PartText, Text: "请把这份材料的重点总结为英文"}}}
context, err := c.mgr.bindWorkContext(conv, msg, &WorkReference{card.ID, 1})
if err != nil || strings.HasPrefix(context, workReceiptPrefix) || !strings.Contains(context, card.Work.Result) {
t.Fatalf("explicit follow-up request discarded: %q %v", context, err)
}
}
func TestButtonAndDirectSummaryRaceKeepsOneExecution(t *testing.T) {
c, card := completedMaterialWork(t)
hold := &holdRunner{release: make(chan struct{})}