fix(swift-ios): honor environment task preferences
This commit is contained in:
10 files changed
+312
-27
No files matched your search
@@ -1671,7 +1671,23 @@ final class NativeFeatureClient: FeatureClient, FeatureDeviceManaging, FeaturePr
|
||||
self.latestServerConfig = config
|
||||
self.serverConfigsByEnvironmentID[activeClient.environment.id] = config
|
||||
case let .providerStatuses(providers):
|
||||
let config = ServerConfigSnapshot(providers: providers)
|
||||
let settings = self.serverConfigsByEnvironmentID[
|
||||
activeClient.environment.id
|
||||
]?.settings
|
||||
let config = ServerConfigSnapshot(
|
||||
providers: providers,
|
||||
settings: settings
|
||||
)
|
||||
self.latestServerConfig = config
|
||||
self.serverConfigsByEnvironmentID[activeClient.environment.id] = config
|
||||
case let .settingsUpdated(settings):
|
||||
let providers = self.serverConfigsByEnvironmentID[
|
||||
activeClient.environment.id
|
||||
]?.providers ?? self.latestServerConfig?.providers ?? []
|
||||
let config = ServerConfigSnapshot(
|
||||
providers: providers,
|
||||
settings: settings
|
||||
)
|
||||
self.latestServerConfig = config
|
||||
self.serverConfigsByEnvironmentID[activeClient.environment.id] = config
|
||||
case .unrelated:
|
||||
@@ -2673,6 +2689,22 @@ final class NativeFeatureClient: FeatureClient, FeatureDeviceManaging, FeaturePr
|
||||
config: serverConfigsByEnvironmentID[environment.id]
|
||||
)
|
||||
}
|
||||
let preferencesByEnvironment = environments.reduce(
|
||||
into: [String: FeatureEnvironmentPreferences]()
|
||||
) { preferences, environment in
|
||||
guard let serverSettings = serverConfigsByEnvironmentID[environment.id]?.settings else {
|
||||
return
|
||||
}
|
||||
let defaultWorkspaceMode: FeatureWorkspaceMode =
|
||||
switch serverSettings.defaultThreadEnvMode {
|
||||
case .local: .local
|
||||
case .worktree: .worktree
|
||||
}
|
||||
preferences[environment.id] = FeatureEnvironmentPreferences(
|
||||
defaultWorkspaceMode: defaultWorkspaceMode,
|
||||
newWorktreesStartFromOrigin: serverSettings.newWorktreesStartFromOrigin
|
||||
)
|
||||
}
|
||||
return FeatureSnapshot(
|
||||
connection: FeatureConnection(
|
||||
state: connectionState,
|
||||
@@ -2687,6 +2719,7 @@ final class NativeFeatureClient: FeatureClient, FeatureDeviceManaging, FeaturePr
|
||||
threads: threads,
|
||||
providers: providersByEnvironment[activeEnvironment.id] ?? [],
|
||||
providersByEnvironment: providersByEnvironment,
|
||||
preferencesByEnvironment: preferencesByEnvironment,
|
||||
settings: loadSettings()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -126,18 +126,49 @@ public struct ServerProviderSnapshot: Codable, Identifiable, Equatable, Sendable
|
||||
public let skills: [ServerProviderSkillSnapshot]?
|
||||
}
|
||||
|
||||
public enum ServerThreadEnvironmentMode: String, Codable, Equatable, Sendable {
|
||||
case local
|
||||
case worktree
|
||||
}
|
||||
|
||||
/// New-thread preferences are server-authoritative, so every saved environment
|
||||
/// can resolve these differently even though they share one mobile client.
|
||||
public struct ServerSettingsSnapshot: Codable, Equatable, Sendable {
|
||||
public let defaultThreadEnvMode: ServerThreadEnvironmentMode
|
||||
public let newWorktreesStartFromOrigin: Bool
|
||||
|
||||
public init(
|
||||
defaultThreadEnvMode: ServerThreadEnvironmentMode = .local,
|
||||
newWorktreesStartFromOrigin: Bool = true
|
||||
) {
|
||||
self.defaultThreadEnvMode = defaultThreadEnvMode
|
||||
self.newWorktreesStartFromOrigin = newWorktreesStartFromOrigin
|
||||
}
|
||||
}
|
||||
|
||||
/// Narrow decode view of the much larger `ServerConfig` RPC result.
|
||||
public struct ServerConfigSnapshot: Codable, Equatable, Sendable {
|
||||
public let providers: [ServerProviderSnapshot]
|
||||
public let settings: ServerSettingsSnapshot?
|
||||
|
||||
public init(
|
||||
providers: [ServerProviderSnapshot],
|
||||
settings: ServerSettingsSnapshot? = nil
|
||||
) {
|
||||
self.providers = providers
|
||||
self.settings = settings
|
||||
}
|
||||
}
|
||||
|
||||
public enum ServerConfigStreamEvent: Decodable, Sendable {
|
||||
case snapshot(ServerConfigSnapshot)
|
||||
case providerStatuses([ServerProviderSnapshot])
|
||||
case settingsUpdated(ServerSettingsSnapshot)
|
||||
case unrelated(type: String)
|
||||
|
||||
private enum CodingKeys: String, CodingKey { case type, config, payload }
|
||||
private struct ProviderPayload: Decodable { let providers: [ServerProviderSnapshot] }
|
||||
private struct SettingsPayload: Decodable { let settings: ServerSettingsSnapshot }
|
||||
|
||||
public init(from decoder: any Decoder) throws {
|
||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||
@@ -151,6 +182,10 @@ public enum ServerConfigStreamEvent: Decodable, Sendable {
|
||||
self = .providerStatuses(
|
||||
try container.decode(ProviderPayload.self, forKey: .payload).providers
|
||||
)
|
||||
case "settingsUpdated":
|
||||
self = .settingsUpdated(
|
||||
try container.decode(SettingsPayload.self, forKey: .payload).settings
|
||||
)
|
||||
default:
|
||||
self = .unrelated(type: type)
|
||||
}
|
||||
|
||||
@@ -136,17 +136,17 @@ public struct SettingsView: View {
|
||||
.lineLimit(1)
|
||||
}
|
||||
Spacer()
|
||||
if environment.isActive {
|
||||
Image(systemName: "checkmark")
|
||||
.font(.subheadline.weight(.bold))
|
||||
.foregroundStyle(.green)
|
||||
.accessibilityLabel("Active")
|
||||
}
|
||||
let status = environmentStatus(for: environment)
|
||||
Label(status.title, systemImage: status.symbol)
|
||||
.font(T3Typography.supportingStrong)
|
||||
.foregroundStyle(status.color)
|
||||
}
|
||||
}
|
||||
.swipeActions {
|
||||
Button("Remove", role: .destructive) {
|
||||
Button(role: .destructive) {
|
||||
removalTarget = environment
|
||||
} label: {
|
||||
Label("Remove", systemImage: "trash")
|
||||
}
|
||||
}
|
||||
.contextMenu {
|
||||
@@ -241,6 +241,46 @@ public struct SettingsView: View {
|
||||
model.snapshot.connection.endpoint ?? "No active server"
|
||||
}
|
||||
|
||||
private func environmentStatus(
|
||||
for environment: FeatureEnvironment
|
||||
) -> EnvironmentStatusPresentation {
|
||||
let state = environment.isActive
|
||||
? model.snapshot.connection.state
|
||||
: environment.connectionState
|
||||
switch state {
|
||||
case .connected where environment.isActive:
|
||||
return EnvironmentStatusPresentation(
|
||||
title: "Live",
|
||||
symbol: "dot.radiowaves.left.and.right",
|
||||
color: T3Colors.accent
|
||||
)
|
||||
case .connected:
|
||||
return EnvironmentStatusPresentation(
|
||||
title: "Available",
|
||||
symbol: "network",
|
||||
color: T3Colors.textSecondary
|
||||
)
|
||||
case .connecting, .reconnecting:
|
||||
return EnvironmentStatusPresentation(
|
||||
title: "Checking",
|
||||
symbol: "arrow.triangle.2.circlepath",
|
||||
color: T3Colors.warning
|
||||
)
|
||||
case .disconnected:
|
||||
return EnvironmentStatusPresentation(
|
||||
title: "Offline",
|
||||
symbol: "network.slash",
|
||||
color: T3Colors.danger
|
||||
)
|
||||
case nil:
|
||||
return EnvironmentStatusPresentation(
|
||||
title: "Saved",
|
||||
symbol: "bookmark",
|
||||
color: T3Colors.textTertiary
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func save() {
|
||||
isSaving = true
|
||||
@@ -253,3 +293,9 @@ public struct SettingsView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private struct EnvironmentStatusPresentation {
|
||||
let title: String
|
||||
let symbol: String
|
||||
let color: Color
|
||||
}
|
||||
@@ -47,6 +47,7 @@ public struct FeatureComposerWorkspaceDraft: Sendable, Equatable {
|
||||
/// this actor so image data is not repeatedly encoded for every keystroke.
|
||||
public actor FeatureComposerDraftStore {
|
||||
public static let shared = FeatureComposerDraftStore()
|
||||
private static let documentVersion = 2
|
||||
|
||||
private struct Document: Codable {
|
||||
let version: Int
|
||||
@@ -192,11 +193,23 @@ public actor FeatureComposerDraftStore {
|
||||
}
|
||||
let data = try Data(contentsOf: fileURL)
|
||||
let document = try JSONDecoder.t3.decode(Document.self, from: data)
|
||||
guard document.version == 1 else {
|
||||
guard document.version == 1 || document.version == Self.documentVersion else {
|
||||
throw CocoaError(.fileReadCorruptFile)
|
||||
}
|
||||
loadedDrafts = document.drafts
|
||||
return document.drafts
|
||||
var drafts = document.drafts
|
||||
if document.version == 1 {
|
||||
// Version 1 wrote resolved project/environment defaults into every
|
||||
// new-task draft. They were not necessarily user choices, so drop
|
||||
// only those derived fields while preserving text and attachments.
|
||||
for key in Array(drafts.keys) where key.contains(":new-task:") {
|
||||
drafts[key]?.selection = nil
|
||||
drafts[key]?.workspace = nil
|
||||
}
|
||||
drafts = drafts.filter { !$0.value.featureValue.isEmpty }
|
||||
try persist(drafts)
|
||||
}
|
||||
loadedDrafts = drafts
|
||||
return drafts
|
||||
}
|
||||
|
||||
private func persist(_ drafts: [String: PersistedDraft]) throws {
|
||||
@@ -204,7 +217,7 @@ public actor FeatureComposerDraftStore {
|
||||
at: fileURL.deletingLastPathComponent(),
|
||||
withIntermediateDirectories: true
|
||||
)
|
||||
let document = Document(version: 1, drafts: drafts)
|
||||
let document = Document(version: Self.documentVersion, drafts: drafts)
|
||||
try JSONEncoder.t3.encode(document).write(to: fileURL, options: .atomic)
|
||||
}
|
||||
}
|
||||
@@ -693,6 +693,19 @@ public struct FeatureSettings: Sendable, Equatable, Codable {
|
||||
}
|
||||
}
|
||||
|
||||
public struct FeatureEnvironmentPreferences: Sendable, Equatable, Codable {
|
||||
public var defaultWorkspaceMode: FeatureWorkspaceMode
|
||||
public var newWorktreesStartFromOrigin: Bool
|
||||
|
||||
public init(
|
||||
defaultWorkspaceMode: FeatureWorkspaceMode = .local,
|
||||
newWorktreesStartFromOrigin: Bool = true
|
||||
) {
|
||||
self.defaultWorkspaceMode = defaultWorkspaceMode
|
||||
self.newWorktreesStartFromOrigin = newWorktreesStartFromOrigin
|
||||
}
|
||||
}
|
||||
|
||||
public struct FeatureSnapshot: Sendable, Equatable, Codable {
|
||||
public var connection: FeatureConnection
|
||||
public var environments: [FeatureEnvironment]
|
||||
@@ -702,6 +715,8 @@ public struct FeatureSnapshot: Sendable, Equatable, Codable {
|
||||
/// Provider catalogues are environment-scoped. `providers` remains the
|
||||
/// active environment's catalogue for source-compatible consumers.
|
||||
public var providersByEnvironment: [String: [FeatureProvider]]?
|
||||
/// Server-authoritative new-thread defaults keyed by saved environment.
|
||||
public var preferencesByEnvironment: [String: FeatureEnvironmentPreferences]?
|
||||
public var settings: FeatureSettings
|
||||
|
||||
public init(
|
||||
@@ -711,6 +726,7 @@ public struct FeatureSnapshot: Sendable, Equatable, Codable {
|
||||
threads: [FeatureThread] = [],
|
||||
providers: [FeatureProvider] = [],
|
||||
providersByEnvironment: [String: [FeatureProvider]]? = nil,
|
||||
preferencesByEnvironment: [String: FeatureEnvironmentPreferences]? = nil,
|
||||
settings: FeatureSettings = .init()
|
||||
) {
|
||||
self.connection = connection
|
||||
@@ -719,6 +735,7 @@ public struct FeatureSnapshot: Sendable, Equatable, Codable {
|
||||
self.threads = threads
|
||||
self.providers = providers
|
||||
self.providersByEnvironment = providersByEnvironment
|
||||
self.preferencesByEnvironment = preferencesByEnvironment
|
||||
self.settings = settings
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +154,17 @@ enum DailyUXCreationContext {
|
||||
providers: providers(for: project, in: snapshot)
|
||||
)
|
||||
}
|
||||
|
||||
static func environmentPreferences(
|
||||
for project: FeatureProject?,
|
||||
in snapshot: FeatureSnapshot
|
||||
) -> FeatureEnvironmentPreferences {
|
||||
let environmentID = project?.environmentID
|
||||
?? snapshot.environments.first(where: \.isActive)?.id
|
||||
guard let environmentID else { return FeatureEnvironmentPreferences() }
|
||||
return snapshot.preferencesByEnvironment?[environmentID]
|
||||
?? FeatureEnvironmentPreferences()
|
||||
}
|
||||
}
|
||||
|
||||
struct DailyUXSidebarIndex {
|
||||
|
||||
@@ -10,8 +10,10 @@ public struct NewThreadView: View {
|
||||
@State private var projectID = ""
|
||||
@State private var prompt = ""
|
||||
@State private var selection: FeatureSelection?
|
||||
@State private var selectionIsExplicit = false
|
||||
@State private var attachments: [FeatureDraftAttachment] = []
|
||||
@State private var workspaceMode: FeatureWorkspaceMode = .local
|
||||
@State private var workspaceSelectionIsExplicit = false
|
||||
@State private var branches: [FeatureWorkspaceBranch] = []
|
||||
@State private var selectedBranch: FeatureWorkspaceBranch?
|
||||
@State private var startFromOrigin = true
|
||||
@@ -54,7 +56,7 @@ public struct NewThreadView: View {
|
||||
|
||||
FeatureComposerView(
|
||||
text: $prompt,
|
||||
selection: $selection,
|
||||
selection: selectionBinding,
|
||||
attachments: $attachments,
|
||||
providers: creationProviders,
|
||||
threadSelection: nil,
|
||||
@@ -77,6 +79,7 @@ public struct NewThreadView: View {
|
||||
.onChange(of: projectID) {
|
||||
restoredDraftProjectID = nil
|
||||
selection = initialSelection
|
||||
selectionIsExplicit = false
|
||||
resetWorkspaceSelection()
|
||||
}
|
||||
.onChange(of: prompt) { scheduleDraftSave() }
|
||||
@@ -97,6 +100,7 @@ public struct NewThreadView: View {
|
||||
isLoading: branchesLoading,
|
||||
loadFailed: branchLoadFailed,
|
||||
onSelect: { branch in
|
||||
workspaceSelectionIsExplicit = true
|
||||
selectedBranch = branch
|
||||
showingBranchPicker = false
|
||||
},
|
||||
@@ -230,6 +234,7 @@ public struct NewThreadView: View {
|
||||
.accessibilityValue(selectedBranch?.name ?? "Not selected")
|
||||
|
||||
Button {
|
||||
workspaceSelectionIsExplicit = true
|
||||
startFromOrigin.toggle()
|
||||
} label: {
|
||||
Label(
|
||||
@@ -297,6 +302,23 @@ public struct NewThreadView: View {
|
||||
)
|
||||
}
|
||||
|
||||
private var environmentPreferences: FeatureEnvironmentPreferences {
|
||||
DailyUXCreationContext.environmentPreferences(
|
||||
for: selectedProject,
|
||||
in: model.snapshot
|
||||
)
|
||||
}
|
||||
|
||||
private var selectionBinding: Binding<FeatureSelection?> {
|
||||
Binding(
|
||||
get: { selection },
|
||||
set: { value in
|
||||
selectionIsExplicit = true
|
||||
selection = value
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/// Model and provider capabilities belong to the project's environment,
|
||||
/// which may not be the connection currently selected in Settings.
|
||||
private var creationProviders: [FeatureProvider] {
|
||||
@@ -401,6 +423,9 @@ public struct NewThreadView: View {
|
||||
branches = []
|
||||
selectedBranch = nil
|
||||
branchLoadFailed = false
|
||||
workspaceMode = environmentPreferences.defaultWorkspaceMode
|
||||
startFromOrigin = environmentPreferences.newWorktreesStartFromOrigin
|
||||
workspaceSelectionIsExplicit = false
|
||||
}
|
||||
|
||||
private func selectProject(_ id: String) {
|
||||
@@ -410,6 +435,7 @@ public struct NewThreadView: View {
|
||||
}
|
||||
|
||||
private func setWorkspaceMode(_ mode: FeatureWorkspaceMode) {
|
||||
workspaceSelectionIsExplicit = true
|
||||
workspaceMode = mode
|
||||
selectedBranch = switch mode {
|
||||
case .local: NewTaskWorkspaceDefaults.localBranch(in: branches)
|
||||
@@ -461,21 +487,24 @@ public struct NewThreadView: View {
|
||||
guard !Task.isCancelled, projectID == requestedProjectID else { return }
|
||||
|
||||
let liveDraft = composerDraft
|
||||
let liveSelectionIsExplicit = selectionIsExplicit
|
||||
let liveWorkspaceSelectionIsExplicit = workspaceSelectionIsExplicit
|
||||
let restored = FeatureComposerDraftRestoration.merge(
|
||||
saved: saved,
|
||||
baseline: baseline,
|
||||
current: liveDraft,
|
||||
fallbackSelection: initialSelection,
|
||||
fallbackWorkspace: FeatureComposerWorkspaceDraft(
|
||||
mode: .local,
|
||||
mode: environmentPreferences.defaultWorkspaceMode,
|
||||
branch: nil,
|
||||
worktreePath: nil,
|
||||
startFromOrigin: true
|
||||
startFromOrigin: environmentPreferences.newWorktreesStartFromOrigin
|
||||
)
|
||||
)
|
||||
prompt = restored.text
|
||||
attachments = restored.attachments
|
||||
selection = restored.selection
|
||||
selectionIsExplicit = liveSelectionIsExplicit || saved?.selection != nil
|
||||
if let workspace = restored.workspace {
|
||||
workspaceMode = workspace.mode
|
||||
selectedBranch = workspace.branch.map {
|
||||
@@ -486,6 +515,8 @@ public struct NewThreadView: View {
|
||||
}
|
||||
startFromOrigin = workspace.startFromOrigin
|
||||
}
|
||||
workspaceSelectionIsExplicit = liveWorkspaceSelectionIsExplicit
|
||||
|| saved?.workspace != nil
|
||||
restoredDraftProjectID = requestedProjectID
|
||||
if liveDraft != baseline {
|
||||
scheduleDraftSave()
|
||||
@@ -502,18 +533,20 @@ public struct NewThreadView: View {
|
||||
FeatureComposerDraft(
|
||||
text: prompt,
|
||||
attachments: attachments,
|
||||
selection: selection,
|
||||
workspace: FeatureComposerWorkspaceDraft(
|
||||
mode: workspaceMode,
|
||||
branch: selectedBranch?.name,
|
||||
worktreePath: workspaceMode == .local
|
||||
? NewTaskWorkspaceDefaults.normalizedWorktreePath(
|
||||
for: selectedBranch,
|
||||
projectPath: selectedProject?.path ?? ""
|
||||
)
|
||||
: nil,
|
||||
startFromOrigin: startFromOrigin
|
||||
)
|
||||
selection: selectionIsExplicit ? selection : nil,
|
||||
workspace: workspaceSelectionIsExplicit
|
||||
? FeatureComposerWorkspaceDraft(
|
||||
mode: workspaceMode,
|
||||
branch: selectedBranch?.name,
|
||||
worktreePath: workspaceMode == .local
|
||||
? NewTaskWorkspaceDefaults.normalizedWorktreePath(
|
||||
for: selectedBranch,
|
||||
projectPath: selectedProject?.path ?? ""
|
||||
)
|
||||
: nil,
|
||||
startFromOrigin: startFromOrigin
|
||||
)
|
||||
: nil
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -134,6 +134,10 @@ final class NativeContractExpansionTests: XCTestCase {
|
||||
from: Data(
|
||||
"""
|
||||
{
|
||||
"settings": {
|
||||
"defaultThreadEnvMode": "worktree",
|
||||
"newWorktreesStartFromOrigin": false
|
||||
},
|
||||
"providers": [{
|
||||
"instanceId": "codex-work",
|
||||
"driver": "codex",
|
||||
@@ -214,6 +218,8 @@ final class NativeContractExpansionTests: XCTestCase {
|
||||
XCTAssertEqual(provider.slashCommands?.first?.name, "review")
|
||||
XCTAssertEqual(provider.slashCommands?.first?.input?.hint, "focus")
|
||||
XCTAssertEqual(provider.skills?.first?.displayName, "Fix CI")
|
||||
XCTAssertEqual(config.settings?.defaultThreadEnvMode, .worktree)
|
||||
XCTAssertEqual(config.settings?.newWorktreesStartFromOrigin, false)
|
||||
let model = try XCTUnwrap(provider.models.first)
|
||||
XCTAssertEqual(model.slug, "gpt-5.6-sol")
|
||||
let descriptors = try XCTUnwrap(model.capabilities?.optionDescriptors)
|
||||
@@ -226,6 +232,32 @@ final class NativeContractExpansionTests: XCTestCase {
|
||||
XCTAssertEqual(effort.currentValue, "high")
|
||||
XCTAssertEqual(fastMode.currentValue, true)
|
||||
}
|
||||
|
||||
func testServerConfigSettingsUpdateDecodesEnvironmentPreferences() throws {
|
||||
let event = try JSONDecoder.t3.decode(
|
||||
ServerConfigStreamEvent.self,
|
||||
from: Data(
|
||||
"""
|
||||
{
|
||||
"version": 1,
|
||||
"type": "settingsUpdated",
|
||||
"payload": {
|
||||
"settings": {
|
||||
"defaultThreadEnvMode": "worktree",
|
||||
"newWorktreesStartFromOrigin": false
|
||||
}
|
||||
}
|
||||
}
|
||||
""".utf8
|
||||
)
|
||||
)
|
||||
|
||||
guard case let .settingsUpdated(settings) = event else {
|
||||
return XCTFail("Expected a settings update")
|
||||
}
|
||||
XCTAssertEqual(settings.defaultThreadEnvMode, .worktree)
|
||||
XCTAssertFalse(settings.newWorktreesStartFromOrigin)
|
||||
}
|
||||
}
|
||||
|
||||
private actor AccessHTTPTransport: HTTPTransport {
|
||||
|
||||
@@ -72,6 +72,52 @@ struct ComposerDraftStoreTests {
|
||||
)
|
||||
}
|
||||
|
||||
@Test func migratesResolvedVersionOneNewTaskDefaultsBackToImplicit() async throws {
|
||||
let directory = FileManager.default.temporaryDirectory
|
||||
.appendingPathComponent(UUID().uuidString, isDirectory: true)
|
||||
defer { try? FileManager.default.removeItem(at: directory) }
|
||||
try FileManager.default.createDirectory(
|
||||
at: directory,
|
||||
withIntermediateDirectories: true
|
||||
)
|
||||
let fileURL = directory.appendingPathComponent("drafts.json")
|
||||
try Data(
|
||||
"""
|
||||
{
|
||||
"version": 1,
|
||||
"drafts": {
|
||||
"environment:test:new-task:project": {
|
||||
"text": "Keep the prompt",
|
||||
"attachments": [],
|
||||
"selection": {
|
||||
"providerID": "codex",
|
||||
"modelID": "gpt-old",
|
||||
"options": []
|
||||
},
|
||||
"workspace": {
|
||||
"mode": "local",
|
||||
"startFromOrigin": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
""".utf8
|
||||
).write(to: fileURL)
|
||||
|
||||
let store = FeatureComposerDraftStore(fileURL: fileURL)
|
||||
let migrated = try await store.draft(
|
||||
for: "environment:test:new-task:project"
|
||||
)
|
||||
|
||||
#expect(migrated?.text == "Keep the prompt")
|
||||
#expect(migrated?.selection == nil)
|
||||
#expect(migrated?.workspace == nil)
|
||||
let persisted = try JSONSerialization.jsonObject(
|
||||
with: Data(contentsOf: fileURL)
|
||||
) as? [String: Any]
|
||||
#expect(persisted?["version"] as? Int == 2)
|
||||
}
|
||||
|
||||
@Test func restorationPreservesLiveEditsAndRestoresUntouchedFields() {
|
||||
let baseline = FeatureComposerDraft(
|
||||
selection: FeatureSelection(providerID: "openai", modelID: "gpt-default"),
|
||||
|
||||
@@ -160,6 +160,16 @@ struct DailyUXNewTaskTests {
|
||||
]
|
||||
),
|
||||
],
|
||||
],
|
||||
preferencesByEnvironment: [
|
||||
"active": .init(
|
||||
defaultWorkspaceMode: .local,
|
||||
newWorktreesStartFromOrigin: true
|
||||
),
|
||||
"passive": .init(
|
||||
defaultWorkspaceMode: .worktree,
|
||||
newWorktreesStartFromOrigin: false
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -180,6 +190,15 @@ struct DailyUXNewTaskTests {
|
||||
DailyUXCreationContext.initialSelection(for: passiveProject, in: snapshot)
|
||||
== passiveDefault
|
||||
)
|
||||
#expect(
|
||||
DailyUXCreationContext.environmentPreferences(
|
||||
for: passiveProject,
|
||||
in: snapshot
|
||||
) == FeatureEnvironmentPreferences(
|
||||
defaultWorkspaceMode: .worktree,
|
||||
newWorktreesStartFromOrigin: false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test @MainActor
|
||||
|
||||
Reference in new issue
Block a user