refactor: remove redundant code and over-defensive branches
Consolidate code that existed twice and drop code nothing reaches.
- SSH: hoist the duplicated ASCII hex-nibble decoder out of
RemoteCharsetConverter and SSHPTYChannel into SSHWireEncoding.hexDigit.
- Transcript: AgentToolDetail.Tint shares BatchTint's vocabulary, so the
byte-identical detailColor map now delegates to batchColor.
- Commerce: replace ProPaywallState's unreachable default branch and its
`preconditionFailure("Handled above")` with an exhaustive switch the
compiler can prove complete.
- Strings: delete the unreferenced Workspace.closePaneAction (the live help
text uses closePane) and its orphan catalog entry.
- Drop the unused SwiftData and UniformTypeIdentifiers imports.
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
1 parent
a53d9f11eb
commit
975358f98a
9 files changed
+43
-67
No files matched your search
@@ -7897,29 +7897,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"Close Pane" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
"ja" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "ペインを閉じる"
|
||||
}
|
||||
},
|
||||
"zh-Hans" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "关闭窗格"
|
||||
}
|
||||
},
|
||||
"zh-Hant" : {
|
||||
"stringUnit" : {
|
||||
"state" : "translated",
|
||||
"value" : "關閉窗格"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Close Window" : {
|
||||
"extractionState" : "manual",
|
||||
"localizations" : {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import Foundation
|
||||
import SwiftData
|
||||
import TermindApplication
|
||||
import TermindDomain
|
||||
|
||||
|
||||
@@ -30,22 +30,31 @@ public nonisolated struct ProPaywallState {
|
||||
case .expired: state = "expired"
|
||||
case .revoked: state = "revoked"
|
||||
}
|
||||
default:
|
||||
case .purchased(let ownership):
|
||||
canManageSubscription = false
|
||||
isFamilyShared = ownership == .familyShared
|
||||
expiresAt = nil
|
||||
if case .purchased(.familyShared) = status {
|
||||
isFamilyShared = true
|
||||
} else {
|
||||
isFamilyShared = false
|
||||
}
|
||||
switch status {
|
||||
case .loading: state = "loading"
|
||||
case .free: state = "free"
|
||||
case .purchased: state = "lifetime"
|
||||
case .verificationFailed: state = "unverified"
|
||||
case .unrestrictedForTesting: state = "development"
|
||||
case .subscription: preconditionFailure("Handled above")
|
||||
}
|
||||
state = "lifetime"
|
||||
case .loading:
|
||||
canManageSubscription = false
|
||||
isFamilyShared = false
|
||||
expiresAt = nil
|
||||
state = "loading"
|
||||
case .free:
|
||||
canManageSubscription = false
|
||||
isFamilyShared = false
|
||||
expiresAt = nil
|
||||
state = "free"
|
||||
case .verificationFailed:
|
||||
canManageSubscription = false
|
||||
isFamilyShared = false
|
||||
expiresAt = nil
|
||||
state = "unverified"
|
||||
case .unrestrictedForTesting:
|
||||
canManageSubscription = false
|
||||
isFamilyShared = false
|
||||
expiresAt = nil
|
||||
state = "development"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
import UniformTypeIdentifiers
|
||||
|
||||
/// Editing policy for single-line UI fields, not a transformation of stored data or secrets.
|
||||
public nonisolated enum SingleLineTextInput {
|
||||
|
||||
@@ -258,10 +258,6 @@ extension AppStrings {
|
||||
"Cancel operation"
|
||||
}
|
||||
|
||||
public static var closePaneAction: LocalizedStringResource {
|
||||
"Close Pane"
|
||||
}
|
||||
|
||||
public static var closeWindow: LocalizedStringResource {
|
||||
"Close Window"
|
||||
}
|
||||
|
||||
@@ -235,7 +235,8 @@ nonisolated struct RemoteOSC7CharsetFilter: Sendable {
|
||||
var index = 0
|
||||
while index < bytes.count {
|
||||
if bytes[index] == 0x25, index + 2 < bytes.count,
|
||||
let high = hex(bytes[index + 1]), let low = hex(bytes[index + 2])
|
||||
let high = SSHWireEncoding.hexDigit(bytes[index + 1]),
|
||||
let low = SSHWireEncoding.hexDigit(bytes[index + 2])
|
||||
{
|
||||
decoded.append(high << 4 | low)
|
||||
index += 3
|
||||
@@ -271,13 +272,4 @@ nonisolated struct RemoteOSC7CharsetFilter: Sendable {
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
private func hex(_ byte: UInt8) -> UInt8? {
|
||||
switch byte {
|
||||
case 0x30...0x39: byte - 0x30
|
||||
case 0x41...0x46: byte - 0x41 + 10
|
||||
case 0x61...0x66: byte - 0x61 + 10
|
||||
default: nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -625,7 +625,8 @@ public nonisolated struct RemoteCommandEventFilter: Sendable {
|
||||
var index = 0
|
||||
while index < bytes.count {
|
||||
if bytes[index] == 0x25, index + 2 < bytes.count,
|
||||
let high = hex(bytes[index + 1]), let low = hex(bytes[index + 2])
|
||||
let high = SSHWireEncoding.hexDigit(bytes[index + 1]),
|
||||
let low = SSHWireEncoding.hexDigit(bytes[index + 2])
|
||||
{
|
||||
decoded.append(high << 4 | low)
|
||||
index += 3
|
||||
@@ -639,15 +640,6 @@ public nonisolated struct RemoteCommandEventFilter: Sendable {
|
||||
?? String(decoding: decodedData, as: UTF8.self)
|
||||
}
|
||||
|
||||
private static func hex(_ byte: UInt8) -> UInt8? {
|
||||
switch byte {
|
||||
case 0x30...0x39: byte - 0x30
|
||||
case 0x41...0x46: byte - 0x41 + 10
|
||||
case 0x61...0x66: byte - 0x61 + 10
|
||||
default: nil
|
||||
}
|
||||
}
|
||||
|
||||
private static func duration(milliseconds text: Substring) -> TimeInterval? {
|
||||
guard let milliseconds = UInt64(text), milliseconds <= 31_536_000_000 else {
|
||||
return nil
|
||||
|
||||
@@ -22,4 +22,14 @@ nonisolated enum SSHWireEncoding {
|
||||
.replacingOccurrences(of: "=", with: "")
|
||||
return "SHA256:\(digest)"
|
||||
}
|
||||
|
||||
/// The value of one ASCII hexadecimal digit, or nil for any other byte.
|
||||
static func hexDigit(_ byte: UInt8) -> UInt8? {
|
||||
switch byte {
|
||||
case 0x30...0x39: byte - 0x30
|
||||
case 0x41...0x46: byte - 0x41 + 10
|
||||
case 0x61...0x66: byte - 0x61 + 10
|
||||
default: nil
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1602,12 +1602,14 @@ private enum NativeTranscriptFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/// `AgentToolDetail.Tint` shares `BatchTint`'s vocabulary, so the color
|
||||
/// mapping has one owner.
|
||||
private static func detailColor(_ tint: AgentToolDetail.Tint) -> NSColor {
|
||||
switch tint {
|
||||
case .secondary: .secondaryLabelColor
|
||||
case .warning: .systemOrange
|
||||
case .success: .systemGreen
|
||||
case .failure: .systemRed
|
||||
case .secondary: batchColor(.secondary)
|
||||
case .warning: batchColor(.warning)
|
||||
case .success: batchColor(.success)
|
||||
case .failure: batchColor(.failure)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user