mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 21:24:32 +00:00
test: dedupe gateway browser discord and channel coverage
This commit is contained in:
@@ -223,6 +223,12 @@ function buildExecApprovalPayload(container: DiscordUiContainer): MessagePayload
|
||||
return { components };
|
||||
}
|
||||
|
||||
function formatCommandPreview(commandText: string, maxChars: number): string {
|
||||
const commandRaw =
|
||||
commandText.length > maxChars ? `${commandText.slice(0, maxChars)}...` : commandText;
|
||||
return commandRaw.replace(/`/g, "\u200b`");
|
||||
}
|
||||
|
||||
function createExecApprovalRequestContainer(params: {
|
||||
request: ExecApprovalRequest;
|
||||
cfg: OpenClawConfig;
|
||||
@@ -230,8 +236,7 @@ function createExecApprovalRequestContainer(params: {
|
||||
actionRow?: Row<Button>;
|
||||
}): ExecApprovalContainer {
|
||||
const commandText = params.request.request.command;
|
||||
const commandRaw = commandText.length > 1000 ? `${commandText.slice(0, 1000)}...` : commandText;
|
||||
const commandPreview = commandRaw.replace(/`/g, "\u200b`");
|
||||
const commandPreview = formatCommandPreview(commandText, 1000);
|
||||
const expiresAtSeconds = Math.max(0, Math.floor(params.request.expiresAtMs / 1000));
|
||||
|
||||
return new ExecApprovalContainer({
|
||||
@@ -255,8 +260,7 @@ function createResolvedContainer(params: {
|
||||
accountId: string;
|
||||
}): ExecApprovalContainer {
|
||||
const commandText = params.request.request.command;
|
||||
const commandRaw = commandText.length > 500 ? `${commandText.slice(0, 500)}...` : commandText;
|
||||
const commandPreview = commandRaw.replace(/`/g, "\u200b`");
|
||||
const commandPreview = formatCommandPreview(commandText, 500);
|
||||
|
||||
const decisionLabel =
|
||||
params.decision === "allow-once"
|
||||
@@ -289,8 +293,7 @@ function createExpiredContainer(params: {
|
||||
accountId: string;
|
||||
}): ExecApprovalContainer {
|
||||
const commandText = params.request.request.command;
|
||||
const commandRaw = commandText.length > 500 ? `${commandText.slice(0, 500)}...` : commandText;
|
||||
const commandPreview = commandRaw.replace(/`/g, "\u200b`");
|
||||
const commandPreview = formatCommandPreview(commandText, 500);
|
||||
|
||||
return new ExecApprovalContainer({
|
||||
cfg: params.cfg,
|
||||
|
||||
Reference in New Issue
Block a user