Skip to content

[FEATURE]: Add --restore-last-session CLI flag (and/or config option) to resume the last session on startup #40661

Closed as duplicate

Description

@twam

Problem

When reopening opencode in a project directory, there is no way to automatically resume the last session. You have to manually navigate to the session list and pick it each time.

Proposed Solution

Add a --restore-last-session CLI flag that resumes the most recently active session for the current working directory on startup:

opencode --restore-last-session

Optionally, expose the same behaviour as a config option so it can be set permanently:

{
  "$schema": "https://opencode.ai/config.json",
  "restore_last_session": true
}

When enabled, opencode would look up the most recent session associated with the current directory and open it directly, skipping the new-session default.

Alternatives Considered

  • Manually selecting a session via the session list on each launch — works but requires extra steps every time.
  • Wrapping the CLI in a shell alias that resolves the last session ID and passes it via a hypothetical --session <id> flag — fragile and depends on internal storage details.

Use Case

Useful for anyone who works on a single project at a time and wants to pick up exactly where they left off without extra navigation.

Activity

  1. github-actions commented on Aug 5, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your request differs meaningfully from #36134, please clarify the distinction in a comment there or in this issue.

  2. changed the title [-]Add `--restore-last-session` CLI flag (and/or config option) to resume the last session on startup[/-] [+][FEATURE]: Add `--restore-last-session` CLI flag (and/or config option) to resume the last session on startup[/+] on Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions