Skip to content

Commit dafe925

Browse files
fix: don't show file tree view in playground output for single file (#10212)
When an emitter produces a single output file nested in a folder (e.g. `src/openapi.yaml`), the playground unnecessarily renders the full tree view with folder navigation panel. This adds clutter for emitters whose output is always nested. - Updated `showFileTree` condition in `file-viewer.tsx` to require `outputFiles.length > 1` before considering folder nesting: ```tsx // Before outputFiles.some((f) => f.includes("/")) || outputFiles.length >= 3 // After outputFiles.length > 1 && (outputFiles.some((f) => f.includes("/")) || outputFiles.length >= 3) ``` Single nested file now renders with the simple tab view; tree view still activates for 2+ nested files or 3+ flat files. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: timotheeguerin <1031227+timotheeguerin@users.noreply.github.com>
1 parent 1f8c6e8 commit dafe925

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
changeKind: fix
3+
packages:
4+
- "@typespec/playground"
5+
---
6+
7+
Don't show file tree view in output when there is only a single file

packages/playground/src/react/output-view/file-viewer.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ const FileViewerComponent = ({
1818
const [content, setContent] = useState<string>("");
1919

2020
const showFileTree = useMemo(
21-
() => outputFiles.some((f) => f.includes("/")) || outputFiles.length >= 3,
21+
() =>
22+
outputFiles.length > 1 &&
23+
(outputFiles.some((f) => f.includes("/")) || outputFiles.length >= 3),
2224
[outputFiles],
2325
);
2426

0 commit comments

Comments
 (0)