Azure / Azure/azure-dev

[ext-agents]: post-init `cd <folder>` next-step hint is not highlighted like the `azd` commands

Open
#8,803 0 comments 0 reactions 1 assignee Claimed by @huimiu View on GitHub
area/ux bug ext-agents
Dominant language
Go
Stars
569
Forks
364
Avg merge
2d 19h
Merged PRs (30d)
136

Description

## Summary

After `azd ai agent init` scaffolds a new project folder, the `Next:` block
leads with a `cd ` step so the user can navigate into the new
project before running `azd provision` / `azd deploy`. The `azd provision` and
`azd deploy` lines render in the highlight color (blue), but the `cd `
line renders in plain text. The inconsistent styling makes the very first
required step the least visible one.

## Repro

1. Run `azd ai agent init -m ` (or from a template) such that init
creates a new subfolder for the project.
2. Observe the post-init `Next:` block, e.g.:

```
Next:
cd my-agent <- plain text
enter your new project folder

azd provision <- highlighted (blue)
...

azd deploy <- highlighted (blue)
...
```
3. The `cd my-agent` command is not highlighted, unlike the `azd ...` commands.

## Expected

The `cd ` command is highlighted in the same color as the other
runnable commands (`azd provision`, `azd deploy`), so all actionable commands in
the block share consistent styling.

## Root cause

`highlightCommand` only colorizes strings that start with the literal prefix
`"azd "`:

`cli/azd/extensions/azure.ai.agents/internal/cmd/nextstep/format.go`
(`highlightCommand`, ~L211-216):

```go
func highlightCommand(cmd string) string {
if strings.HasPrefix(cmd, "azd ") {
return output.WithHighLightFormat("%s", cmd)
}
return cmd
}
```

The renderer applies this to every suggestion's `Command` (format.go ~L182).
The `cd` suggestion is produced by `ResolveAfterInit` and its `Command` is
`cd `, which does not match the `"azd "` prefix and therefore stays
plain:

`cli/azd/extensions/azure.ai.agents/internal/cmd/nextstep/resolver.go`
(~L145-151):

```go
if state.CreatedFolderDisplay != "" {
out = append(out, Suggestion{
Command: fmt.Sprintf("cd %s", state.CreatedFolderDisplay),
Description: "enter your new project folder",
Priority: 0,
})
}
```

The `"azd "` prefix check was intentional so prose suggestions stay plain --
e.g. `see /README.md` pointers and
`edit agent.yaml: replace {{NAME}} ...` instructions (resolver.go) should NOT be
colorized. `cd ` is a real runnable command and was simply not
accounted for by the prefix heuristic.

## Suggested fix

Two options:

1. Minimal: extend `highlightCommand` to also treat `cd ` as a runnable command
prefix.
2. Cleaner / less brittle: add an explicit field to `Suggestion` (e.g.
`Runnable bool` or `Highlight bool`) in
`cli/azd/extensions/azure.ai.agents/internal/cmd/nextstep/types.go`
(~L37-42), set it `true` for actual shell commands (`cd ...`, `azd ...`) and
`false` for the prose suggestions (`edit agent.yaml: ...`,
`see /README.md`), then highlight on that flag instead of string-
sniffing the prefix. This removes the coupling between command rendering and
the `"azd "` literal and makes future non-`azd` commands highlight correctly
by construction.

Highlighting already self-gates on color settings via
`output.WithHighLightFormat` (NO_COLOR / non-TTY -> plain text), so either fix
preserves the no-color and piped behavior. Add a renderer test asserting the
`cd` line is wrapped in the highlight format and that prose suggestions remain
plain.

## Environment

* azd AI Agent extension: v0.1.41-preview
* File references are from a local working copy; line numbers approximate.

## Related

* #8802 -- a different bug in the same `cd` hint (the hint is suppressed
entirely when the target folder pre-exists). This issue is purely about the
color/styling of the hint when it IS shown.
* #7975 -- introduced the post-command `Next:` guidance.
* #8730 -- post-deploy `Next:` readability.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.