@phenx-inc/ctlsurf 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/headless/index.mjs +36 -18
- package/out/headless/index.mjs.map +2 -2
- package/package.json +1 -1
- package/src/main/tui.ts +39 -17
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phenx-inc/ctlsurf",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Agent-agnostic terminal and desktop app for ctlsurf — run Claude Code, Codex, or any coding agent with live session logging and remote control",
|
|
5
5
|
"main": "out/main/index.js",
|
|
6
6
|
"bin": {
|
package/src/main/tui.ts
CHANGED
|
@@ -140,6 +140,10 @@ export class Tui {
|
|
|
140
140
|
let selected = 0
|
|
141
141
|
let trackTime = options.initialTrackTime
|
|
142
142
|
let logChat = options.initialLogChat
|
|
143
|
+
// Navigable items: agent rows, then Track time and Log chat checkbox rows
|
|
144
|
+
const trackIdx = agents.length
|
|
145
|
+
const logIdx = agents.length + 1
|
|
146
|
+
const itemCount = agents.length + 2
|
|
143
147
|
const modalWidth = 44
|
|
144
148
|
// +4 for borders/title/sep, +3 for separator + track-time row + log-chat row
|
|
145
149
|
const modalHeight = agents.length + 4 + 3
|
|
@@ -190,26 +194,27 @@ export class Tui {
|
|
|
190
194
|
const sepRow = startRow + 3 + agents.length
|
|
191
195
|
this.write(`${CSI}${sepRow};${startCol}H${BG_MODAL}${FG_DIM}${innerSep}${RESET}`)
|
|
192
196
|
|
|
197
|
+
const drawCheckboxRow = (row: number, label: string, checked: boolean, isSelected: boolean) => {
|
|
198
|
+
const bg = isSelected ? BG_SELECTED : BG_MODAL
|
|
199
|
+
const pointer = isSelected ? `${FG_ACCENT}▸ ` : ' '
|
|
200
|
+
const checkbox = checked ? `${FG_GREEN}[✓]${RESET}${bg}` : `${FG_DIM}[ ]${RESET}${bg}`
|
|
201
|
+
const labelFg = checked || isSelected ? FG_WHITE : FG_DIM
|
|
202
|
+
const content = `${pointer}${checkbox} ${labelFg}${label}${RESET}${bg}`
|
|
203
|
+
const contentLen = 2 + 3 + 1 + label.length
|
|
204
|
+
const pad = ' '.repeat(Math.max(0, modalWidth - 2 - contentLen))
|
|
205
|
+
this.write(`${CSI}${row};${startCol}H${bg}${FG_DIM}│${RESET}${bg}${content}${pad}${RESET}${BG_MODAL}${FG_DIM}│${RESET}`)
|
|
206
|
+
}
|
|
207
|
+
|
|
193
208
|
const trackRow = sepRow + 1
|
|
194
|
-
|
|
195
|
-
const trackLabelFg = trackTime ? FG_WHITE : FG_DIM
|
|
196
|
-
const trackContent = ` ${checkbox} ${trackLabelFg}Track time${RESET}${BG_MODAL}`
|
|
197
|
-
const trackContentLen = 2 + 3 + 1 + 'Track time'.length
|
|
198
|
-
const trackPad = ' '.repeat(Math.max(0, modalWidth - 2 - trackContentLen))
|
|
199
|
-
this.write(`${CSI}${trackRow};${startCol}H${BG_MODAL}${FG_DIM}│${RESET}${BG_MODAL}${trackContent}${trackPad}${FG_DIM}│${RESET}`)
|
|
209
|
+
drawCheckboxRow(trackRow, 'Track time', trackTime, selected === trackIdx)
|
|
200
210
|
|
|
201
211
|
const logRow = trackRow + 1
|
|
202
|
-
|
|
203
|
-
const logLabelFg = logChat ? FG_WHITE : FG_DIM
|
|
204
|
-
const logContent = ` ${logCheckbox} ${logLabelFg}Log chat${RESET}${BG_MODAL}`
|
|
205
|
-
const logContentLen = 2 + 3 + 1 + 'Log chat'.length
|
|
206
|
-
const logPad = ' '.repeat(Math.max(0, modalWidth - 2 - logContentLen))
|
|
207
|
-
this.write(`${CSI}${logRow};${startCol}H${BG_MODAL}${FG_DIM}\u2502${RESET}${BG_MODAL}${logContent}${logPad}${FG_DIM}\u2502${RESET}`)
|
|
212
|
+
drawCheckboxRow(logRow, 'Log chat', logChat, selected === logIdx)
|
|
208
213
|
|
|
209
214
|
const botRow = logRow + 1
|
|
210
215
|
this.write(`${CSI}${botRow};${startCol}H${BG_MODAL}${FG_DIM}${botBorder}${RESET}`)
|
|
211
216
|
|
|
212
|
-
const hint = '\u2191\u2193 nav \u00B7 Enter
|
|
217
|
+
const hint = '\u2191\u2193 nav \u00B7 Enter select \u00B7 Space toggle \u00B7 q quit'
|
|
213
218
|
const hintCol = Math.max(1, Math.floor((this.cols - hint.length) / 2))
|
|
214
219
|
this.write(`${CSI}${botRow + 2};${hintCol}H${FG_DIM}${hint}${RESET}`)
|
|
215
220
|
}
|
|
@@ -224,11 +229,23 @@ export class Tui {
|
|
|
224
229
|
const onKey = (data: Buffer) => {
|
|
225
230
|
const key = data.toString()
|
|
226
231
|
|
|
232
|
+
const toggleSelected = (): boolean => {
|
|
233
|
+
if (selected === trackIdx) {
|
|
234
|
+
trackTime = !trackTime
|
|
235
|
+
} else if (selected === logIdx) {
|
|
236
|
+
logChat = !logChat
|
|
237
|
+
} else {
|
|
238
|
+
return false
|
|
239
|
+
}
|
|
240
|
+
drawModal()
|
|
241
|
+
return true
|
|
242
|
+
}
|
|
243
|
+
|
|
227
244
|
if (key === '\x1b[A' || key === 'k') {
|
|
228
|
-
selected = (selected - 1 +
|
|
245
|
+
selected = (selected - 1 + itemCount) % itemCount
|
|
229
246
|
drawModal()
|
|
230
247
|
} else if (key === '\x1b[B' || key === 'j') {
|
|
231
|
-
selected = (selected + 1) %
|
|
248
|
+
selected = (selected + 1) % itemCount
|
|
232
249
|
drawModal()
|
|
233
250
|
} else if (key === 't' || key === 'T') {
|
|
234
251
|
trackTime = !trackTime
|
|
@@ -236,9 +253,14 @@ export class Tui {
|
|
|
236
253
|
} else if (key === 'l' || key === 'L') {
|
|
237
254
|
logChat = !logChat
|
|
238
255
|
drawModal()
|
|
256
|
+
} else if (key === ' ') {
|
|
257
|
+
toggleSelected()
|
|
239
258
|
} else if (key === '\r' || key === '\n') {
|
|
240
|
-
|
|
241
|
-
|
|
259
|
+
// Enter on a checkbox row toggles it; on an agent row it confirms
|
|
260
|
+
if (!toggleSelected()) {
|
|
261
|
+
cleanup()
|
|
262
|
+
resolve({ agentIdx: selected, trackTime, logChat })
|
|
263
|
+
}
|
|
242
264
|
} else if (key === 'q' || key === '\x1b' || key === '\x03') {
|
|
243
265
|
cleanup()
|
|
244
266
|
this.write(`${CSI}?25h`)
|