Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/table-narrow-terminal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@shopify/cli-kit': patch
'@shopify/cli': patch
---

Keep every character of table cells, such as in `shopify app logs` and `shopify app versions list`, when the terminal is narrower than the table. The table keeps one line per row, and the terminal wraps the long lines.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"rimraf": "^6.1.3",
"ts-node": "^10.9.1",
"typescript": "5.9.3",
"vitest": "^4.1.10",
"vitest": "^4.1.11",
"zod": "4.6.6"
},
"workspaces": {
Expand Down
16 changes: 9 additions & 7 deletions packages/cli-kit/src/public/node/ui.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,11 @@ describe('renderTable', async () => {
`)
})

test("keeps a terminal's own width", async () => {
// Given: a terminal 80 columns wide.
test('keeps every character of a cell in a terminal narrower than the table', async () => {
// Given: a terminal 50 columns wide, where Ink wrapping drops characters from cells.
const mockOutput = mockAndCaptureOutput()
const stdoutColumns = Object.getOwnPropertyDescriptor(process.stdout, 'columns')
Object.defineProperty(process.stdout, 'columns', {value: 80, configurable: true})
Object.defineProperty(process.stdout, 'columns', {value: 50, configurable: true})

try {
// When
Expand All @@ -240,10 +240,12 @@ describe('renderTable', async () => {
else delete (process.stdout as {columns?: number}).columns
}

// Then: Ink fits the table to the terminal, as before.
const lines = unstyled(mockOutput.info()).split('\n')
expect(Math.max(...lines.map((line) => line.length))).toBeLessThanOrEqual(80)
expect(lines.length).toBeGreaterThan(3)
// Then: one line per row, with every header and cell whole; the terminal wraps the long lines.
expect(unstyled(mockOutput.info())).toMatchInlineSnapshot(`
"Subdomain Name Type Plan Created
───────────────────────────────── ───────────────────────────────── ──── ──── ────────────
parimi-photography-dev-test-store Parimi photography dev test store Dev Plus Apr 01, 2026"
`)
})
})

Expand Down
12 changes: 8 additions & 4 deletions packages/cli-kit/src/public/node/ui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -493,14 +493,18 @@ export function renderTable<T extends ScalarDict>({renderOptions, ...props}: Ren
}

// Output that isn't a terminal (a pipe, a file, a CI log) has no width, and Ink then lays the table out in 80
// columns, squeezing headers to "Typ" and wrapping cells onto extra lines. Give the table the width it needs
// instead; a terminal keeps its own width.
// columns, squeezing headers to "Typ" and wrapping cells onto extra lines. In a terminal narrower than the table,
// Ink wraps the cells too, and each wrap loses a character ("WEBHOOK" becomes "WEBH" and "OK"). In both cases,
// give the table the width it needs; a terminal wraps the long lines itself and keeps every character.
function tableRenderOptions<T extends ScalarDict>(
props: TableProps<T>,
renderOptions: RenderOptions | undefined,
): RenderOptions | undefined {
if (renderOptions?.stdout || process.stdout.columns !== undefined) return renderOptions
const columns = Math.max(DEFAULT_OUTPUT_COLUMNS, tableWidth(props))
if (renderOptions?.stdout) return renderOptions
const width = tableWidth(props)
const terminalColumns = process.stdout.columns
if (terminalColumns !== undefined && terminalColumns >= width) return renderOptions
const columns = Math.max(terminalColumns ?? DEFAULT_OUTPUT_COLUMNS, width)
return {...renderOptions, stdout: new Stdout({columns}) as unknown as NodeJS.WriteStream}
}

Expand Down
Loading
Loading