fix(flowchat): report an unreadable session permission mode - #3169
Merged
nonoqing merged 1 commit intoSep 21, 2026
Merged
Conversation
A Session whose permission mode cannot be read falls back to the user-level default, and that fallback was displayed as if the Session had chosen it. Together with a generic switch failure it made a Session held open for writing by another OpenBitFun instance look like a lost setting. Mark the fallback as unread instead of passing it off as the Session's own selection: report it once per Session, name the cause when the host reports session_in_use, keep the permission menu from marking an unverified mode, and point the switch failure at the other instance. Stop wrapping session_in_use and outcome_unknown in the selector-update prose so their stable error codes reach the frontend, which recognizes those two by message prefix. Co-authored-by: bitfun-ai <318544290+bitfun-ai@users.noreply.github.com>
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.
Summary
A Session whose permission mode cannot be read now says so, and a failed switch names the cause instead of reporting a generic failure.
Fixes #
Type and Areas
Type: bug fix / regression fix.
Areas: desktop/Tauri, web UI.
Motivation / Impact
A user upgraded from 1.0.0 to 1.0.1, opened a Session created on 1.0.0, and saw its permission mode change to "Ask" even though the Session had been set to full access. Switching it back failed with a generic error, while a newly created Session switched normally. No setting was actually lost.
The real error was
session_in_use: Session is already open for writing: <session_id>— the previous OpenBitFun instance was still running and held the per-Session write lock. Three separate presentation defects turned that into a phantom setting loss:get_session_permission_modefailing is swallowed withsetSessionPermissionMode(null), so the control silently falls back to the user-level default (askin this case) and displays it as the Session's own selection.update_session_permission_modefailing reportschatInput.permissionMode.changeFailed, which says nothing about the cause or what to do.ensure_session_loaded_for_selector_updatewrapped the error asFailed to restore session before selector update: {error}, burying the stablesession_in_usecode that the frontend recognizes by message prefix.isSessionInUseErrortherefore returnedfalsefor this path.What changes for users:
session_in_use, the read and switch messages name the other instance and ask the user to close it.session_in_useandoutcome_unknownkeep their stable code prefix through the selector-update restore, so the frontend can tell them apart from a generic restore failure. Every other reason keeps theFailed to restore session before selector update:context.New user-facing keys:
changeFailedSessionInUse,unread,unreadSessionInUse,unreadTooltip,unreadMenuNotice(en-US, zh-CN, zh-TW).No behavior change to which mode a Session actually runs with: the fallback remains the narrow default, never a wider mode than the Session uses.
Verification
pnpm run type-check:web— passed.pnpm run i18n:audit— passed with 0 warnings.pnpm run fmt:rs— formatted.cargo test -p openbitfun-desktop selector_update_restore_error— 3 passed (new tests pin the preservedsession_in_use/outcome_unknownprefixes and the retained context for other reasons).pnpm vitest run src/flow_chat/components/ChatInputWorkspaceStrip.test.tsx— 31 passed, including a new case that mounts the unread state and asserts no mode radio is marked plus the menu notice is present.pnpm vitest run src/flow_chat/components/ChatInputWorkspaceStripLayout.test.ts src/flow_chat/components/chatInputRegistration.test.ts src/flow_chat/components/overlayClippingContract.test.ts src/infrastructure/api/errors/TauriCommandError.test.ts— 71 passed.npx eslint src/flow_chat/components/ChatInput.tsx src/flow_chat/components/ChatInputWorkspaceStrip.tsx— 0 errors.Remote scenarios: not exercised. The permission selector reads and writes through the desktop host only; the change does not add a new command, wire field, or persisted shape.
Upgrade compatibility: no persisted shape changes. The error message shape changes only for the two stable codes, which the frontend recognizes by prefix; older frontends still see a readable message.
Reviewer Notes
isSessionInUseErrorhelper from@/infrastructure/api/errors/TauriCommandErrorrather than adding a second string match; the Rust test pins the prefix shape it depends on.get_session_permission_mode,update_session_permission_mode,update_active_turn_permission_mode). Other commands that flatten error codes are untouched.Checklist