Skip to content

feat(cli): resume without sessionId opens tui session picker#139

Merged
remarkablemark merged 1 commit into
masterfrom
feat/resume
Jun 4, 2026
Merged

feat(cli): resume without sessionId opens tui session picker#139
remarkablemark merged 1 commit into
masterfrom
feat/resume

Conversation

@remarkablemark
Copy link
Copy Markdown
Member

@remarkablemark remarkablemark commented Jun 4, 2026

What is the motivation for this pull request?

Feature: allow resume to be called without a <sessionId> argument. Previously the argument was required; users had to know the session ID to resume. This makes the command more discoverable and convenient.

plan.md

What is the current behavior?

code-ollama resume requires a <sessionId> argument — omitting it results in a CLI usage error.

What is the new behavior?

  • code-ollama resume <sessionId> — unchanged: loads and resumes the specific session.
  • code-ollama resume — opens the TUI directly on the session manager screen, where the user can pick a session to open (or start a new one).

Internally, renderApp now accepts a LaunchOptions object ({ sessionId?, initialScreen? }) instead of a plain sessionId string. useScreenRouter accepts an initialScreen option to seed its initial useState.

Checklist:

Make `resume` work without `<sessionId>` by opening the TUI directly on the session manager screen, using a `LaunchOptions` object to pass both `sessionId` and `initialScreen`.

Changes:

1. `src/tui.tsx`

- Change `renderApp(sessionId?: string)` → `renderApp(options: LaunchOptions = {})`.
- Pass `options.sessionId` and `options.initialScreen` through to `<App>`.
- `screen.setClearHandler` rerender: pass `{ sessionId: nextSessionId ?? options.sessionId }` (drop `initialScreen` on rerender — resets to chat).

2. `src/components/App/App.tsx`

- Change `Props` from `{ sessionId?: string }` → `{ sessionId?: string; initialScreen?: Screen }`.
- Pass `initialScreen` to `useScreenRouter`.

3. `src/components/App/hooks/useScreenRouter.ts`

- Accept `initialScreen?: Screen` param.
- Change `useState<Screen>(SCREEN.CHAT)` → `useState<Screen>(initialScreen ?? SCREEN.CHAT)`.

4. `src/cli.ts`

- Import `{ SCREEN } from './constants'` and `type { Screen } from './types'`.
- Define `interface LaunchOptions { sessionId?: string; initialScreen?: Screen }`.
- Change `'resume <sessionId>'` → `'resume [sessionId]'` (optional arg).
- Update action: if `sessionId` provided, load + validate as today; if absent, `launchTui({ initialScreen: SCREEN.SESSION_MANAGER })`.
- Change `launchTui(sessionId?: string)` → `launchTui(options: LaunchOptions = {})`, pass `options` to `renderApp`.

5. Tests

**`src/cli.test.ts`**

- Update `ResumeAction` type: `(sessionId?: string) => Promise<void>`.
- Update existing `renderApp` call assertions: `renderApp('session-1')` → `renderApp({ sessionId: 'session-1' })`.
- Update no-args TUI test: `renderApp(undefined)` → `renderApp({})`.
- Add: `resume` with no `sessionId` → `renderApp({ initialScreen: SCREEN.SESSION_MANAGER })`, no `loadSession` call.

**`src/tui.test.tsx`**

- Update `renderApp()` call → `renderApp({})` (or keep no-arg if default param is used).
- Verify `App` receives correct props for both `sessionId` and `initialScreen` paths.

**`src/components/App/hooks/useScreenRouter.test.ts`** _(if it exists)_

- Add a test for `initialScreen: SCREEN.SESSION_MANAGER` starting on that screen.
@remarkablemark remarkablemark self-assigned this Jun 4, 2026
@remarkablemark remarkablemark added the enhancement New feature or request label Jun 4, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/cli.ts 100.00% <100.00%> (ø)
src/components/App/App.tsx 100.00% <100.00%> (ø)
src/components/App/hooks/useScreenRouter.ts 100.00% <100.00%> (ø)
src/tui.tsx 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@remarkablemark remarkablemark enabled auto-merge June 4, 2026 19:07
@remarkablemark remarkablemark merged commit 15fdedc into master Jun 4, 2026
16 checks passed
@remarkablemark remarkablemark deleted the feat/resume branch June 4, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant