fix(ci): restore model override and trash-path fallbacks

This commit is contained in:
Vincent Koc
2026-04-02 16:59:27 +09:00
parent 68bb76519a
commit 53f1c9968a
2 changed files with 52 additions and 4 deletions

View File

@@ -1,4 +1,5 @@
import type { OpenClawConfig } from "../config/config.js";
import { parseRawSessionConversationRef } from "../sessions/session-key-utils.js";
import { normalizeMessageChannel } from "../utils/message-channel.js";
import {
buildChannelKeyCandidates,
@@ -57,6 +58,10 @@ function buildChannelCandidates(
normalizeMessageChannel(params.channel ?? "") ?? params.channel?.trim().toLowerCase();
const groupId = params.groupId?.trim();
const sessionConversation = resolveSessionConversationRef(params.parentSessionKey);
const feishuParentFallbacks = resolveFeishuParentSessionFallbackCandidates({
channel: normalizedChannel,
parentSessionKey: params.parentSessionKey,
});
const groupConversationKind =
normalizeChatType(params.groupChatType ?? undefined) === "channel"
? "channel"
@@ -81,6 +86,7 @@ function buildChannelCandidates(
sessionConversation?.rawId,
...(groupConversation?.parentConversationCandidates ?? []),
...(sessionConversation?.parentConversationCandidates ?? []),
...feishuParentFallbacks,
),
parentKeys: buildChannelKeyCandidates(
groupChannel,
@@ -93,6 +99,43 @@ function buildChannelCandidates(
};
}
function resolveFeishuParentSessionFallbackCandidates(params: {
channel?: string;
parentSessionKey?: string | null;
}): string[] {
if (params.channel !== "feishu") {
return [];
}
const rawId = parseRawSessionConversationRef(params.parentSessionKey)?.rawId?.trim();
if (!rawId) {
return [];
}
const topicSenderMatch = rawId.match(/^(.+):topic:([^:]+):sender:([^:]+)$/i);
if (topicSenderMatch) {
const chatId = topicSenderMatch[1]?.trim().toLowerCase();
const topicId = topicSenderMatch[2]?.trim().toLowerCase();
if (chatId && topicId) {
return [`${chatId}:topic:${topicId}`, chatId];
}
return [];
}
const topicMatch = rawId.match(/^(.+):topic:([^:]+)$/i);
if (topicMatch) {
const chatId = topicMatch[1]?.trim().toLowerCase();
const topicId = topicMatch[2]?.trim().toLowerCase();
if (chatId && topicId) {
return [chatId];
}
return [];
}
const senderMatch = rawId.match(/^(.+):sender:([^:]+)$/i);
if (senderMatch) {
const chatId = senderMatch[1]?.trim().toLowerCase();
return chatId ? [chatId] : [];
}
return [];
}
export function resolveChannelModelOverride(
params: ChannelModelOverrideParams,
): ChannelModelOverride | null {

View File

@@ -37,14 +37,19 @@ export const movePathToTrash: BrowserRuntimeModule["movePathToTrash"] = (async (
}
return targetPath;
} catch {
const trashDir = path.join(os.homedir(), ".Trash");
const homeDir = os.homedir();
const pathRuntime = homeDir.startsWith("/") ? path.posix : path;
const trashDir = pathRuntime.join(homeDir, ".Trash");
await fs.mkdir(trashDir, { recursive: true });
const base = path.basename(targetPath);
const base = pathRuntime.basename(targetPath);
const timestamp = Date.now();
let destination = path.join(trashDir, `${base}-${timestamp}`);
let destination = pathRuntime.join(trashDir, `${base}-${timestamp}`);
try {
await fs.access(destination);
destination = path.join(trashDir, `${base}-${timestamp}-${createTrashCollisionSuffix()}`);
destination = pathRuntime.join(
trashDir,
`${base}-${timestamp}-${createTrashCollisionSuffix()}`,
);
} catch {
// The initial destination is free to use.
}