You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "mikemikimike (via GitHub)" <gi...@apache.org> on 2026/08/23 08:57:17 UTC

[PR] fix(cli): discover resumable sessions from /resume [maka]

mikemikimike opened a new pull request, #3582:
URL: https://github.com/apache/maka/pull/3582

   ## Summary
   
   Fixes #3508.
   
   When the TUI has no attached session, `/resume` now opens a picker limited to sessions whose resume availability is ready, instead of attempting an attached-session-only resume. Startup also performs a best-effort availability check and surfaces a passive hint for the current or cwd session when safe-boundary resume is available.
   
   ## Implementation
   
   - Reused the existing session resume-availability checks.
   - Added an availability-filtered picker mode used only by `/resume` without an attached session.
   - Kept existing `/session` rows, attached-session resume behavior, sandbox boundaries, and Desktop policy unchanged.
   
   ## Verification
   
   - `node --test --test-name-pattern="opens a picker containing only resumable" packages/cli/dist/__tests__/pi-tui-runner.test.js` — passed.
   - `npm --workspace maka-agent run build` — passed.
   - `npm --workspace maka-agent run typecheck` — passed.
   - `npm run lint -- packages/cli/src/pi-tui-runner.ts packages/cli/src/__tests__/pi-tui-runner.test.ts` — passed.
   - `npm run format:check -- packages/cli/src/pi-tui-runner.ts packages/cli/src/__tests__/pi-tui-runner.test.ts` — passed.
   - `git diff --check` — passed.
   - `npm --workspace maka-agent test` — 378 passed, 12 failed, 1 skipped; failures are existing environment/Windows-dependent tests outside this diff.
   
   Not run: full repository build and Docker-based checks; this is a pure CLI/TUI unit behavior change with no external service dependency.
   
   ## AI use
   
   - [ ] No generative tool made a substantive contribution
   - [x] Generative tooling made a substantive contribution
   
   Tool(s) and scope: Codex assisted with remote issue selection, implementation, regression testing, and PR text. The commit includes a `Generated-by: Codex` trailer.
   
   ## Checklist
   
   - [x] Tests cover the change and fail without it
   - [x] Lint, format, typecheck and the affected suite pass locally
   
   Does this PR entail a change in behavior?
   
   - [x] Yes — `/resume` now discovers resumable sessions when no session is attached.
   - [ ] No


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r3839511828


##########
packages/cli/src/runtime-host-session-driver.ts:
##########
@@ -254,7 +254,14 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
       .map(({ session }) => session);
   }
 
-  getSessionResumeAvailability(session: SessionSummary): Promise<SessionResumeAvailability> {
+  async getSessionResumeAvailability(session: SessionSummary): Promise<SessionResumeAvailability> {
+    if (this.#executionLocation.kind === 'host') {

Review Comment:
   **[P1] `/session` now refuses to navigate to sessions that are perfectly attachable.**
   
   On the host path this used to return `{ available: true }` unconditionally (see the `inspectRuntimeHostSessionResumeAvailability` change further down, where the old `location.kind === 'host' ? Promise.resolve({ available: true })` branch is preserved but no longer reached from here). It now returns the result of `turn.resume.query`, which answers a narrower question: *does this session have an interrupted run with a safe boundary to resume from?*
   
   But `showSessionList` has only one availability map, and both `/session` and `/resume` read it. In `pi-tui-runner.ts` the selection handler does `if (availability.get(item.value)?.available === false) return;` — so under `/session`, a completed session, a session with no resume candidate, and a currently-running session are all now unselectable. Before this change every one of them could be attached.
   
   That these are two different predicates is already visible in the code: `switchSession` validates only cwd attachability, not resume readiness. Please split them — keep `getSessionResumeAvailability` for `/resume` and give `/session` its own attachability query — rather than overloading one field.
   
   **Second reachable path, same root cause:** for an archived session `turn.resume.query` rejects with `session_archived`. The availability map is built with a bare `Promise.all(sessions.map(...))` (`pi-tui-runner.ts:2170-2179`) with no per-session error containment, so one archived row takes down the whole picker — `/session` simply never opens. Worth noting that the sibling foreign-session scan in that same `Promise.all` *is* guarded, with `.then(summaries => ..., error => ({ error }))` and an explicit comment about surfacing rather than swallowing the error. The Maka-session branch deserves the same treatment: per-session failures should degrade that row, not the list.



##########
packages/cli/src/pi-tui-runner.ts:
##########
@@ -2275,6 +2285,30 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
     renderScope();
   };
 
+  const announceResumeAvailability = async (): Promise<void> => {

Review Comment:
   **[P1] Startup fires a second, unconditional `listSessions()` that races the user's own.**
   
   `announceResumeAvailability` is scheduled with `setTimeout(..., 0)` at the end of the boot path and calls `input.driver.listSessions()` for every launch, whether or not there is anything to announce. If the user opens `/session` immediately, that call is in flight concurrently with `showSessionList`'s own `listSessions()`.
   
   This is not just theoretical: the existing CLI test `blocks prompts while the session list is loading` fails reproducibly at this head (full `pi-tui` suite: 131 pass / 1 fail), because `DeferredListSessionsDriver` has a single shared resolver and the two enumerations contend for it. A test that was green before this PR and is red after it is the finding, independent of whether the shared-resolver fake is an ideal model of the real driver.
   
   Two things to fix: avoid the duplicate enumeration (reuse the session list the boot path already has, or gate the announcement on cheaper state), and add a regression test that pins the concurrent-open behavior so this does not silently come back.
   
   The `catch {}` with its "advisory and must never prevent the TUI from starting" comment is the right instinct for this feature — the problem is the I/O it performs on the way there, not its failure handling.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r3890247213


##########
packages/cli/src/pi-tui-runner.ts:
##########
@@ -2457,18 +2471,31 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
     const [availabilityEntries, foreignScan] = await Promise.all([
       Promise.all(

Review Comment:
   Thanks for bounding the foreign import side of this picker. The Maka-session side still appears unbounded on the normal `/resume` path: `listSessions()` materializes the complete paged Host catalog, then this `Promise.all` sends a `turn.resume.query` for every historical Session before the UI applies the current-cwd filter below. The 32-row protocol bound is only per page, so catalog size directly becomes memory, RPC fan-out, and open/startup latency (the startup hint uses the same discovery). Could the Host/catalog query apply cwd/age/cursor/limit at the source boundary, or at least filter first and bound query concurrency, with a large-history regression? I would rate this P2 as a local scale/performance issue; please push back if the catalog has a documented total-size bound I missed.



##########
packages/cli/src/pi-tui-runner.ts:
##########
@@ -2542,9 +2574,18 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
           void importForeignSession(foreign);
           return;
         }
-        if (availability.get(item.value)?.available === false) return;
+        const itemAvailability = availability.get(item.value);
+        if (
+          itemAvailability?.available === false &&
+          itemAvailability.reason === 'Missing working directory'
+        ) {
+          return;
+        }
         closeOverlay();
-        void goToSession(item.value);
+        void (async () => {
+          await goToSession(item.value);
+          if (options.onlyResumable) await runControl(resumeSession);

Review Comment:
   Thanks for fixing the no-attached `/resume` flow. In a category ② stale-selection path, could this only call `resumeSession` after a successful switch? `goToSession()` wraps `switchSession()` in `runControl()`, and `runControl()` reports errors but resolves normally. If the selected Session is archived/deleted or becomes ineligible while the picker is open, the failed switch therefore falls through here and reopens the same `/resume` picker; an ineligible-but-still-listed row can repeat that loop. I suggest returning an explicit success result (or combining switch + resume into one control action) and covering a stale selection. This looks P2 because Esc recovers, but please push back if another guard makes the selected row stable.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r4118275028


##########
packages/cli/src/pi-tui-runner.ts:
##########
@@ -3354,46 +3379,109 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
     showSelectPicker(
       copy.externalSourceTitle,
       copy.externalSourceTitle,
-      adapterIds.map((adapterId) => ({
-        value: adapterId,
-        label: externalSourceLabel(adapterId),
-      })),
+      adapterIds.map((adapterId) => ({ value: adapterId, label: externalSourceLabel(adapterId) })),
       (item) => void showExternalSessionPage(item.value, initialScope),
       { minPrimaryColumnWidth: 20, maxPrimaryColumnWidth: 40 },
     );
   };
 
-  const showSessionList = async () => {
-    const sessions = await input.driver.listSessions();
-    const sessionTree = projectRevisionLinkedSessionTree(
+  const showSessionCatalogIncompleteNotice = (): void => {
+    const text = pickerCopy.resumeCatalogIncompleteNotice;
+    if (state.entries.some((entry) => entry.kind === 'notice' && entry.text === text)) return;

Review Comment:
   P2: this de-duplicates against the whole transcript. The startup probe (`announceResumeAvailability`) also calls `readSessionCatalog`, so a large catalog shows this notice at launch with no list on screen. A later, genuinely truncated `/resume` then shows nothing. Consider keeping the probe from emitting it, and scoping the de-duplication to the current picker.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r4183345594


##########
packages/cli/src/__tests__/pi-tui-runner.test.ts:
##########
@@ -5988,7 +5992,575 @@ Slug openai-work<cursor>
     ]);
   });
 
-  test('opens the latest imported task without importing another copy', async () => {
+  test('/resume opens a picker containing only resumable sessions when none is attached', async () => {
+    const terminal = new FakeTerminal();
+    const resumable = fakeSessionSummary('resumable', '/repo');
+    const unavailable = fakeSessionSummary('unavailable', '/repo');
+    const driver = new BoundedResumeAvailabilityDriver([resumable, unavailable]);
+    driver.unavailableSessionIds.add(unavailable.id);
+    (driver as unknown as { sessionId: string | null }).sessionId = null;
+    const run = runMakaPiTui({
+      title: 'Maka',
+      driver,
+      cwd: '/repo',
+      model: 'm',
+      connectionSlug: 'c',
+      permissionMode: 'bypass',
+      terminal,
+    });
+
+    terminal.input('/resume');
+    terminal.input('\r');
+    await waitFor(() => plainTerminalOutput(terminal.output()).includes('Resume Session Current'));
+    const output = plainTerminalOutput(terminal.output());
+    assert.match(output, /resumabl/);
+    assert.doesNotMatch(output, /unavailable/);
+
+    terminal.input('\r');
+    await waitFor(() => driver.resumeCalls === 1);
+    terminal.input('/exit');
+    terminal.input('\r');
+    await run;
+  });
+
+  test('/resume reports when current-workspace discovery is incomplete', async () => {
+    const terminal = new FakeTerminal();
+    const partial = fakeSessionSummary('partial-resume', '/repo', 'Partial workspace session');
+    const driver = new BoundedResumeAvailabilityDriver([partial]);
+    driver.listSessions = async () => {
+      throw new MakaSessionCatalogIncompleteError(8, [partial]);
+    };
+    (driver as unknown as { sessionId: string | null }).sessionId = null;
+    const run = runMakaPiTui({
+      title: 'Maka',
+      driver,
+      cwd: '/repo',
+      model: 'm',
+      connectionSlug: 'c',
+      permissionMode: 'bypass',
+      terminal,
+    });
+
+    terminal.input('/resume');
+    terminal.input('\r');
+    const visibleOutput = () => plainTerminalOutput(terminal.output()).replace(/\s+/g, ' ');
+    await waitFor(
+      () =>
+        visibleOutput().includes(getTuiPickerCopy('en').resumeCatalogIncompleteNotice) &&
+        visibleOutput().includes('Partial workspace session'),
+    );
+    assert.doesNotMatch(visibleOutput(), /No matching sessions/);
+
+    terminal.input('\r');
+    await waitFor(() => driver.resumeCalls === 1);
+    terminal.input('/exit');
+    terminal.input('\r');
+    await run;
+  });
+
+  test('startup resume hint uses sessions found before catalog discovery is incomplete', async () => {
+    const terminal = new FakeTerminal();
+    const partial = fakeSessionSummary(
+      'partial-startup-resume',
+      '/repo',
+      'Partial startup session',
+    );
+    const driver = new BoundedResumeAvailabilityDriver([partial]);
+    driver.setAttachedSessionId(null);
+    let catalogReads = 0;
+    driver.listSessions = async () => {
+      catalogReads += 1;
+      throw new MakaSessionCatalogIncompleteError(8, [partial]);
+    };
+    const run = runMakaPiTui({
+      title: 'Maka',
+      driver,
+      cwd: '/repo',
+      model: 'm',
+      connectionSlug: 'c',
+      permissionMode: 'bypass',
+      terminal,
+    });
+
+    const visibleOutput = () => plainTerminalOutput(terminal.output()).replace(/\s+/g, ' ');
+    await waitFor(() => catalogReads > 0);
+    await waitFor(
+      () =>
+        driver.availabilityCalls > 0 &&
+        driver.activeCalls === 0 &&
+        visibleOutput().includes(getTuiPickerCopy('en').resumeAvailabilityNotice),
+    );
+    assert.doesNotMatch(visibleOutput(), /This session/);
+    assert.equal(
+      visibleOutput().includes(getTuiPickerCopy('en').resumeCatalogIncompleteNotice),
+      false,
+    );
+
+    terminal.input('/resume');
+    terminal.input('\r');
+    await waitFor(
+      () =>
+        visibleOutput().includes(getTuiPickerCopy('en').resumeCatalogIncompleteNotice) &&
+        visibleOutput().includes('Partial startup session'),
+    );
+    exitMaka(terminal);
+    await run;
+  });
+
+  test('/resume finds current-workspace sessions beyond the global catalog prefix', async () => {
+    const terminal = new FakeTerminal();
+    const target = fakeSessionSummary('current-after-prefix', '/repo', 'Current workspace');
+    const sessions = [
+      ...Array.from({ length: 200 }, (_, index) =>
+        fakeSessionSummary(`other-${index}`, `/other/${index}`),
+      ),
+      target,
+    ];
+    const driver = new BoundedResumeAvailabilityDriver(sessions);
+    driver.setAttachedSessionId(null);
+    const run = runMakaPiTui({
+      title: 'Maka',
+      driver,
+      cwd: '/repo',
+      model: 'm',
+      connectionSlug: 'c',
+      permissionMode: 'bypass',
+      terminal,
+    });
+
+    await waitForTuiPaint(terminal);
+    terminal.input('/resume');
+    terminal.input('\r');
+    await waitFor(() => plainTerminalOutput(terminal.output()).includes('Current workspace'));
+    assert.deepEqual(driver.listRequests[0], { limit: 256, cwd: '/repo' });
+    assert.match(plainTerminalOutput(terminal.output()), /Current workspace/);
+    assert.doesNotMatch(plainTerminalOutput(terminal.output()), /No matching sessions/);
+
+    terminal.input('\r');
+    await waitFor(() => driver.sessionIds.includes(target.id));
+    exitMaka(terminal);
+    await run;
+  });
+
+  test('/resume checks past 200 unavailable sessions for a later resumable candidate', async () => {
+    const terminal = new FakeTerminal();
+    const unavailable = Array.from({ length: 200 }, (_, index) =>
+      fakeSessionSummary(`unavailable-${index}`, '/repo'),
+    );
+    const target = fakeSessionSummary('resumable-201', '/repo', 'Later interrupted session');
+    const driver = new BoundedResumeAvailabilityDriver([...unavailable, target]);
+    driver.availabilityDelayMs = 0;
+    for (const session of unavailable) driver.unavailableSessionIds.add(session.id);
+    driver.setAttachedSessionId(null);
+    const run = runMakaPiTui({
+      title: 'Maka',
+      driver,
+      cwd: '/repo',
+      model: 'm',
+      connectionSlug: 'c',
+      permissionMode: 'bypass',
+      terminal,
+    });
+
+    await waitForTuiPaint(terminal);
+    terminal.input('/resume');
+    terminal.input('\r');
+    await waitFor(() =>
+      plainTerminalOutput(terminal.output()).includes('Later interrupted session'),
+    );
+    assert.equal(driver.listLimits[0], 256);
+    assert.ok(driver.availabilitySessionIds.includes(target.id));
+    assert.doesNotMatch(plainTerminalOutput(terminal.output()), /No matching sessions/);
+
+    terminal.input('\r');
+    await waitFor(() => driver.sessionIds.includes(target.id));
+    exitMaka(terminal);
+    await run;
+  });
+
+  test('startup resume hint does not use a different session when the attached session is absent', async () => {
+    const terminal = new FakeTerminal();
+    const other = fakeSessionSummary('other-current-session', '/repo');
+    const driver = new BoundedResumeAvailabilityDriver([other]);
+    const attachedSessionId = 'missing-attached-session';
+    driver.setAttachedSessionId(attachedSessionId);
+    const run = runMakaPiTui({
+      title: 'Maka',
+      driver,
+      cwd: '/repo',
+      model: 'm',
+      connectionSlug: 'c',
+      permissionMode: 'bypass',
+      terminal,
+    });
+
+    await waitFor(() => driver.completedSummaryLookups.includes(attachedSessionId));
+    await waitFor(() => driver.completedListRequests.length > 0);
+    assert.deepEqual(driver.availabilitySessionIds, []);
+
+    exitMaka(terminal);
+    await run;
+  });
+
+  test('startup resume hint looks up the attached session beyond the current workspace limit', async () => {
+    const terminal = new FakeTerminal();
+    const attached = fakeSessionSummary('attached-after-prefix', '/repo');
+    const sessions = [
+      ...Array.from({ length: 200 }, (_, index) =>
+        fakeSessionSummary(`newer-current-${index}`, '/repo'),
+      ),
+      attached,
+    ];
+    const driver = new BoundedResumeAvailabilityDriver(sessions);
+    driver.setAttachedSessionId(attached.id);
+    const run = runMakaPiTui({
+      title: 'Maka',
+      driver,
+      cwd: '/repo',
+      model: 'm',
+      connectionSlug: 'c',
+      permissionMode: 'bypass',
+      terminal,
+    });
+
+    await waitFor(() => driver.availabilitySessionIds.includes(attached.id));
+    assert.deepEqual(driver.availabilitySessionIds, [attached.id]);
+
+    exitMaka(terminal);
+    await run;
+  });
+
+  test('/resume fails closed when candidate discovery is unavailable', async () => {
+    const terminal = new FakeTerminal();
+    const session = fakeSessionSummary('attachable-only', '/repo', 'Attachable only');
+    const driver = new SlashCommandDriver([session]);
+    (driver as unknown as { sessionId: string | null }).sessionId = null;
+    const run = runMakaPiTui({
+      title: 'Maka',
+      driver,
+      cwd: '/repo',
+      model: 'm',
+      connectionSlug: 'c',
+      permissionMode: 'bypass',
+      terminal,
+    });
+
+    terminal.input('/resume');
+    terminal.input('\r');
+    await waitFor(() => plainTerminalOutput(terminal.output()).includes('Resume Session Current'));
+    assert.doesNotMatch(plainTerminalOutput(terminal.output()), /Attachable only/);
+
+    terminal.input('\x1b');
+    exitMaka(terminal);
+    await run;
+  });
+
+  test('/resume does not resume after a stale selection fails to switch', async () => {
+    const terminal = new FakeTerminal();
+    const session = fakeSessionSummary('stale', '/repo');
+    const driver = new RejectingSwitchSessionDriver([session]);
+    (driver as unknown as { sessionId: string | null }).sessionId = null;
+    const run = runMakaPiTui({
+      title: 'Maka',
+      driver,
+      cwd: '/repo',
+      model: 'm',
+      connectionSlug: 'c',
+      permissionMode: 'bypass',
+      terminal,
+    });
+
+    terminal.input('/resume');
+    terminal.input('\r');
+    await waitFor(() => plainTerminalOutput(terminal.output()).includes('Resume Session Current'));
+    terminal.input('\r');
+    await waitFor(() => driver.switchCalls === 1);
+    await delay(0);
+    assert.equal(driver.resumeCalls, 0);
+
+    exitMaka(terminal);
+    await run;
+  });
+
+  test('/resume bounds concurrent resumability checks for large session catalogs', async () => {
+    const terminal = new FakeTerminal();
+    const sessions = Array.from({ length: 24 }, (_, index) =>
+      fakeSessionSummary(`session-${index}`, '/repo'),
+    );
+    const driver = new BoundedResumeAvailabilityDriver(sessions);
+    (driver as unknown as { sessionId: string | null }).sessionId = null;
+    const run = runMakaPiTui({
+      title: 'Maka',
+      driver,
+      cwd: '/repo',
+      model: 'm',
+      connectionSlug: 'c',
+      permissionMode: 'bypass',
+      terminal,
+    });
+
+    terminal.input('/resume');
+    terminal.input('\r');
+    await waitFor(() => plainTerminalOutput(terminal.output()).includes('Resume Session Current'));
+    assert.equal(driver.listLimits[0], 256);
+    assert.ok(driver.availabilityCalls >= sessions.length);
+    assert.ok(driver.maxActiveCalls <= 8);
+
+    terminal.input('\x1b');
+    exitMaka(terminal);
+    await run;
+  });
+
+  test('/resume bounds total candidate checks after switching to All', async () => {
+    const terminal = new FakeTerminal();
+    const sessions = [
+      ...Array.from({ length: 100 }, (_, index) => fakeSessionSummary(`current-${index}`, '/repo')),
+      ...Array.from({ length: 124 }, (_, index) =>
+        fakeSessionSummary(`other-${index}`, `/other/${index}`),
+      ),
+    ];
+    const driver = new BoundedResumeAvailabilityDriver(sessions);
+    (driver as unknown as { sessionId: string | null }).sessionId = null;
+    const run = runMakaPiTui({
+      title: 'Maka',
+      driver,
+      cwd: '/repo',
+      model: 'm',
+      connectionSlug: 'c',
+      permissionMode: 'bypass',
+      terminal,
+    });
+
+    terminal.input('/resume');
+    terminal.input('\r');
+    await waitFor(() => plainTerminalOutput(terminal.output()).includes('Resume Session Current'));
+    assert.equal(driver.availabilityCalls, 101);
+
+    terminal.input('\t');
+    await waitFor(() => driver.availabilityCalls === 225);
+    assert.equal(driver.availabilityCalls, 225);
+
+    terminal.input('\x1b');
+    exitMaka(terminal);
+    await run;
+  });
+
+  test('/resume checks only the current cwd before rendering the default scope', async () => {
+    const terminal = new FakeTerminal();
+    const sessions = [
+      fakeSessionSummary('current-session', '/repo'),
+      fakeSessionSummary('unavailable-current-session', '/repo'),
+      ...Array.from({ length: 16 }, (_, index) =>
+        fakeSessionSummary(`other-session-${index}`, `/other/${index}`),
+      ),
+    ];
+    const driver = new BoundedResumeAvailabilityDriver(sessions);
+    driver.unavailableSessionIds.add('unavailable-current-session');
+    (driver as unknown as { sessionId: string | null }).sessionId = null;
+    const run = runMakaPiTui({
+      title: 'Maka',
+      driver,
+      cwd: '/repo',
+      model: 'm',
+      connectionSlug: 'c',
+      permissionMode: 'bypass',
+      terminal,
+      sessionListScope: 'all',
+    });
+
+    terminal.input('/resume');
+    terminal.input('\r');
+    await waitFor(() => plainTerminalOutput(terminal.output()).includes('Resume Session Current'));
+    assert.ok(driver.availabilitySessionIds.length > 0);
+    assert.ok(
+      driver.availabilitySessionIds.every(
+        (sessionId) =>
+          sessionId === 'current-session' || sessionId === 'unavailable-current-session',
+      ),
+    );
+    assert.doesNotMatch(plainTerminalOutput(terminal.output()), /other-session/);
+    assert.doesNotMatch(plainTerminalOutput(terminal.output()), /unavailable-current-session/);
+
+    terminal.input('\x1b');
+    exitMaka(terminal);
+    await run;
+  });
+
+  test('/resume excludes foreign sessions when none is attached', async () => {
+    const terminal = new FakeTerminal();
+    const driver = new SlashCommandDriver([]);
+    (driver as unknown as { sessionId: string | null }).sessionId = null;
+    const foreignSession = {
+      source: 'claude-code' as const,
+      id: 'foreign-resume',
+      title: 'Foreign interrupted work',
+      cwd: '/repo',
+      updatedAtMs: Date.now(),
+      transcriptPath: '/home/u/.claude/projects/-repo/foreign-resume.jsonl',
+    };
+    let listSessionsCalls = 0;
+    let listSourcesCalls = 0;
+    let readDigestCalls = 0;
+    const externalSessions = {
+      listScopes: () => ['all'] as const,
+      listSources: async () => {
+        listSourcesCalls += 1;
+        return ['claude-code'] as const;
+      },
+      listSessions: async () => {
+        listSessionsCalls += 1;
+        return {
+          sessions: [
+            {
+              id: foreignSession.id,
+              name: foreignSession.title,
+              hostCwd: foreignSession.cwd,
+              importState: {
+                importedCount: 0,
+                importedSessionIds: [],
+                isImporting: false,
+              },
+            },
+          ],
+          nextCursor: null,
+        };
+      },
+      importSession: async () => {
+        readDigestCalls += 1;
+        throw new Error('foreign import must not run from /resume');
+      },
+    };
+    const run = runMakaPiTui({
+      title: 'Maka',
+      driver,
+      cwd: '/repo',
+      model: 'm',
+      connectionSlug: 'c',
+      permissionMode: 'bypass',
+      terminal,
+      externalSessions,
+    });
+
+    terminal.input('/resume');
+    terminal.input('\r');
+    await waitFor(() => plainTerminalOutput(terminal.output()).includes('Resume Session Current'));
+    const output = plainTerminalOutput(terminal.output());
+    assert.doesNotMatch(output, /Foreign interrupted work/);
+    assert.equal(listSourcesCalls, 0);
+    assert.equal(listSessionsCalls, 0);
+
+    terminal.input('\x1b');
+    terminal.input('/exit');
+    terminal.input('\r');
+    await run;
+    assert.equal(readDigestCalls, 0);
+    assert.equal(driver.startNewSessionCalls, 0);
+    assert.equal(driver.prompts.length, 0);
+  });
+
+  test('/session keeps attachable rows when resume discovery fails for another session', async () => {
+    const terminal = new FakeTerminal();
+    const attachable = fakeSessionSummary('attachable', '/repo');
+    const archived = fakeSessionSummary('archived', '/repo');
+    const driver = new SlashCommandDriver([attachable, archived]);
+    driver.getSessionResumeAvailability = async (session) => {
+      if (session.id === archived.id) throw new Error('session archived');
+      return { available: false, reason: 'no resumable turn' };
+    };
+    const run = runMakaPiTui({
+      title: 'Maka',
+      driver,
+      cwd: '/repo',
+      model: 'm',
+      connectionSlug: 'c',
+      permissionMode: 'bypass',
+      terminal,
+    });
+
+    terminal.input('/session');
+    terminal.input('\r');
+    await waitFor(() => plainTerminalOutput(terminal.output()).includes('Resume Session Current'));
+    assert.match(plainTerminalOutput(terminal.output()), /attachab/);
+
+    let switched = false;
+    try {
+      terminal.input('\r');
+      await waitFor(() => driver.sessionIds.includes(attachable.id));
+      switched = true;
+    } finally {
+      exitMaka(terminal);
+      await run;
+    }
+    assert.equal(switched, true);
+  });
+
+  test('/session shows and opens rows found before catalog discovery is incomplete', async () => {
+    const terminal = new FakeTerminal();
+    const partial = fakeSessionSummary('partial-session', '/repo', 'Partial session');
+    const driver = new SlashCommandDriver([partial]);
+    driver.listSessions = async () => {
+      throw new MakaSessionCatalogIncompleteError(8, [partial]);
+    };
+    const run = runMakaPiTui({
+      title: 'Maka',
+      driver,
+      cwd: '/repo',
+      model: 'm',
+      connectionSlug: 'c',
+      permissionMode: 'bypass',
+      terminal,
+    });
+
+    terminal.input('/session');
+    terminal.input('\r');
+    await waitFor(() => {
+      const output = plainTerminalOutput(terminal.output()).replace(/\s+/g, ' ');
+      return (
+        output.includes(getTuiPickerCopy('en').resumeCatalogIncompleteNotice) &&
+        output.includes('Partial session')
+      );
+    });
+
+    terminal.input('\r');
+    try {
+      await waitFor(() => driver.sessionIds.includes(partial.id));
+    } finally {
+      exitMaka(terminal);
+      await run;
+    }
+  });
+
+  test('/session continues after a concurrent startup catalog scan fails', async () => {
+    const terminal = new FakeTerminal();
+    const session = fakeSessionSummary('session-after-startup-scan', '/repo', 'Current session');
+    const driver = new RejectFirstListSessionsDriver([session]);
+    driver.setAttachedSessionId(null);
+    const run = runMakaPiTui({
+      title: 'Maka',
+      driver,
+      cwd: '/repo',
+      model: 'm',
+      connectionSlug: 'c',
+      permissionMode: 'bypass',
+      terminal,
+    });
+
+    await waitFor(() => driver.listCalls === 1);
+    terminal.input('/session');
+    terminal.input('\r');
+    await delay(0);
+    driver.rejectFirstListCall();
+
+    await waitFor(() => driver.listCalls === 2);
+    await waitFor(() => plainTerminalOutput(terminal.output()).includes('Current session'));
+    assert.deepEqual(driver.listOptions[0], { limit: 256, cwd: '/repo' });
+    assert.deepEqual(driver.listOptions[1], {});
+
+    exitMaka(terminal);
+    await run;
+  });
+
+  test('surfaces a notice when the foreign-session scan fails', async () => {

Review Comment:
   **P3 (nit, test name):** this is main's `opens the latest imported task without importing another copy` test. The body is identical to main's, but it carries the title main used before #5308 (`84266767`) replaced the body. Nothing here touches a foreign-session scan failure; the test opens the latest import and checks that `importSession` is never called. Please restore main's title so the PR does not rename an unrelated test and the suite name matches what it covers.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "hqhq1025 (via GitHub)" <gi...@apache.org>.
hqhq1025 commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r4116592070


##########
packages/cli/src/runtime-host-session-driver.ts:
##########
@@ -336,10 +347,79 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
       .map(({ session }) => session);
   }
 
-  getSessionResumeAvailability(session: SessionSummary): Promise<SessionResumeAvailability> {
+  async getSessionSummary(sessionId: string): Promise<SessionSummary | undefined> {
+    const projection = await getRuntimeHostSession(this.#connection, sessionId);
+    if (!projection) return undefined;
+    const [session] = representableSession(projection);
+    return session ? projectSessionCatalogSummary(session) : undefined;
+  }
+
+  async #readBoundedSessionCatalog(
+    limit: number | undefined,
+    cwd?: string,
+  ): Promise<SessionCatalogProjection[]> {
+    if (limit !== undefined && (!Number.isSafeInteger(limit) || limit < 0)) {
+      throw new Error(`Session catalog limit must be a non-negative safe integer: ${limit}`);
+    }
+    if (limit === 0) return [];
+    for (let attempt = 0; attempt < 3; attempt += 1) {
+      try {
+        const sessions: SessionCatalogProjection[] = [];
+        const cursors = new Set<string>();
+        let cursor: RuntimeHostSessionCatalogPageCursor | undefined;
+        let pagesRead = 0;
+        while (pagesRead < MAX_SESSION_CATALOG_SCAN_PAGES) {
+          const page = await readRuntimeHostSessionCatalogPage(this.#connection, cursor);
+          pagesRead += 1;
+          for (const item of page.sessions) {
+            for (const session of representableSession(item)) {
+              if (
+                (cwd === undefined || session.workspace.hostCwd === cwd) &&
+                !isSideConversationSession(session.labels)
+              ) {
+                sessions.push(session);
+                if (limit !== undefined && sessions.length >= limit) break;
+              }
+            }
+            if (limit !== undefined && sessions.length >= limit) break;
+          }
+          if (!page.nextCursor || (limit !== undefined && sessions.length >= limit)) {
+            cursor = undefined;
+            break;
+          }
+          cursor = page.nextCursor;
+          if (cursors.has(cursor.cursor)) {
+            throw new Error('Runtime Host Session catalog returned a repeated cursor');
+          }
+          cursors.add(cursor.cursor);
+        }
+        if (cursor !== undefined && pagesRead === MAX_SESSION_CATALOG_SCAN_PAGES) {

Review Comment:
   [P2] Preserve already-discovered current-workspace candidates when the global eight-page scan bound is hit. With one ready `/repo` Session on page one and unrelated Sessions filling pages two through nine, this throws after page eight and `showSessionList` converts the error into an incomplete notice before it can render the known ready Session. I reproduced that using this head's production driver (`MakaSessionCatalogIncompleteError`, eight pages, known candidate ready). The existing test asserts the exception but not the user-visible loss. Return a partial result with an explicit incomplete state, or otherwise allow the known safe candidates to remain selectable; add a picker regression for this distribution.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "mikemikimike (via GitHub)" <gi...@apache.org>.
mikemikimike commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r3839905748


##########
packages/cli/src/pi-tui-runner.ts:
##########
@@ -2275,6 +2285,30 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
     renderScope();
   };
 
+  const announceResumeAvailability = async (): Promise<void> => {

Review Comment:
   System.Collections.Hashtable[3839511832]



##########
packages/cli/src/runtime-host-session-driver.ts:
##########
@@ -254,7 +254,14 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
       .map(({ session }) => session);
   }
 
-  getSessionResumeAvailability(session: SessionSummary): Promise<SessionResumeAvailability> {
+  async getSessionResumeAvailability(session: SessionSummary): Promise<SessionResumeAvailability> {
+    if (this.#executionLocation.kind === 'host') {

Review Comment:
   System.Collections.Hashtable[3839511828]



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on PR #3582:
URL: https://github.com/apache/maka/pull/3582#issuecomment-5391774334

   CI note, with one part that needs your judgement rather than a mechanical fix.
   
   This head's checks had never executed — the run was parked awaiting maintainer approval. I released it (`32686697153`), so what follows is a real result and not a new regression from anything on our side.
   
   **Unlike the other parked runs I released today, this one gets all the way through.** Lint, formatting, the Astryx inventory, `Build`, `Typecheck`, both Knip gates and the Linux sandbox smoke all pass. It fails at step 28, `Run affected standard workspace tests`, with exactly two failures, both in `packages/cli/dist/__tests__/pi-tui-runner.test.js`. They are different in kind, so I am separating them.
   
   ---
   
   **1. `/session keeps attachable rows when resume discovery fails for another session` — a new test this PR adds, failing on a string the layout truncates. Certain, and cheap to fix.**
   
   `pi-tui-runner.test.ts:3373` asserts `/attachable/`, but the rendered row is:
   
   ```
   → Existing chat       attachab claude-subscription claude-sonnet-4-5
     Existing chat       archived session archived
   ```
   
   The id column is eight characters wide, so `fakeSessionSummary('attachable', …)` renders as `attachab`. The sibling row passes only because `archived` happens to be exactly eight characters. **Nothing is wrong with the feature — the assertion is on a full-length id the column cannot show.** A shorter id, a wider `FakeTerminal`, or asserting on the visible form all resolve it.
   
   **2. `keeps live status visible for a session without a cwd but prevents resuming it` — a pre-existing test, and this is a regression. Certain that it regressed; I have not pinned the mechanism.**
   
   What I established:
   
   - This test exists on the merge base, `84ed9a31018ce31aee228473af4d03c35def0f3f`, which is a `main` commit whose own `test` check is **`success`**. So it passed there.
   - On this head it fails. Same test, same name, not touched by your diff.
   
   The expected/actual gap is not a near-miss. It expects the session list to render a row reading roughly `Legacy chat … · running Missing working directory`; what the terminal actually contains is:
   
   ```
    Note: Resumed session "Legacy chat"
   ```
   
   and then an otherwise empty screen — **no list at all, and a resume that did happen.** The test's whole point is that this session must stay visible but must not be resumable.
   
   **I am not going to guess which of your changes causes it**, because two new paths could and I would rather you check than have me assert. For what it is worth, both are in `pi-tui-runner.ts`:
   
   - `resumeSession` now falls through to `showSessionList({ onlyResumable: true })` when `getSessionId()` returns nothing, where it previously did not; and inside that list, selecting a row calls `runControl(resumeSession)` directly.
   - the availability lookup gained a preferred source under `onlyResumable`: `getSessionResumeCandidateAvailability` is consulted ahead of `getSessionResumeAvailability` and the `inspect…` fallback.
   
   To be fair to the second one: **`getSessionResumeCandidateAvailability` does check `cwd` first** (`runtime-host-session-driver.ts`, `if (!session.cwd) return { available: false, reason: 'Missing working directory' }`), so the obvious "the new authority is weaker" story does **not** hold as stated — which is exactly why I am not stating it. The test's driver is a stub, so which of the three sources it actually reaches is worth checking directly.
   
   ---
   
   **Neither failure is flaky.** The first is deterministic by construction, and the second contradicts a green run on its own merge base. **Both are reproducible with `npm --workspace @maka/cli run build` followed by the two test names**, which will be faster for you than another CI round trip.
   
   <details>
   <summary>中文</summary>
   
   CI 提示,其中一条需要你判断,不是机械修复。
   
   这个 head 的检查此前从没执行过——run 卡在等 maintainer 放行,我已放行(`32686697153`),所以下面是真实结果,不是我们这边引入的新回归。
   
   **与我今天放行的其他几个不同,这个 run 一路走到了很后面**:lint、格式、Astryx 清单、`Build`、`Typecheck`、两个 Knip 门、Linux sandbox smoke 全过。它失败在第 28 步 `Run affected standard workspace tests`,**恰好两个失败**,都在 `pi-tui-runner.test.js`。两者性质不同,我分开写。
   
   **1. `/session keeps attachable rows when resume discovery fails for another session` —— 本 PR 新增的测试,断言在一个被布局截断的字符串上。确定,且好修。**
   
   `pi-tui-runner.test.ts:3373` 断言 `/attachable/`,而实际渲染出的行是 `→ Existing chat       attachab claude-subscription …`。**id 列只有 8 个字符宽**,所以 `fakeSessionSummary('attachable', …)` 渲染成 `attachab`;旁边那行能过只是因为 `archived` 恰好是 8 个字符。**功能没问题,是断言写在了列显示不出来的完整 id 上。** 换个短 id、把 `FakeTerminal` 加宽、或者断言可见形式,都能解决。
   
   **2. `keeps live status visible for a session without a cwd but prevents resuming it` —— 既有测试,这是一处回归。我确定它回归了,但没有钉死机制。**
   
   已确立的事实:这个测试在 merge base `84ed9a310`(一个 `main` 提交)上存在,而**该提交自己的 `test` 检查是 success**,所以它在那里是通过的;在本 head 上它失败,同名同测试,且不在你的 diff 里。
   
   期望与实际的差距不是"差一点":它期望会话列表渲染出一行大致为 `Legacy chat … · running Missing working directory`,而终端实际内容是 `Note: Resumed session "Legacy chat"` 之后一片空白——**没有列表,而且确实发生了一次 resume。** 这个测试的全部意义就是"该会话必须可见但不可 resume"。
   
   **我不去猜是哪一处改动导致的**,因为有两条新路径都可能,我宁愿你去查,也不愿我来断言。两条都在 `pi-tui-runner.ts`:① `resumeSession` 现在在 `getSessionId()` 为空时会落到 `showSessionList({ onlyResumable: true })`(此前不会),而该列表里选中一行会直接 `runControl(resumeSession)`;② availability 查询在 `onlyResumable` 下新增了优先来源,`getSessionResumeCandidateAvailability` 排在 `getSessionResumeAvailability` 和 `inspect…` 兜底之前。
   
   **为第二条说句公道话**:`getSessionResumeCandidateAvailability` **确实先查了 `cwd`**(`runtime-host-session-driver.ts` 里 `if (!session.cwd) return { available: false, reason: 'Missing working directory' }`),所以"新权威更弱"这个顺理成章的说法**并不成立**——这正是我不去这么说的原因。该测试用的是 stub driver,它实际走到三个来源中的哪一个,值得直接查一下。
   
   **两个失败都不是 flake**:第一个由构造决定必然失败,第二个与它自己 merge base 上的绿色 run 相矛盾。**都可以用 `npm --workspace @maka/cli run build` 加上那两个测试名在本地复现**,比再等一轮 CI 快。
   </details>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "me2seeks (via GitHub)" <gi...@apache.org>.
me2seeks commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r3878732595


##########
packages/cli/src/pi-tui-runner.ts:
##########
@@ -2317,7 +2344,10 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
         sessionListScope === 'current'
           ? projectedSessions.filter(({ session }) => session.cwd === cwd)
           : projectedSessions;
-      const items: SelectItem[] = visibleSessions.map(({ session, depth }) => {
+      const selectableSessions = options.onlyResumable

Review Comment:
   **[P1] `/resume` still offers foreign import sessions that are not safe-boundary candidates.**\n\nThis `onlyResumable` filter applies only to the projected Maka sessions. The same `showSessionList` call still runs `foreignSessions.listSessions({ cwd })`, and the render path later appends every `foreignByValue` row unconditionally. The production local TUI always supplies `foreignSessions`, so with no attached Maka Session, `/resume` can show a Codex/Claude row. Selecting it takes the `importForeignSession` branch, creates a new Maka Session, and starts a handoff turn; it never passes `turn.resume.query` and is not a safe-boundary continuation. That contradicts the PR summary that this picker is limited to sessions whose resume availability is ready, and can turn a recovery command into an unrelated provider call.\n\nPlease skip the foreign scan and foreign rows when `options.onlyResumable` is true, while preserving them for `/session`. A regression should use no attached Maka Sess
 ion plus one foreign session, invoke `/resume`, and prove that the foreign row is absent and neither import nor a new turn occurs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r4115485179


##########
packages/cli/src/pi-tui-runner.ts:
##########
@@ -3267,31 +3301,16 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
             void runControl(() => importExternalSession(adapterId, source));
             return;
           }
-          const actionTitle = formatUiMessage(
-            copy.externalImportedActionsTitle,
-            { source: source.name },
-            locale,
-          );
-          const actions: SelectItem[] = [
-            { value: 'open-latest', label: copy.externalOpenLatestImported },
-            ...(!source.importState.isImporting
-              ? [{ value: 'import-again', label: copy.externalImportAgain }]
-              : []),
-          ];
           showSelectPicker(
-            actionTitle,
+            formatUiMessage(copy.externalImportedActionsTitle, { source: source.name }, locale),
             source.name,
-            actions,
+            [
+              { value: 'open-latest', label: copy.externalOpenLatestImported },
+              ...(!source.importState.isImporting
+                ? [{ value: 'import-again', label: copy.externalImportAgain }]
+                : []),
+            ],
             (action) => {
-              if (busy || turnRunning) {
-                state.entries.push({
-                  kind: 'notice',
-                  level: 'error',
-                  text: copy.externalImportBusy,
-                });
-                requestRender();
-                return;
-              }
               if (action.value === 'import-again') {
                 void runControl(() => importExternalSession(adapterId, source));

Review Comment:
   This action lost its `busy || turnRunning` guard in this revision, and `runControl` does not replace it: it returns silently when `busy` (`pi-tui-runner.ts:1105`) and never looks at a running Turn. So "Import again" now does nothing at all when the shell is busy, with no explanation, and proceeds while a Turn is running where it previously reported `externalImportBusy`.
   
   That may well be intended, but it is a behaviour change in the external-import path with no line in the description, and the rest of that file's edits are formatting. Worth either restoring the guard or stating the intent.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r4116170006


##########
packages/cli/src/runtime-host-session-driver.ts:
##########
@@ -336,10 +347,79 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
       .map(({ session }) => session);
   }
 
-  getSessionResumeAvailability(session: SessionSummary): Promise<SessionResumeAvailability> {
+  async getSessionSummary(sessionId: string): Promise<SessionSummary | undefined> {
+    const projection = await getRuntimeHostSession(this.#connection, sessionId);
+    if (!projection) return undefined;
+    const [session] = representableSession(projection);
+    return session ? projectSessionCatalogSummary(session) : undefined;
+  }
+
+  async #readBoundedSessionCatalog(
+    limit: number | undefined,
+    cwd?: string,
+  ): Promise<SessionCatalogProjection[]> {
+    if (limit !== undefined && (!Number.isSafeInteger(limit) || limit < 0)) {
+      throw new Error(`Session catalog limit must be a non-negative safe integer: ${limit}`);
+    }
+    if (limit === 0) return [];
+    for (let attempt = 0; attempt < 3; attempt += 1) {
+      try {
+        const sessions: SessionCatalogProjection[] = [];
+        const cursors = new Set<string>();
+        let cursor: RuntimeHostSessionCatalogPageCursor | undefined;
+        let pagesRead = 0;
+        while (pagesRead < MAX_SESSION_CATALOG_SCAN_PAGES) {
+          const page = await readRuntimeHostSessionCatalogPage(this.#connection, cursor);
+          pagesRead += 1;
+          for (const item of page.sessions) {
+            for (const session of representableSession(item)) {
+              if (
+                (cwd === undefined || session.workspace.hostCwd === cwd) &&
+                !isSideConversationSession(session.labels)
+              ) {
+                sessions.push(session);
+                if (limit !== undefined && sessions.length >= limit) break;
+              }
+            }
+            if (limit !== undefined && sessions.length >= limit) break;
+          }
+          if (!page.nextCursor || (limit !== undefined && sessions.length >= limit)) {
+            cursor = undefined;
+            break;
+          }
+          cursor = page.nextCursor;
+          if (cursors.has(cursor.cursor)) {
+            throw new Error('Runtime Host Session catalog returned a repeated cursor');
+          }
+          cursors.add(cursor.cursor);
+        }
+        if (cursor !== undefined && pagesRead === MAX_SESSION_CATALOG_SCAN_PAGES) {
+          throw new MakaSessionCatalogIncompleteError(pagesRead);
+        }

Review Comment:
   **P2** — Hitting the page cap throws and discards the `sessions` collected so far. With 32-item pages, 8 pages cover the newest 256 catalog rows. A current-workspace scan that finds fewer than `limit` matches there (common for users with many projects) fails outright. `/resume` then shows only the incomplete notice, even when the target session was on page 1. Returning `{ sessions, incomplete: true }` and letting the picker show partial results plus the notice would keep the feature usable exactly where it's most needed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "mikemikimike (via GitHub)" <gi...@apache.org>.
mikemikimike commented on PR #3582:
URL: https://github.com/apache/maka/pull/3582#issuecomment-5385544135

   Follow-up fix pushed in the new head.
   
   - `/resume` selection now switches to the chosen session and immediately runs the safe-boundary resume flow; it no longer stops after view navigation.
   - Runtime Host resume availability now delegates to `turn.resume.query`, so completed/running/no-candidate sessions are not treated as resumable merely because their cwd is attachable.
   - Added coverage that selects the picker row and observes `resumeLatest()`.
   
   Verification on the new head: CLI build, typecheck, lint, format check, `git diff --check`, the picker/resume regression, and the Runtime Host availability test pass.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han merged PR #3582:
URL: https://github.com/apache/maka/pull/3582


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "hqhq1025 (via GitHub)" <gi...@apache.org>.
hqhq1025 commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r4116588743


##########
packages/cli/src/runtime-host-session-driver.ts:
##########
@@ -336,10 +347,79 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
       .map(({ session }) => session);
   }
 
-  getSessionResumeAvailability(session: SessionSummary): Promise<SessionResumeAvailability> {
+  async getSessionSummary(sessionId: string): Promise<SessionSummary | undefined> {
+    const projection = await getRuntimeHostSession(this.#connection, sessionId);
+    if (!projection) return undefined;
+    const [session] = representableSession(projection);
+    return session ? projectSessionCatalogSummary(session) : undefined;
+  }
+
+  async #readBoundedSessionCatalog(
+    limit: number | undefined,
+    cwd?: string,
+  ): Promise<SessionCatalogProjection[]> {
+    if (limit !== undefined && (!Number.isSafeInteger(limit) || limit < 0)) {
+      throw new Error(`Session catalog limit must be a non-negative safe integer: ${limit}`);
+    }
+    if (limit === 0) return [];
+    for (let attempt = 0; attempt < 3; attempt += 1) {
+      try {
+        const sessions: SessionCatalogProjection[] = [];
+        const cursors = new Set<string>();
+        let cursor: RuntimeHostSessionCatalogPageCursor | undefined;
+        let pagesRead = 0;
+        while (pagesRead < MAX_SESSION_CATALOG_SCAN_PAGES) {
+          const page = await readRuntimeHostSessionCatalogPage(this.#connection, cursor);
+          pagesRead += 1;
+          for (const item of page.sessions) {
+            for (const session of representableSession(item)) {
+              if (
+                (cwd === undefined || session.workspace.hostCwd === cwd) &&
+                !isSideConversationSession(session.labels)
+              ) {
+                sessions.push(session);
+                if (limit !== undefined && sessions.length >= limit) break;
+              }
+            }
+            if (limit !== undefined && sessions.length >= limit) break;
+          }
+          if (!page.nextCursor || (limit !== undefined && sessions.length >= limit)) {

Review Comment:
   [P2] Do not mark this catalog read complete merely because 200 raw Session candidates were collected. The `/resume` picker requests `{ limit: 200, cwd }`, then checks resumability afterward (`pi-tui-runner.ts:3401,3423-3450`). If the first 200 matching Sessions cannot resume but the 201st can, this branch clears `nextCursor`, returns a complete-looking list, and the picker shows no match without the incomplete notice. I reproduced that on this head with the production driver: 200 listed, 0 ready, while a direct check of omitted `session-200` was ready. Keep a partial signal or continue catalog discovery based on ready candidates, and add a regression with this distribution.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "hqhq1025 (via GitHub)" <gi...@apache.org>.
hqhq1025 commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r3964675494


##########
packages/cli/src/pi-tui-runner.ts:
##########
@@ -2809,18 +2846,33 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
     const [availabilityEntries, foreignScan] = await Promise.all([
       Promise.all(

Review Comment:
   [P2] Filter the default Current scope before awaiting candidate checks. `visibleSessions` excludes other working directories only at lines 2911-2914, after this `Promise.all` has started and awaited `turn.resume.query` for every row returned by the fully paged catalog. On this exact head, a compiled TUI probe with one `/repo` Session and sixteen `/other` Sessions whose candidate checks were held had not rendered the Current picker after 100 ms; nine checks had already started, including eight rows that could not be displayed, and the picker appeared only after those checks were released. The concurrency limit caps Host pressure, but open latency still scales with the entire catalog. Please query the current-cwd set first and defer the all-scope checks until the user selects All, or apply the filter/limit at the Host boundary.



##########
packages/cli/src/pi-tui-runner.ts:
##########
@@ -2944,6 +3010,31 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
     renderScope();
   };
 
+  const announceResumeAvailability = async (): Promise<void> => {
+    const sessionId = input.driver.getSessionId();
+    try {
+      if (!input.driver.getSessionResumeCandidateAvailability) return;
+      const sessions = await listSessions();
+      const session =
+        sessions.find((candidate) => candidate.id === sessionId) ??
+        sessions.find((candidate) => candidate.cwd === cwd);
+      if (!session) return;
+      const availability = await runResumeAvailabilityCheck(() =>
+        input.driver.getSessionResumeCandidateAvailability!(session),
+      );
+      if (availability.available) {
+        state.entries.push({
+          kind: 'notice',
+          level: 'info',
+          text: 'This session has an interrupted run — /resume to continue from the safe boundary.',

Review Comment:
   [P2] Move this new user-visible hint into the localized TUI copy catalog. The TUI supports `en`, `zh-CN`, and `zh-TW`, but this path always emits English. More immediately, `npm run check:tui-copy` fails on this exact line, which is also the sole failure in the hosted `test` job, so the required gate cannot pass. Add the message to the appropriate catalog domain with aligned translations and resolve it through `locale`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "hqhq1025 (via GitHub)" <gi...@apache.org>.
hqhq1025 commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r4113282059


##########
packages/cli/src/runtime-host-session-driver.ts:
##########
@@ -336,10 +346,75 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
       .map(({ session }) => session);
   }
 
-  getSessionResumeAvailability(session: SessionSummary): Promise<SessionResumeAvailability> {
+  async getSessionSummary(sessionId: string): Promise<SessionSummary | undefined> {
+    const projection = await getRuntimeHostSession(this.#connection, sessionId);
+    if (!projection) return undefined;
+    const [session] = representableSession(projection);
+    return session ? projectSessionCatalogSummary(session) : undefined;
+  }
+
+  async #readBoundedSessionCatalog(
+    limit: number | undefined,
+    cwd?: string,
+  ): Promise<SessionCatalogProjection[]> {
+    if (limit !== undefined && (!Number.isSafeInteger(limit) || limit < 0)) {
+      throw new Error(`Session catalog limit must be a non-negative safe integer: ${limit}`);
+    }
+    if (limit === 0) return [];
+    for (let attempt = 0; attempt < 3; attempt += 1) {
+      try {
+        const sessions: SessionCatalogProjection[] = [];
+        const cursors = new Set<string>();
+        let cursor: RuntimeHostSessionCatalogPageCursor | undefined;
+        let pagesRead = 0;
+        while (pagesRead < MAX_SESSION_CATALOG_SCAN_PAGES) {

Review Comment:
   [P2] Do not return the eight-page prefix as a complete cwd result
   
   Stopping here returns a normal `SessionSummary[]` even when the eighth page still has `nextCursor`, so callers cannot distinguish a complete empty result from a truncated search. The TUI interprets that empty array authoritatively: `/resume` renders `No matching sessions`, and startup emits no interrupted-run hint.
   
   An exact-head production-driver probe with 256 newer Sessions from other cwd values followed by one resumable `/repo` Session made eight `session.catalog.query` calls and returned `[]`. The existing positive regression places its target at index 200, which is still inside seven pages, while the new no-match test only asserts that scanning stops. Please keep the scan bounded but preserve completeness semantics: filter by cwd/visibility in the Host query, or return a cursor/truncation signal that lets the recovery UI continue or say the result is incomplete rather than claiming no match.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "me2seeks (via GitHub)" <gi...@apache.org>.
me2seeks commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r4192050444


##########
packages/cli/src/runtime-host-session-driver.ts:
##########
@@ -336,10 +350,100 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
       .map(({ session }) => session);
   }
 
-  getSessionResumeAvailability(session: SessionSummary): Promise<SessionResumeAvailability> {
+  async getSessionSummary(sessionId: string): Promise<SessionSummary | undefined> {
+    const projection = await getRuntimeHostSession(this.#connection, sessionId);
+    if (!projection) return undefined;
+    const [session] = representableSession(projection);
+    return session ? projectSessionCatalogSummary(session) : undefined;
+  }
+
+  async #readBoundedSessionCatalog(
+    limit: number | undefined,
+    cwd?: string,
+  ): Promise<SessionCatalogProjection[]> {
+    if (limit !== undefined && (!Number.isSafeInteger(limit) || limit < 0)) {
+      throw new Error(`Session catalog limit must be a non-negative safe integer: ${limit}`);
+    }
+    if (limit === 0) return [];
+    for (let attempt = 0; attempt < MAX_SESSION_CATALOG_READ_ATTEMPTS; attempt += 1) {
+      try {
+        const sessions: SessionCatalogProjection[] = [];
+        const cursors = new Set<string>();
+        let cursor: RuntimeHostSessionCatalogPageCursor | undefined;
+        let pagesRead = 0;
+        while (pagesRead < SESSION_CATALOG_MAX_SCAN_PAGES) {
+          const page = await readRuntimeHostSessionCatalogPage(this.#connection, cursor);
+          pagesRead += 1;
+          for (const item of page.sessions) {
+            for (const session of representableSession(item)) {
+              if (
+                (cwd === undefined || session.workspace.hostCwd === cwd) &&
+                !isSideConversationSession(session.labels)
+              ) {
+                sessions.push(session);
+                if (limit !== undefined && sessions.length >= limit) break;
+              }
+            }
+            if (limit !== undefined && sessions.length >= limit) break;
+          }
+          if (!page.nextCursor) {
+            cursor = undefined;
+            break;
+          }
+          cursor = page.nextCursor;
+          if (limit !== undefined && sessions.length >= limit) {
+            throw new MakaSessionCatalogIncompleteError(
+              pagesRead,
+              sessions.map(projectSessionCatalogSummary),
+            );
+          }
+          if (cursors.has(cursor.cursor)) {
+            throw new Error('Runtime Host Session catalog returned a repeated cursor');
+          }
+          cursors.add(cursor.cursor);
+        }
+        if (cursor !== undefined && pagesRead === SESSION_CATALOG_MAX_SCAN_PAGES) {
+          throw new MakaSessionCatalogIncompleteError(
+            pagesRead,
+            sessions.map(projectSessionCatalogSummary),
+          );
+        }
+        return sessions;
+      } catch (error) {
+        if (
+          !(error instanceof RuntimeHostSessionCatalogRevisionChangedError) ||
+          attempt + 1 === MAX_SESSION_CATALOG_READ_ATTEMPTS
+        ) {
+          throw error;
+        }
+        await new Promise<void>((resolve) =>
+          setTimeout(
+            resolve,
+            Math.min(
+              SESSION_CATALOG_READ_RETRY_BASE_DELAY_MS * 2 ** attempt,
+              SESSION_CATALOG_READ_RETRY_MAX_DELAY_MS,
+            ),
+          ),
+        );
+      }
+    }
+    throw new Error('Runtime Host Session catalog could not be read consistently');
+  }
+
+  async getSessionResumeAvailability(session: SessionSummary): Promise<SessionResumeAvailability> {
     return inspectRuntimeHostSessionResumeAvailability(session, this.#executionLocation);
   }
 
+  async getSessionResumeCandidateAvailability(
+    session: SessionSummary,
+  ): Promise<SessionResumeAvailability> {
+    if (!session.cwd) return { available: false, reason: 'Missing working directory' };
+    const plan = await this.#request('turn.resume.query', { sessionId: session.id });

Review Comment:
   **[P3] `/resume` can list a local session whose working directory no longer exists**
   
   For a local (`client_path`) session, this candidate check only asks the Host whether `turn.resume.query` is ready; it does not apply the existing local `cwd` existence check. I reproduced the mismatch on the current-main merge tree: with a deleted cwd and a ready resume plan, `/resume` marks the row available, while `switchSession()` rejects it with `Session cwd no longer exists`. Selecting that row therefore closes the picker without starting the resume. The switch guard still prevents attaching to the missing directory.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "mikemikimike (via GitHub)" <gi...@apache.org>.
mikemikimike commented on PR #3582:
URL: https://github.com/apache/maka/pull/3582#issuecomment-5442036649

   Thanks for the CI report. I rechecked the exact current head 4e8521360575d26950acdad2d4f1a81028278100. The truncation assertion is now on the visible id form (attachab), and the regression test now also selects an attachable row whose resume availability is false and observes switchSession. The loading test exercises the startup advisory capability and asserts a single listSessions call. Both focused tests pass, including five repeated combined runs. The CLI build, typecheck, changed-file Biome check, and git diff --check pass. The GitHub check for this new head is currently queued; no terminal CI result is available yet.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "me2seeks (via GitHub)" <gi...@apache.org>.
me2seeks commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r3878732595


##########
packages/cli/src/pi-tui-runner.ts:
##########
@@ -2317,7 +2344,10 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
         sessionListScope === 'current'
           ? projectedSessions.filter(({ session }) => session.cwd === cwd)
           : projectedSessions;
-      const items: SelectItem[] = visibleSessions.map(({ session, depth }) => {
+      const selectableSessions = options.onlyResumable

Review Comment:
   **[P1] `/resume` still offers foreign import sessions that are not safe-boundary candidates.**
   
   This `onlyResumable` filter applies only to the projected Maka sessions. The same `showSessionList` call still runs `foreignSessions.listSessions({ cwd })`, and the render path later appends every `foreignByValue` row unconditionally. The production local TUI always supplies `foreignSessions`, so with no attached Maka Session, `/resume` can show a Codex/Claude row. Selecting it takes the `importForeignSession` branch, creates a new Maka Session, and starts a handoff turn; it never passes `turn.resume.query` and is not a safe-boundary continuation. That contradicts the PR summary that this picker is limited to sessions whose resume availability is ready, and can turn a recovery command into an unrelated provider call.
   
   Please skip the foreign scan and foreign rows when `options.onlyResumable` is true, while preserving them for `/session`. A regression should use no attached Maka Session plus one foreign session, invoke `/resume`, and prove that the foreign row is absent and neither import nor a new turn occurs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "hqhq1025 (via GitHub)" <gi...@apache.org>.
hqhq1025 commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r4106147767


##########
packages/cli/src/pi-tui-runner.ts:
##########
@@ -3354,17 +3369,16 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
     showSelectPicker(
       copy.externalSourceTitle,
       copy.externalSourceTitle,
-      adapterIds.map((adapterId) => ({
-        value: adapterId,
-        label: externalSourceLabel(adapterId),
-      })),
+      adapterIds.map((adapterId) => ({ value: adapterId, label: externalSourceLabel(adapterId) })),
       (item) => void showExternalSessionPage(item.value, initialScope),
       { minPrimaryColumnWidth: 20, maxPrimaryColumnWidth: 40 },
     );
   };
 
-  const showSessionList = async () => {
-    const sessions = await input.driver.listSessions();
+  const showSessionList = async (options: { onlyResumable?: boolean } = {}) => {
+    const sessions = await listSessions(
+      options.onlyResumable ? { limit: MAX_SESSION_RESUME_CANDIDATES } : {},

Review Comment:
   [P2] Preserve current-workspace candidates before applying the global cap. `listSessions({ limit: 200 })` makes the Runtime Host driver stop after the first 200 catalog records, which are ordered globally by activity; only afterward does this function filter by `cwd`. A valid resumable session in the current workspace can therefore disappear when 200 newer sessions belong to other workspaces. On this exact head, a limit-honoring driver with 200 newer other-cwd sessions plus one resumable `/repo` session at position 201 makes `/resume` show `No matching sessions`, and toggling to All cannot recover it. The same cutoff also affects startup discovery: if the attached session is outside the prefix, `announceResumeAvailability()` falls back to another same-cwd session and can display the interrupted-run notice for the wrong session. The added `BoundedResumeAvailabilityDriver` records `options.limit` but returns the full array, so the 224-session tests do not exercise production truncat
 ion. Please either support a server-side workspace/current-session filter or keep paging until the required scope is populated, and add a regression whose fake actually honors the limit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r4181532268


##########
packages/cli/src/pi-tui-runner.ts:
##########
@@ -3267,31 +3301,16 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
             void runControl(() => importExternalSession(adapterId, source));
             return;
           }
-          const actionTitle = formatUiMessage(
-            copy.externalImportedActionsTitle,
-            { source: source.name },
-            locale,
-          );
-          const actions: SelectItem[] = [
-            { value: 'open-latest', label: copy.externalOpenLatestImported },
-            ...(!source.importState.isImporting
-              ? [{ value: 'import-again', label: copy.externalImportAgain }]
-              : []),
-          ];
           showSelectPicker(
-            actionTitle,
+            formatUiMessage(copy.externalImportedActionsTitle, { source: source.name }, locale),
             source.name,
-            actions,
+            [
+              { value: 'open-latest', label: copy.externalOpenLatestImported },
+              ...(!source.importState.isImporting
+                ? [{ value: 'import-again', label: copy.externalImportAgain }]
+                : []),
+            ],
             (action) => {
-              if (busy || turnRunning) {
-                state.entries.push({
-                  kind: 'notice',
-                  level: 'error',
-                  text: copy.externalImportBusy,
-                });
-                requestRender();
-                return;
-              }
               if (action.value === 'import-again') {

Review Comment:
   **P3 (re-opened by the revert):** this reverts the restoration of main's inner guard, not an addition unrelated to resume. Main has `if (busy || turnRunning) { ...externalImportBusy...; return; }` right here (main `pi-tui-runner.ts:3281-3290`), so this head still changes external-import behavior. If a Turn or control action starts while this second picker is open, "Import again" either returns silently from `runControl` (busy) or imports while the Turn is running. The outer guard at `:3294` only checks state when the first picker closes. To keep this PR out of the import path, restore main's block (and main's deleted test `opens the latest imported task without importing another copy`) rather than dropping it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "mikemikimike (via GitHub)" <gi...@apache.org>.
mikemikimike commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r3873655091


##########
packages/cli/src/runtime-host-session-driver.ts:
##########
@@ -254,7 +254,14 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
       .map(({ session }) => session);
   }
 
-  getSessionResumeAvailability(session: SessionSummary): Promise<SessionResumeAvailability> {
+  async getSessionResumeAvailability(session: SessionSummary): Promise<SessionResumeAvailability> {
+    if (this.#executionLocation.kind === 'host') {

Review Comment:
   Rechecked at head 4e8521360575d26950acdad2d4f1a81028278100. The attach and resume predicates are now independent: /session keeps the row selectable, while the unavailable-selection guard is applied only when options.onlyResumable is true. Per-session availability failures remain contained, so one archived row cannot prevent the picker from opening. I strengthened the regression to return unavailable for the attachable row and assert that selecting it calls switchSession. The focused test passes. CLI build, typecheck, changed-file Biome check, and git diff --check also pass.



##########
packages/cli/src/pi-tui-runner.ts:
##########
@@ -2275,6 +2285,30 @@ export async function runMakaPiTui(input: MakaPiTuiInput): Promise<void> {
     renderScope();
   };
 
+  const announceResumeAvailability = async (): Promise<void> => {

Review Comment:
   Rechecked at head 4e8521360575d26950acdad2d4f1a81028278100. The startup advisory and the session picker share the memoized sessionListPromise, so concurrent opens join one listSessions call; the advisory also returns early when the candidate-availability capability is absent. I updated DeferredListSessionsDriver to exercise the advisory path and added an assertion that listCalls remains 1 after the picker renders. The focused test passes in five repeated combined runs. CLI build, typecheck, changed-file Biome check, and git diff --check also pass.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "hqhq1025 (via GitHub)" <gi...@apache.org>.
hqhq1025 commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r4112824048


##########
packages/cli/src/runtime-host-session-driver.ts:
##########
@@ -336,10 +347,72 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
       .map(({ session }) => session);
   }
 
-  getSessionResumeAvailability(session: SessionSummary): Promise<SessionResumeAvailability> {
+  async getSessionSummary(sessionId: string): Promise<SessionSummary | undefined> {
+    const projection = await getRuntimeHostSession(this.#connection, sessionId);
+    if (!projection) return undefined;
+    const [session] = representableSession(projection);
+    return session ? projectSessionCatalogSummary(session) : undefined;
+  }
+
+  async #readBoundedSessionCatalog(
+    limit: number | undefined,
+    cwd?: string,
+  ): Promise<SessionCatalogItem[]> {
+    if (limit !== undefined && (!Number.isSafeInteger(limit) || limit < 0)) {
+      throw new Error(`Session catalog limit must be a non-negative safe integer: ${limit}`);
+    }
+    if (limit === 0) return [];
+    for (let attempt = 0; attempt < 3; attempt += 1) {
+      try {
+        const sessions: SessionCatalogItem[] = [];
+        const cursors = new Set<string>();
+        let cursor: RuntimeHostSessionCatalogPageCursor | undefined;
+        let hasMore = true;
+        while (hasMore) {
+          const page = await readRuntimeHostSessionCatalogPage(this.#connection, cursor);
+          for (const item of page.sessions) {
+            if (
+              cwd === undefined ||
+              representableSession(item).some((session) => session.workspace.hostCwd === cwd)
+            ) {
+              sessions.push(item);

Review Comment:
   [P2] Apply the bound after the visible catalog predicate
   
   This makes `{ limit: 200, cwd }` neither a bounded Host read nor a guaranteed 200 visible results. When cwd matches are sparse, the loop walks every global page sequentially; an exact-head driver probe with 3,200 unrelated Sessions issued 100 `session.catalog.query` requests before returning `[]`. That path runs both when opening `/resume` and automatically at startup with no attached Session, so a remote Host's latency grows with the entire catalog.
   
   Conversely, matching items are counted here before `listSessions()` removes `mode:side_conversation` rows at lines 335-337. In an exact-head probe, 200 hidden same-cwd side Sessions followed by one ordinary resumable Session returned `[]`, stopping before the visible candidate. Please move cwd/visibility filtering into the Host catalog query (or use another filtered cursor with an explicit scan budget), count `limit` after all product-visible filters, and cover both a no-match multi-page catalog and a hidden-side-session prefix.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "hqhq1025 (via GitHub)" <gi...@apache.org>.
hqhq1025 commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r4116130905


##########
packages/cli/src/runtime-host-session-driver.ts:
##########
@@ -336,10 +347,79 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
       .map(({ session }) => session);
   }
 
-  getSessionResumeAvailability(session: SessionSummary): Promise<SessionResumeAvailability> {
+  async getSessionSummary(sessionId: string): Promise<SessionSummary | undefined> {
+    const projection = await getRuntimeHostSession(this.#connection, sessionId);
+    if (!projection) return undefined;
+    const [session] = representableSession(projection);
+    return session ? projectSessionCatalogSummary(session) : undefined;
+  }
+
+  async #readBoundedSessionCatalog(
+    limit: number | undefined,
+    cwd?: string,
+  ): Promise<SessionCatalogProjection[]> {
+    if (limit !== undefined && (!Number.isSafeInteger(limit) || limit < 0)) {
+      throw new Error(`Session catalog limit must be a non-negative safe integer: ${limit}`);
+    }
+    if (limit === 0) return [];
+    for (let attempt = 0; attempt < 3; attempt += 1) {
+      try {
+        const sessions: SessionCatalogProjection[] = [];
+        const cursors = new Set<string>();
+        let cursor: RuntimeHostSessionCatalogPageCursor | undefined;
+        let pagesRead = 0;
+        while (pagesRead < MAX_SESSION_CATALOG_SCAN_PAGES) {
+          const page = await readRuntimeHostSessionCatalogPage(this.#connection, cursor);
+          pagesRead += 1;
+          for (const item of page.sessions) {
+            for (const session of representableSession(item)) {
+              if (
+                (cwd === undefined || session.workspace.hostCwd === cwd) &&
+                !isSideConversationSession(session.labels)
+              ) {
+                sessions.push(session);
+                if (limit !== undefined && sessions.length >= limit) break;
+              }
+            }
+            if (limit !== undefined && sessions.length >= limit) break;
+          }
+          if (!page.nextCursor || (limit !== undefined && sessions.length >= limit)) {

Review Comment:
   [P2] Do not treat the first 200 candidate rows as a complete resumable search. When `sessions.length` reaches `limit`, this branch clears `cursor` even if `page.nextCursor` says more rows exist. `/resume` checks readiness only after `listSessions` returns. With 200 newer same-cwd Sessions that have no resume candidate and a 201st Session whose `turn.resume.query` is `ready`, the production driver returns the first 200 after seven page reads; the picker reports `No matching sessions` and never signals incompleteness. I reproduced that with the compiled driver. Please preserve an explicit partial-result signal at the candidate limit, or continue discovery against actual resume readiness, so the bounded scan cannot silently hide a valid recovery.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [PR] fix(cli): discover resumable sessions from /resume [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han commented on code in PR #3582:
URL: https://github.com/apache/maka/pull/3582#discussion_r4116591420


##########
packages/cli/src/runtime-host-session-driver.ts:
##########
@@ -336,10 +347,79 @@ class RuntimeHostMakaSessionDriverImpl implements RuntimeHostMakaSessionDriver {
       .map(({ session }) => session);
   }
 
-  getSessionResumeAvailability(session: SessionSummary): Promise<SessionResumeAvailability> {
+  async getSessionSummary(sessionId: string): Promise<SessionSummary | undefined> {
+    const projection = await getRuntimeHostSession(this.#connection, sessionId);
+    if (!projection) return undefined;
+    const [session] = representableSession(projection);
+    return session ? projectSessionCatalogSummary(session) : undefined;
+  }
+
+  async #readBoundedSessionCatalog(
+    limit: number | undefined,
+    cwd?: string,
+  ): Promise<SessionCatalogProjection[]> {
+    if (limit !== undefined && (!Number.isSafeInteger(limit) || limit < 0)) {
+      throw new Error(`Session catalog limit must be a non-negative safe integer: ${limit}`);
+    }
+    if (limit === 0) return [];
+    for (let attempt = 0; attempt < 3; attempt += 1) {
+      try {
+        const sessions: SessionCatalogProjection[] = [];
+        const cursors = new Set<string>();
+        let cursor: RuntimeHostSessionCatalogPageCursor | undefined;
+        let pagesRead = 0;
+        while (pagesRead < MAX_SESSION_CATALOG_SCAN_PAGES) {
+          const page = await readRuntimeHostSessionCatalogPage(this.#connection, cursor);
+          pagesRead += 1;
+          for (const item of page.sessions) {
+            for (const session of representableSession(item)) {
+              if (
+                (cwd === undefined || session.workspace.hostCwd === cwd) &&
+                !isSideConversationSession(session.labels)
+              ) {
+                sessions.push(session);
+                if (limit !== undefined && sessions.length >= limit) break;
+              }
+            }
+            if (limit !== undefined && sessions.length >= limit) break;
+          }
+          if (!page.nextCursor || (limit !== undefined && sessions.length >= limit)) {
+            cursor = undefined;
+            break;
+          }
+          cursor = page.nextCursor;
+          if (cursors.has(cursor.cursor)) {
+            throw new Error('Runtime Host Session catalog returned a repeated cursor');
+          }
+          cursors.add(cursor.cursor);
+        }
+        if (cursor !== undefined && pagesRead === MAX_SESSION_CATALOG_SCAN_PAGES) {

Review Comment:
   P1: at the page cap this throws and discards `sessions` already collected. For a heavy user whose cwd has fewer than 200 matches in the first ~256 catalog entries, `/resume` never opens. Please return the partial list with an explicit incomplete flag instead.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org