Skip to content

Tool transcript headers render root workdir as in . #28058

@samiralibabic

Description

@samiralibabic

Description

Tool transcript headers can render the current session/repo root as in ..

Example:

# Final whitespace check before commit in .
$ git diff --check

# List changed files before commit in .
$ git status --short

This looks like a truncated or malformed sentence. The location suffix is useful for meaningful non-root directories, but . adds no information when it only means “current session root”.

Expected behavior:

# Final whitespace check before commit
$ git diff --check

For commands run in a meaningful subdirectory, the suffix should remain:

# Run API tests in apps/api
$ bun test

Likely cause:

In packages/opencode/src/cli/cmd/run/tool.ts, toolPath() returns "." when the formatted path equals process.cwd().

scrollBashStart() checks the raw workdir before formatting:

const wd = p.input.workdir ?? ""
const dir = wd && wd !== "." ? toolPath(wd) : ""
const title = dir && !desc.includes(dir) ? `${desc} in ${dir}` : desc

So an absolute root workdir passes wd !== ".", then toolPath(wd) returns ".", and the rendered title becomes ${desc} in ..

Similar direct in ${toolPath(...)} patterns appear to exist for glob/grep display output and should use the same suppression rule.

Suggested fix:

Suppress root/current-directory display after formatting, not before formatting.

Rule:

  • no suffix for missing workdir
  • no suffix for .
  • no suffix for absolute paths that normalize to .
  • keep suffix for meaningful relative paths like apps/api
  • keep readable absolute/home-relative paths for external directories

A small shared helper would keep Bash, Glob, and Grep display behavior consistent.

Plugins

none relevant

OpenCode version

dev / current source around packages/opencode/src/cli/cmd/run/tool.ts

Steps to reproduce

  1. Start opencode from a repository root.
  2. Trigger a Bash tool call where workdir is an absolute path equal to the session/repo root.
  3. Observe the rendered transcript header.

Screenshot and/or share link

Example transcript:

# Final whitespace check before commit in .
$ git diff --check
(no output)

# List changed files before commit in .
$ git status --short
M apps/api/.env.example
M apps/api/README.md
M apps/api/package.json

Operating System

macOS

Terminal

iTerm2

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions