oficina / equipo Public

Merge origin/main into design/assistant-attachments

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev bffe07d17e05bd41fa8df372eb8efcaf53828d9c parent 59d7c48parent 70e4880
8 files changed, +202 −3
  • docs/superpowers/plans/CONTROLLER-REPORT-changes-facts-followups.md +63 −0
  • internal/wire/change_files.go +1 −1
  • internal/wire/testdata/change-paths.json +4 −0
  • native/apple/Sources/EquipoKit/API/ChangeFiles.swift +1 −1
  • native/apple/Sources/EquipoKit/Presentation/TaskDetailModel.swift +8 −0
  • native/apple/Sources/EquipoKit/UI/Screens/TaskDetailScreen.swift +1 −1
  • native/apple/Tests/EquipoKitTests/ChangeFilesRefreshTests.swift +78 −0
  • native/apple/Tests/EquipoKitTests/ChangeFilesTests.swift +46 −0
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-changes-facts-followups.md b/docs/superpowers/plans/CONTROLLER-REPORT-changes-facts-followups.md
new file mode 100644
index 00000000..1c1a2409
--- /dev/null
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-changes-facts-followups.md
@@ -0,0 +1,63 @@
+# Changed-file facts follow-ups
+
+Branch `changes/facts-followups`, fresh worktree from main `478e0055`.
+No new copy, server routes, runner protocol, or merge-authority changes.
+
+The Changed files tab retains the last detail facts while a newer list revision
+for the same candidate is being read. The task's status and action rules still
+use the current revision; stale detail facts never enable a stale action.
+A different candidate drops the displayed facts immediately. A completed detail
+read replaces the retained facts, including a response without facts. A failed
+read leaves same-candidate facts visible alongside the existing read failure.
+
+Both path validators reject U+061C through the shared change-paths.json fixture.
+Other valid format characters, including ZWJ emoji names, remain accepted.
+
+## Verification
+
+Only focused tests run locally while the shared Mac is loaded. No simulators
+or fixture apps are started. Go uses GOMAXPROCS=2, GOTOOLCHAIN=go1.26.11,
+CGO_ENABLED=0 and -p 1. Swift uses --jobs 2 and named test filters.
+
+Test-first: TestChangePathSharedCases failed for U+061C before the Go validator
+change, then passed. Native tests cover a suspended detail read, candidate
+change, failed read, completed replacement and missing-facts fallback; all three
+non-truncated totals; grouping at 9, 10 and 11 files; and malformed optional
+change_files objects, arrays, scalars and nested fields without losing the step.
+
+Native red run failed the U+061C path/rename cases and the three same-candidate
+retention assertions. The implementation then passed all 15 focused tests in
+the ChangeFilesTests and ChangeFilesRefreshTests suites. The read fixture uses
+continuations to hold and finish a real model request; it has no timing sleeps.
+No screenshot is needed to prove the pending-read behavior, and no simulator
+was started.
+
+Commands:
+
+- `go test -p 1 ./internal/wire -run '^TestChangePathSharedCases$' -count=1`
+ with the Go environment above: red, then green.
+- `swift test --package-path native/apple --jobs 2 --filter
+ 'ChangeFilesTests|ChangeFilesRefreshTests'`: red, then green.
+- Each mutation runs only its named test with the same Go/Swift limits;
+ the mutation script restores each source file in a finally block.
+
+All eight mutations were killed:
+
+1. Remove the non-truncated totals equality check: all three totals fail.
+2. Group lists shorter than eleven files: the 9/10-file assertions fail.
+3. Delay grouping until twelve files: the 11-file assertion fails.
+4. Throw on malformed change_files instead of dropping the optional field:
+ the step-decode regression fails.
+5. Accept U+061C natively: shared path and rename-source assertions fail.
+6. Drop retained facts during the next detail read: pending-read assertions fail.
+7. Retain facts after the candidate changes: candidate-change assertion fails.
+8. Accept U+061C in Go: TestChangePathSharedCases fails.
+
+Individual commands, failure logs and results are archived under
+`site/build/slice5/followups/validation/`. Full local suites and simulator runs
+are intentionally omitted under the controller's machine-load ruling; Linux
+CI is the final gate. The focused suites are rerun after restoring mutations.
+
+Final restored-source results: the two focused Go tests passed (0.216s), and
+all 15 focused native tests passed (0.289s). No new copy or outstanding copy
+questions. No runtime processes or simulator resources were created.
diff --git a/internal/wire/change_files.go b/internal/wire/change_files.go
index cb5d91fe..a7302280 100644
--- a/internal/wire/change_files.go
+++ b/internal/wire/change_files.go
@@ -48,7 +48,7 @@ func ValidChangePath(s string) bool {
// Keep in sync with native ThinChangeFiles.path and the shared path fixture.
// Other format characters (for example ZWJ in emoji names) are valid.
func unsafeChangePathRune(r rune) bool {
- return unicode.IsControl(r) || r == 0x200e || r == 0x200f ||
+ return unicode.IsControl(r) || r == 0x061c || r == 0x200e || r == 0x200f ||
r >= 0x202a && r <= 0x202e || r >= 0x2066 && r <= 0x2069
}
diff --git a/internal/wire/testdata/change-paths.json b/internal/wire/testdata/change-paths.json
index 5e42630e..0bef614b 100644
--- a/internal/wire/testdata/change-paths.json
+++ b/internal/wire/testdata/change-paths.json
@@ -98,5 +98,9 @@
{
"path": "a\u2069b",
"valid": false
+ },
+ {
+ "path": "a\u061cb",
+ "valid": false
}
]
diff --git a/native/apple/Sources/EquipoKit/API/ChangeFiles.swift b/native/apple/Sources/EquipoKit/API/ChangeFiles.swift
index 2ee56890..ba2c5825 100644
--- a/native/apple/Sources/EquipoKit/API/ChangeFiles.swift
+++ b/native/apple/Sources/EquipoKit/API/ChangeFiles.swift
@@ -58,7 +58,7 @@ public struct ThinChangeFiles: Codable, Sendable, Equatable {
static func path(_ value: String) -> Bool {
!value.isEmpty && value.utf8.count <= 4096 && !value.contains("\\")
&& !value.unicodeScalars.contains {
- $0.properties.generalCategory == .control || $0.value == 0x200e || $0.value == 0x200f
+ $0.properties.generalCategory == .control || $0.value == 0x061c || $0.value == 0x200e || $0.value == 0x200f
|| (0x202a...0x202e).contains($0.value) || (0x2066...0x2069).contains($0.value)
}
&& value.split(separator: "/", omittingEmptySubsequences: false).allSatisfy { !$0.isEmpty && $0 != "." && $0 != ".." }
diff --git a/native/apple/Sources/EquipoKit/Presentation/TaskDetailModel.swift b/native/apple/Sources/EquipoKit/Presentation/TaskDetailModel.swift
index 3c5777c0..45c69a5a 100644
--- a/native/apple/Sources/EquipoKit/Presentation/TaskDetailModel.swift
+++ b/native/apple/Sources/EquipoKit/Presentation/TaskDetailModel.swift
@@ -39,6 +39,14 @@ import Observation
guard let loaded, loaded.revision >= listed.revision else { return listed }
return loaded
}
+ var changeFiles: ThinChangeFiles? {
+ guard let task else { return nil }
+ if let facts = ChangedFilesPresentation.facts(task) { return facts }
+ // List revisions omit detail facts. Retain only this candidate's facts
+ // while the next detail read replaces loaded; never retain task actions.
+ guard let loaded, loaded.candidateSha == task.candidateSha else { return nil }
+ return ChangedFilesPresentation.facts(loaded)
+ }
var rules: TaskActionRules {
guard let task, loaded?.revision == task.revision, readFailure == nil else { return .init() }
return TaskActionRules(task: task, viewer: session.me?.address ?? "", owner: session.me?.role == "owner", cards: session.cards)
diff --git a/native/apple/Sources/EquipoKit/UI/Screens/TaskDetailScreen.swift b/native/apple/Sources/EquipoKit/UI/Screens/TaskDetailScreen.swift
index 108c7441..bea29989 100644
--- a/native/apple/Sources/EquipoKit/UI/Screens/TaskDetailScreen.swift
+++ b/native/apple/Sources/EquipoKit/UI/Screens/TaskDetailScreen.swift
@@ -47,7 +47,7 @@ public struct TaskScreen: View {
case .overview: overview(task)
case .checks: TaskChecksView(task: task, client: model.session.client)
case .changes:
- if let facts = ChangedFilesPresentation.facts(task) {
+ if let facts = model.changeFiles {
ChangedFilesList(facts: facts) { file in
if let url = ChangedFilesPresentation.fileURL(task: task, facts: facts, file: file) {
model.session.settings.openChanges(origin: model.session.origin, url: url)
diff --git a/native/apple/Tests/EquipoKitTests/ChangeFilesRefreshTests.swift b/native/apple/Tests/EquipoKitTests/ChangeFilesRefreshTests.swift
new file mode 100644
index 00000000..d5a9c852
--- /dev/null
+++ b/native/apple/Tests/EquipoKitTests/ChangeFilesRefreshTests.swift
@@ -0,0 +1,78 @@
+import Foundation
+import Testing
+@testable import EquipoKit
+
+@MainActor @Suite struct ChangeFilesRefreshTests {
+ static func detail() throws -> ThinTask {
+ var task = try TaskDetailTests.task()
+ task.candidateSha = ChangeFilesTests.sha
+ var step = task.steps![0]
+ step.specialist = "engineering"; step.state = "done"
+ step.baseSha = ChangeFilesTests.base; step.candidateSha = task.candidateSha
+ step.changeFiles = ChangeFilesTests.facts(); task.steps = [step]
+ return task
+ }
+ @Test func sameCandidateKeepsFactsDuringReadAndReplacesThemOnCompletion() async throws {
+ let server = ChangeFilesReadServer(), model = try TaskDetailModelTests.model(server)
+ let detail = try Self.detail(); model.loaded = detail
+ var listed = detail; listed.revision += 1; listed.steps?[0].changeFiles = nil
+ await server.list(listed); await model.session.refresh()
+ #expect(model.task?.revision == listed.revision)
+ #expect(model.changeFiles == ChangeFilesTests.facts())
+ #expect(model.rules.available.isEmpty)
+ let read = Task { await model.load() }
+ await server.waitForRead()
+ #expect(model.changeFiles == ChangeFilesTests.facts())
+ var fresh = listed
+ var facts = ChangeFilesTests.facts(); facts.entries[0].path = "updated.txt"
+ fresh.steps?[0].changeFiles = facts
+ try await server.finish(fresh)
+ #expect(await read.value == nil)
+ #expect(model.changeFiles == facts)
+ // A completed detail read without facts restores the old-runner fallback.
+ model.loaded = listed
+ #expect(model.changeFiles == nil)
+ }
+ @Test func changedCandidateDropsFactsAndFailedReadDoesNotEraseSameCandidate() async throws {
+ let server = ChangeFilesReadServer(), model = try TaskDetailModelTests.model(server)
+ let detail = try Self.detail(); model.loaded = detail
+ var listed = detail; listed.revision += 1; listed.steps?[0].changeFiles = nil
+ await server.list(listed); await model.session.refresh()
+ let read = Task { await model.load() }
+ await server.waitForRead(); await server.fail(); #expect(await read.value != nil)
+ #expect(model.readFailure != nil)
+ #expect(model.changeFiles == ChangeFilesTests.facts())
+ listed.candidateSha = ChangeFilesTests.base
+ await server.list(listed); await model.session.refresh()
+ #expect(model.changeFiles == nil)
+ }
+}
+
+private actor ChangeFilesReadServer: EquipoTransport {
+ nonisolated let origin = URL(string: "https://facts.invalid")!
+ private var listed: ThinTask?
+ func list(_ task: ThinTask) { listed = task }
+ private var pending: CheckedContinuation<APIResponse, any Error>?
+ private var waiting: CheckedContinuation<Void, Never>?
+ func waitForRead() async {
+ if pending != nil { return }
+ await withCheckedContinuation { waiting = $0 }
+ }
+ func send(_ request: APIRequest) async throws -> APIResponse {
+ if request.path == "/snapshot" { return APIResponse(status: 200, data: Fixture.data("thin/snapshot")) }
+ if request.path == "/time-zone" { return APIResponse(status: 200, data: Data(#"{"time_zone":"Europe/Dublin"}"#.utf8)) }
+ if ["/tasks", "/needs-you"].contains(request.path) {
+ let encoder = EquipoJSON.encoder; encoder.dateEncodingStrategy = .iso8601
+ return APIResponse(status: 200, data: try encoder.encode(ThinList(items: listed.map { [$0] } ?? [])))
+ }
+ return try await withCheckedThrowingContinuation { continuation in
+ pending = continuation; waiting?.resume(); waiting = nil
+ }
+ }
+ func finish(_ task: ThinTask) throws {
+ let encoder = EquipoJSON.encoder; encoder.dateEncodingStrategy = .iso8601
+ pending?.resume(returning: APIResponse(status: 200, data: try encoder.encode(task))); pending = nil
+ }
+ func fail() { pending?.resume(throwing: URLError(.notConnectedToInternet)); pending = nil }
+ func lines(_ request: APIRequest) async throws -> AsyncThrowingStream<String, Error> { .init { $0.finish() } }
+}
diff --git a/native/apple/Tests/EquipoKitTests/ChangeFilesTests.swift b/native/apple/Tests/EquipoKitTests/ChangeFilesTests.swift
index 3f9575eb..279dc2c8 100644
--- a/native/apple/Tests/EquipoKitTests/ChangeFilesTests.swift
+++ b/native/apple/Tests/EquipoKitTests/ChangeFilesTests.swift
@@ -149,3 +149,49 @@ extension ChangeFilesTests {
}
}
}
+
+
+extension ChangeFilesTests {
+ @Test func completeTotalsMustEqualTheirEntries() {
+ for field in [\ThinChangeFiles.additions, \ThinChangeFiles.deletions, \ThinChangeFiles.binary] {
+ var facts = Self.facts()
+ facts[keyPath: field] += 1
+ #expect(!facts.isValid)
+ facts.files = 2; facts.truncated = true
+ #expect(facts.isValid)
+ }
+ }
+ @Test func folderGroupingStartsAfterTenFiles() {
+ for count in [9, 10, 11] {
+ var facts = Self.facts()
+ facts.entries = (0..<count).map { .init(path: "folder\($0 % 2)/file\($0)", status: "added", additions: 1, deletions: 0, binary: false) }
+ facts.files = count; facts.additions = count
+ let groups = ChangedFilesPresentation.groups(facts)
+ if count <= 10 {
+ #expect(groups.count == 1)
+ #expect(groups.first?.folder == "")
+ #expect(groups.first?.files == facts.entries)
+ } else {
+ #expect(groups.map(\.folder) == ["folder0", "folder1"])
+ #expect(Set(groups.flatMap(\.files).map(\.path)) == Set(facts.entries.map(\.path)))
+ }
+ }
+ }
+ @Test func malformedOptionalFactsCannotHideTheStep() throws {
+ let encoder = EquipoJSON.encoder; encoder.dateEncodingStrategy = .iso8601
+ let original = try TaskDetailTests.task().steps![0]
+ let good = try JSONSerialization.jsonObject(with: encoder.encode(Self.facts())) as! [String: Any]
+ var wrongEntries = good; wrongEntries["entries"] = "not an array"
+ var wrongCount = good; wrongCount["files"] = "one"
+ var wrongEntry = good; wrongEntry["entries"] = [["path": "only-a-path"]]
+ let malformedValues: [Any] = ["not an object", 42, [1, 2], [:] as [String: Any], wrongEntries, wrongCount, wrongEntry]
+ for malformed in malformedValues {
+ var body = try JSONSerialization.jsonObject(with: encoder.encode(original)) as! [String: Any]
+ body["change_files"] = malformed
+ let decoded = try EquipoJSON.decoder.decode(ThinStep.self, from: JSONSerialization.data(withJSONObject: body))
+ #expect(decoded.changeFiles == nil)
+ #expect(decoded.id == original.id)
+ #expect(decoded.state == original.state)
+ }
+ }
+}