[codex] Fix scheduled state leaking into new chats#1018
Merged
Conversation
Manual chats should always start from chat defaults, even when the reused window session previously displayed a scheduled run. Resetting the origin metadata with the session identity prevents sidebar filtering and badges from inheriting schedule state. Add regression coverage for resetting a scheduled session and saving the first manual turn afterward.
RaajeevChandran
approved these changes
May 4, 2026
Contributor
Author
|
@tpae PR-specific CI note / next step: This PR is currently failing Required next step: merge the green base fix in #1025 first, then I will rebase/rerun this PR and update the status. Why: this PR's diff is unrelated to provider refresh/model picker caching, so debugging it before #1025 lands would chase the wrong failure. |
tpae
approved these changes
May 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Business rationale
New chats created from the chat UI must be classified as manual chats. When schedule metadata leaks into those chats, users lose trust in sidebar filters and cannot reliably distinguish scheduled automation from manually started work.
Coding rationale
ChatWindowState.startNewChat()reuses the currentChatSessioninstance and callsreset(for:).ChatSession.reset()cleared content and identity but left source metadata intact, so the first save of the next manual chat reused.schedule,externalSessionKey, and dispatch metadata from the previously selected session. Resetting these fields besidesessionIdkeeps the session origin contract local to the session reset boundary.What changed
source,sourcePluginId,externalSessionKey, anddispatchTaskIdto manual-chat defaults inChatSession.reset().Validation
git fetch origin main && git rebase origin/mainswift build --package-path Packages/OsaurusCoreswift build -c release --package-path Packages/OsaurusCoreswift test --package-path Packages/OsaurusCorexcrun swift-format lint --configuration .swift-format Packages/OsaurusCore/Views/Chat/ChatView.swift Packages/OsaurusCore/Tests/Chat/SessionSourcePersistenceTests.swiftswiftlint lint Packages/OsaurusCore/Views/Chat/ChatView.swift Packages/OsaurusCore/Tests/Chat/SessionSourcePersistenceTests.swiftgit diff --checkNon-scope
ChatView.swiftoutside the touched hunk.Residual risks
The fix relies on all UI-created manual chats flowing through
ChatSession.reset(). Programmatic dispatch paths still explicitly set their own source metadata throughExecutionContext.