mirror of
https://github.com/stablyai/orca.git
synced 2026-11-04 11:07:42 +00:00
Linear-provided titles, states, assignees, projects, labels, workspace names and error messages were printed verbatim, so remote text could emit OSC/CSI/C1 sequences or forge extra output lines. Move terminalSafe into src/shared/terminal-safe-text.ts, add terminalSafeLine (collapses CR/LF), and apply it to every Linear text field in the human-readable formatters. --json output is unchanged. Fixes #20478 Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import type { LinearProjectListResult } from './agent-result-types'
|
|
import { appendLinearListTruncation } from './list-truncation-format'
|
|
import { terminalSafeLine as safe } from '../terminal-safe-text'
|
|
|
|
// Why: non-JSON project output aligns ids with the existing compact Linear tables.
|
|
const LINEAR_PROJECT_NAME_COLUMN_WIDTH = 28
|
|
|
|
export function formatLinearProjectListRows(result: LinearProjectListResult): string {
|
|
if (result.projects.length === 0) {
|
|
return 'No Linear projects found.'
|
|
}
|
|
const body = result.projects
|
|
.map((project) => {
|
|
const teams =
|
|
project.teams
|
|
?.map((team) => {
|
|
const key = team.key?.trim()
|
|
return safe(key ? key : team.name)
|
|
})
|
|
.filter(Boolean)
|
|
.join(',') || 'no-teams'
|
|
const workspace = project.workspaceName ? ` ${safe(project.workspaceName)}` : ''
|
|
return `${safe(project.name).padEnd(LINEAR_PROJECT_NAME_COLUMN_WIDTH)} ${safe(project.id)} ${teams}${workspace}`
|
|
})
|
|
.join('\n')
|
|
return appendLinearListTruncation(
|
|
body,
|
|
result.projects.length,
|
|
result.truncated ?? result.meta.hasMore
|
|
)
|
|
}
|
|
|
|
export function linearProjectListWarningLines(result: LinearProjectListResult): string[] {
|
|
const warnings: string[] = []
|
|
if (result.meta.hasMore) {
|
|
warnings.push(`warning: showing first ${result.meta.returned} Linear projects`)
|
|
}
|
|
for (const error of result.meta.workspaceErrors ?? []) {
|
|
warnings.push(
|
|
`warning: ${safe(error.workspace.name)} unavailable for Linear: ${safe(error.message)}`
|
|
)
|
|
}
|
|
return warnings
|
|
}
|