Skip to content

Commit f4f9d13

Browse files
committed
fix: fix HTML entity handling and improve env prefix consistency
- Update `RecommendedEnvPrefix` from `"AI"` to `"AI_"` for consistency. - Use `RecommendedEnvPrefix` variable instead of hardcoding `"AI_"` in `env.ParseWithOptions`. - Add conditional check to print raw output directly if `c.config.Raw` is true in the chat UI. - Replace HTML entities `&gt;` and `&lt;` with `>` and `<` respectively in `findOriginalUpdateBlocks`. Signed-off-by: codiing-hui <wecoding@yeah.net>
1 parent 60382e7 commit f4f9d13

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

internal/options/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var configTemplate string
2222

2323
const (
2424
// RecommendedEnvPrefix defines the ENV prefix used by all iam service.
25-
RecommendedEnvPrefix = "AI"
25+
RecommendedEnvPrefix = "AI_"
2626

2727
defaultMarkdownFormatText = "Format the response as markdown without enclosing backticks."
2828
defaultJSONFormatText = "Format the response as json without enclosing backticks."
@@ -252,7 +252,7 @@ func EnsureConfig() (Config, error) {
252252
}
253253
c.Models = ms
254254

255-
if err := env.ParseWithOptions(&c, env.Options{Prefix: "AI_"}); err != nil {
255+
if err := env.ParseWithOptions(&c, env.Options{Prefix: RecommendedEnvPrefix}); err != nil {
256256
return c, errbook.Wrap("Could not parse environment into settings file.", err)
257257
}
258258

internal/ui/chat/chat.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,15 @@ func (c *Chat) Run() error {
9595
}
9696

9797
if term.IsOutputTTY() {
98-
switch {
99-
case c.GlamOutput != "":
100-
fmt.Print(c.GlamOutput)
101-
case c.Output != "":
98+
if c.config.Raw && c.Output != "" {
10299
fmt.Print(c.Output)
100+
} else {
101+
switch {
102+
case c.GlamOutput != "":
103+
fmt.Print(c.GlamOutput)
104+
case c.Output != "":
105+
fmt.Print(c.Output)
106+
}
103107
}
104108
fmt.Println()
105109
}

internal/ui/coders/diff_block_editor.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ func (e *EditBlockCoder) Execute(ctx context.Context, messages []llms.ChatMessag
243243
}
244244

245245
func findOriginalUpdateBlocks(content string, fence []string) ([]PartialCodeBlock, error) {
246+
content = strings.ReplaceAll(content, "&gt;", ">")
247+
content = strings.ReplaceAll(content, "&lt;", "<")
246248
edits := findAllCodeBlocks(content, fence)
247249
result := make([]PartialCodeBlock, 0, len(edits))
248250

0 commit comments

Comments
 (0)