Skip to content

Commit 4b5faa6

Browse files
committed
fix(ios): default new skill requirement fields
1 parent 6070726 commit 4b5faa6

2 files changed

Lines changed: 46 additions & 1 deletion

File tree

‎apps/ios/Sources/Design/AgentProModels.swift‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ struct SkillStatusEntryLite: Decodable {
195195
var hasMissingRequirements: Bool {
196196
guard let missing else { return false }
197197
return !missing.bins.isEmpty
198+
|| !missing.anyBins.isEmpty
198199
|| !missing.env.isEmpty
199200
|| !missing.config.isEmpty
200201
|| !missing.os.isEmpty
@@ -204,6 +205,7 @@ struct SkillStatusEntryLite: Decodable {
204205
guard let missing else { return nil }
205206
let values = [
206207
missing.bins,
208+
missing.anyBins,
207209
missing.env,
208210
missing.config,
209211
missing.os,
@@ -217,7 +219,8 @@ struct SkillStatusEntryLite: Decodable {
217219
}
218220

219221
var missingBins: [String] {
220-
self.missing?.bins ?? []
222+
guard let missing else { return [] }
223+
return missing.bins + missing.anyBins
221224
}
222225

223226
var homepageURL: URL? {
@@ -272,9 +275,27 @@ struct ClawHubInstallParams: Encodable {
272275

273276
struct SkillStatusMissingLite: Decodable {
274277
let bins: [String]
278+
let anyBins: [String]
275279
let env: [String]
276280
let config: [String]
277281
let os: [String]
282+
283+
private enum CodingKeys: String, CodingKey {
284+
case bins
285+
case anyBins
286+
case env
287+
case config
288+
case os
289+
}
290+
291+
init(from decoder: Decoder) throws {
292+
let container = try decoder.container(keyedBy: CodingKeys.self)
293+
self.bins = try container.decode([String].self, forKey: .bins)
294+
self.anyBins = try container.decodeIfPresent([String].self, forKey: .anyBins) ?? []
295+
self.env = try container.decode([String].self, forKey: .env)
296+
self.config = try container.decode([String].self, forKey: .config)
297+
self.os = try container.decodeIfPresent([String].self, forKey: .os) ?? []
298+
}
278299
}
279300

280301
struct CronStatusLite: Decodable {

‎apps/ios/Tests/AgentOverviewRefreshGateTests.swift‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,30 @@ import Testing
33
@testable import OpenClaw
44

55
struct AgentOverviewRefreshGateTests {
6+
@Test func `legacy skill missing requirements default new fields`() throws {
7+
let report = try JSONDecoder().decode(
8+
SkillStatusReportLite.self,
9+
from: Data(#"{"skills":[{"name":"Legacy","missing":{"bins":[],"env":[],"config":[]}}]}"#.utf8))
10+
let skill = try #require(report.skills.first)
11+
12+
#expect(skill.missing?.anyBins == [])
13+
#expect(skill.missing?.os == [])
14+
#expect(!skill.hasMissingRequirements)
15+
}
16+
17+
@Test func `any binary requirements participate in skill setup state`() throws {
18+
let report = try JSONDecoder().decode(
19+
SkillStatusReportLite.self,
20+
from: Data(
21+
#"{"skills":[{"name":"Search","missing":{"bins":[],"anyBins":["rg","grep"],"env":[],"config":[],"os":[]}}]}"#
22+
.utf8))
23+
let skill = try #require(report.skills.first)
24+
25+
#expect(skill.hasMissingRequirements)
26+
#expect(skill.missingSummary == "rg, grep")
27+
#expect(skill.missingBins == ["rg", "grep"])
28+
}
29+
630
@Test func `new overview refresh invalidates an older result`() {
731
var gate = AgentOverviewRefreshGate()
832

0 commit comments

Comments
 (0)