@moberg_hr/work-tree 1.7.0 → 1.8.0

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/dist/bin.js CHANGED
@@ -323,26 +323,110 @@ async function fetchRemoteAsync(cwd) {
323
323
  git(["remote", "set-head", "origin", "--auto"], cwd);
324
324
  }
325
325
  }
326
- function rebaseOntoMain(branch, cwd) {
327
- const defaultBranch = getDefaultBranch(cwd) ?? "main";
328
- git(["fetch", "--quiet"], cwd);
329
- const base = remoteBranchExists(defaultBranch, cwd) ? `origin/${defaultBranch}` : defaultBranch;
330
- const result = git(["rebase", base, branch], cwd);
331
- if (result.exitCode !== 0) {
332
- git(["rebase", "--abort"], cwd);
333
- return result.stderr || "Rebase failed";
326
+ function gitAsync(args, cwd) {
327
+ debug("gitAsync", args.join(" "), `cwd=${cwd}`);
328
+ return new Promise((resolve) => {
329
+ execFile(
330
+ "git",
331
+ args,
332
+ { cwd, encoding: "utf-8", timeout: 6e4, windowsHide: true },
333
+ (err, stdout, stderr) => {
334
+ const r = {
335
+ stdout: (stdout ?? "").toString().trim(),
336
+ stderr: (stderr ?? "").toString().trim(),
337
+ exitCode: err ? err.code ?? 1 : 0
338
+ };
339
+ if (typeof r.exitCode !== "number") r.exitCode = 1;
340
+ if (r.exitCode !== 0) {
341
+ debug("gitAsync failed", { args, exitCode: r.exitCode, stderr: r.stderr });
342
+ }
343
+ resolve(r);
344
+ }
345
+ );
346
+ });
347
+ }
348
+ async function getDefaultBranchAsync(cwd) {
349
+ const result = await gitAsync(["symbolic-ref", "refs/remotes/origin/HEAD"], cwd);
350
+ if (result.exitCode === 0 && result.stdout) {
351
+ return result.stdout.replace(/^refs\/remotes\/origin\//, "");
334
352
  }
335
353
  return null;
336
354
  }
337
- function countConflicts(branch, cwd) {
338
- const defaultBranch = getDefaultBranch(cwd) ?? "main";
339
- const base = remoteBranchExists(defaultBranch, cwd) ? `origin/${defaultBranch}` : defaultBranch;
340
- const mergeBase = git(["merge-base", base, branch], cwd);
355
+ async function refExistsAsync(ref, cwd) {
356
+ return (await gitAsync(["rev-parse", "--verify", ref], cwd)).exitCode === 0;
357
+ }
358
+ async function checkSquashMergedAsync(branch, baseRef, cwd) {
359
+ const mb = await gitAsync(["merge-base", baseRef, branch], cwd);
360
+ if (mb.exitCode !== 0) return false;
361
+ const tree = await gitAsync(["rev-parse", `${branch}^{tree}`], cwd);
362
+ if (tree.exitCode !== 0) return false;
363
+ const dangling = await gitAsync(["commit-tree", tree.stdout, "-p", mb.stdout, "-m", ""], cwd);
364
+ if (dangling.exitCode !== 0) return false;
365
+ const cherry = await gitAsync(["cherry", baseRef, dangling.stdout], cwd);
366
+ if (cherry.exitCode !== 0) return false;
367
+ return cherry.stdout.startsWith("-");
368
+ }
369
+ async function checkMergeStatusAsync(branch, baseRef, cwd) {
370
+ const branchInBase = await gitAsync(["merge-base", "--is-ancestor", branch, baseRef], cwd);
371
+ if (branchInBase.exitCode !== 0) {
372
+ if (await checkSquashMergedAsync(branch, baseRef, cwd)) return "squash-merged";
373
+ return "unrelated";
374
+ }
375
+ const baseInBranch = await gitAsync(["merge-base", "--is-ancestor", baseRef, branch], cwd);
376
+ if (baseInBranch.exitCode === 0) return "merged";
377
+ const tip = await gitAsync(["rev-parse", branch], cwd);
378
+ if (tip.exitCode !== 0) return "unrelated";
379
+ const mainLine = await gitAsync(["rev-list", "--first-parent", "-n", "500", baseRef], cwd);
380
+ if (mainLine.exitCode === 0 && mainLine.stdout.includes(tip.stdout)) {
381
+ return "stale";
382
+ }
383
+ return "merged";
384
+ }
385
+ async function isBranchMergedAsync(branch, cwd, baseBranch) {
386
+ const defaultBranch = await getDefaultBranchAsync(cwd);
387
+ const bases = baseBranch ? [baseBranch] : [defaultBranch, "main", "master"].filter(
388
+ (b) => b !== null
389
+ );
390
+ const uniqueBases = [...new Set(bases)];
391
+ for (const base of uniqueBases) {
392
+ if (await refExistsAsync(`origin/${base}`, cwd)) {
393
+ const baseRef = `origin/${base}`;
394
+ const status = await checkMergeStatusAsync(branch, baseRef, cwd);
395
+ if (status === "merged") return { merged: true, into: baseRef, confidence: "merged" };
396
+ if (status === "squash-merged")
397
+ return { merged: true, into: baseRef, confidence: "squash-merged" };
398
+ if (status === "stale") return { merged: false, into: null, confidence: null };
399
+ }
400
+ if (await refExistsAsync(base, cwd)) {
401
+ const status = await checkMergeStatusAsync(branch, base, cwd);
402
+ if (status === "merged") return { merged: true, into: base, confidence: "merged" };
403
+ if (status === "squash-merged")
404
+ return { merged: true, into: base, confidence: "squash-merged" };
405
+ if (status === "stale") return { merged: false, into: null, confidence: null };
406
+ }
407
+ }
408
+ return { merged: false, into: null, confidence: null };
409
+ }
410
+ async function countConflictsAsync(branch, cwd) {
411
+ const defaultBranch = await getDefaultBranchAsync(cwd) ?? "main";
412
+ const base = await refExistsAsync(`origin/${defaultBranch}`, cwd) ? `origin/${defaultBranch}` : defaultBranch;
413
+ const mergeBase = await gitAsync(["merge-base", base, branch], cwd);
341
414
  if (mergeBase.exitCode !== 0) return 0;
342
- const result = git(["merge-tree", mergeBase.stdout, base, branch], cwd);
415
+ const result = await gitAsync(["merge-tree", mergeBase.stdout, base, branch], cwd);
343
416
  const conflicts = (result.stdout.match(/^<<<<<<< /gm) || []).length;
344
417
  return conflicts;
345
418
  }
419
+ async function rebaseOntoMainAsync(branch, cwd) {
420
+ const defaultBranch = await getDefaultBranchAsync(cwd) ?? "main";
421
+ await gitAsync(["fetch", "--quiet"], cwd);
422
+ const base = await refExistsAsync(`origin/${defaultBranch}`, cwd) ? `origin/${defaultBranch}` : defaultBranch;
423
+ const result = await gitAsync(["rebase", base, branch], cwd);
424
+ if (result.exitCode !== 0) {
425
+ await gitAsync(["rebase", "--abort"], cwd);
426
+ return result.stderr || "Rebase failed";
427
+ }
428
+ return null;
429
+ }
346
430
  function getUnpushedCommits(cwd) {
347
431
  const branch = getCurrentBranch(cwd);
348
432
  if (!branch) return "";
@@ -3220,7 +3304,7 @@ import { render } from "ink";
3220
3304
 
3221
3305
  // src/tui-ink/App.tsx
3222
3306
  import { useState, useEffect, useRef, useCallback, useMemo } from "react";
3223
- import { Box as Box4 } from "ink";
3307
+ import { Box as Box5 } from "ink";
3224
3308
  import fs23 from "fs";
3225
3309
  import os6 from "os";
3226
3310
  import path20 from "path";
@@ -3537,7 +3621,7 @@ var PtySession = class {
3537
3621
  cwd;
3538
3622
  outputHandler;
3539
3623
  _exited = false;
3540
- _idle = true;
3624
+ _status = "idle";
3541
3625
  _outputBuffer = "";
3542
3626
  _loggedOutput = false;
3543
3627
  onExit;
@@ -3607,13 +3691,18 @@ var PtySession = class {
3607
3691
  get exited() {
3608
3692
  return this._exited;
3609
3693
  }
3694
+ /** True when the session is not actively working (idle or needs input). */
3610
3695
  get idle() {
3611
- return this._idle;
3696
+ return this._status !== "running";
3697
+ }
3698
+ /** Live status: 'running', 'idle' (turn finished) or 'attention' (needs input). */
3699
+ get status() {
3700
+ return this._status;
3612
3701
  }
3613
- /** Called by the dashboard when a hook event indicates idle state change. */
3614
- setIdle(idle) {
3615
- if (this._exited || this._idle === idle) return;
3616
- this._idle = idle;
3702
+ /** Called by the dashboard when a hook event indicates a state change. */
3703
+ setStatus(status) {
3704
+ if (this._exited || this._status === status) return;
3705
+ this._status = status;
3617
3706
  this.onStatusChange?.();
3618
3707
  }
3619
3708
  write(data) {
@@ -4080,7 +4169,7 @@ function renderBufferLines(buffer, cols, rows, scrollBack = 0) {
4080
4169
  // src/tui-ink/Sidebar.tsx
4081
4170
  import React from "react";
4082
4171
  import { Box, Text } from "ink";
4083
- import { jsx, jsxs } from "react/jsx-runtime";
4172
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4084
4173
  function buildSessionRows(sessions, statusMap) {
4085
4174
  if (sessions.length === 0) return [];
4086
4175
  const rows = [];
@@ -4089,7 +4178,7 @@ function buildSessionRows(sessions, statusMap) {
4089
4178
  for (const s of sessions) {
4090
4179
  const key = `${s.target}:${s.branch}`;
4091
4180
  const status = statusMap?.get(key);
4092
- if (status === "running" || status === "idle") {
4181
+ if (status !== void 0 && status !== "stopped") {
4093
4182
  active.push(s);
4094
4183
  } else {
4095
4184
  inactive.push(s);
@@ -4213,6 +4302,47 @@ function cursorToRow(rows, cursor) {
4213
4302
  function sessionKey2(s) {
4214
4303
  return `${s.target}:${s.branch}`;
4215
4304
  }
4305
+ function computeScrollOffset(rows, cursor, contentHeight) {
4306
+ let cursorRowIdx = 0;
4307
+ let selectableCount = 0;
4308
+ for (let i = 0; i < rows.length; i++) {
4309
+ if (rows[i].type !== "header") {
4310
+ if (selectableCount === cursor) {
4311
+ cursorRowIdx = i;
4312
+ break;
4313
+ }
4314
+ selectableCount++;
4315
+ }
4316
+ }
4317
+ if (rows.length > contentHeight && cursorRowIdx >= contentHeight - 1) {
4318
+ return Math.min(
4319
+ cursorRowIdx - contentHeight + 2,
4320
+ rows.length - contentHeight
4321
+ );
4322
+ }
4323
+ return 0;
4324
+ }
4325
+ function InputText({ value, pos, budget }) {
4326
+ let v = value;
4327
+ let p = pos;
4328
+ if (budget !== void 0 && value.length + 1 > budget) {
4329
+ const windowLen = Math.max(1, budget - 1);
4330
+ const start = Math.max(0, p - windowLen);
4331
+ v = value.slice(start, start + windowLen);
4332
+ p = pos - start;
4333
+ }
4334
+ if (p >= v.length) {
4335
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
4336
+ /* @__PURE__ */ jsx(Text, { children: v }),
4337
+ /* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2588" })
4338
+ ] });
4339
+ }
4340
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
4341
+ /* @__PURE__ */ jsx(Text, { children: v.slice(0, p) }),
4342
+ /* @__PURE__ */ jsx(Text, { inverse: true, children: v[p] }),
4343
+ /* @__PURE__ */ jsx(Text, { children: v.slice(p + 1) })
4344
+ ] });
4345
+ }
4216
4346
  function truncate(str, max) {
4217
4347
  if (max <= 1) return "";
4218
4348
  return str.length > max ? str.slice(0, max - 1) + "\u2026" : str;
@@ -4257,8 +4387,8 @@ function SessionRow({
4257
4387
  active,
4258
4388
  width
4259
4389
  }) {
4260
- const dotChar = status === "idle" ? "\u25C6" : status === "running" ? "\u25CF" : "\u25CB";
4261
- const dotColor = status === "idle" ? "yellow" : status === "running" ? "green" : "gray";
4390
+ const dotChar = status === "attention" ? "\u25C6" : status === "idle" ? "\u25C7" : status === "running" ? "\u25CF" : "\u25CB";
4391
+ const dotColor = status === "attention" ? "yellow" : status === "idle" ? "cyan" : status === "running" ? "green" : "gray";
4262
4392
  const agoStr = timeAgo(effectiveLastAccessedAt(s));
4263
4393
  const mergedLen = merged ? 8 : 0;
4264
4394
  const conflictLen = conflicts > 0 ? 2 + String(conflicts).length : 0;
@@ -4303,11 +4433,8 @@ function ProjectRow({
4303
4433
  /* @__PURE__ */ jsx(Text, { color: "magenta", children: truncate(name, width - 15) }),
4304
4434
  /* @__PURE__ */ jsx(Text, { children: " " }),
4305
4435
  /* @__PURE__ */ jsx(Text, { color: "cyan", children: "branch:" }),
4306
- /* @__PURE__ */ jsxs(Text, { children: [
4307
- " ",
4308
- branchInput.value
4309
- ] }),
4310
- /* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2588" })
4436
+ /* @__PURE__ */ jsx(Text, { children: " " }),
4437
+ /* @__PURE__ */ jsx(InputText, { value: branchInput.value, pos: branchInput.pos })
4311
4438
  ] });
4312
4439
  }
4313
4440
  return /* @__PURE__ */ jsxs(Box, { width, children: [
@@ -4365,26 +4492,7 @@ function BorderedPane({
4365
4492
  }) {
4366
4493
  const innerWidth = width - 2;
4367
4494
  const contentHeight = height - 2;
4368
- let cursorRowIdx = 0;
4369
- let selectableCount = 0;
4370
- for (let i = 0; i < sidebarRows.length; i++) {
4371
- if (sidebarRows[i].type !== "header") {
4372
- if (selectableCount === cursor) {
4373
- cursorRowIdx = i;
4374
- break;
4375
- }
4376
- selectableCount++;
4377
- }
4378
- }
4379
- let scrollOffset = 0;
4380
- if (sidebarRows.length > contentHeight) {
4381
- if (cursorRowIdx >= contentHeight - 1) {
4382
- scrollOffset = Math.min(
4383
- cursorRowIdx - contentHeight + 2,
4384
- sidebarRows.length - contentHeight
4385
- );
4386
- }
4387
- }
4495
+ const scrollOffset = computeScrollOffset(sidebarRows, cursor, contentHeight);
4388
4496
  const rendered = [];
4389
4497
  let selectableIdx = 0;
4390
4498
  for (let i = 0; i < scrollOffset; i++) {
@@ -4405,7 +4513,14 @@ function BorderedPane({
4405
4513
  rendered.push(renderRow(row, rowIdx, sel));
4406
4514
  }
4407
4515
  }
4408
- const topBorder = title ? "\u250C\u2500 " + title + " " + "\u2500".repeat(Math.max(0, innerWidth - title.length - 3)) + "\u2510" : "\u250C" + "\u2500".repeat(innerWidth) + "\u2510";
4516
+ const hiddenAbove = scrollOffset;
4517
+ const hiddenBelow = Math.max(0, sidebarRows.length - (scrollOffset + contentHeight));
4518
+ const upText = hiddenAbove > 0 ? ` \u2191${hiddenAbove} ` : "";
4519
+ const downText = hiddenBelow > 0 ? ` \u2193${hiddenBelow} ` : "";
4520
+ const titlePart = title ? "\u2500 " + title + " " : "";
4521
+ const topFill = Math.max(0, innerWidth - titlePart.length - upText.length);
4522
+ const topBorder = "\u250C" + titlePart + "\u2500".repeat(topFill) + upText + "\u2510";
4523
+ const bottomBorder = "\u2514" + "\u2500".repeat(Math.max(0, innerWidth - downText.length)) + downText + "\u2518";
4409
4524
  return /* @__PURE__ */ jsxs(Box, { flexDirection: "column", width, children: [
4410
4525
  /* @__PURE__ */ jsx(Text, { color: borderColor, children: topBorder }),
4411
4526
  rendered.map((row, i) => /* @__PURE__ */ jsxs(Box, { children: [
@@ -4413,12 +4528,13 @@ function BorderedPane({
4413
4528
  row,
4414
4529
  /* @__PURE__ */ jsx(Text, { color: borderColor, children: "\u2502" })
4415
4530
  ] }, i)),
4416
- /* @__PURE__ */ jsx(Text, { color: borderColor, children: "\u2514" + "\u2500".repeat(innerWidth) + "\u2518" })
4531
+ /* @__PURE__ */ jsx(Text, { color: borderColor, children: bottomBorder })
4417
4532
  ] });
4418
4533
  }
4419
- function Sidebar({ sidebarRows, cursor, focused, statusMap, conflictCounts, mergedSet, prMap, activeKey, width, height, branchInput }) {
4534
+ var Sidebar = React.memo(function Sidebar2({ sidebarRows, cursor, focused, statusMap, conflictCounts, mergedSet, prMap, activeKey, width, height, branchInput, filter }) {
4420
4535
  const borderColor = focused ? "cyan" : "gray";
4421
4536
  const innerWidth = width - 2;
4537
+ const title = filter ? `Worktrees /${filter.value}${filter.editing ? "\u2588" : ""}` : "Worktrees";
4422
4538
  return /* @__PURE__ */ jsx(
4423
4539
  BorderedPane,
4424
4540
  {
@@ -4426,7 +4542,7 @@ function Sidebar({ sidebarRows, cursor, focused, statusMap, conflictCounts, merg
4426
4542
  cursor,
4427
4543
  focused,
4428
4544
  borderColor,
4429
- title: "Worktrees",
4545
+ title,
4430
4546
  width,
4431
4547
  height,
4432
4548
  renderRow: (row, i, sel) => {
@@ -4467,7 +4583,7 @@ function Sidebar({ sidebarRows, cursor, focused, statusMap, conflictCounts, merg
4467
4583
  }
4468
4584
  }
4469
4585
  );
4470
- }
4586
+ });
4471
4587
  function statusColor(status) {
4472
4588
  const lower = status.toLowerCase();
4473
4589
  if (lower.includes("progress") || lower.includes("review")) return "cyan";
@@ -4492,7 +4608,7 @@ function JiraListRow({
4492
4608
  /* @__PURE__ */ jsx(Text, { children: truncate(issue.summary, summaryBudget) })
4493
4609
  ] });
4494
4610
  }
4495
- function PrPane({ prRows, cursor, focused, localBranches, width, height }) {
4611
+ var PrPane = React.memo(function PrPane2({ prRows, cursor, focused, localBranches, width, height }) {
4496
4612
  const borderColor = focused ? "cyan" : "gray";
4497
4613
  const innerWidth = width - 2;
4498
4614
  return /* @__PURE__ */ jsx(
@@ -4523,7 +4639,7 @@ function PrPane({ prRows, cursor, focused, localBranches, width, height }) {
4523
4639
  }
4524
4640
  }
4525
4641
  );
4526
- }
4642
+ });
4527
4643
  function TaskListRow({
4528
4644
  task,
4529
4645
  selected,
@@ -4545,22 +4661,21 @@ function TaskListRow({
4545
4661
  /* @__PURE__ */ jsx(Text, { dimColor: true, children: idStr })
4546
4662
  ] });
4547
4663
  }
4548
- function TaskInputRow({ value, width }) {
4664
+ function TaskInputRow({ value, pos, width }) {
4549
4665
  const budget = Math.max(4, width - 8);
4550
4666
  return /* @__PURE__ */ jsxs(Box, { width, children: [
4551
4667
  /* @__PURE__ */ jsx(Text, { children: " " }),
4552
4668
  /* @__PURE__ */ jsx(Text, { color: "cyan", children: "+ " }),
4553
- /* @__PURE__ */ jsx(Text, { children: truncate(value, budget) }),
4554
- /* @__PURE__ */ jsx(Text, { dimColor: true, children: "\u2588" })
4669
+ /* @__PURE__ */ jsx(InputText, { value, pos, budget })
4555
4670
  ] });
4556
4671
  }
4557
- function TaskPane({ taskRows, cursor, focused, width, height, taskInput }) {
4672
+ var TaskPane = React.memo(function TaskPane2({ taskRows, cursor, focused, width, height, taskInput }) {
4558
4673
  const borderColor = focused ? "cyan" : "gray";
4559
4674
  const innerWidth = width - 2;
4560
4675
  const contentHeight = height - 2;
4561
4676
  if (taskInput !== null && taskInput !== void 0) {
4562
4677
  const rendered = [];
4563
- rendered.push(/* @__PURE__ */ jsx(TaskInputRow, { value: taskInput, width: innerWidth }, "input"));
4678
+ rendered.push(/* @__PURE__ */ jsx(TaskInputRow, { value: taskInput.value, pos: taskInput.pos, width: innerWidth }, "input"));
4564
4679
  let selectableIdx = 0;
4565
4680
  for (let i = 0; i < contentHeight - 1 && i < taskRows.length; i++) {
4566
4681
  const row = taskRows[i];
@@ -4615,8 +4730,8 @@ function TaskPane({ taskRows, cursor, focused, width, height, taskInput }) {
4615
4730
  }
4616
4731
  }
4617
4732
  );
4618
- }
4619
- function JiraPane({ jiraRows, cursor, focused, width, height }) {
4733
+ });
4734
+ var JiraPane = React.memo(function JiraPane2({ jiraRows, cursor, focused, width, height }) {
4620
4735
  const borderColor = focused ? "cyan" : "gray";
4621
4736
  const innerWidth = width - 2;
4622
4737
  return /* @__PURE__ */ jsx(
@@ -4646,12 +4761,13 @@ function JiraPane({ jiraRows, cursor, focused, width, height }) {
4646
4761
  }
4647
4762
  }
4648
4763
  );
4649
- }
4764
+ });
4650
4765
 
4651
4766
  // src/tui-ink/TerminalPane.tsx
4767
+ import React2 from "react";
4652
4768
  import { Box as Box2, Text as Text2 } from "ink";
4653
4769
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
4654
- function TerminalPane({ lines, width, height, focused, placeholder, title }) {
4770
+ var TerminalPane = React2.memo(function TerminalPane2({ lines, width, height, focused, placeholder, title, scrollback }) {
4655
4771
  const borderColor = focused ? "cyan" : "gray";
4656
4772
  const innerWidth = width - 2;
4657
4773
  const contentHeight = height - 2;
@@ -4677,8 +4793,10 @@ function TerminalPane({ lines, width, height, focused, placeholder, title }) {
4677
4793
  }
4678
4794
  }
4679
4795
  }
4796
+ const scrolledTitle = scrollback && scrollback > 0 ? `${title ?? "Terminal"} \u2500 \u2191${scrollback} paused (pgdn/type to resume)` : title;
4797
+ const topBorder = scrolledTitle ? "\u250C\u2500 " + scrolledTitle + " " + "\u2500".repeat(Math.max(0, innerWidth - scrolledTitle.length - 3)) + "\u2510" : "\u250C" + "\u2500".repeat(innerWidth) + "\u2510";
4680
4798
  return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", width, children: [
4681
- /* @__PURE__ */ jsx2(Text2, { color: borderColor, children: title ? "\u250C\u2500 " + title + " " + "\u2500".repeat(Math.max(0, innerWidth - title.length - 3)) + "\u2510" : "\u250C" + "\u2500".repeat(innerWidth) + "\u2510" }),
4799
+ /* @__PURE__ */ jsx2(Text2, { color: scrollback && scrollback > 0 ? "yellow" : borderColor, children: topBorder }),
4682
4800
  content.map((row, i) => /* @__PURE__ */ jsxs2(Box2, { children: [
4683
4801
  /* @__PURE__ */ jsx2(Text2, { color: borderColor, children: "\u2502" }),
4684
4802
  /* @__PURE__ */ jsx2(Box2, { width: innerWidth, children: row }),
@@ -4686,19 +4804,20 @@ function TerminalPane({ lines, width, height, focused, placeholder, title }) {
4686
4804
  ] }, i)),
4687
4805
  /* @__PURE__ */ jsx2(Text2, { color: borderColor, children: "\u2514" + "\u2500".repeat(innerWidth) + "\u2518" })
4688
4806
  ] });
4689
- }
4807
+ });
4690
4808
 
4691
4809
  // src/tui-ink/StatusBar.tsx
4810
+ import React3 from "react";
4692
4811
  import { Box as Box3, Text as Text3 } from "ink";
4693
- import { Fragment, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
4812
+ import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
4694
4813
  var PANE_HINTS = {
4695
- sessions: " tab pane j/k nav enter start n new d remove . editor u rebase g sync G sync all q quit ",
4696
- tasks: " tab pane j/k nav enter toggle a add e edit w worktree d remove g sync G sync all q quit ",
4697
- prs: " tab pane j/k nav enter checkout g sync G sync all q quit ",
4698
- jira: " tab pane j/k nav enter worktree o open g sync G sync all q quit ",
4699
- terminal: " tab pane ctrl+] detach "
4814
+ sessions: " tab pane j/k nav / filter enter start n new d remove u rebase g sync ? help q quit ",
4815
+ tasks: " tab pane j/k nav enter toggle a add e edit w worktree d remove ? help q quit ",
4816
+ prs: " tab pane j/k nav enter checkout o open g sync ? help q quit ",
4817
+ jira: " tab pane j/k nav enter worktree o open g sync ? help q quit ",
4818
+ terminal: " tab pane ctrl+] detach pgup/pgdn scroll "
4700
4819
  };
4701
- function StatusBar({ message, pane, syncing }) {
4820
+ var StatusBar = React3.memo(function StatusBar2({ message, pane, syncing }) {
4702
4821
  if (message) {
4703
4822
  return /* @__PURE__ */ jsxs3(Box3, { children: [
4704
4823
  /* @__PURE__ */ jsxs3(Text3, { color: "yellow", children: [
@@ -4711,21 +4830,217 @@ function StatusBar({ message, pane, syncing }) {
4711
4830
  }
4712
4831
  return /* @__PURE__ */ jsxs3(Box3, { children: [
4713
4832
  /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: PANE_HINTS[pane] }),
4714
- pane === "sessions" && /* @__PURE__ */ jsxs3(Fragment, { children: [
4833
+ pane === "sessions" && /* @__PURE__ */ jsxs3(Fragment2, { children: [
4715
4834
  /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "[" }),
4716
4835
  /* @__PURE__ */ jsx3(Text3, { color: "green", children: "\u25CF" }),
4717
4836
  /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " working " }),
4718
4837
  /* @__PURE__ */ jsx3(Text3, { color: "yellow", children: "\u25C6" }),
4719
4838
  /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " needs input " }),
4839
+ /* @__PURE__ */ jsx3(Text3, { color: "cyan", children: "\u25C7" }),
4840
+ /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: " done " }),
4720
4841
  /* @__PURE__ */ jsx3(Text3, { dimColor: true, children: "\u25CB stopped]" })
4721
4842
  ] }),
4722
4843
  syncing && /* @__PURE__ */ jsx3(Box3, { flexGrow: 1 }),
4723
4844
  syncing && /* @__PURE__ */ jsx3(Text3, { color: "cyan", children: " syncing" })
4724
4845
  ] });
4846
+ });
4847
+
4848
+ // src/tui-ink/HelpOverlay.tsx
4849
+ import React4 from "react";
4850
+ import { Box as Box4, Text as Text4 } from "ink";
4851
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
4852
+ var HELP = [
4853
+ { type: "section", label: "Navigation" },
4854
+ { type: "key", keys: "tab", desc: "cycle pane focus" },
4855
+ { type: "key", keys: "j/k or \u2191/\u2193", desc: "move cursor" },
4856
+ { type: "key", keys: "ctrl+d / ctrl+u", desc: "half-page down / up" },
4857
+ { type: "key", keys: "pgup / pgdn", desc: "page up / down" },
4858
+ { type: "key", keys: "mouse", desc: "wheel scrolls, click focuses + selects" },
4859
+ { type: "blank" },
4860
+ { type: "section", label: "Worktrees pane" },
4861
+ { type: "key", keys: "enter", desc: "start / show session" },
4862
+ { type: "key", keys: "/", desc: "filter sessions (enter keeps, esc clears)" },
4863
+ { type: "key", keys: "n", desc: "new worktree" },
4864
+ { type: "key", keys: "d", desc: "remove worktree (press d again to confirm)" },
4865
+ { type: "key", keys: ".", desc: "open in editor" },
4866
+ { type: "key", keys: "u", desc: "rebase onto main" },
4867
+ { type: "blank" },
4868
+ { type: "section", label: "Pull Requests / Jira panes" },
4869
+ { type: "key", keys: "enter", desc: "checkout PR / create worktree for issue" },
4870
+ { type: "key", keys: "o", desc: "open in browser" },
4871
+ { type: "blank" },
4872
+ { type: "section", label: "Tasks pane" },
4873
+ { type: "key", keys: "enter or x", desc: "toggle done" },
4874
+ { type: "key", keys: "a / e / d", desc: "add / edit / remove task" },
4875
+ { type: "key", keys: "w", desc: "create worktree from task" },
4876
+ { type: "blank" },
4877
+ { type: "section", label: "Terminal" },
4878
+ { type: "key", keys: "ctrl+]", desc: "detach back to sidebar" },
4879
+ { type: "key", keys: "pgup / pgdn", desc: "scroll history (typing resumes live)" },
4880
+ { type: "blank" },
4881
+ { type: "section", label: "Global" },
4882
+ { type: "key", keys: "g / G", desc: "sync focused pane / sync everything" },
4883
+ { type: "key", keys: "r", desc: "refresh all panes" },
4884
+ { type: "key", keys: "?", desc: "toggle this help" },
4885
+ { type: "key", keys: "q or ctrl+c", desc: "quit" }
4886
+ ];
4887
+ var HelpOverlay = React4.memo(function HelpOverlay2({ width, height }) {
4888
+ const innerWidth = width - 2;
4889
+ const contentHeight = height - 2;
4890
+ const title = "Help \u2014 press ? or esc to close";
4891
+ const topBorder = "\u250C\u2500 " + title + " " + "\u2500".repeat(Math.max(0, innerWidth - title.length - 3)) + "\u2510";
4892
+ const rows = [];
4893
+ for (let i = 0; i < contentHeight; i++) {
4894
+ const line = HELP[i];
4895
+ if (!line || line.type === "blank") {
4896
+ rows.push(/* @__PURE__ */ jsx4(Text4, { children: " ".repeat(innerWidth) }, i));
4897
+ continue;
4898
+ }
4899
+ if (line.type === "section") {
4900
+ rows.push(
4901
+ /* @__PURE__ */ jsx4(Box4, { width: innerWidth, children: /* @__PURE__ */ jsx4(Text4, { color: "yellow", bold: true, children: " " + line.label }) }, i)
4902
+ );
4903
+ continue;
4904
+ }
4905
+ rows.push(
4906
+ /* @__PURE__ */ jsxs4(Box4, { width: innerWidth, children: [
4907
+ /* @__PURE__ */ jsx4(Text4, { color: "cyan", children: " " + line.keys.padEnd(18) }),
4908
+ /* @__PURE__ */ jsx4(Text4, { children: line.desc })
4909
+ ] }, i)
4910
+ );
4911
+ }
4912
+ return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", width, children: [
4913
+ /* @__PURE__ */ jsx4(Text4, { color: "cyan", children: topBorder }),
4914
+ rows.map((row, i) => /* @__PURE__ */ jsxs4(Box4, { children: [
4915
+ /* @__PURE__ */ jsx4(Text4, { color: "cyan", children: "\u2502" }),
4916
+ row,
4917
+ /* @__PURE__ */ jsx4(Text4, { color: "cyan", children: "\u2502" })
4918
+ ] }, i)),
4919
+ /* @__PURE__ */ jsx4(Text4, { color: "cyan", children: "\u2514" + "\u2500".repeat(innerWidth) + "\u2518" })
4920
+ ] });
4921
+ });
4922
+
4923
+ // src/tui-ink/line-editor.ts
4924
+ var KEYS = {
4925
+ UP: "\x1B[A",
4926
+ DOWN: "\x1B[B",
4927
+ RIGHT: "\x1B[C",
4928
+ LEFT: "\x1B[D",
4929
+ HOME: "\x1B[H",
4930
+ END: "\x1B[F",
4931
+ HOME_ALT: "\x1B[1~",
4932
+ END_ALT: "\x1B[4~",
4933
+ PAGE_UP: "\x1B[5~",
4934
+ PAGE_DOWN: "\x1B[6~",
4935
+ DELETE: "\x1B[3~",
4936
+ ESC: "\x1B",
4937
+ ENTER: "\r",
4938
+ BACKSPACE: "\x7F",
4939
+ BACKSPACE_ALT: "\b",
4940
+ CTRL_C: "",
4941
+ CTRL_D: "",
4942
+ CTRL_U: "",
4943
+ TAB: " "
4944
+ };
4945
+ function splitInputChunks(data) {
4946
+ const tokens = [];
4947
+ let i = 0;
4948
+ let run2 = "";
4949
+ const flushRun = () => {
4950
+ if (run2) {
4951
+ tokens.push(run2);
4952
+ run2 = "";
4953
+ }
4954
+ };
4955
+ while (i < data.length) {
4956
+ const ch = data[i];
4957
+ if (ch === "\x1B") {
4958
+ flushRun();
4959
+ const next = data[i + 1];
4960
+ if (next === "[") {
4961
+ let j = i + 2;
4962
+ while (j < data.length) {
4963
+ const code2 = data.charCodeAt(j);
4964
+ if (code2 >= 64 && code2 <= 126) break;
4965
+ j++;
4966
+ }
4967
+ tokens.push(data.slice(i, Math.min(j + 1, data.length)));
4968
+ i = j + 1;
4969
+ continue;
4970
+ }
4971
+ if (next === "O" && i + 2 < data.length) {
4972
+ tokens.push(data.slice(i, i + 3));
4973
+ i += 3;
4974
+ continue;
4975
+ }
4976
+ tokens.push("\x1B");
4977
+ i++;
4978
+ continue;
4979
+ }
4980
+ const code = data.charCodeAt(i);
4981
+ if (code < 32 || code === 127) {
4982
+ flushRun();
4983
+ tokens.push(ch);
4984
+ i++;
4985
+ continue;
4986
+ }
4987
+ run2 += ch;
4988
+ i++;
4989
+ }
4990
+ flushRun();
4991
+ return tokens;
4992
+ }
4993
+ function sanitizePaste(text) {
4994
+ const firstLine = text.split(/\r|\n/, 1)[0] ?? "";
4995
+ return firstLine.replace(/[\u0000-\u001f\u007f]/g, "");
4996
+ }
4997
+ function editLine(state, token) {
4998
+ const { value, pos } = state;
4999
+ switch (token) {
5000
+ case KEYS.ESC:
5001
+ case KEYS.CTRL_C:
5002
+ return { state, action: "cancel" };
5003
+ case KEYS.ENTER:
5004
+ return { state, action: "submit" };
5005
+ case KEYS.BACKSPACE:
5006
+ case KEYS.BACKSPACE_ALT:
5007
+ if (pos === 0) return { state, action: null };
5008
+ return {
5009
+ state: { value: value.slice(0, pos - 1) + value.slice(pos), pos: pos - 1 },
5010
+ action: null
5011
+ };
5012
+ case KEYS.DELETE:
5013
+ if (pos >= value.length) return { state, action: null };
5014
+ return {
5015
+ state: { value: value.slice(0, pos) + value.slice(pos + 1), pos },
5016
+ action: null
5017
+ };
5018
+ case KEYS.LEFT:
5019
+ return { state: { value, pos: Math.max(0, pos - 1) }, action: null };
5020
+ case KEYS.RIGHT:
5021
+ return { state: { value, pos: Math.min(value.length, pos + 1) }, action: null };
5022
+ case KEYS.HOME:
5023
+ case KEYS.HOME_ALT:
5024
+ return { state: { value, pos: 0 }, action: null };
5025
+ case KEYS.END:
5026
+ case KEYS.END_ALT:
5027
+ return { state: { value, pos: value.length }, action: null };
5028
+ case KEYS.CTRL_U:
5029
+ return { state: { value: value.slice(pos), pos: 0 }, action: null };
5030
+ }
5031
+ if (token.startsWith("\x1B") || token.charCodeAt(0) < 32 || token === "\x7F") {
5032
+ return { state, action: null };
5033
+ }
5034
+ const insert = sanitizePaste(token);
5035
+ if (!insert) return { state, action: null };
5036
+ return {
5037
+ state: { value: value.slice(0, pos) + insert + value.slice(pos), pos: pos + insert.length },
5038
+ action: null
5039
+ };
4725
5040
  }
4726
5041
 
4727
5042
  // src/tui-ink/App.tsx
4728
- import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
5043
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
4729
5044
  var DETACH_KEY = "";
4730
5045
  var TAB_KEY = " ";
4731
5046
  var RENDER_INTERVAL_MS = 50;
@@ -4733,7 +5048,7 @@ var MOUSE_SGR_RE = /\x1b\[<(\d+);(\d+);(\d+)[Mm]/;
4733
5048
  function hasClaudeConversation(dir) {
4734
5049
  try {
4735
5050
  const resolved = path20.resolve(dir);
4736
- const projectDir = resolved.replace(/[/\\:]/g, "-");
5051
+ const projectDir = resolved.replace(/[^a-zA-Z0-9-]/g, "-");
4737
5052
  const claudeProjectPath = path20.join(os6.homedir(), ".claude", "projects", projectDir);
4738
5053
  if (!fs23.existsSync(claudeProjectPath)) return false;
4739
5054
  const files = fs23.readdirSync(claudeProjectPath);
@@ -4828,20 +5143,35 @@ function App({ unsafe, onExit }) {
4828
5143
  const [pendingJiraIssue, setPendingJiraIssue] = useState(null);
4829
5144
  const [pendingTask, setPendingTask] = useState(null);
4830
5145
  const [savedSessionCursor, setSavedSessionCursor] = useState(0);
5146
+ const [showHelp2, setShowHelp] = useState(false);
5147
+ const [filter, setFilter] = useState(null);
5148
+ const [pendingRemoveKey, setPendingRemoveKey] = useState(null);
5149
+ const [termScroll, setTermScroll] = useState(0);
5150
+ const setScrollBack = useCallback((n) => {
5151
+ termScrollBack.current = n;
5152
+ setTermScroll(n);
5153
+ }, []);
4831
5154
  const localBranches = useMemo(() => new Set(sessions.map((s) => s.branch)), [sessions]);
4832
5155
  const projectRows = useMemo(() => buildProjectRows(projects), [projects]);
4833
5156
  const prRows = useMemo(() => buildPrRows(prMap), [prMap]);
4834
5157
  const jiraRows = useMemo(() => buildJiraRows(jiraIssues), [jiraIssues]);
4835
5158
  const taskRows = useMemo(() => buildTaskRows(tasks), [tasks]);
5159
+ const filteredSessions = useMemo(() => {
5160
+ const q = filter?.value.trim().toLowerCase();
5161
+ if (!q) return sessions;
5162
+ return sessions.filter(
5163
+ (s) => s.branch.toLowerCase().includes(q) || s.target.toLowerCase().includes(q)
5164
+ );
5165
+ }, [sessions, filter]);
4836
5166
  const ptySessions = useRef(/* @__PURE__ */ new Map());
4837
5167
  const sessionRows = useMemo(() => {
4838
5168
  const sMap = /* @__PURE__ */ new Map();
4839
5169
  for (const [key, pty2] of ptySessions.current) {
4840
5170
  if (pty2.exited) continue;
4841
- sMap.set(key, pty2.idle ? "idle" : "running");
5171
+ sMap.set(key, pty2.status);
4842
5172
  }
4843
- return buildSessionRows(sessions, sMap);
4844
- }, [sessions, statusVersion]);
5173
+ return buildSessionRows(filteredSessions, sMap);
5174
+ }, [filteredSessions, statusVersion]);
4845
5175
  const topRows = topPaneMode === 0 /* SESSIONS */ ? sessionRows : projectRows;
4846
5176
  const renderPending = useRef(false);
4847
5177
  const focusRef = useRef(focus);
@@ -4881,6 +5211,13 @@ function App({ unsafe, onExit }) {
4881
5211
  prRowsRef.current = prRows;
4882
5212
  const acliAvailableRef = useRef(acliAvailable);
4883
5213
  acliAvailableRef.current = acliAvailable;
5214
+ const showHelpRef = useRef(showHelp2);
5215
+ showHelpRef.current = showHelp2;
5216
+ const filterRef = useRef(filter);
5217
+ filterRef.current = filter;
5218
+ const pendingRemoveRef = useRef(pendingRemoveKey);
5219
+ pendingRemoveRef.current = pendingRemoveKey;
5220
+ const rebasingRef = useRef(false);
4884
5221
  const hookServerRef = useRef(null);
4885
5222
  const notifiedSessionsRef = useRef(/* @__PURE__ */ new Set());
4886
5223
  const [dims, setDims] = useState(() => ({
@@ -4897,16 +5234,21 @@ function App({ unsafe, onExit }) {
4897
5234
  const taskPaneHeight = Math.max(5, Math.floor(contentHeight * 0.2));
4898
5235
  const prPaneHeight = Math.max(5, Math.floor((contentHeight - jiraPaneHeight - taskPaneHeight) * 0.45));
4899
5236
  const sessionPaneHeight = contentHeight - prPaneHeight - taskPaneHeight - jiraPaneHeight;
5237
+ const layoutRef = useRef({ sidebarWidth, termInner, contentHeight, sessionPaneHeight, prPaneHeight, jiraPaneHeight, taskPaneHeight });
5238
+ layoutRef.current = { sidebarWidth, termInner, contentHeight, sessionPaneHeight, prPaneHeight, jiraPaneHeight, taskPaneHeight };
4900
5239
  useEffect(() => {
5240
+ let attentionCount = 0;
4901
5241
  let idleCount = 0;
4902
5242
  let runningCount = 0;
4903
5243
  for (const pty2 of ptySessions.current.values()) {
4904
5244
  if (pty2.exited) continue;
4905
- if (pty2.idle) idleCount++;
5245
+ if (pty2.status === "attention") attentionCount++;
5246
+ else if (pty2.status === "idle") idleCount++;
4906
5247
  else runningCount++;
4907
5248
  }
4908
5249
  const parts = [];
4909
- if (idleCount > 0) parts.push(`\u{1F7E1} ${idleCount}`);
5250
+ if (attentionCount > 0) parts.push(`\u{1F7E1} ${attentionCount}`);
5251
+ if (idleCount > 0) parts.push(`\u{1F535} ${idleCount}`);
4910
5252
  if (runningCount > 0) parts.push(`\u{1F7E2} ${runningCount}`);
4911
5253
  const title = parts.length > 0 ? parts.join(" ") : "work dash";
4912
5254
  process.stdout.write(`\x1B]0;${title}\x07`);
@@ -4914,23 +5256,21 @@ function App({ unsafe, onExit }) {
4914
5256
  const computeGeneration = useRef(0);
4915
5257
  const computeConflictsAndMerged = useCallback((sessionList) => {
4916
5258
  const generation = ++computeGeneration.current;
4917
- const tick = () => new Promise((r) => setTimeout(r, 0));
4918
5259
  (async () => {
4919
5260
  const counts = /* @__PURE__ */ new Map();
4920
5261
  const merged = /* @__PURE__ */ new Set();
4921
5262
  for (const s of sessionList) {
4922
5263
  if (computeGeneration.current !== generation) return;
4923
- await tick();
4924
5264
  const existing = s.paths.find((p) => fs23.existsSync(p));
4925
5265
  if (!existing || !s.branch) continue;
4926
5266
  const key = sessionKey2(s);
4927
5267
  try {
4928
- const c = countConflicts(s.branch, existing);
5268
+ const c = await countConflictsAsync(s.branch, existing);
4929
5269
  if (c > 0) counts.set(key, c);
4930
5270
  } catch {
4931
5271
  }
4932
5272
  try {
4933
- const { merged: isMerged } = isBranchMerged(s.branch, existing);
5273
+ const { merged: isMerged } = await isBranchMergedAsync(s.branch, existing);
4934
5274
  if (isMerged) merged.add(key);
4935
5275
  } catch {
4936
5276
  }
@@ -4942,10 +5282,10 @@ function App({ unsafe, onExit }) {
4942
5282
  })();
4943
5283
  }, []);
4944
5284
  const refreshPrs = useCallback(() => {
4945
- if (!ghAvailable || !config || prFetching.current) return;
5285
+ if (!ghAvailable || !config || prFetching.current) return Promise.resolve();
4946
5286
  prFetching.current = true;
4947
5287
  setMessage("Loading PRs...");
4948
- fetchAllPullRequests(config.repos).then((prs) => {
5288
+ return fetchAllPullRequests(config.repos).then((prs) => {
4949
5289
  setPrMap(prs);
4950
5290
  setMessage("");
4951
5291
  }).catch(() => {
@@ -4954,9 +5294,9 @@ function App({ unsafe, onExit }) {
4954
5294
  });
4955
5295
  }, [ghAvailable, config]);
4956
5296
  const refreshJira = useCallback(() => {
4957
- if (!acliAvailable || jiraFetching.current) return;
5297
+ if (!acliAvailable || jiraFetching.current) return Promise.resolve();
4958
5298
  jiraFetching.current = true;
4959
- fetchMyJiraIssues().then((issues) => setJiraIssues(issues)).catch(() => {
5299
+ return fetchMyJiraIssues().then((issues) => setJiraIssues(issues)).catch(() => {
4960
5300
  }).finally(() => {
4961
5301
  jiraFetching.current = false;
4962
5302
  });
@@ -4969,11 +5309,11 @@ function App({ unsafe, onExit }) {
4969
5309
  setSessions(updated);
4970
5310
  computeConflictsAndMerged(updated);
4971
5311
  }, [computeConflictsAndMerged]);
4972
- const buildStatusMap = useCallback(() => {
5312
+ const statusMap = useMemo(() => {
4973
5313
  const map = /* @__PURE__ */ new Map();
4974
5314
  for (const [key, pty2] of ptySessions.current) {
4975
5315
  if (pty2.exited) continue;
4976
- map.set(key, pty2.idle ? "idle" : "running");
5316
+ map.set(key, pty2.status);
4977
5317
  }
4978
5318
  return map;
4979
5319
  }, [statusVersion]);
@@ -4983,6 +5323,8 @@ function App({ unsafe, onExit }) {
4983
5323
  setTimeout(() => {
4984
5324
  renderPending.current = false;
4985
5325
  try {
5326
+ const activeKey2 = activeKeyRef.current;
5327
+ if (!activeKey2 || ptySessions.current.get(activeKey2) !== pty2) return;
4986
5328
  if (termScrollBack.current > 0) return;
4987
5329
  const lines = renderBufferLines(pty2.terminal.buffer.active, termInner, contentHeight - 2);
4988
5330
  setTermLines(lines);
@@ -4999,6 +5341,16 @@ function App({ unsafe, onExit }) {
4999
5341
  } catch {
5000
5342
  }
5001
5343
  }, [termInner, contentHeight]);
5344
+ const scrollTerminal = useCallback((linesUp) => {
5345
+ const pty2 = activeKeyRef.current ? ptySessions.current.get(activeKeyRef.current) : void 0;
5346
+ if (!pty2 || pty2.exited) return;
5347
+ const maxScroll = pty2.terminal.buffer.active.baseY;
5348
+ const next = Math.max(0, Math.min(maxScroll, termScrollBack.current + linesUp));
5349
+ if (next !== termScrollBack.current) {
5350
+ setScrollBack(next);
5351
+ renderTermAtScroll();
5352
+ }
5353
+ }, [setScrollBack, renderTermAtScroll]);
5002
5354
  const findPtyByCwd = useCallback((cwd) => {
5003
5355
  const normalized = path20.resolve(cwd).toLowerCase();
5004
5356
  for (const pty2 of ptySessions.current.values()) {
@@ -5065,10 +5417,12 @@ function App({ unsafe, onExit }) {
5065
5417
  callback: (cwd, event) => {
5066
5418
  const pty2 = findPtyByCwd(cwd);
5067
5419
  if (!pty2) return;
5068
- if (event === "stop" || event === "notification") {
5069
- pty2.setIdle(true);
5420
+ if (event === "notification") {
5421
+ pty2.setStatus("attention");
5422
+ } else if (event === "stop") {
5423
+ pty2.setStatus("idle");
5070
5424
  } else if (event === "prompt_submit") {
5071
- pty2.setIdle(false);
5425
+ pty2.setStatus("running");
5072
5426
  }
5073
5427
  const dedupKey = ptyDedupKey(pty2);
5074
5428
  const kind = notifyKindForEvent(
@@ -5129,7 +5483,7 @@ function App({ unsafe, onExit }) {
5129
5483
  const switchDisplay = useCallback((s) => {
5130
5484
  const k = sessionKey2(s);
5131
5485
  if (activeKeyRef.current === k) return;
5132
- termScrollBack.current = 0;
5486
+ setScrollBack(0);
5133
5487
  if (activeKeyRef.current) {
5134
5488
  ptySessions.current.get(activeKeyRef.current)?.setOutputHandler(void 0);
5135
5489
  }
@@ -5180,6 +5534,7 @@ function App({ unsafe, onExit }) {
5180
5534
  if (activeKeyRef.current && activeKeyRef.current !== key) {
5181
5535
  ptySessions.current.get(activeKeyRef.current)?.setOutputHandler(void 0);
5182
5536
  }
5537
+ setScrollBack(0);
5183
5538
  setActiveKey(key);
5184
5539
  setFocus(4 /* TERMINAL */);
5185
5540
  pty2.resize(termInner, contentHeight - 2);
@@ -5370,8 +5725,8 @@ function App({ unsafe, onExit }) {
5370
5725
  connectPty(key, setupPty);
5371
5726
  }, [unsafe, termInner, contentHeight, refreshSessions, connectPty, registerPty, savedSessionCursor, config]);
5372
5727
  useEffect(() => {
5373
- const handler = (data) => {
5374
- const key = data.toString("utf8");
5728
+ const handleKey = (key) => {
5729
+ const layout = layoutRef.current;
5375
5730
  const mouseMatch = MOUSE_SGR_RE.exec(key);
5376
5731
  if (mouseMatch) {
5377
5732
  const button = parseInt(mouseMatch[1], 10);
@@ -5379,48 +5734,52 @@ function App({ unsafe, onExit }) {
5379
5734
  const row = parseInt(mouseMatch[3], 10);
5380
5735
  if (button === 64 || button === 65) {
5381
5736
  const delta = button === 64 ? -1 : 1;
5382
- if (col <= sidebarWidth) {
5383
- if (row <= sessionPaneHeight) {
5737
+ if (col <= layout.sidebarWidth) {
5738
+ if (row <= layout.sessionPaneHeight) {
5384
5739
  moveSessionCursor(delta);
5385
- } else if (row <= sessionPaneHeight + prPaneHeight) {
5740
+ } else if (row <= layout.sessionPaneHeight + layout.prPaneHeight) {
5386
5741
  movePrCursor(delta);
5387
- } else if (jiraPaneHeight > 0 && row <= sessionPaneHeight + prPaneHeight + jiraPaneHeight) {
5742
+ } else if (layout.jiraPaneHeight > 0 && row <= layout.sessionPaneHeight + layout.prPaneHeight + layout.jiraPaneHeight) {
5388
5743
  moveJiraCursor(delta);
5389
5744
  } else {
5390
5745
  moveTaskCursor(delta);
5391
5746
  }
5392
5747
  } else {
5393
- const pty2 = activeKeyRef.current ? ptySessions.current.get(activeKeyRef.current) : void 0;
5394
- if (pty2 && !pty2.exited) {
5395
- const maxScroll = pty2.terminal.buffer.active.baseY;
5396
- const newScroll = Math.max(0, Math.min(maxScroll, termScrollBack.current - delta * 3));
5397
- if (newScroll !== termScrollBack.current) {
5398
- termScrollBack.current = newScroll;
5399
- renderTermAtScroll();
5400
- }
5401
- }
5748
+ scrollTerminal(-delta * 3);
5402
5749
  }
5403
5750
  return;
5404
5751
  }
5405
5752
  if (button === 0) {
5406
- if (col <= sidebarWidth) {
5407
- if (row <= sessionPaneHeight) {
5753
+ if (col <= layout.sidebarWidth) {
5754
+ if (row <= layout.sessionPaneHeight) {
5408
5755
  setFocus(0 /* SESSIONS */);
5409
5756
  const visualIdx = row - 2;
5410
- if (visualIdx >= 0) setSessionCursor(visualRowToCursor(topRowsRef.current, visualIdx));
5411
- } else if (row <= sessionPaneHeight + prPaneHeight) {
5757
+ if (visualIdx >= 0) {
5758
+ const offset = computeScrollOffset(topRowsRef.current, sessionCursorRef.current, layout.sessionPaneHeight - 2);
5759
+ setSessionCursor(visualRowToCursor(topRowsRef.current, visualIdx + offset));
5760
+ }
5761
+ } else if (row <= layout.sessionPaneHeight + layout.prPaneHeight) {
5412
5762
  setFocus(2 /* PRS */);
5413
- const visualIdx = row - sessionPaneHeight - 2;
5414
- if (visualIdx >= 0) setPrCursor(visualRowToCursor(prRowsRef.current, visualIdx));
5415
- } else if (jiraPaneHeight > 0 && row <= sessionPaneHeight + prPaneHeight + jiraPaneHeight) {
5763
+ const visualIdx = row - layout.sessionPaneHeight - 2;
5764
+ if (visualIdx >= 0) {
5765
+ const offset = computeScrollOffset(prRowsRef.current, prCursorRef.current, layout.prPaneHeight - 2);
5766
+ setPrCursor(visualRowToCursor(prRowsRef.current, visualIdx + offset));
5767
+ }
5768
+ } else if (layout.jiraPaneHeight > 0 && row <= layout.sessionPaneHeight + layout.prPaneHeight + layout.jiraPaneHeight) {
5416
5769
  setFocus(3 /* JIRA */);
5417
- const visualIdx = row - sessionPaneHeight - prPaneHeight - 2;
5418
- if (visualIdx >= 0) setJiraCursor(visualRowToCursor(jiraRowsRef.current, visualIdx));
5770
+ const visualIdx = row - layout.sessionPaneHeight - layout.prPaneHeight - 2;
5771
+ if (visualIdx >= 0) {
5772
+ const offset = computeScrollOffset(jiraRowsRef.current, jiraCursorRef.current, layout.jiraPaneHeight - 2);
5773
+ setJiraCursor(visualRowToCursor(jiraRowsRef.current, visualIdx + offset));
5774
+ }
5419
5775
  } else {
5420
5776
  setFocus(1 /* TASKS */);
5421
- const taskStart = sessionPaneHeight + prPaneHeight + jiraPaneHeight;
5777
+ const taskStart = layout.sessionPaneHeight + layout.prPaneHeight + layout.jiraPaneHeight;
5422
5778
  const visualIdx = row - taskStart - 2;
5423
- if (visualIdx >= 0) setTaskCursor(visualRowToCursor(taskRowsRef.current, visualIdx));
5779
+ if (visualIdx >= 0) {
5780
+ const offset = computeScrollOffset(taskRowsRef.current, taskCursorRef.current, layout.taskPaneHeight - 2);
5781
+ setTaskCursor(visualRowToCursor(taskRowsRef.current, visualIdx + offset));
5782
+ }
5424
5783
  }
5425
5784
  } else {
5426
5785
  const activePty = activeKeyRef.current ? ptySessions.current.get(activeKeyRef.current) : void 0;
@@ -5431,18 +5790,25 @@ function App({ unsafe, onExit }) {
5431
5790
  }
5432
5791
  return;
5433
5792
  }
5793
+ if (showHelpRef.current) {
5794
+ if (key === "?" || key === KEYS.ESC || key === "q" || key === KEYS.CTRL_C) {
5795
+ setShowHelp(false);
5796
+ }
5797
+ return;
5798
+ }
5434
5799
  if (branchInputRef.current) {
5435
- if (key === "\x1B" || key === "") {
5800
+ const { projectName, isGroup, value, pos } = branchInputRef.current;
5801
+ const { state, action } = editLine({ value, pos }, key);
5802
+ if (action === "cancel") {
5436
5803
  setBranchInput(null);
5437
5804
  setTopPaneMode(1 /* PROJECTS */);
5438
5805
  setMessage("Esc to go back");
5439
5806
  return;
5440
5807
  }
5441
- if (key === "\r") {
5442
- const { projectName, value, isGroup } = branchInputRef.current;
5808
+ if (action === "submit") {
5443
5809
  setBranchInput(null);
5444
- if (value.trim()) {
5445
- handleCreateWorktree(projectName, value.trim());
5810
+ if (state.value.trim()) {
5811
+ handleCreateWorktree(projectName, state.value.trim());
5446
5812
  } else if (!isGroup) {
5447
5813
  handleLaunchBaseRepo(projectName);
5448
5814
  } else {
@@ -5450,12 +5816,36 @@ function App({ unsafe, onExit }) {
5450
5816
  }
5451
5817
  return;
5452
5818
  }
5453
- if (key === "\x7F" || key === "\b") {
5454
- setBranchInput((prev) => prev ? { ...prev, value: prev.value.slice(0, -1) } : null);
5819
+ setBranchInput({ projectName, isGroup, ...state });
5820
+ return;
5821
+ }
5822
+ if (filterRef.current?.editing) {
5823
+ if (key === KEYS.UP) {
5824
+ moveSessionCursor(-1);
5825
+ return;
5826
+ }
5827
+ if (key === KEYS.DOWN) {
5828
+ moveSessionCursor(1);
5455
5829
  return;
5456
5830
  }
5457
- if (key.charCodeAt(0) < 32) return;
5458
- setBranchInput((prev) => prev ? { ...prev, value: prev.value + key } : null);
5831
+ const current = filterRef.current.value;
5832
+ const { state, action } = editLine({ value: current, pos: current.length }, key);
5833
+ if (action === "cancel") {
5834
+ setFilter(null);
5835
+ setSessionCursor(0);
5836
+ setMessage("");
5837
+ return;
5838
+ }
5839
+ if (action === "submit" || key === TAB_KEY) {
5840
+ const value = current.trim();
5841
+ setFilter(value ? { value, editing: false } : null);
5842
+ setMessage(value ? `Filtering: ${value} (esc clears)` : "");
5843
+ return;
5844
+ }
5845
+ if (state.value !== current) {
5846
+ setFilter({ value: state.value, editing: true });
5847
+ setSessionCursor(0);
5848
+ }
5459
5849
  return;
5460
5850
  }
5461
5851
  if (key === TAB_KEY) {
@@ -5488,11 +5878,24 @@ function App({ unsafe, onExit }) {
5488
5878
  setMessage("");
5489
5879
  return;
5490
5880
  }
5491
- termScrollBack.current = 0;
5881
+ if (key === KEYS.PAGE_UP) {
5882
+ scrollTerminal(Math.max(1, layout.contentHeight - 3));
5883
+ return;
5884
+ }
5885
+ if (key === KEYS.PAGE_DOWN) {
5886
+ scrollTerminal(-Math.max(1, layout.contentHeight - 3));
5887
+ return;
5888
+ }
5889
+ if (termScrollBack.current > 0) setScrollBack(0);
5492
5890
  ptySessions.current.get(activeKeyRef.current)?.write(key);
5493
5891
  return;
5494
5892
  }
5495
5893
  setMessage("");
5894
+ if (pendingRemoveRef.current && key !== "d") setPendingRemoveKey(null);
5895
+ if (key === "?") {
5896
+ setShowHelp(true);
5897
+ return;
5898
+ }
5496
5899
  if (key === "G") {
5497
5900
  if (syncing) return;
5498
5901
  setSyncing(true);
@@ -5507,8 +5910,7 @@ function App({ unsafe, onExit }) {
5507
5910
  );
5508
5911
  }
5509
5912
  refreshSessions();
5510
- refreshPrs();
5511
- refreshJira();
5913
+ await Promise.all([refreshPrs(), refreshJira()]);
5512
5914
  refreshTasks();
5513
5915
  computeConflictsAndMerged(sessionsRef.current);
5514
5916
  setSyncing(false);
@@ -5516,6 +5918,33 @@ function App({ unsafe, onExit }) {
5516
5918
  })();
5517
5919
  return;
5518
5920
  }
5921
+ if (taskInputRef.current === null) {
5922
+ const pageJump = (dir, full) => {
5923
+ const heightFor = focusRef.current === 2 /* PRS */ ? layout.prPaneHeight : focusRef.current === 3 /* JIRA */ ? layout.jiraPaneHeight : focusRef.current === 1 /* TASKS */ ? layout.taskPaneHeight : layout.sessionPaneHeight;
5924
+ const page = Math.max(1, full ? heightFor - 2 : Math.floor((heightFor - 2) / 2));
5925
+ const delta = page * dir;
5926
+ if (focusRef.current === 2 /* PRS */) movePrCursor(delta);
5927
+ else if (focusRef.current === 3 /* JIRA */) moveJiraCursor(delta);
5928
+ else if (focusRef.current === 1 /* TASKS */) moveTaskCursor(delta);
5929
+ else moveSessionCursor(delta);
5930
+ };
5931
+ if (key === KEYS.PAGE_UP) {
5932
+ pageJump(-1, true);
5933
+ return;
5934
+ }
5935
+ if (key === KEYS.PAGE_DOWN) {
5936
+ pageJump(1, true);
5937
+ return;
5938
+ }
5939
+ if (key === KEYS.CTRL_U) {
5940
+ pageJump(-1, false);
5941
+ return;
5942
+ }
5943
+ if (key === KEYS.CTRL_D) {
5944
+ pageJump(1, false);
5945
+ return;
5946
+ }
5947
+ }
5519
5948
  if (topPaneModeRef.current === 1 /* PROJECTS */) {
5520
5949
  if (key === "\x1B" || key === "" || key === "q") {
5521
5950
  setTopPaneMode(0 /* SESSIONS */);
@@ -5560,7 +5989,7 @@ function App({ unsafe, onExit }) {
5560
5989
  handleCreateWorktree(row.name, branch);
5561
5990
  } else {
5562
5991
  setTopPaneMode(2 /* BRANCH_INPUT */);
5563
- setBranchInput({ projectName: row.name, value: "", isGroup: row.isGroup });
5992
+ setBranchInput({ projectName: row.name, value: "", pos: 0, isGroup: row.isGroup });
5564
5993
  setMessage(row.isGroup ? "Type branch name, Enter to create, Esc to cancel" : "Type branch name (empty for base repo), Enter to create, Esc to cancel");
5565
5994
  }
5566
5995
  }
@@ -5570,14 +5999,15 @@ function App({ unsafe, onExit }) {
5570
5999
  }
5571
6000
  if (focusRef.current === 1 /* TASKS */) {
5572
6001
  if (taskInputRef.current !== null) {
5573
- if (key === "\x1B" || key === "") {
6002
+ const { state, action } = editLine(taskInputRef.current, key);
6003
+ if (action === "cancel") {
5574
6004
  setTaskInput(null);
5575
6005
  setTaskEditId(null);
5576
6006
  setMessage("");
5577
6007
  return;
5578
6008
  }
5579
- if (key === "\r") {
5580
- const text = taskInputRef.current.trim();
6009
+ if (action === "submit") {
6010
+ const text = taskInputRef.current.value.trim();
5581
6011
  const editId = taskEditIdRef.current;
5582
6012
  setTaskInput(null);
5583
6013
  setTaskEditId(null);
@@ -5592,12 +6022,7 @@ function App({ unsafe, onExit }) {
5592
6022
  }
5593
6023
  return;
5594
6024
  }
5595
- if (key === "\x7F" || key === "\b") {
5596
- setTaskInput((prev) => prev !== null ? prev.slice(0, -1) : null);
5597
- return;
5598
- }
5599
- if (key.charCodeAt(0) < 32) return;
5600
- setTaskInput((prev) => prev !== null ? prev + key : null);
6025
+ setTaskInput(state);
5601
6026
  return;
5602
6027
  }
5603
6028
  if (key === "\x1B[A" || key === "k") {
@@ -5617,7 +6042,7 @@ function App({ unsafe, onExit }) {
5617
6042
  return;
5618
6043
  }
5619
6044
  if (key === "a") {
5620
- setTaskInput("");
6045
+ setTaskInput({ value: "", pos: 0 });
5621
6046
  setMessage("Type task, Enter to add, Esc to cancel");
5622
6047
  return;
5623
6048
  }
@@ -5625,7 +6050,7 @@ function App({ unsafe, onExit }) {
5625
6050
  const row = cursorToRow(taskRowsRef.current, taskCursorRef.current);
5626
6051
  if (row?.type === "task") {
5627
6052
  setTaskEditId(row.task.id);
5628
- setTaskInput(row.task.text);
6053
+ setTaskInput({ value: row.task.text, pos: row.task.text.length });
5629
6054
  setMessage("Edit task, Enter to save, Esc to cancel");
5630
6055
  }
5631
6056
  return;
@@ -5781,6 +6206,16 @@ function App({ unsafe, onExit }) {
5781
6206
  onExit();
5782
6207
  return;
5783
6208
  }
6209
+ if (key === KEYS.ESC && filterRef.current) {
6210
+ setFilter(null);
6211
+ setSessionCursor(0);
6212
+ return;
6213
+ }
6214
+ if (key === "/" && topPaneModeRef.current === 0 /* SESSIONS */) {
6215
+ setFilter({ value: filterRef.current?.value ?? "", editing: true });
6216
+ setMessage("Type to filter, Enter to keep, Esc to clear");
6217
+ return;
6218
+ }
5784
6219
  if (key === "\x1B[A" || key === "k") {
5785
6220
  moveSessionCursor(-1);
5786
6221
  return;
@@ -5801,6 +6236,12 @@ function App({ unsafe, onExit }) {
5801
6236
  if (row?.type !== "session") return;
5802
6237
  const s = row.session;
5803
6238
  const k = sessionKey2(s);
6239
+ if (pendingRemoveRef.current !== k) {
6240
+ setPendingRemoveKey(k);
6241
+ setMessage(`Remove ${s.target}/${s.branch}? Press d again to confirm, any other key cancels`);
6242
+ return;
6243
+ }
6244
+ setPendingRemoveKey(null);
5804
6245
  const pty2 = ptySessions.current.get(k);
5805
6246
  if (pty2) {
5806
6247
  notifiedSessionsRef.current.delete(ptyDedupKey(pty2));
@@ -5857,14 +6298,22 @@ function App({ unsafe, onExit }) {
5857
6298
  setMessage("Session path no longer exists");
5858
6299
  return;
5859
6300
  }
5860
- setMessage(`Rebasing ${s.branch}...`);
5861
- const err = rebaseOntoMain(s.branch, existing);
5862
- if (err) {
5863
- setMessage(`Rebase failed: ${err}`);
5864
- } else {
5865
- setMessage(`Rebased ${s.branch} onto main`);
5866
- computeConflictsAndMerged(sessionsRef.current);
6301
+ if (rebasingRef.current) {
6302
+ setMessage("A rebase is already running");
6303
+ return;
5867
6304
  }
6305
+ rebasingRef.current = true;
6306
+ setMessage(`Rebasing ${s.branch}...`);
6307
+ void rebaseOntoMainAsync(s.branch, existing).then((err) => {
6308
+ if (err) {
6309
+ setMessage(`Rebase failed: ${err}`);
6310
+ } else {
6311
+ setMessage(`Rebased ${s.branch} onto main`);
6312
+ computeConflictsAndMerged(sessionsRef.current);
6313
+ }
6314
+ }).catch((e) => setMessage(`Rebase failed: ${e.message}`)).finally(() => {
6315
+ rebasingRef.current = false;
6316
+ });
5868
6317
  return;
5869
6318
  }
5870
6319
  if (key === "g") {
@@ -5881,7 +6330,7 @@ function App({ unsafe, onExit }) {
5881
6330
  );
5882
6331
  }
5883
6332
  refreshSessions();
5884
- refreshPrs();
6333
+ await refreshPrs();
5885
6334
  computeConflictsAndMerged(sessionsRef.current);
5886
6335
  setSyncing(false);
5887
6336
  setMessage("Sessions synced");
@@ -5890,18 +6339,23 @@ function App({ unsafe, onExit }) {
5890
6339
  }
5891
6340
  if (key === "r") {
5892
6341
  refreshSessions();
5893
- refreshPrs();
5894
- refreshJira();
6342
+ void refreshPrs();
6343
+ void refreshJira();
5895
6344
  refreshTasks();
5896
6345
  if (!ghAvailable) setMessage("Refreshed");
5897
6346
  return;
5898
6347
  }
5899
6348
  };
6349
+ const handler = (data) => {
6350
+ for (const key of splitInputChunks(data.toString("utf8"))) {
6351
+ handleKey(key);
6352
+ }
6353
+ };
5900
6354
  process.stdin.on("data", handler);
5901
6355
  return () => {
5902
6356
  process.stdin.removeListener("data", handler);
5903
6357
  };
5904
- }, [onExit, activateSession, refreshSessions, refreshPrs, refreshJira, refreshTasks, moveSessionCursor, movePrCursor, moveJiraCursor, moveTaskCursor, syncSessionCursorToActive, handleCreateWorktree, savedSessionCursor, config, computeConflictsAndMerged, syncing, ghAvailable, prMap]);
6358
+ }, [onExit, activateSession, refreshSessions, refreshPrs, refreshJira, refreshTasks, moveSessionCursor, movePrCursor, moveJiraCursor, moveTaskCursor, syncSessionCursorToActive, handleCreateWorktree, handleLaunchBaseRepo, savedSessionCursor, config, computeConflictsAndMerged, syncing, ghAvailable, prMap, scrollTerminal, setScrollBack]);
5905
6359
  useEffect(() => {
5906
6360
  const handler = () => {
5907
6361
  const newCols = process.stdout.columns || 80;
@@ -5913,6 +6367,10 @@ function App({ unsafe, onExit }) {
5913
6367
  const newTermInner = newCols - Math.min(60, Math.floor(newCols * 0.525)) - 2;
5914
6368
  const newContentHeight = newRows - 3;
5915
6369
  pty2.resize(newTermInner, newContentHeight);
6370
+ try {
6371
+ setTermLines(renderBufferLines(pty2.terminal.buffer.active, newTermInner, newContentHeight, termScrollBack.current));
6372
+ } catch {
6373
+ }
5916
6374
  }
5917
6375
  }
5918
6376
  };
@@ -5932,12 +6390,11 @@ function App({ unsafe, onExit }) {
5932
6390
  }, 5 * 60 * 1e3);
5933
6391
  return () => clearInterval(interval);
5934
6392
  }, []);
5935
- const statusMap = buildStatusMap();
5936
6393
  const placeholder = !activeKey ? "Select a session and press Enter" : "Press Enter to start session";
5937
- return /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", width: cols, height: rows, children: [
5938
- /* @__PURE__ */ jsxs4(Box4, { flexDirection: "row", height: contentHeight, children: [
5939
- /* @__PURE__ */ jsxs4(Box4, { flexDirection: "column", width: sidebarWidth, children: [
5940
- /* @__PURE__ */ jsx4(
6394
+ return /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", width: cols, height: rows, children: [
6395
+ showHelp2 ? /* @__PURE__ */ jsx5(HelpOverlay, { width: cols, height: contentHeight }) : /* @__PURE__ */ jsxs5(Box5, { flexDirection: "row", height: contentHeight, children: [
6396
+ /* @__PURE__ */ jsxs5(Box5, { flexDirection: "column", width: sidebarWidth, children: [
6397
+ /* @__PURE__ */ jsx5(
5941
6398
  Sidebar,
5942
6399
  {
5943
6400
  sidebarRows: topRows,
@@ -5950,10 +6407,11 @@ function App({ unsafe, onExit }) {
5950
6407
  activeKey,
5951
6408
  width: sidebarWidth,
5952
6409
  height: sessionPaneHeight,
5953
- branchInput
6410
+ branchInput,
6411
+ filter
5954
6412
  }
5955
6413
  ),
5956
- /* @__PURE__ */ jsx4(
6414
+ /* @__PURE__ */ jsx5(
5957
6415
  PrPane,
5958
6416
  {
5959
6417
  prRows,
@@ -5964,7 +6422,7 @@ function App({ unsafe, onExit }) {
5964
6422
  height: prPaneHeight
5965
6423
  }
5966
6424
  ),
5967
- jiraPaneHeight > 0 && /* @__PURE__ */ jsx4(
6425
+ jiraPaneHeight > 0 && /* @__PURE__ */ jsx5(
5968
6426
  JiraPane,
5969
6427
  {
5970
6428
  jiraRows,
@@ -5974,7 +6432,7 @@ function App({ unsafe, onExit }) {
5974
6432
  height: jiraPaneHeight
5975
6433
  }
5976
6434
  ),
5977
- /* @__PURE__ */ jsx4(
6435
+ /* @__PURE__ */ jsx5(
5978
6436
  TaskPane,
5979
6437
  {
5980
6438
  taskRows,
@@ -5986,7 +6444,7 @@ function App({ unsafe, onExit }) {
5986
6444
  }
5987
6445
  )
5988
6446
  ] }),
5989
- /* @__PURE__ */ jsx4(
6447
+ /* @__PURE__ */ jsx5(
5990
6448
  TerminalPane,
5991
6449
  {
5992
6450
  lines: termLines,
@@ -5994,16 +6452,17 @@ function App({ unsafe, onExit }) {
5994
6452
  height: contentHeight,
5995
6453
  focused: focus === 4 /* TERMINAL */,
5996
6454
  placeholder,
5997
- title: "Terminal"
6455
+ title: "Terminal",
6456
+ scrollback: termScroll
5998
6457
  }
5999
6458
  )
6000
6459
  ] }),
6001
- /* @__PURE__ */ jsx4(StatusBar, { message, pane: focus === 4 /* TERMINAL */ ? "terminal" : focus === 2 /* PRS */ ? "prs" : focus === 3 /* JIRA */ ? "jira" : focus === 1 /* TASKS */ ? "tasks" : "sessions", syncing })
6460
+ /* @__PURE__ */ jsx5(StatusBar, { message, pane: focus === 4 /* TERMINAL */ ? "terminal" : focus === 2 /* PRS */ ? "prs" : focus === 3 /* JIRA */ ? "jira" : focus === 1 /* TASKS */ ? "tasks" : "sessions", syncing })
6002
6461
  ] });
6003
6462
  }
6004
6463
 
6005
6464
  // src/tui-ink/index.tsx
6006
- import { jsx as jsx5 } from "react/jsx-runtime";
6465
+ import { jsx as jsx6 } from "react/jsx-runtime";
6007
6466
  function crashLog(label2, err) {
6008
6467
  try {
6009
6468
  const msg = err instanceof Error ? err.stack || err.message : String(err);
@@ -6022,11 +6481,11 @@ async function startDashboard(unsafe) {
6022
6481
  process.stdin.setRawMode(true);
6023
6482
  process.stdin.resume();
6024
6483
  const restore = () => {
6025
- process.stdout.write("\x1B]0;\x07\x1B[?25h\x1B[?1049l");
6484
+ process.stdout.write("\x1B]0;\x07\x1B[?1000l\x1B[?1006l\x1B[?25h\x1B[?1049l");
6026
6485
  };
6027
6486
  try {
6028
6487
  const { waitUntilExit, unmount } = render(
6029
- /* @__PURE__ */ jsx5(App, { unsafe, onExit: () => {
6488
+ /* @__PURE__ */ jsx6(App, { unsafe, onExit: () => {
6030
6489
  unmount();
6031
6490
  restore();
6032
6491
  process.exit(0);
@@ -10626,7 +11085,7 @@ function completeGroupBranches(groupName, repoAliases, current, config, done) {
10626
11085
  }
10627
11086
 
10628
11087
  // src/version.ts
10629
- var VERSION = true ? "1.7.0" : "dev";
11088
+ var VERSION = true ? "1.8.0" : "dev";
10630
11089
 
10631
11090
  // src/cli.ts
10632
11091
  function showHelp() {