feat(session): add /session-persist to toggle auto-resume on launch (#2238)#2243
Conversation
|
@codex review |
There was a problem hiding this comment.
💡 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"), |
There was a problem hiding this comment.
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 👍 / 👎.
|
@esengine 新 PR,CI 4/4 ✅,等 Codex 审完就彻底干净了。麻烦有空看一下,感谢 🙏 |
ae1a700 to
4118c05
Compare
|
Fixed in @codex review |
There was a problem hiding this comment.
💡 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".
| 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; |
There was a problem hiding this comment.
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 👍 / 👎.
| 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; |
There was a problem hiding this comment.
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
4118c05 to
e767918
Compare
|
Fixed both P2s in
@codex review |
There was a problem hiding this comment.
💡 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".
| mcpPrefix: opts.mcpPrefix, | ||
| forceResume: continueOpts.forceResume, | ||
| forceNew: !!opts.new, | ||
| forceNew: !!opts.new || !!defaults.forceNew, |
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Reviewed the full diff. Clean, well-scoped implementation of #2238:
autoResumeSession?: booleanadded to config; default (undefined/true) preserves existing auto-resume behavior —!== falsechecks throughout keep it backward-compatible.resolveSession()returnsundefinedwhenautoResume === falseso launches no longer fall back to the "default" session;code.tsxmirrors this for the per-directorycode-*session.- Explicit
-r/--resumeand--newstill 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.
问题
关闭 #2238。每次启动
reasonix code/reasonix chat都会自动恢复上次未归档的对话,用户无法方便地改变这个行为。尤其是让其他 agent 调用 reasonix 时,每次都会累积上下文,导致效果变差。方案
添加
config.autoResumeSession字段(默认true保持现有行为)和/session-persist슬래시 커맨드:配置持久化到
~/.reasonix/config.json,也可以手动设置:{ "autoResumeSession": false }-c/--continue和--session <name>等显式标志