feat: review text hits and release false-positive mappings

This commit is contained in:
muena
2026-10-19 06:44:21 +02:00
parent ebf78128c4
commit 03a793ad7c
20 changed files with 536 additions and 210 deletions

View File

@@ -2,6 +2,8 @@ import { LocalStorage } from "@raycast/api";
import { randomUUID } from "node:crypto";
import { getPreferences } from "./preferences";
import type { PlaceholderMapping, VelumSession } from "./types";
import { mappingRoot } from "./lib/mapping-groups";
import { whitelistKey } from "./lib/project-whitelist";
const SESSIONS_STORAGE_KEY = "velum.sessions.v1";
const ACTIVE_SESSION_STORAGE_KEY = "velum.sessions.active.v1";
@@ -85,6 +87,7 @@ export async function updateSessionMapping(
id: string,
mapping: PlaceholderMapping,
entityTypes?: string[],
excludedTerms?: VelumSession["excludedTerms"],
): Promise<VelumSession> {
const sessions = await listSessions();
const timestamp = nowIso();
@@ -98,6 +101,7 @@ export async function updateSessionMapping(
updatedAt: timestamp,
mapping,
entityTypes,
excludedTerms,
};
await saveSessions([created, ...sessions]);
return created;
@@ -107,6 +111,7 @@ export async function updateSessionMapping(
...sessions[index],
mapping,
entityTypes,
excludedTerms: excludedTerms ?? sessions[index].excludedTerms,
updatedAt: timestamp,
};
const next = [...sessions];
@@ -115,6 +120,18 @@ export async function updateSessionMapping(
return updated;
}
export async function releaseSessionMappingGroup(id: string, root: string): Promise<VelumSession> {
const session = await getSession(id);
if (!session) throw new Error("Sitzung nicht gefunden.");
if (!session.mapping[root]) throw new Error("Zuordnung nicht gefunden. Bitte die Ansicht aktualisieren.");
const removed = Object.keys(session.mapping).filter((key) => mappingRoot(key, session.mapping) === root);
const mapping = Object.fromEntries(Object.entries(session.mapping).filter(([key]) => !removed.includes(key)));
const excludedTerms = [...new Map([...(session.excludedTerms ?? []),
...removed.map((key) => ({ type: session.mapping[key].type, original: session.mapping[key].original }))]
.map((entry) => [whitelistKey(entry), entry])).values()];
return updateSessionMapping(id, mapping, session.entityTypes, excludedTerms);
}
export async function renameSession(id: string, name: string): Promise<void> {
const sessions = await listSessions();
await saveSessions(