Compare commits

...
2 Commits
Author SHA1 Message Date
openhands 92b0ba3b18 fix: make notImported studio filter work independently of import status
CI / check (push) Successful in 27s
CI / release (push) Skipped
CI / deploy (push) Successful in 56s
2026-08-21 13:41:06 +02:00
openhands 4b7cb519df fix: furniture interaction detection and automatic catalog offer_id rebuild
Interaction detection:
- Trust SWF-derived sit/lay/stand flags only when the logic XML actually
  contains action data (new hasActions metadata); otherwise fall back to
  keyword detection so custom furni without <action> nodes are still
  classified correctly
- Add French/Dutch/German/Spanish/Italian keywords (chaise, banquette,
  stoel, silla, sedia, stuhl, tafel, mesa, ...) to sit/lay/stand detection
  with token-boundary matching to avoid false positives like bedside_table
- Unify interaction_modes_count priority: mechanic fixed modes, then raw
  animation state count, then sit/lay fallback, then keyword default
- Detect mechanic type even when real flags are not used

Catalog integrity:
- Skip duplicate catalog_items inserts in clone and upload imports
- Re-check live catalog rows before applying generated repair SQL
- Add rebuildCatalogOfferIds() which rebuilds every catalog_items.offer_id
  from the local FurnitureData.json (matched by entry id, then classname)
  and run it after every import path (single, batch, batch-regen, clone)
2026-08-21 13:39:21 +02:00
15 changed files with 419 additions and 54 deletions

No files matched your search

@@ -10,6 +10,7 @@ import { getSource } from "@/lib/services/clone-sources";
import {
appendFurniEntriesBatch,
appendFurniEntry,
rebuildCatalogOfferIds,
reconcileFurniDataWithItemsBase,
} from "@/lib/services/furni-data";
import {
@@ -142,6 +143,7 @@ export const POST = withAdmin(
try {
await reconcileImportedOfferIds();
await reconcileFurniDataWithItemsBase();
await rebuildCatalogOfferIds();
await verifyAndFixInteractionModesCount();
await ensureFurniOwnership();
await syncAssetsToGamedataBundle();
@@ -10,6 +10,7 @@ import {
appendFurniEntriesBatch,
buildFurniEntry,
readFurniData,
rebuildCatalogOfferIds,
reconcileFurniDataWithItemsBase,
} from "@/lib/services/furni-data";
import {
@@ -269,6 +270,9 @@ export const POST = withAdmin(
// Verify the furnidata matches the DB ids
const furniReconcile = await reconcileFurniDataWithItemsBase();
// Rebuild every catalog offer_id from the furnidata
const offerRebuild = await rebuildCatalogOfferIds();
send({
type: "regen_complete",
succeeded,
@@ -281,6 +285,8 @@ export const POST = withAdmin(
furniDataFixedIds: furniReconcile.fixedIds,
furniDataMissing: furniReconcile.missing,
furniDataConflicts: furniReconcile.conflicts,
offerRebuildChecked: offerRebuild.checked,
offerRebuildFixed: offerRebuild.fixed,
duration: Date.now() - startTime,
});
@@ -5,6 +5,7 @@ import { logAudit } from "@/lib/services/audit";
import { getSource } from "@/lib/services/clone-sources";
import {
appendFurniEntriesBatch,
rebuildCatalogOfferIds,
reconcileFurniDataWithItemsBase,
} from "@/lib/services/furni-data";
import {
@@ -227,6 +228,7 @@ export const POST = withAdmin(
let furniDataFixedOfferIds = 0;
let furniDataMissing = 0;
let furniDataConflicts = 0;
let offerRebuildFixed = 0;
let interactionFixed = 0;
try {
offerIdsFixed = (await reconcileImportedOfferIds()).fixed;
@@ -239,6 +241,7 @@ export const POST = withAdmin(
furniDataFixedOfferIds = furniReconcile.fixedOfferIds;
furniDataMissing = furniReconcile.missing;
furniDataConflicts = furniReconcile.conflicts;
offerRebuildFixed = (await rebuildCatalogOfferIds()).fixed;
interactionFixed = (await verifyAndFixInteractionModesCount()).fixed;
} catch (err) {
console.warn(
@@ -260,6 +263,7 @@ export const POST = withAdmin(
furniDataFixedOfferIds,
furniDataMissing,
furniDataConflicts,
offerRebuildFixed,
interactionFixed,
duration: Date.now() - startTime,
});
+17 -1
View File
@@ -9,7 +9,10 @@ import { logAudit } from "@/lib/services/audit";
import { getCloneList } from "@/lib/services/clone-import";
import { getSource } from "@/lib/services/clone-sources";
import { getFurniAssetDirs } from "@/lib/services/furni-asset-dirs";
import { reconcileFurniDataWithItemsBase } from "@/lib/services/furni-data";
import {
rebuildCatalogOfferIds,
reconcileFurniDataWithItemsBase,
} from "@/lib/services/furni-data";
import {
autoPriceFurni,
CATEGORY_PAGE,
@@ -171,11 +174,14 @@ export const GET = withAdmin(
// Live furnidata reconcile (without hotel RCON reload)
if (action === "live-reconcile") {
const furniReconcile = await reconcileFurniDataWithItemsBase();
const offerRebuild = await rebuildCatalogOfferIds();
return apiOk({
furniDataFixedIds: furniReconcile.fixedIds,
furniDataFixedOfferIds: furniReconcile.fixedOfferIds,
furniDataMissing: furniReconcile.missing,
furniDataConflicts: furniReconcile.conflicts,
offerRebuildChecked: offerRebuild.checked,
offerRebuildFixed: offerRebuild.fixed,
});
}
@@ -452,6 +458,9 @@ export const POST = withAdmin(
// Verify the furnidata matches the DB ids
const furniReconcile = await reconcileFurniDataWithItemsBase();
// Rebuild every catalog offer_id from the furnidata
const offerRebuild = await rebuildCatalogOfferIds();
// Verify + fix interaction_modes_count once for the whole batch
const verification = await verifyAndFixInteractionModesCount();
@@ -471,6 +480,8 @@ export const POST = withAdmin(
furniDataFixedOfferIds: furniReconcile.fixedOfferIds,
furniDataMissing: furniReconcile.missing,
furniDataConflicts: furniReconcile.conflicts,
offerRebuildChecked: offerRebuild.checked,
offerRebuildFixed: offerRebuild.fixed,
interactionFixed: verification.fixed,
});
}
@@ -533,6 +544,9 @@ export const POST = withAdmin(
// Verify the furnidata matches the DB ids
const furniReconcile = await reconcileFurniDataWithItemsBase();
// Rebuild every catalog offer_id from the furnidata
const offerRebuild = await rebuildCatalogOfferIds();
// Verify + fix interaction_modes_count (single consolidated pass)
const verification = await verifyAndFixInteractionModesCount();
@@ -564,6 +578,8 @@ export const POST = withAdmin(
furniDataFixedOfferIds: furniReconcile.fixedOfferIds,
furniDataMissing: furniReconcile.missing,
furniDataConflicts: furniReconcile.conflicts,
offerRebuildChecked: offerRebuild.checked,
offerRebuildFixed: offerRebuild.fixed,
interactionFixed: verification.fixed,
spriteCount: result.spriteCount,
warnings: result.warnings,
+12 -7
View File
@@ -151,17 +151,16 @@ export function StudioClient({
result = result.filter((i) => i.category === categoryFilter);
}
if (statusFilter !== "all") {
if (statusFilter === "new")
result = result.filter((i) => !i.alreadyImported);
else if (statusFilter === "imported")
if (statusFilter === "imported")
result = result.filter((i) => i.alreadyImported);
else if (statusFilter === "inCatalog")
result = result.filter((i) => i.alreadyImported && i.nitroExists);
else if (statusFilter === "missingNitro")
result = result.filter((i) => i.alreadyImported && !i.nitroExists);
else if (statusFilter === "notImported")
result = result.filter((i) => !i.alreadyImported);
}
// Not imported filter - works independently (also with statusFilter === "all")
if (statusFilter === "notImported" || statusFilter === "all")
result = result.filter((i) => i.alreadyImported === false);
const sorted = [...result];
if (sortBy === "name") sorted.sort((a, b) => a.name.localeCompare(b.name));
else if (sortBy === "classname")
@@ -597,6 +596,11 @@ export function StudioClient({
[filteredItems],
);
const notImportedCount = useMemo(
() => filteredItems.filter((i) => i.alreadyImported === false).length,
[filteredItems],
);
return (
<div
className="flex h-[calc(100dvh-7rem)] min-h-[520px] flex-col overflow-hidden rounded-xl border border-[var(--admin-border)]"
@@ -741,8 +745,9 @@ export function StudioClient({
<SelectValue placeholder="Status" />
</SelectTrigger>
<SelectContent>
<SelectItem value="all">All statuses</SelectItem>
<SelectItem value="new">Not imported</SelectItem>
<SelectItem value="all">
All statuses {notImportedCount > 0 && notImportedCount}
</SelectItem>
<SelectItem value="imported">Imported</SelectItem>
<SelectItem value="inCatalog">In catalog</SelectItem>
<SelectItem value="missingNitro">Missing nitro</SelectItem>
+39 -3
View File
@@ -30,16 +30,52 @@ describe("autoDetectInteraction with real data", () => {
expect(result.interactionType).toBe("bed");
});
it("respects all-false real flags (no keyword false positive)", () => {
it("respects curated all-false real flags (no keyword false positive)", () => {
const result = autoDetectInteraction("table_plasto_4leg", "Table", {
cansiton: false,
canlayon: false,
canstandon: false,
hasActionData: true,
});
expect(result.canSit).toBe(false);
expect(result.canLay).toBe(false);
expect(result.canStand).toBe(false);
expect(result.interactionModesCount).toBe(0);
});
it("falls back to keywords when flags carry no action data", () => {
const result = autoDetectInteraction("chaise_metal_lamarr", "Chaise", {
cansiton: false,
canlayon: false,
canstandon: false,
animationStates: 4,
});
expect(result.canSit).toBe(true);
expect(result.canStand).toBe(false);
expect(result.interactionModesCount).toBe(4);
});
it("detects French bench (banquette) with raw state count", () => {
const result = autoDetectInteraction("banquette_lamarr", "Banquette", {
cansiton: false,
canlayon: false,
canstandon: false,
animationStates: 6,
});
expect(result.canSit).toBe(true);
expect(result.interactionType).toBe("bench");
expect(result.interactionModesCount).toBe(6);
});
it("does not match short keywords without token boundaries", () => {
const result = autoDetectInteraction("bedside_table", "Bedside Table", {
cansiton: false,
canlayon: false,
canstandon: false,
});
expect(result.canSit).toBe(false);
expect(result.canLay).toBe(false);
expect(result.canStand).toBe(false);
expect(result.interactionModesCount).toBe(0);
expect(result.interactionType).toBe("table");
});
it("detects dice mechanics from classname with fixed modes=6", () => {
File diff suppressed because it is too large. Load diff
+10
View File
@@ -361,6 +361,16 @@ export async function generateCatalogSql(
skipped++;
continue;
}
// Re-check against the live table: the audit snapshot may be stale and
// an import may have created the entry in the meantime. Inserting would
// create a duplicate catalog_items row for the same item_ids.
const [existing] = (await db.execute(sql`
SELECT id FROM catalog_items WHERE item_ids = ${String(entry.itemId)} LIMIT 1
`)) as unknown as [Array<{ id: number }>, unknown];
if (existing.length > 0) {
skipped++;
continue;
}
let pageId: number;
if (organizeSql && parentPageId) {
const catKey = classifyFurni(entry.classname, entry.itemType);
+13
View File
@@ -379,6 +379,8 @@ export async function cloneSingleFurni(params: {
cansiton: entry.cansiton,
canlayon: entry.canlayon,
canstandon: entry.canstandon,
// Source furnidata flags are curated → authoritative over keywords.
hasActionData: true,
logicType: (clonedNitroJson?.logicType as string) || undefined,
animationStates: nitroAnimationStatesCount(clonedNitroJson),
});
@@ -440,7 +442,17 @@ export async function cloneSingleFurni(params: {
}
// Catalog entry (category sub-page + auto price), serialized id allocation.
// Skip when the item already has a catalog row — re-imports must never
// create a second row for the same item_ids.
try {
const [existingCatalog] = (await db.execute(sql`
SELECT id FROM catalog_items WHERE item_ids = ${String(newId)} LIMIT 1
`)) as unknown as [Array<{ id: number }>, unknown];
if (existingCatalog.length > 0) {
warnings.push(
`catalog entry already exists (#${existingCatalog[0].id}) — skipped duplicate`,
);
} else {
const pageId = await getOrCreateCategoryPage(classname, itemType);
const price = autoPriceFurni(classname);
await allocateCatalogItemId(async (nextCatalogId) => {
@@ -449,6 +461,7 @@ export async function cloneSingleFurni(params: {
VALUES (${nextCatalogId}, ${String(pageId)}, ${String(newId)}, ${classname}, ${price.credits}, ${price.points}, ${price.pointsType}, 1, 1, ${newId}, '')`);
return nextCatalogId;
});
}
} catch (err) {
logger.warn("[clone-import] catalog entry failed for", {
classname,
File diff suppressed because it is too large. Load diff
+21 -10
View File
@@ -848,10 +848,21 @@ export async function importSingleFurni(params: {
: { x: 1, y: 1, z: 0 });
const meta = conversionResult?.metadata ?? null;
// Prefer .nitro flags, then the configured official Habbo furnidata.
const cansiton = meta?.cansiton ?? officialHabbo?.cansiton ?? false;
const canlayon = meta?.canlayon ?? officialHabbo?.canlayon ?? false;
const canstandon = meta?.canstandon ?? officialHabbo?.canstandon ?? false;
// Real sit/lay/stand flags: prefer .nitro logic flags, then the configured
// official Habbo furnidata. Only pass them when a real source exists —
// defaulted all-false values must not suppress keyword detection (custom
// SWFs often ship without <action> nodes even for sittable furniture).
const realSource = meta ?? officialHabbo;
const realFlags = realSource
? {
cansiton: realSource.cansiton ?? false,
canlayon: realSource.canlayon ?? false,
canstandon: realSource.canstandon ?? false,
// Official furnidata is curated → authoritative. SWF-derived flags
// are only authoritative when the logic actually had <action> nodes.
hasActionData: meta ? (meta.hasActions ?? true) : true,
}
: undefined;
// Derive interaction_type. Priority:
// 1. Wired LOGIC items (wf_act_/wf_trg_/wf_cnd_/wf_slc_/wf_xtra_/wf_var_)
@@ -903,9 +914,7 @@ export async function importSingleFurni(params: {
// no .nitro JSON available — keyword fallback only
}
const autoInteraction = autoDetectInteraction(classname, bestName, {
cansiton,
canlayon,
canstandon,
...realFlags,
logicType,
animationStates: nitroAnimationStatesCount(nitroJsonForModes),
});
@@ -929,9 +938,9 @@ export async function importSingleFurni(params: {
const update = buildItemsBaseEnrichmentUpdate({
id: spriteId,
dims,
cansiton,
canlayon,
canstandon,
cansiton: autoInteraction.canSit,
canlayon: autoInteraction.canLay,
canstandon: autoInteraction.canStand,
allowStack,
interactionType,
interactionModesCount,
@@ -1123,6 +1132,8 @@ export async function verifyAndFixInteractionModesCount(): Promise<{
cansiton: realFlags.cansiton,
canlayon: realFlags.canlayon,
canstandon: realFlags.canstandon,
// Furnidata flags are curated → authoritative over keywords.
hasActionData: true,
animationStates: animationModes,
});
+1
View File
@@ -425,6 +425,7 @@ export function convertSwfToNitro(
canstandon: logic.canstandon,
cansiton: logic.cansiton,
canlayon: logic.canlayon,
hasActions: logic.hasActions,
specialtype: indexData?.specialtype ?? 0,
defaultdir: computeDefaultDir(logic.directions),
partcolors: extractPartColors(visualizations),
+4
View File
@@ -226,6 +226,8 @@ export interface LogicResult {
canstandon: boolean;
cansiton: boolean;
canlayon: boolean;
/** True when the logic XML actually declared <action> nodes — flags are then authoritative. */
hasActions: boolean;
action?: { link?: string; startState?: number };
credits?: string;
soundSample?: { id: number; noPitch?: boolean };
@@ -242,6 +244,7 @@ export function processLogic(xml: string): LogicResult {
canstandon: false,
cansiton: false,
canlayon: false,
hasActions: false,
};
const root = parseXml(xml);
if (!root) return defaults;
@@ -285,6 +288,7 @@ export function processLogic(xml: string): LogicResult {
canstandon,
cansiton,
canlayon,
hasActions: actions.length > 0,
};
// Parse action link/startState
+14
View File
@@ -337,6 +337,8 @@ export async function uploadSingleFurni(params: {
cansiton,
canlayon,
canstandon,
// Flags come from explicit user input → authoritative over keywords.
hasActionData: true,
logicType: (nitroMeta?.logicType as string) || undefined,
animationStates: nitroAnimationStatesCount(nitroMeta),
});
@@ -387,6 +389,17 @@ export async function uploadSingleFurni(params: {
let catalogItemId: number | null = null;
try {
// Skip when the item already has a catalog row — re-uploads must never
// create a second row for the same item_ids.
const [existingCatalog] = (await db.execute(sql`
SELECT id FROM catalog_items WHERE item_ids = ${String(newId)} LIMIT 1
`)) as unknown as [Array<{ id: number }>, unknown];
if (existingCatalog.length > 0) {
catalogItemId = existingCatalog[0].id;
warnings.push(
`catalog entry already exists (#${catalogItemId}) — skipped duplicate`,
);
} else {
const pageId = await getOrCreateCategoryPage(classname, itemType);
catalogItemId = await allocateCatalogItemId(async (nextCatalogId) => {
await db.execute(sql`
@@ -394,6 +407,7 @@ export async function uploadSingleFurni(params: {
VALUES (${nextCatalogId}, ${String(pageId)}, ${String(newId)}, ${classname}, ${price.credits}, ${price.points}, ${price.pointsType}, 1, 1, ${newId}, '')`);
return nextCatalogId;
});
}
} catch (err) {
warnings.push(`catalog entry failed: ${(err as Error).message}`);
}
+2
View File
@@ -24,6 +24,8 @@ export interface FurniMetadata {
canstandon: boolean;
cansiton: boolean;
canlayon: boolean;
/** True when the SWF logic XML declared <action> nodes (flags authoritative). */
hasActions?: boolean;
specialtype: number;
defaultdir: number;
partcolors: { color: string[] };