Skip to content

feat(session): add /session-persist to toggle auto-resume on launch (#2238)#2243

Merged
esengine merged 1 commit into
esengine:mainfrom
nianyi778:fix/session-auto-resume-config
May 29, 2026
Merged

feat(session): add /session-persist to toggle auto-resume on launch (#2238)#2243
esengine merged 1 commit into
esengine:mainfrom
nianyi778:fix/session-auto-resume-config

Conversation

@nianyi778

Copy link
Copy Markdown

问题

关闭 #2238。每次启动 reasonix code / reasonix chat 都会自动恢复上次未归档的对话,用户无法方便地改变这个行为。尤其是让其他 agent 调用 reasonix 时,每次都会累积上下文,导致效果变差。

方案

添加 config.autoResumeSession 字段(默认 true 保持现有行为)和 /session-persist 슬래시 커맨드:

/session-persist off   # 之后每次启动开启新会话
/session-persist on    # 恢复默认行为(启动时恢复上次会话)
/session-persist       # 查看当前设置

配置持久化到 ~/.reasonix/config.json,也可以手动设置:

{ "autoResumeSession": false }
  • 不影响 -c/--continue--session <name> 等显式标志
  • i18n:EN + zh-CN

@nianyi778

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 67d3468531

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

/* disk full / perms — runtime change still noted */
}
return {
info: next ? t("handlers.sessions.persistSetOn") : t("handlers.sessions.persistSetOff"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor session-persist for code launches

When users run /session-persist off from a code session, this message promises that the next launch starts fresh, but reasonix code never reads autoResumeSession: src/cli/commands/code.tsx still always passes session = code-${basename} into chatCommand, and the unchanged memory.resolveSession() then auto-selects the existing prefixed session when forceResume is false. I checked the code launch path in src/cli/index.ts/src/cli/commands/code.tsx; only the chat path uses the new resolveDefaults(...cfg.autoResumeSession), so the new toggle does not work for the reasonix code case described by the feature.

Useful? React with 👍 / 👎.

@nianyi778

Copy link
Copy Markdown
Author

@esengine 新 PR,CI 4/4 ✅,等 Codex 审完就彻底干净了。麻烦有空看一下,感谢 🙏

@nianyi778 nianyi778 force-pushed the fix/session-auto-resume-config branch 2 times, most recently from ae1a700 to 4118c05 Compare May 29, 2026 07:35
@nianyi778

Copy link
Copy Markdown
Author

Fixed in 4118c051. reasonix code now also respects autoResumeSession: if false, it passes session: undefined instead of the per-directory session name, so each launch starts fresh. The --no-session flag still overrides unconditionally.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4118c0519b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/resolve.ts
if (typeof configSession === "string" && configSession.length > 0) return configSession;
// When autoResumeSession is explicitly false, don't default to "default" session
// so each launch starts fresh instead of resuming the previous conversation (#2238).
if (autoResume === false) return undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bypass the session picker when auto-resume is off

When autoResumeSession is false and the workspace already has saved sessions, returning undefined here does not make reasonix chat start fresh: chatCommand still treats !opts.session as a reason to open the session picker (src/cli/commands/chat.tsx:360-361). In that common case /session-persist off blocks on the picker instead of launching a fresh ephemeral chat, so the new setting does not deliver its documented behavior unless there are no saved sessions.

Useful? React with 👍 / 👎.

Comment thread src/cli/commands/code.tsx
const session = opts.noSession ? undefined : `code-${sanitizeName(basename(rootDir))}`;
// Per-directory session unless --no-session or autoResumeSession:false in config (#2238).
const autoResume = opts.noSession ? false : readConfig().autoResumeSession !== false;
const session = autoResume ? `code-${sanitizeName(basename(rootDir))}` : undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor explicit code resume when persistence is off

When autoResumeSession is disabled, reasonix code -r (and bare reasonix -c, which passes forceResume) now sends session: undefined into chatCommand; the downstream resolveSession(opts.session, ..., opts.forceResume) has no base code-<dir> name to resolve, so it cannot load the prior code session. This makes an explicit resume flag ineffective precisely after users opt into fresh launches by default; only --no-session should force the session name to be absent.

Useful? React with 👍 / 👎.

…sengine#2238)

Users who want a fresh session each time (e.g. agents calling reasonix
in loops) had to manually pass --no-session every invocation. Add:

- config.autoResumeSession (default true = existing behaviour)
- /session-persist on|off slash command to toggle and persist the setting
- resolveSession() respects the new flag: when false, skips the 'default'
  session fallback so each launch starts with a new timestamped session
@nianyi778 nianyi778 force-pushed the fix/session-auto-resume-config branch from 4118c05 to e767918 Compare May 29, 2026 07:47
@nianyi778

Copy link
Copy Markdown
Author

Fixed both P2s in e7679187:

  1. Session picker bypass: resolveDefaults now returns forceNew: true when autoResumeSession:false and no explicit --session flag is set. chatCommand receives this and skips the session picker — same as --new flag.

  2. Explicit resume when persistence is off: code.tsx now checks opts.forceResume || opts.forceNew before consulting autoResumeSession, so reasonix code -r still loads the prior session even when the default launch behaviour is set to fresh.

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e7679187d8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli/index.ts
mcpPrefix: opts.mcpPrefix,
forceResume: continueOpts.forceResume,
forceNew: !!opts.new,
forceNew: !!opts.new || !!defaults.forceNew,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip the picker when auto-resume is disabled

When autoResumeSession:false is set and there is at least one saved session, this passes forceNew into chatCommand, but the picker is still opened because chatCommand computes showPicker as !opts.session && !opts.forceResume && listSessionsForWorkspace(...) and never checks opts.forceNew. In that common case reasonix chat still prompts the user to resume an old session instead of honoring the new “start fresh on launch” setting.

Useful? React with 👍 / 👎.

@esengine esengine left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full diff. Clean, well-scoped implementation of #2238:

  • autoResumeSession?: boolean added to config; default (undefined/true) preserves existing auto-resume behavior — !== false checks throughout keep it backward-compatible.
  • resolveSession() returns undefined when autoResume === false so launches no longer fall back to the "default" session; code.tsx mirrors this for the per-directory code-* session.
  • Explicit -r/--resume and --new still override the toggle, so manual resume/fresh-start always works.
  • /session-persist <on|off> handler persists to config.json with a graceful try/catch on write failure; bare invocation reports current state.
  • i18n parity present for EN + zh-CN (descriptions + status strings).
  • Slash-command count tests updated 47 → 48 to pin the new command.

CI green (build ubuntu+windows, CodeQL). LGTM.

@esengine esengine merged commit c0f2320 into esengine:main May 29, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants