Skip to content

fix(tui): label Windows folder session tabs - #44297

Open
opencode-agent[bot] wants to merge 3 commits into
v2from
tab-folder-label
Open

fix(tui): label Windows folder session tabs#44297
opencode-agent[bot] wants to merge 3 commits into
v2from
tab-folder-label

Conversation

@opencode-agent

Copy link
Copy Markdown
Contributor

Summary

  • recognize Windows drive roots when resolving project labels
  • fall back to each session directory basename for non-repository tabs
  • add Windows folder fixtures to the session-tabs story and a cross-platform regression test

Checks

  • bun test test/util/project.test.ts test/context/session-tabs-model.test.ts
  • bun typecheck
  • bun x prettier --check packages/tui/src/util/project.ts packages/tui/test/util/project.test.ts packages/tui/src/feature-plugins/system/storybook/session-tabs.tsx
  • OpenCode Drive before/after capture at 100×35 cells

Requested by: @kitlangton (Kit via Slack)

@Enough1122

Copy link
Copy Markdown

AI code review — automated review for reference, author can ignore or act on any point.

Right root cause and a clean fix: path.win32.basename("C:\\") returns an empty string, which is why drive-root projects lost their tab labels, and choosing the parser family up front via /^(?:[A-Za-z]:[\\/]|\\\\)/ correctly covers drive letters (mixed separators included), UNC shares, and keeps POSIX names containing backslashes intact — the new regression test documenting that last nuance is a nice touch.

Two suggestions:

  1. Explicit name is still ignored for root projects (packages/tui/src/util/project.ts, the if (paths.parse(canonical).root === canonical) branch): it returns basename(fallback) before ever consulting project?.name. A workspace that has an explicit name but whose canonical path is a filesystem root gets relabeled by whichever directory one session happened to open. If that ordering wasn't deliberate, consider return project?.name ?? (fallback ? paths.basename(fallback) : undefined) for the root branch. At minimum, a test pinning the intended precedence would prevent future churn.

  2. Test coverage gaps worth locking down: (a) drive root with no fallback → expected undefined; (b) a lowercase drive letter (c:\) exercising the i flag; (c) UNC canonical (\\server\share) — path.win32.parse treats the whole share as .root, so it takes the fallback path; asserting that behavior makes the UNC handling intentional rather than accidental.

Minor: the storybook fixture list now mixes two shapes and relies on TS inferring a union plus the "project" in tab narrowing — works fine today; an explicit fixture type would keep it stable as fixtures grow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants