Skip to content

fix: align furniture construction rendering with BN data#138

Merged
ushkinaz merged 1 commit intomainfrom
codex/fix-135-furniture-construction
Mar 19, 2026
Merged

fix: align furniture construction rendering with BN data#138
ushkinaz merged 1 commit intomainfrom
codex/fix-135-furniture-construction

Conversation

@ushkinaz
Copy link
Owner

Summary

  • add explicit BN furniture construction fields and central helpers for terrain/furniture construction links
  • show furniture page construction sections from post_furniture instead of terrain-only lookups
  • remove legacy f_ prefix inference from construction views and add focused regression tests

Testing

  • pnpm lint
  • pnpm check
  • pnpm vitest run src --exclude "src/all.*.test.ts" --exclude "src/__mod_tests__/**" --no-color
  • browser check against http://127.0.0.1:3000/stable/furniture/f_sign

Closes #135

@ushkinaz
Copy link
Owner Author

ushkinaz commented Mar 18, 2026

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2026

@ushkinaz: Acknowledged. Initiating review sequence for PR #138. Scanning diffs — furniture construction rendering alignment, BN data integration, and regression test coverage are primary targets. Stand by.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 18, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Construction prerequisites and results now display as comprehensive lists instead of single items.
  • Bug Fixes

    • Improved null construction result handling with explicit "nothing" messaging.
  • Tests

    • Added component tests for construction prerequisites and results display.

Walkthrough

TypeScript type definitions now explicitly model furniture construction targets via dedicated pre_furniture and post_furniture fields, replacing implicit f_ prefix encoding. New utility functions extract construction prerequisites and results, and UI components refactored to render these as searchable lists instead of single values.

Changes

Cohort / File(s) Summary
Type System Expansion
src/types.ts
Added pre_furniture and post_furniture optional fields to Construction type; removed inline comment describing f_ prefix encoding strategy. Structure now explicitly separates furniture from terrain.
Construction Display Infrastructure
src/types/construction.ts, src/types/Construction.svelte, src/types/Construction.test.ts
New module exports ConstructionSurfaceTarget type and helper functions (getConstructionPrerequisites, getConstructionResults, isNullConstructionResult). Construction component refactored to render prerequisite/result lists via helpers; dual test cases validate furniture and terrain prerequisite/result rendering with null-result handling.
Furniture Construction Filtering
src/types/Furniture.svelte, src/types/Furniture.test.ts
Construction filter changed from post_terrain === item.id to post_furniture === item.id for furniture item pages. Test validates that only post_furniture-linked constructions and not post_terrain-linked constructions are displayed.
Prerequisite Rendering Updates
src/types/ToolQuality.svelte, src/types/item/ComponentOf.svelte, src/types/item/ConstructionByproduct.svelte
Replaced manual pre_terrain string parsing and type inference (via f_ prefix detection) with calls to getConstructionPrerequisites. Components now iterate explicit {type, id} prerequisite objects and render comma-separated ItemLink lists instead of OR-joined single values.

Sequence Diagram

sequenceDiagram
    participant Component as UI Component
    participant Helper as construction.ts<br/>(Helpers)
    participant Data as Construction<br/>Data
    participant Render as Rendered<br/>Output

    Component->>Data: pass construction object
    Component->>Helper: getConstructionPrerequisites(construction)
    Helper->>Data: extract pre_terrain / pre_furniture
    Data-->>Helper: raw field values
    Helper->>Helper: map to ConstructionSurfaceTarget[]<br/>(explicit type + id)
    Helper-->>Component: prerequisites array
    
    Component->>Helper: getConstructionResults(construction)
    Helper->>Data: extract post_terrain / post_furniture
    Data-->>Helper: raw field values
    Helper->>Helper: map to ConstructionSurfaceTarget[]<br/>(explicit type + id)
    Helper-->>Component: results array
    
    Component->>Component: iterate prerequisites
    Component->>Render: render ItemLink per<br/>prerequisite.type/.id
    
    Component->>Component: iterate results
    Component->>Helper: isNullConstructionResult(result)?
    Helper-->>Component: boolean (t_null / f_null check)
    alt null result
        Component->>Render: render "nothing" label
    else valid result
        Component->>Render: render ItemLink per<br/>result.type/.id
    end
Loading

Poem

🏗️ No more shadows in the f_ prefix—
Furniture constructions step into daylight,
Pre and post split explicit and right,
Lists cascade where singles once sat.
BN semantics crystallize at last. ⚙️

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Title directly summarizes the primary change: aligning furniture construction rendering with BN data structure by adding post_furniture/pre_furniture fields.
Description check ✅ Passed Description provides relevant context: explicit furniture construction fields, central helpers, post_furniture filtering instead of post_terrain, removal of legacy f_ prefix inference, and testing protocols.
Linked Issues check ✅ Passed All core objectives from #135 are met: types updated with pre_furniture/post_furniture [src/types.ts], furniture filtering changed to post_furniture [src/types/Furniture.svelte], legacy f_ prefix inference removed [src/types/ToolQuality.svelte, ComponentOf.svelte, ConstructionByproduct.svelte], and regression tests added [Construction.test.ts, Furniture.test.ts].
Out of Scope Changes check ✅ Passed All changes target furniture construction alignment: new construction.ts utility module supports terrain/furniture separation, helper functions remove prefix inference, and component updates consistently adopt post_furniture semantics. No extraneous modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📋 Issue Planner

Built with CodeRabbit's Coding Plans for faster development and fewer bugs.

View plan used: #135

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-135-furniture-construction
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/types/ToolQuality.svelte`:
- Around line 210-215: The UI currently outputs a raw "on" literal in the
prerequisites list (in the block that calls getConstructionPrerequisites and
renders ItemLink), which must be localized; replace the hardcoded "on" with a
localized string using t from `@transifex/native` (e.g., t('on')) or extract a
small shared renderer/helper to render the separator so the same localized
string is reused in ConstructionByproduct.svelte and ComponentOf.svelte; update
the occurrences around getConstructionPrerequisites/ItemLink and the matching
fragments in ConstructionByproduct and ComponentOf to use the t(...) call or the
shared component instead of the raw literal so all user-facing text is
localized.

In `@src/utils/construction.ts`:
- Around line 8-47: Add JSDoc comments for the public functions
getConstructionPrerequisites, getConstructionResults, and
isNullConstructionResult: for each function include a one-line description, a
`@param` describing the construction parameter shape (e.g., Pick<Construction,
"..."> and meaning of fields like pre_terrain/pre_furniture or
post_terrain/post_furniture), and a `@returns` describing the
ConstructionSurfaceTarget[] (or boolean for isNullConstructionResult) and what
the values represent (terrain vs furniture and null ids t_null/f_null). Keep the
comments brief and place them immediately above each function so IDEs and docs
can pick them up.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b98890bd-4f20-45ce-a93b-dc9fa370e51e

📥 Commits

Reviewing files that changed from the base of the PR and between bfb65ce and 1eab576.

📒 Files selected for processing (9)
  • src/types.ts
  • src/types/Construction.svelte
  • src/types/Construction.test.ts
  • src/types/Furniture.svelte
  • src/types/Furniture.test.ts
  • src/types/ToolQuality.svelte
  • src/types/item/ComponentOf.svelte
  • src/types/item/ConstructionByproduct.svelte
  • src/utils/construction.ts

Comment on lines +210 to +215
{@const prerequisites = getConstructionPrerequisites(f)}
{#if prerequisites.length}
on {#each prerequisites as prerequisite, i}
{#if i !== 0},
{/if}
<ItemLink type={prerequisite.type} id={prerequisite.id} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Localize the new prerequisite separator.

The raw on literal is now shipped in UI output, so translated builds will leak English here. The same fragment was copied into src/types/item/ConstructionByproduct.svelte (Lines 36-41) and src/types/item/ComponentOf.svelte (Lines 132-137 and 155-160); route it through t(...) or extract a shared renderer before this drifts further.

As per coding guidelines, "Use t from @transifex/native for all user-facing text".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/types/ToolQuality.svelte` around lines 210 - 215, The UI currently
outputs a raw "on" literal in the prerequisites list (in the block that calls
getConstructionPrerequisites and renders ItemLink), which must be localized;
replace the hardcoded "on" with a localized string using t from
`@transifex/native` (e.g., t('on')) or extract a small shared renderer/helper to
render the separator so the same localized string is reused in
ConstructionByproduct.svelte and ComponentOf.svelte; update the occurrences
around getConstructionPrerequisites/ItemLink and the matching fragments in
ConstructionByproduct and ComponentOf to use the t(...) call or the shared
component instead of the raw literal so all user-facing text is localized.

