permissions hook helper
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Pin shortcut keys and proposed rule to bottom of review TUI

+22 -10
+22 -10
chook.mjs
··· 490 490 } 491 491 492 492 function render() { 493 + const rows = process.stdout.rows || 24; 494 + const cols = process.stdout.columns || 100; 495 + 496 + // Reserve: 1 title + 1 blank + list + 1 blank + rule lines + 1 blank + 1 keys 497 + const rule = buildRuleFromEntry(unique[cursor], "allow"); 498 + const ruleLines = rule.split("\n"); 499 + const footerHeight = ruleLines.length + 3; // blank + rule + blank + keys 500 + const headerHeight = 2; // title + blank 501 + const pageSize = Math.max(3, rows - headerHeight - footerHeight); 502 + 493 503 // Clear screen and move to top 494 504 process.stdout.write("\x1b[2J\x1b[H"); 495 - console.log( 496 - `chook review - ${unique.length} unique denied/passthrough entries\n`, 497 - ); 498 - console.log(" [j/k] navigate [a] allow [d] deny [s] skip [q] quit\n"); 499 505 500 - const pageSize = process.stdout.rows ? process.stdout.rows - 10 : 15; 506 + // Header 507 + console.log(`chook review - ${unique.length} entries (${cursor + 1}/${unique.length})`); 508 + console.log(""); 509 + 510 + // Scrolling list 501 511 const halfPage = Math.floor(pageSize / 2); 502 512 let start = Math.max(0, cursor - halfPage); 503 513 let end = Math.min(unique.length, start + pageSize); ··· 509 519 const decision = e.decision.toUpperCase().padEnd(11); 510 520 const tool = e.tool_name.padEnd(12); 511 521 let detail = getDetail(e); 512 - const maxDetail = (process.stdout.columns || 100) - 32; 522 + const maxDetail = cols - 32; 513 523 if (detail.length > maxDetail) 514 524 detail = detail.slice(0, maxDetail - 3) + "..."; 515 525 516 526 if (i === cursor) { 517 - // Highlight current line 518 527 process.stdout.write(`\x1b[7m ${marker} ${decision} ${tool} ${detail}\x1b[0m\n`); 519 528 } else { 520 529 console.log(` ${marker} ${decision} ${tool} ${detail}`); 521 530 } 522 531 } 523 532 524 - // Show proposed rule for current entry 533 + // Footer: proposed rule + keys (always visible at bottom) 525 534 console.log(""); 526 - const rule = buildRuleFromEntry(unique[cursor], "allow"); 527 - console.log(` Proposed rule:\n ${rule.split("\n").join("\n ")}`); 535 + for (const line of ruleLines) { 536 + console.log(` ${line}`); 537 + } 538 + console.log(""); 539 + console.log(" \x1b[2m[j/k] navigate [a] allow [d] deny [s] skip [q] quit\x1b[0m"); 528 540 } 529 541 530 542 // Raw mode for keypress handling