Repository navigation
Keep mobile chat GUI cached during reconnect #7064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 20 commits
6a9a45b
deed98d
80776fc
c903d7f
7647783
ae96779
d04fd04
98d2deb
7b6c129
8bc77c6
b1a88d0
ab4dafe
6cdb66b
75fbba8
c97f40f
7714488
58b69e9
020ff85
e1d70f1
ff0a90f
b185e49
09fb2b7
167437a
51b17a7
1aa5a33
5680f3f
7d9712b
d0d7e06
931e52c
756f6ab
7516c10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,23 @@ internal import CmuxMobileRPC | |
| /// Agent-chat access for the shell store: surfaces sessions and a | ||
| /// conversation event source bound to the current Mac connection. | ||
| extension MobileShellComposite { | ||
| /// Cached chat-capable sessions for a workspace, from the last authoritative | ||
| /// pull or push-derived session list. Used by workspace detail views before | ||
| /// their per-view refresh task has reconnected. | ||
| public func cachedChatSessions(workspaceID: String) -> [ChatSessionDescriptor] { | ||
| chatSessionSnapshotsByWorkspaceID[workspaceID] ?? [] | ||
| } | ||
|
|
||
| /// Replaces the cached chat-session snapshot for a workspace. Call only when | ||
| /// data came from an authoritative pull or from the live session event stream, | ||
| /// not when the transport is unavailable. | ||
| public func rememberChatSessions( | ||
| _ sessions: [ChatSessionDescriptor], | ||
| workspaceID: String | ||
| ) { | ||
| chatSessionSnapshotsByWorkspaceID[workspaceID] = sessions | ||
| } | ||
|
|
||
| /// A chat event source over the current connection, or `nil` when not | ||
| /// connected. Construct one ``ChatConversationStore`` per opened | ||
| /// conversation from this. | ||
|
|
@@ -22,6 +39,23 @@ extension MobileShellComposite { | |
| return (try? await source.sessions(workspaceID: workspaceID)) ?? [] | ||
| } | ||
|
|
||
| /// Returns whether a chat-session list failure means the connected Mac does | ||
| /// not support chat RPCs, rather than a transient transport failure. | ||
| public func chatSessionListFailureMeansUnsupported(_ error: any Error) -> Bool { | ||
| guard case let MobileShellConnectionError.rpcError(code, message) = error else { | ||
| return false | ||
| } | ||
| let normalizedCode = code?.trimmingCharacters(in: .whitespacesAndNewlines).lowercased() | ||
| let normalizedMessage = message.trimmingCharacters(in: .whitespacesAndNewlines).lowercased() | ||
| if let normalizedCode, | ||
| ["method_not_found", "not_found", "unknown_method", "unsupported_method"].contains(normalizedCode) { | ||
| return true | ||
| } | ||
| return normalizedMessage.contains("unknown method") | ||
| || normalizedMessage.contains("method not found") | ||
| || normalizedMessage.contains("unsupported method") | ||
| } | ||
|
Comment on lines
+44
to
+57
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the Mac returns an The code-based branch ( |
||
|
|
||
| /// The connected RPC client, for chat use only. | ||
| private func chatRPCClient() -> MobileCoreRPCClient? { | ||
| guard connectionState == .connected else { return nil } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.