Skip to content

Commit 1c7656a

Browse files
Copilotmaansaake
andauthored
fix: address code review — use syscall.Kill, extract opNameWidth constant
Agent-Logs-Url: https://github.com/maansaake/arbiter/sessions/e36b0028-6fde-4e9c-bfc1-db80cedd96f8 Co-authored-by: maansaake <15028979+maansaake@users.noreply.github.com>
1 parent 2fb7374 commit 1c7656a

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

pkg/report/interactive/model.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type modInfo struct {
4747
const (
4848
refreshInterval = time.Second
4949
defaultWidth = 80
50+
opNameWidth = 20
5051
)
5152

5253
// Styles used throughout the TUI.
@@ -142,13 +143,10 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
142143
case tea.KeyMsg:
143144
if msg.String() == "ctrl+c" {
144145
if !m.done {
145-
// Send SIGINT so arbiter stops traffic and generates the report
146-
// before we exit. The Signal call is best-effort; failure here
147-
// cannot be meaningfully recovered inside the TUI model.
148-
if proc, err := os.FindProcess(os.Getpid()); err == nil {
149-
_ = proc.Signal(syscall.SIGINT)
150-
}
151-
}
146+
// Send SIGINT so arbiter stops traffic and generates the report
147+
// before we exit.
148+
_ = syscall.Kill(os.Getpid(), syscall.SIGINT)
149+
}
152150
return m, tea.Quit
153151
}
154152

@@ -284,7 +282,7 @@ func (m model) renderOp(modName string, op opInfo, w int) string {
284282

285283
if op.disabled {
286284
content := opDisabledTextStyle.Render(
287-
fmt.Sprintf("%-20s [DISABLED]", op.name),
285+
fmt.Sprintf("%-*s [DISABLED]", opNameWidth, op.name),
288286
)
289287

290288
return opDisabledBoxStyle.Width(innerW).Render(content)
@@ -303,8 +301,8 @@ func (m model) renderOp(modName string, op opInfo, w int) string {
303301
}
304302

305303
content := fmt.Sprintf(
306-
"%-20s rate: %d/min calls: %d failed: %d success: %s",
307-
op.name, op.rate, executions, nok, successStr(executions, okCount),
304+
"%-*s rate: %d/min calls: %d failed: %d success: %s",
305+
opNameWidth, op.name, op.rate, executions, nok, successStr(executions, okCount),
308306
)
309307

310308
return opBoxStyle.Width(innerW).Render(content)

0 commit comments

Comments
 (0)