diff --git a/backend/internal/cli/preview.go b/backend/internal/cli/preview.go index b57dd48a..4517b736 100644 --- a/backend/internal/cli/preview.go +++ b/backend/internal/cli/preview.go @@ -23,9 +23,14 @@ func newPreviewCommand(ctx *commandContext) *cobra.Command { Use: "preview [url]", Short: "Open a URL (or the workspace's index.html) in the desktop browser panel for the current session", Long: "Open a URL in the desktop browser panel for the current session.\n\n" + - "With no argument it opens the workspace's index.html. A workspace-relative path\n" + - "(e.g. ./dist/index.html) is served as a local file. Use `ao preview\n" + - "clear` to empty the panel.", + "With no argument it opens the workspace's static entry point, falling\n" + + "back to this session's existing preview target when no entry point exists.\n" + + "A local file can be opened by its absolute file:// URL\n" + + "(e.g. file:///home/me/proj/index.html). Use `ao preview clear` to empty the panel.", + Example: ` ao preview + ao preview file://$(pwd)/index.html + ao preview http://localhost:5173 + ao preview clear`, Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { var target string diff --git a/backend/internal/cli/preview_test.go b/backend/internal/cli/preview_test.go index 5da492ba..ad12e85a 100644 --- a/backend/internal/cli/preview_test.go +++ b/backend/internal/cli/preview_test.go @@ -154,6 +154,24 @@ func TestPreview_MissingSessionIDIsUsageError(t *testing.T) { } } +func TestPreview_HelpIncludesExamples(t *testing.T) { + out, _, err := executeCLI(t, Deps{}, "preview", "--help") + if err != nil { + t.Fatalf("unexpected error: %v", err) + } + // Examples section present. + if !strings.Contains(out, "EXAMPLES") && !strings.Contains(out, "Examples") { + t.Errorf("help output missing Examples section:\n%s", out) + } + // file:// URL example (not a relative path). + if !strings.Contains(out, "file://$(pwd)/index.html") { + t.Errorf("help output missing file:// example:\n%s", out) + } + if strings.Contains(out, "./dist/index.html") { + t.Errorf("help output still references relative ./dist/index.html:\n%s", out) + } +} + func TestPreview_BlankSessionIDIsUsageError(t *testing.T) { t.Setenv("AO_SESSION_ID", " \t ") cfg := setConfigEnv(t)