Files
hapi/ios/Hapi/Models/LocalizedNoticeMapper.swift
T
weishuandClaude Opus 5.5 423c5f51df feat(ios): schedule sends from the composer
iOS showed scheduled messages but could not create them. A clock
button now sits next to the composer's attachment button. It offers
the web presets (in 5 min, 30 min, 1 h, 4 h) or a specific time up to 7
days ahead. A chip above the input shows the pending time; its × sends
normally again.

Presets resolve when the user taps Send, so "in 5 minutes" counts from
the send. Validation follows the web: a 30 s grace period for past
times and a 7-day maximum.

A scheduled send is text-only and queued. The hub rejects scheduledAt
with attachments or steer, so the clock is disabled while attachments
are present and the steer menu is hidden. The schedule clears once the
send dispatches. Sending reuses the existing optimistic path, and a
retry keeps the row's scheduledAt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 18:00:00 +08:00

71 lines
3.1 KiB
Swift

import Foundation
/// Display-point localization for user-facing strings emitted by HapiKit
/// (the package layer stays language-free, A-M5): a known package-produced
/// notice maps to its `Localizable.xcstrings` entry, everything else
/// (server-originated errors, dynamic content) passes through verbatim.
///
/// Covered sources: `ChatInteractor` notices, `DictationController` errors,
/// `MessageWindowController` tail-sync warnings, and the files models'
/// fallback errors. Low-value/debug package strings are deliberately not
/// mapped.
enum LocalizedNoticeMapper {
static func map(_ message: String) -> String {
guard knownMessages.contains(message) else { return message }
return String(localized: String.LocalizationValue(message))
}
/// Exact strings the package can emit — each is a key in
/// `Localizable.xcstrings` (hand-authored; runtime-built keys are not
/// extracted by the compiler).
private static let knownMessages: Set<String> = [
// ChatInteractor
"Attachments are still uploading — wait, or retry/remove the failed ones",
"Failed to abort",
"Session is inactive and could not be resumed",
"Failed to cancel queued message",
"Message cancelled — kept your current draft",
"Already delivered to the agent",
"Failed to steer message",
"Request was already handled",
"Request failed",
"Failed to load models",
"Failed to update session",
"Failed to rename session",
"Failed to delete session",
"Active sessions can't be deleted — archive first",
"Failed to reopen session",
"Scheduled messages can't include attachments — remove them or send now",
"Scheduled time must be in the future",
"Scheduled sends can be at most 7 days ahead",
"Draft parked to scratchlist",
"Scratchlist is full (200 entries)",
"Couldn't park the draft — check the hub connection",
"Drafts can contain at most 10,000 characters — shorten the text before saving",
"Couldn't prepare the attachments — retry or remove the failed files",
"The attachments exceed the scratchlist limits — remove a file or choose a smaller one",
"Your input changed — review it and try again",
"Couldn't queue the draft — retry",
"Draft added to the send queue",
"Already queued — couldn't remove the draft. Retry removal only.",
// DictationController
"Could not start recording",
"Could not reach the hub",
"Audio recording failed",
"No audio was recorded",
"Transcription failed",
// NewSessionLogic
"Name needs at least one letter or digit",
"Path is outside workspace roots",
// MessageWindowController (degraded-sync banner)
"Failed to synchronize messages",
"Failed to load older messages",
// FilesModel / FileViewerModel fallbacks
"Git status unavailable",
"Failed to list directory",
"Failed to search files",
"Failed to read file",
"Failed to load diff",
]
}