mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-10 10:03:58 +00:00
* feat(ios): read-only offline cache for chat sessions and transcripts Cache-first cold open for the iOS chat tab: the last known transcript and session list render immediately from a local SQLite cache, then live gateway history replaces them wholesale through the existing reconciliation path. When the gateway is unreachable, recent sessions and transcripts stay browsable read-only; sending remains gated by the existing connection state. - New OpenClawChatTranscriptCache protocol seam plus SQLite-backed store in OpenClawChatUI (raw SQLite3, no new dependencies), scoped per gateway stableID so transcripts never leak across paired gateways. - Bounds: 50 sessions, 50 transcripts, 200 messages per session; text rows only (attachment/binary payloads and tool arguments are stripped). - Disposable cache: schema versioned via user_version; any open/schema/decode mismatch drops and rebuilds silently. File protection completeUntilFirstUserAuthentication on iOS. - View model pre-paints from cache only until a live response applies (hasAppliedLiveHistory/hasAppliedLiveSessions guards); write-through is chained and off the render path. - iOS wiring keys the chat view model identity on transport mode plus cache gateway ID so switching paired gateways rebuilds the view model. Part of #100194 * fix(ios): harden offline transcript cache * fix(ios): expose offline cached sessions * fix(ios): isolate transcript caches by gateway * chore(i18n): sync native inventory * fix(ios): allow cache extension to replace messages
110 lines
4.9 KiB
JavaScript
110 lines
4.9 KiB
JavaScript
#!/usr/bin/env node
|
|
import { existsSync, lstatSync, mkdirSync, readdirSync, writeFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
|
|
const repoRoot = path.resolve(import.meta.dirname, "..");
|
|
const iosRoot = path.join(repoRoot, "apps", "ios");
|
|
const outputPath = path.join(iosRoot, "SwiftSources.input.xcfilelist");
|
|
|
|
const iosSourceRoots = [
|
|
"Sources",
|
|
"ShareExtension",
|
|
"ActivityWidget",
|
|
path.join("WatchApp", "Sources"),
|
|
];
|
|
|
|
const sharedSwiftFiles = [
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatComposer.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatCodeHighlighter.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatMarkdownBlockSegmenter.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatMarkdownBlockViews.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatMarkdownPreprocessor.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatMarkdownRenderer.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatMessageViews.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatModels.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatPayloadDecoding.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatSessions.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatSheets.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatTheme.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatTranscriptCache.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatTransport.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatView.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+Attachments.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+SessionKeys.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel+TranscriptCache.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/ChatViewModel.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawChatUI/OpenClawMascotView.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/AnyCodable.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/BonjourEscapes.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/BonjourTypes.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/BridgeFrames.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/CameraCommands.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/CanvasA2UIAction.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/CanvasA2UICommands.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/CanvasA2UIJSONL.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/CanvasCommandParams.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/CanvasCommands.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/Capabilities.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/DeepLinks.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/JPEGTranscoder.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/NodeError.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/OpenClawKitResources.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/ScreenCommands.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/StoragePaths.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/SystemCommands.swift",
|
|
"../shared/OpenClawKit/Sources/OpenClawKit/TalkDirective.swift",
|
|
"../swabble/Sources/SwabbleKit/WakeWordGate.swift",
|
|
];
|
|
|
|
function normalizeFileListPath(filePath) {
|
|
return filePath.split(path.sep).join("/");
|
|
}
|
|
|
|
function collectSwiftFiles(rootRelativePath) {
|
|
const root = path.join(iosRoot, rootRelativePath);
|
|
if (!existsSync(root)) {
|
|
throw new Error(`Missing iOS Swift source root: ${rootRelativePath}`);
|
|
}
|
|
|
|
const entries = [];
|
|
const visit = (dir) => {
|
|
for (const entry of readdirSync(dir, { withFileTypes: true })) {
|
|
const fullPath = path.join(dir, entry.name);
|
|
if (entry.isDirectory()) {
|
|
visit(fullPath);
|
|
} else if (entry.isFile() && entry.name.endsWith(".swift")) {
|
|
entries.push(normalizeFileListPath(path.relative(iosRoot, fullPath)));
|
|
}
|
|
}
|
|
};
|
|
visit(root);
|
|
return entries;
|
|
}
|
|
|
|
function assertSharedFilesExist(filePaths) {
|
|
for (const filePath of filePaths) {
|
|
const absolutePath = path.resolve(iosRoot, filePath);
|
|
if (!existsSync(absolutePath)) {
|
|
throw new Error(`Missing shared Swift file listed for iOS lint: ${filePath}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
function writeGeneratedFile(filePath, contents) {
|
|
if (existsSync(filePath) && lstatSync(filePath).isSymbolicLink()) {
|
|
throw new Error(`Refusing to overwrite symlinked file: ${filePath}`);
|
|
}
|
|
mkdirSync(path.dirname(filePath), { recursive: true });
|
|
writeFileSync(filePath, contents, "utf8");
|
|
}
|
|
|
|
assertSharedFilesExist(sharedSwiftFiles);
|
|
|
|
const iosFiles = iosSourceRoots.flatMap(collectSwiftFiles);
|
|
const fileList = [...new Set([...iosFiles, ...sharedSwiftFiles])].toSorted((left, right) =>
|
|
left.localeCompare(right),
|
|
);
|
|
|
|
writeGeneratedFile(outputPath, `${fileList.join("\n")}\n`);
|
|
process.stdout.write(`Prepared iOS Swift file list: ${path.relative(repoRoot, outputPath)}\n`);
|