fix(ci): escape square brackets in pipeline view job titles and modals
Description
glab ci view hands job names to tview unescaped, and tview parses [...] as a color tag. Any name whose bracketed segment is tag-shaped - letters, #rrggbb or -, optionally followed by :background:flags - is consumed as markup and never displayed.
Three places were affected:
- Job box titles. A job named
deploy [TARGET]renders as■ deploy …. It is centered as though it were short, and carries a trailing…even though nothing overflowed: tview does not count the swallowed tag's bytes as printed, so it reports an overflow that did not happen. The box looks truncated rather than mangled. - Run and cancel confirmation modals. "Are you sure you want to cancel deploy [TARGET]?" loses the
[TARGET], so the modal no longer identifies which job is about to be cancelled or run. - The downstream-pipeline information modal, same cause.
Jobs generated by parallel:matrix are the common case: several jobs sharing a prefix collapse into indistinguishable look-alikes.
This is the same root cause as #8008, which reported [MASKED] vanishing from job logs. That was fixed in cfa2803c by adding bracketEscaper to the trace writer, which covers the log stream only; the titles and modal texts still passed raw names through.
tview.Escape is applied at the display boundary only. The raw name is also the boxes map key and the page name ("jobs-"+j.Name, "logs-"+j.Name), so those keep the unescaped value - job navigation, the log pages and the stage connectors drawn by linkJobs are untouched.
Names whose brackets are not tag-shaped, such as [DEPLOY_TARGET=target], already rendered literally and are unchanged by this MR.
Related Issues
Resolves #8487
Related to #8008 - same root cause, fixed for job logs only.
How has this been tested?
- The
Test_jobsViewfixture now includes a job namedstage2-job1[step], and the expected screen matrix asserts the bracketed segment is rendered. Without this change the assertion fails, because[step]is tag-shaped and gets swallowed. This is a regression test for the titles. go test ./internal/commands/ci/view/- passgo build ./...- cleangofmt -l internal/commands/ci/view/- clean- Manual:
glab ci view -p <pipeline-id>against a pipeline withparallel:matrixjobs; verified the bracketed segments appear in the box titles and in theCtrl+D/Ctrl+Pconfirmation modals.