fix(ci): unblock discord boundary typing

This commit is contained in:
Vincent Koc
2026-04-13 21:59:55 +01:00
parent 9315302516
commit ea25cf2595
3 changed files with 14 additions and 3 deletions

View File

@@ -69,5 +69,11 @@ export function releaseDiscordInboundReplay(params: {
function normalizeDiscordInboundReplayKeys(
replayKeys?: readonly (string | null | undefined)[],
): string[] {
return [...new Set((replayKeys ?? []).map((replayKey) => replayKey?.trim()).filter(Boolean))];
return [
...new Set(
(replayKeys ?? [])
.map((replayKey) => replayKey?.trim())
.filter((replayKey): replayKey is string => Boolean(replayKey)),
),
];
}

View File

@@ -47,6 +47,10 @@ export type DiscordMessageHandlerWithLifecycle = DiscordMessageHandler & {
deactivate: () => void;
};
function isNonEmptyString(value: string | undefined): value is string {
return typeof value === "string" && value.length > 0;
}
export function createDiscordMessageHandler(
params: DiscordMessageHandlerParams,
): DiscordMessageHandlerWithLifecycle {
@@ -114,7 +118,7 @@ export function createDiscordMessageHandler(
if (!last) {
return;
}
const replayKeys = entries.map((entry) => entry.replayKey).filter(Boolean);
const replayKeys = entries.map((entry) => entry.replayKey).filter(isNonEmptyString);
const abortSignal = last.abortSignal;
if (abortSignal?.aborted) {
releaseDiscordInboundReplay({
@@ -177,7 +181,7 @@ export function createDiscordMessageHandler(
}
applyImplicitReplyBatchGate(ctx, params.replyToMode, true);
if (entries.length > 1) {
const ids = entries.map((entry) => entry.data.message?.id).filter(Boolean) as string[];
const ids = entries.map((entry) => entry.data.message?.id).filter(isNonEmptyString);
if (ids.length > 0) {
const ctxBatch = ctx as typeof ctx & {
MessageSids?: string[];

View File

@@ -80,6 +80,7 @@ describe("production lint suppressions", () => {
expect(summarizeSuppressions(collectProductionLintSuppressions())).toEqual([
"extensions/browser/src/browser/pw-tools-core.interactions.ts|@typescript-eslint/no-implied-eval|2",
"scripts/e2e/mcp-channels-harness.ts|unicorn/prefer-add-event-listener|1",
"src/agents/agent-scope-config.ts|no-control-regex|1",
"src/agents/agent-scope.ts|no-control-regex|1",
"src/agents/pi-embedded-runner/run/images.ts|no-control-regex|1",
"src/agents/skills-clawhub.ts|no-control-regex|1",