mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-22 04:17:05 +00:00
Part 1 — Simplified Chinese localization of the iOS app layer: - ios/Hapi/Resources/Localizable.xcstrings: hand-authored String Catalog (395 keys, zh-Hans; en implicit as source). Terminology mined from web/src/lib/locales/zh-CN.ts (会话/新建会话/权限模式/允许/拒绝/工作树/ 机器/语音输入/用量/草稿夹 …). - Mechanical edits only: merged multi-part string concatenations into single LocalizedStringKey literals, converted ternary/plain-String user copy to String(localized:), switched helper params (detailRow, DashboardCard, optionPicker, notice) to LocalizedStringKey. - LocalizedNoticeMapper (app layer): display-point translation of the 27 known HapiKit-emitted strings (ChatInteractor notices, dictation errors, window-sync warnings, files fallbacks, worktree-name validation) with verbatim passthrough for server-originated text; package stays language-free. - Deliberately untranslated (web parity / non-copy): event rows (EventPresentation — web renders presentation.ts verbatim), catalog option labels (Default/Auto/Sonnet/permission modes — web shows them verbatim), tool names, code-like titles (grep(pattern:), MCP:, Skill, Task), unit suffixes (B/KB/MB, m/h/d/w), decorative separators. - Language row wired: AppLanguage gains .system (follow system, new default); explicit picks write the AppleLanguages override, Follow system removes it; footer notes a relaunch applies it (no supported in-place SwiftUI locale swap). - project.pbxproj: zh-Hans added to knownRegions. Part 2 — #39 catalog dedupe (HapiProtocol): - NewSessionCatalogs.claudeModels/claudeEfforts now derive from ClaudeModels/ClaudeEfforts (single source shared with ModelCatalog); codexReasoningEfforts stays own data (web CODEX_REASONING_EFFORT_OPTIONS minus max); effortLabel delegates to ModelCatalog.capitalizedFirst. - New CatalogTests lock test for the derived option lists. Gate: bash ios/scripts/linux-test.sh — 459 tests green.
85 lines
3.0 KiB
Swift
85 lines
3.0 KiB
Swift
import HapiClient
|
|
import SwiftUI
|
|
|
|
/// Floating bar above the composer for queued (uninvoked) sends — the
|
|
/// SwiftUI twin of `QueuedMessagesBar.tsx` via the Android port. Per row:
|
|
/// Steer (while a turn is active), Edit (cancel + prefill composer) and
|
|
/// Cancel. Rows without a server echo yet (`id == localId`) keep their
|
|
/// actions disabled until the SSE echo lands.
|
|
struct QueuedMessagesBarView: View {
|
|
let interactor: ChatInteractor
|
|
|
|
var body: some View {
|
|
let rows = interactor.queuedRows
|
|
if !rows.isEmpty {
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
Text(rows.count == 1
|
|
? String(localized: "1 queued message")
|
|
: String(format: String(localized: "%lld queued messages"), Int64(rows.count)))
|
|
.font(.caption2)
|
|
.foregroundStyle(.secondary)
|
|
.padding(.horizontal, 10)
|
|
ScrollView {
|
|
VStack(spacing: 4) {
|
|
ForEach(rows) { row in
|
|
QueuedRowView(row: row, interactor: interactor)
|
|
}
|
|
}
|
|
.padding(.horizontal, 10)
|
|
}
|
|
.frame(maxHeight: 160)
|
|
.scrollBounceBehavior(.basedOnSize)
|
|
}
|
|
.padding(.vertical, 4)
|
|
.background(.bar)
|
|
}
|
|
}
|
|
}
|
|
|
|
private struct QueuedRowView: View {
|
|
let row: QueuedMessageRow
|
|
let interactor: ChatInteractor
|
|
|
|
var body: some View {
|
|
HStack(alignment: .center, spacing: 4) {
|
|
VStack(alignment: .leading, spacing: 1) {
|
|
Text(row.text.isEmpty ? row.attachmentNames.joined(separator: ", ") : row.text)
|
|
.font(.footnote)
|
|
.lineLimit(2)
|
|
if let scheduledAt = row.scheduledAt {
|
|
Text("Scheduled · \(Self.timeLabel(scheduledAt))")
|
|
.font(.caption2)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
}
|
|
Spacer(minLength: 8)
|
|
if row.canSteer {
|
|
Button("Steer") {
|
|
interactor.steerQueuedMessage(row.id)
|
|
}
|
|
.font(.footnote.weight(.medium))
|
|
}
|
|
Button("Edit") {
|
|
interactor.editQueuedMessage(row.id)
|
|
}
|
|
.font(.footnote.weight(.medium))
|
|
.disabled(!row.canAct)
|
|
Button("Cancel") {
|
|
interactor.cancelQueuedMessage(row.id)
|
|
}
|
|
.font(.footnote.weight(.medium))
|
|
.tint(.red)
|
|
.disabled(!row.canAct)
|
|
}
|
|
.buttonStyle(.borderless)
|
|
.padding(.horizontal, 10)
|
|
.padding(.vertical, 6)
|
|
.background(.fill.tertiary, in: RoundedRectangle(cornerRadius: 10, style: .continuous))
|
|
}
|
|
|
|
private static func timeLabel(_ epochMs: Int) -> String {
|
|
Date(timeIntervalSince1970: TimeInterval(epochMs) / 1000)
|
|
.formatted(date: .omitted, time: .shortened)
|
|
}
|
|
}
|