Repository navigation
fix(cloud): keep renamed workspace projections in lockstep #11929
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 10 commits
397e299
72e6bca
70e026a
beab98c
9f9532d
89cae58
8c4e519
0238b4e
467e457
09707e4
4acdf8f
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 |
|---|---|---|
|
|
@@ -61958,6 +61958,176 @@ | |
| } | ||
| } | ||
| }, | ||
| "cloudTree.error.renameWorkspaceEmpty": { | ||
| "extractionState": "manual", | ||
| "localizations": { | ||
| "en": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "A cloud workspace name cannot be empty." | ||
| } | ||
| }, | ||
| "ja": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "クラウドワークスペース名を空にすることはできません。" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "cloudTree.error.renameLocalUnsupported": { | ||
| "extractionState": "manual", | ||
| "localizations": { | ||
| "en": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "Only cloud workspaces can be renamed through this path." | ||
| } | ||
| }, | ||
| "ja": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "この経路で名前を変更できるのはクラウドワークスペースのみです。" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "cloudTree.error.renameWorkspaceMissing": { | ||
| "extractionState": "manual", | ||
| "localizations": { | ||
| "en": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "workspace %@ on %@" | ||
| } | ||
| }, | ||
| "ja": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "%@(%@上のワークスペース)" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "cloudTree.error.snapshotOnlyRename": { | ||
| "extractionState": "manual", | ||
| "localizations": { | ||
| "en": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "This machine uses an older cmux-tui protocol and cannot safely rename a workspace. Refresh and retry." | ||
|
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. 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- localization entries ---'
sed -n '61945,62145p' Resources/Localizable.xcstrings
printf '%s\n' '--- direct key references ---'
rg -n -C 3 'cloudTree\.error\.(renameWorkspaceMissing|invalidSnapshot|renameReceipt|.*)' --glob '!Resources/Localizable.xcstrings' .Repository: manaflow-ai/cmux Length of output: 15315 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- relevant provider error mapping ---'
sed -n '165,240p' Sources/Surfaces/CmuxTuiSurfaceProviders.swift
printf '%s\n' '--- rename write-through flow ---'
sed -n '1,145p' Sources/Surfaces/CloudWorkspaceRenameWriteThrough.swift
printf '%s\n' '--- catalog rename contract ---'
sed -n '270,335p' Sources/Surfaces/SurfaceCatalog.swift
printf '%s\n' '--- error presentation callers ---'
rg -n -C 4 'SurfaceCatalogError|renameWorkspace|errorMessage|reject\(workspace' Sources/Surfaces Sources/CloudRepository: manaflow-ai/cmux Length of output: 50372 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- rename failure notification producer and consumer ---'
rg -n -C 8 'didFailNotification|errorText\(' Sources
printf '%s\n' '--- rejection implementation ---'
sed -n '135,215p' Sources/Surfaces/CloudWorkspaceRenameWriteThrough.swift
printf '%s\n' '--- provider error conversion ---'
rg -n -C 6 'func errorText|CloudMachineLink\.errorText|ProviderError' Sources/Surfaces Sources/CloudRepository: manaflow-ai/cmux Length of output: 50372 🏁 Script executed: #!/bin/bash
set -e
printf '%s\n' '--- tree error display ---'
rg -n -C 6 'treeErrorDescription|errorDescription' Sources/Cloud/MachinesPanelViewModel.swift Sources/Cloud --glob '*.swift'
printf '%s\n' '--- panel error rendering ---'
rg -n -C 8 'treeErrorDescription' SourcesRepository: manaflow-ai/cmux Length of output: 33626 Information Disclosure (CWE-200): Exposure of Sensitive Information to an Unauthorized Actor Reachability: External · Exploitability: Moderate Remove implementation terms from cloud workspace errors. These strings are shown directly in the Machines panel. Replace 🤖 Prompt for AI AgentsSource: Path instructions |
||
| } | ||
| }, | ||
| "ja": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "このマシンは古い cmux-tui プロトコルを使用しているため、安全にワークスペース名を変更できません。更新して再試行してください。" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "cloudTree.error.invalidSnapshot": { | ||
| "extractionState": "manual", | ||
| "localizations": { | ||
| "en": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "cmux-tui returned an invalid session snapshot for %@. Refresh and retry." | ||
| } | ||
| }, | ||
| "ja": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "cmux-tui が %@ の無効なセッションスナップショットを返しました。更新して再試行してください。" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "cloudTree.error.invalidRenameReceipt": { | ||
| "extractionState": "manual", | ||
| "localizations": { | ||
| "en": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "The cloud rename receipt was invalid. Refresh and retry." | ||
| } | ||
| }, | ||
| "ja": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "クラウドの名称変更レシートが無効です。更新して再試行してください。" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "cloudTree.error.renameRevisionConflict": { | ||
| "extractionState": "manual", | ||
| "localizations": { | ||
| "en": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "This cloud workspace changed elsewhere. Refresh and retry so a newer name is not overwritten." | ||
| } | ||
| }, | ||
| "ja": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "このクラウドワークスペースは別の場所で変更されました。新しい名前を上書きしないよう更新して再試行してください。" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "cloudTree.error.renameAmbiguous": { | ||
| "extractionState": "manual", | ||
| "localizations": { | ||
| "en": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "This workspace maps to more than one cloud workspace. Rename it from the Cloud machine row." | ||
| } | ||
| }, | ||
| "ja": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "このワークスペースは複数のクラウドワークスペースに対応しています。Cloud マシンの行から名前を変更してください。" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "cloudTree.error.renameUnavailable": { | ||
| "extractionState": "manual", | ||
| "localizations": { | ||
| "en": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "This cloud workspace is not connected. Refresh the machine and retry." | ||
| } | ||
| }, | ||
| "ja": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "このクラウドワークスペースは接続されていません。マシンを更新して再試行してください。" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "cloudTree.error.noSelectedWorkspace": { | ||
| "extractionState": "manual", | ||
| "localizations": { | ||
| "en": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "Select a local workspace and retry." | ||
| } | ||
| }, | ||
| "ja": { | ||
| "stringUnit": { | ||
| "state": "translated", | ||
| "value": "ローカルワークスペースを選択して、もう一度お試しください。" | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "cloudTree.rename.confirm": { | ||
| "extractionState": "manual", | ||
| "localizations": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -442,6 +442,7 @@ final class MachinesPanelViewModel: ObservableObject { | |
| private var authSignOutObserver: NSObjectProtocol? | ||
| private var treeChangeObserver: NSObjectProtocol? | ||
| private var createChangeObserver: NSObjectProtocol? | ||
| private var renameFailureObserver: NSObjectProtocol? | ||
| private var treeTask: Task<Void, Never>? | ||
| private static let statsInterval: Duration = .seconds(20) | ||
|
|
||
|
|
@@ -476,6 +477,17 @@ final class MachinesPanelViewModel: ObservableObject { | |
| // Delivered on the main queue (`queue: .main`), which is the main actor. | ||
| MainActor.assumeIsolated { self?.scheduleCatalogRead() } | ||
| } | ||
| renameFailureObserver = NotificationCenter.default.addObserver( | ||
| forName: CloudWorkspaceRenameWriteThrough.didFailNotification, | ||
| object: nil, | ||
| queue: .main | ||
| ) { [weak self] notification in | ||
| let message = notification.userInfo?["message"] as? String | ||
| MainActor.assumeIsolated { | ||
| guard let self, let message, !message.isEmpty else { return } | ||
| self.treeErrorDescription = message | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /// Catalog changes arrive in bursts (a link snapshot upserts dozens of resources, a | ||
|
|
@@ -519,6 +531,9 @@ final class MachinesPanelViewModel: ObservableObject { | |
| if let createChangeObserver { | ||
| NotificationCenter.default.removeObserver(createChangeObserver) | ||
| } | ||
| if let renameFailureObserver { | ||
| NotificationCenter.default.removeObserver(renameFailureObserver) | ||
| } | ||
| } | ||
|
|
||
| /// Mirrors the coordinator's rows. A completion also re-reads the fleet so | ||
|
|
@@ -543,6 +558,7 @@ final class MachinesPanelViewModel: ObservableObject { | |
| /// Publishes the catalog's current value and the local workspace list. Cheap | ||
| /// (a value read), so every change notification may call it. | ||
| func readCatalog() { | ||
| CloudWorkspaceRenameWriteThrough.reconcileRemoteProjections(catalog: SurfaceCatalog.shared) | ||
|
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. 📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift Move projection reconciliation out of the panel read path to a single owner.
Two consequences follow:
Drive reconciliation once from the place that accepts a new cloud graph (the catalog's accepted-snapshot path in ♻️ Proposed change func readCatalog() {
- CloudWorkspaceRenameWriteThrough.reconcileRemoteProjections(catalog: SurfaceCatalog.shared)
catalog = SurfaceCatalog.shared.snapshot
localWorkspaces = localWorkspacesProvider()
}Invoke As per coding guidelines: "Do not wire the same behavior separately through multiple surfaces; use one shared action path." 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
| catalog = SurfaceCatalog.shared.snapshot | ||
| localWorkspaces = localWorkspacesProvider() | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Treat the post-create
workspace.cloud_vm_bindas best effort.surface.new_terminalcreates and projects the remote terminal before this bind. A bind error makessendV2throw, so the open reports failure while the remote terminal can remain running. The catch closes only a newly created local workspace; an existing target receives no cleanup. The first bind already records the VM, andCloudWorkspaceRenameWriteThroughcan recoverremote_workspace_idfrom the projection. Continue the open when this metadata bind fails, then close the placeholder and return the successful result.🤖 Prompt for AI Agents