Merge pull request #1715 from entireio/fix/1423-ide-tag-title · Entire

Merge pull request #1715 from entireio/fix/1423-ide-tag-title

0d3d1d7→main·

gtrrz-victor·2d ago·2 files·+23 added/-2 removed

fix(claudecode): strip IDE context tags from the captured turn prompt

Changes

2

11 unmodified lines

12
13
14
15
16
17
18
119 unmodified lines

138
139
140
140
141
141
142
143
144
145
146
147
148

11 unmodified lines

"github.com/entireio/cli/cmd/entire/cli/agent"
    "github.com/entireio/cli/cmd/entire/cli/logging"
    "github.com/entireio/cli/cmd/entire/cli/textutil"

// Compile-time interface assertions for new interfaces.
119 unmodified lines

Type:       agent.TurnStart,
    SessionID:  raw.SessionID,
    SessionRef: raw.TranscriptPath,
    Prompt:     raw.Prompt,
    Timestamp:  time.Now(),
    // Strip IDE-injected context (e.g. <ide_opened_file> from the VS Code
    // extension) so the session/checkpoint title and prompt show what the
    // user actually typed, not the injected block.
    Prompt:    textutil.StripIDEContextTags(raw.Prompt),
    Timestamp: time.Now(),
}, nil
}

Mcmd/entire/cli/agent/claudecode/lifecycle.go+6/-2

98 unmodified lines

99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

98 unmodified lines

}
}

// The VS Code extension prepends an <ide_opened_file> context block to the
// prompt; it must be stripped so the session/checkpoint title and prompt show
// only what the user typed.
func TestParseHookEvent_TurnStart_StripsIDEContextTags(t *testing.T) {
     t.Parallel()

ag := &ClaudeCodeAgent{}
    input := `{"session_id":"s1","transcript_path":"/tmp/t.jsonl","prompt":"<ide_opened_file>The user opened /a/b.md in the IDE.</ide_opened_file>\n\nrewrite these docs as one plan"}`

event, err := ag.ParseHookEvent(context.Background(), HookNameUserPromptSubmit, strings.NewReader(input))
    require.NoError(t, err)
    require.NotNil(t, event)
    if event.Prompt != "rewrite these docs as one plan" {
         t.Errorf("IDE context tag not stripped; prompt = %q", event.Prompt)
    }
}

func TestParseHookEvent_TurnEnd(t *testing.T) {
     t.Parallel()