Skip to content

Commit 6a4e7cd

Browse files
committed
Show agent restart prompt after CLI registration
1 parent 19568ab commit 6a4e7cd

5 files changed

Lines changed: 38 additions & 0 deletions

File tree

Sources/App/Services/UISmokeRunner.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ enum UISmokeRunner {
167167
let restartNotice = AgentRestartNotice.afterCLIRegistration(cliName: "hcloud", shimInstalled: true)
168168
try expect(restartNotice.contains("Restart Codex"), "register success notice names the agent restart action")
169169
try expect(AgentRestartNotice.requiresManualDismiss(restartNotice), "agent restart notice stays visible until the user dismisses it")
170+
let modalMessage = AgentRestartNotice.modalMessageAfterCLIRegistration(cliName: "hcloud")
171+
try expect(modalMessage.contains("Codex, Claude Code"), "register modal names common agent apps")
172+
try expect(modalMessage.contains("Cmd+Q"), "register modal tells users to fully quit agent apps")
170173
try expect(
171174
ExecutablePathSelection.inferredCLIName(from: URL(fileURLWithPath: "/opt/homebrew/bin/hcloud")) == "hcloud",
172175
"register CLI infers a CLI name from the selected executable path"
@@ -236,6 +239,8 @@ enum UISmokeRunner {
236239
)
237240
try expect(registered, "valid direct register submit succeeds")
238241
try expect(store.successMessage == AgentRestartNotice.afterCLIRegistration(cliName: "hcloud", shimInstalled: false), "successful registration tells the user to restart already-running agent apps")
242+
try expect(store.agentRestartPrompt?.title == AgentRestartNotice.restartPromptTitle, "successful registration opens a modal restart prompt")
243+
try expect(store.agentRestartPrompt?.message == AgentRestartNotice.modalMessageAfterCLIRegistration(cliName: "hcloud"), "modal restart prompt uses concise Cmd+Q guidance")
239244
}
240245

241246
private static func testCLIShimInstallerEnvironment() throws {

Sources/App/Stores/ControlPlaneStore.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ struct APISessionPresentation: Equatable {
8484
var token: String
8585
}
8686

87+
struct AgentRestartPrompt: Identifiable, Equatable {
88+
let id = UUID()
89+
var cliName: String
90+
91+
var title: String {
92+
AgentRestartNotice.restartPromptTitle
93+
}
94+
95+
var message: String {
96+
AgentRestartNotice.modalMessageAfterCLIRegistration(cliName: cliName)
97+
}
98+
}
99+
87100
@Observable
88101
@MainActor
89102
final class ControlPlaneStore {
@@ -115,6 +128,7 @@ final class ControlPlaneStore {
115128
var showingBitwardenBindingEditor = false
116129
var exportedAudit: String?
117130
var oneTimeAPISession: APISessionPresentation?
131+
var agentRestartPrompt: AgentRestartPrompt?
118132
var availableUpdate: AppUpdateRelease?
119133
var isCheckingForUpdates = false
120134
var lastUpdateCheck: Date?
@@ -555,6 +569,7 @@ final class ControlPlaneStore {
555569
let summary = try await client.registerCLI(ControlPlaneCommandLineToolRegistrationRequest(name: normalizedName, targetPath: normalizedTargetPath, environmentSecrets: normalizedSecrets))
556570
selectedCLI = summary.name
557571
showingRegisterCLI = false
572+
agentRestartPrompt = AgentRestartPrompt(cliName: summary.name)
558573
if installShim {
559574
do {
560575
_ = try CLIShimInstaller.install(name: summary.name)

Sources/App/Views/ContentView.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ struct ContentView: View {
1919
.sheet(isPresented: $store.showingBitwardenBindingEditor) {
2020
BitwardenBindingEditor(store: store)
2121
}
22+
.alert(item: $store.agentRestartPrompt) { prompt in
23+
Alert(
24+
title: Text(prompt.title),
25+
message: Text(prompt.message),
26+
dismissButton: .default(Text("OK")) {
27+
store.agentRestartPrompt = nil
28+
}
29+
)
30+
}
2231
}
2332

2433
@ViewBuilder

Sources/Broker/AgentRestartNotice.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import Foundation
22

33
public enum AgentRestartNotice {
4+
public static let restartPromptTitle = "Restart agent apps"
5+
46
public static func afterCLIRegistration(cliName: String, shimInstalled: Bool) -> String {
57
if shimInstalled {
68
return "CLI registered and shim installed. Make sure the shims folder is on PATH. Restart Codex or any other already-running agent app before using normal \(cliName) commands from that app so it reloads shell startup files and current Agentic Secrets state."
79
}
810
return "CLI registered. Restart Codex or any other already-running agent app before using \(cliName) from that app so it refreshes current Agentic Secrets state."
911
}
1012

13+
public static func modalMessageAfterCLIRegistration(cliName: String) -> String {
14+
"CLI registration is saved. Quit and reopen Codex, Claude Code, or the agent app that will use \(cliName). Use Cmd+Q so the app fully reloads PATH and Agentic Secrets state."
15+
}
16+
1117
public static func afterShimPathConfiguration(cliName: String) -> String {
1218
"Shell PATH configured for future sessions. Restart Codex or any other already-running agent app before using \(cliName) from that app so it reloads shell startup files and sees the Agentic Secrets shim."
1319
}

Sources/ContractTests/main.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ func runContracts() throws {
109109
let restartNotice = AgentRestartNotice.afterCLIRegistration(cliName: "hcloud", shimInstalled: true)
110110
try expect(restartNotice.contains("Restart Codex"), "CLI registration success notice must tell agent users to restart")
111111
try expect(AgentRestartNotice.requiresManualDismiss(restartNotice), "agent restart notices must remain visible until dismissed")
112+
let restartPromptMessage = AgentRestartNotice.modalMessageAfterCLIRegistration(cliName: "hcloud")
113+
try expect(restartPromptMessage.contains("Codex, Claude Code"), "CLI registration modal guidance must name common agent apps")
114+
try expect(restartPromptMessage.contains("Cmd+Q"), "CLI registration modal guidance must tell users to fully quit agent apps")
112115

113116
let classifier = CommandClassifier()
114117
let hcloudRead = classifier.classify(executableName: "hcloud", arguments: ["server", "list"], observedVersion: "1.52.0")

0 commit comments

Comments
 (0)