Comment on lines +8 to +47
export function getConstructionPrerequisites(
construction: Pick<Construction, "pre_terrain" | "pre_furniture">,
): ConstructionSurfaceTarget[] {
const prerequisites: ConstructionSurfaceTarget[] = [];

if (construction.pre_terrain) {
prerequisites.push({ id: construction.pre_terrain, type: "terrain" });
}

if (construction.pre_furniture) {
prerequisites.push({ id: construction.pre_furniture, type: "furniture" });
}

return prerequisites;
}

export function getConstructionResults(
construction: Pick<Construction, "post_terrain" | "post_furniture">,
): ConstructionSurfaceTarget[] {
const results: ConstructionSurfaceTarget[] = [];

if (construction.post_terrain) {
results.push({ id: construction.post_terrain, type: "terrain" });
}

if (construction.post_furniture) {
results.push({ id: construction.post_furniture, type: "furniture" });
}

return results;
}

export function isNullConstructionResult(
result: ConstructionSurfaceTarget,
): boolean {
return (
(result.type === "terrain" && result.id === "t_null") ||
(result.type === "furniture" && result.id === "f_null")
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Advisory: Consider JSDoc for public API surface.

Per coding guidelines, public functions warrant JSDoc documentation. Current signatures are self-documenting, but brief descriptions would enhance IDE telemetry and onboarding velocity for downstream consumers.

📝 Optional: Add JSDoc headers
+/**
+ * Extracts prerequisite surfaces (terrain/furniture) from a construction definition.
+ */
 export function getConstructionPrerequisites(
   construction: Pick<Construction, "pre_terrain" | "pre_furniture">,
 ): ConstructionSurfaceTarget[] {
+/**
+ * Extracts result surfaces (terrain/furniture) from a construction definition.
+ */
 export function getConstructionResults(
   construction: Pick<Construction, "post_terrain" | "post_furniture">,
 ): ConstructionSurfaceTarget[] {
+/**
+ * Returns true if the target represents a null/removal result (t_null or f_null).
+ */
 export function isNullConstructionResult(
   result: ConstructionSurfaceTarget,
 ): boolean {

As per coding guidelines: "Use JSDoc comments for public functions and complex logic."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export function getConstructionPrerequisites(
construction: Pick<Construction, "pre_terrain" | "pre_furniture">,
): ConstructionSurfaceTarget[] {
const prerequisites: ConstructionSurfaceTarget[] = [];
if (construction.pre_terrain) {
prerequisites.push({ id: construction.pre_terrain, type: "terrain" });
}
if (construction.pre_furniture) {
prerequisites.push({ id: construction.pre_furniture, type: "furniture" });
}
return prerequisites;
}
export function getConstructionResults(
construction: Pick<Construction, "post_terrain" | "post_furniture">,
): ConstructionSurfaceTarget[] {
const results: ConstructionSurfaceTarget[] = [];
if (construction.post_terrain) {
results.push({ id: construction.post_terrain, type: "terrain" });
}
if (construction.post_furniture) {
results.push({ id: construction.post_furniture, type: "furniture" });
}
return results;
}
export function isNullConstructionResult(
result: ConstructionSurfaceTarget,
): boolean {
return (
(result.type === "terrain" && result.id === "t_null") ||
(result.type === "furniture" && result.id === "f_null")
);
}
/**
* Extracts prerequisite surfaces (terrain/furniture) from a construction definition.
*/
export function getConstructionPrerequisites(
construction: Pick<Construction, "pre_terrain" | "pre_furniture">,
): ConstructionSurfaceTarget[] {
const prerequisites: ConstructionSurfaceTarget[] = [];
if (construction.pre_terrain) {
prerequisites.push({ id: construction.pre_terrain, type: "terrain" });
}
if (construction.pre_furniture) {
prerequisites.push({ id: construction.pre_furniture, type: "furniture" });
}
return prerequisites;
}
/**
* Extracts result surfaces (terrain/furniture) from a construction definition.
*/
export function getConstructionResults(
construction: Pick<Construction, "post_terrain" | "post_furniture">,
): ConstructionSurfaceTarget[] {
const results: ConstructionSurfaceTarget[] = [];
if (construction.post_terrain) {
results.push({ id: construction.post_terrain, type: "terrain" });
}
if (construction.post_furniture) {
results.push({ id: construction.post_furniture, type: "furniture" });
}
return results;
}
/**
* Returns true if the target represents a null/removal result (t_null or f_null).
*/
export function isNullConstructionResult(
result: ConstructionSurfaceTarget,
): boolean {
return (
(result.type === "terrain" && result.id === "t_null") ||
(result.type === "furniture" && result.id === "f_null")
);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils/construction.ts` around lines 8 - 47, Add JSDoc comments for the
public functions getConstructionPrerequisites, getConstructionResults, and
isNullConstructionResult: for each function include a one-line description, a
`@param` describing the construction parameter shape (e.g., Pick<Construction,
"..."> and meaning of fields like pre_terrain/pre_furniture or
post_terrain/post_furniture), and a `@returns` describing the
ConstructionSurfaceTarget[] (or boolean for isNullConstructionResult) and what
the values represent (terrain vs furniture and null ids t_null/f_null). Keep the
comments brief and place them immediately above each function so IDEs and docs
can pick them up.

Show furniture constructions from post_furniture and remove

legacy f_ prefix inference across construction views.

Add focused regression tests and verify the furniture

construction path in the browser.

Refs #135
@ushkinaz ushkinaz force-pushed the codex/fix-135-furniture-construction branch from 1eab576 to e388ca2 Compare March 19, 2026 12:25
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/types/Furniture.test.ts`:
- Around line 49-55: The terrain test fixture object in Furniture.test.ts (the
terrain entry in the test data array) is missing required schema fields
`symbol`, `color`, and `move_cost`, which may break future strict validation;
update the terrain object in the test fixture to include these fields (e.g., add
`symbol`, `color`, and `move_cost`) so it conforms to the schema used by the
CBNData constructor/validation logic (refer to the terrain object in the test
data array and CBNData usage to locate where to update).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 00d2b0e3-af7d-4e9e-8720-dcc6b8c5606e

📥 Commits

Reviewing files that changed from the base of the PR and between 1eab576 and e388ca2.

📒 Files selected for processing (9)
  • src/types.ts
  • src/types/Construction.svelte
  • src/types/Construction.test.ts
  • src/types/Furniture.svelte
  • src/types/Furniture.test.ts
  • src/types/ToolQuality.svelte
  • src/types/construction.ts
  • src/types/item/ComponentOf.svelte
  • src/types/item/ConstructionByproduct.svelte

Comment on lines +49 to +55
{
type: "terrain",
id: "t_pit",
name: "pit",
description: "A test pit.",
},
]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Test fixture incomplete but non-critical.

Terrain record at Lines 50-54 lacks required schema fields (symbol, color, move_cost). CBNData constructor may tolerate partial records for test purposes. If strict validation is later enforced, this fixture will require augmentation.

🔧 Optional: Complete terrain fixture
       {
         type: "terrain",
         id: "t_pit",
         name: "pit",
         description: "A test pit.",
+        symbol: "0",
+        color: "brown",
+        move_cost: 10,
       },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
type: "terrain",
id: "t_pit",
name: "pit",
description: "A test pit.",
},
]);
{
type: "terrain",
id: "t_pit",
name: "pit",
description: "A test pit.",
symbol: "0",
color: "brown",
move_cost: 10,
},
]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/types/Furniture.test.ts` around lines 49 - 55, The terrain test fixture
object in Furniture.test.ts (the terrain entry in the test data array) is
missing required schema fields `symbol`, `color`, and `move_cost`, which may
break future strict validation; update the terrain object in the test fixture to
include these fields (e.g., add `symbol`, `color`, and `move_cost`) so it
conforms to the schema used by the CBNData constructor/validation logic (refer
to the terrain object in the test data array and CBNData usage to locate where
to update).

@ushkinaz ushkinaz merged commit cd878b1 into main Mar 19, 2026
6 checks passed
@ushkinaz ushkinaz deleted the codex/fix-135-furniture-construction branch March 19, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Furniture construction section ignores post_furniture and needs a BN rewrite

1 participant