Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/ui/src/builder/sidebar/BuilderSidebarToolkit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,12 @@ function getRelevantToolsInCategory(categoryId: string) {
});
const q = query.value.toLocaleLowerCase();
const queryApplied = enriched
.filter((tool) => !q || tool.name.toLocaleLowerCase().includes(q))
.filter(
(tool) =>
!q ||
tool.name.toLocaleLowerCase().includes(q) ||
tool.description.toLocaleLowerCase().includes(q),
)
.sort((a, b) =>
a.name.localeCompare(b.name, undefined, {
sensitivity: "base",
Expand Down Expand Up @@ -302,7 +307,12 @@ function getRelevantToolsInCategory(categoryId: string) {
});
const q = query.value.toLocaleLowerCase();
const queryApplied = enriched
.filter((tool) => !q || tool.name.toLocaleLowerCase().includes(q))
.filter(
(tool) =>
!q ||
tool.name.toLocaleLowerCase().includes(q) ||
tool.description.toLocaleLowerCase().includes(q),
)
Comment on lines +310 to +315
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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash

echo "=== Searching for getComponentDefinition implementation ==="
rg -n "getComponentDefinition" -A 8 -B 2 | head -100

echo ""
echo "=== Searching for component definition types ==="
rg -n "ComponentDefinition|interface.*Component|type.*Component" -A 5 | head -150

Repository: writer/writer-framework

Length of output: 16981


🏁 Script executed:

#!/bin/bash

echo "=== Reading BuilderSidebarToolkit.vue around lines 300-320 ==="
sed -n '300,320p' src/ui/src/builder/sidebar/BuilderSidebarToolkit.vue

echo ""
echo "=== Searching for getComponentDefinition implementation in writer framework ==="
rg -n "getComponentDefinition.*=" -A 15 | grep -v ".spec" | head -150

echo ""
echo "=== Checking ComponentDefinition TypeScript type ==="
fd -e "ts" -e "tsx" -e "d.ts" | xargs rg -l "interface.*ComponentDefinition|type.*ComponentDefinition" | head -5

Repository: writer/writer-framework

Length of output: 7301


🏁 Script executed:

#!/bin/bash

echo "=== Reading more of BuilderSidebarToolkit.vue to see typeList source ==="
sed -n '275,320p' src/ui/src/builder/sidebar/BuilderSidebarToolkit.vue

echo ""
echo "=== Searching for wf.getComponentDefinition implementation ==="
fd -e ts -e tsx | xargs rg -l "export.*getComponentDefinition|getComponentDefinition\s*=" | grep -v spec | grep -v node_modules

echo ""
echo "=== Looking at the wf object initialization ==="
rg -n "getComponentDefinition" src/ui/src/main.ts -A 2 -B 2

Repository: writer/writer-framework

Length of output: 1657


🏁 Script executed:

#!/bin/bash

echo "=== Searching for getComponentDefinition in templateMap.ts ==="
cat src/ui/src/core/templateMap.ts

echo ""
echo "=== Searching for getSupportedComponentTypes definition ==="
rg -n "getSupportedComponentTypes" -A 5 -B 2 | head -50

echo ""
echo "=== Checking writerTypes.ts for ComponentDefinition interface ==="
rg -n "interface.*ComponentDefinition|type.*ComponentDefinition" -A 20 src/ui/src/writerTypes.ts

Repository: writer/writer-framework

Length of output: 15309


Address TypeScript type safety and add defensive checks for description property.

The code accesses tool.description at line 314 without verifying it exists. While getComponentDefinition() is typed to return a WriterComponentDefinition with a required description: string, the actual implementation can return undefined due to optional chaining (getTemplate(type)?.writer). This type mismatch creates a maintenance risk.

Add optional chaining or a null check when destructuring the definition at line 305:

const { name, description = "", category } = getComponentDefinition(type) ?? {};

Or check whether getComponentDefinition result exists before destructuring properties, matching the defensive pattern already used elsewhere in the codebase (e.g., useFieldsErrors.ts line 37).

🤖 Prompt for AI Agents
In src/ui/src/builder/sidebar/BuilderSidebarToolkit.vue around lines 305 to 315,
the code destructures getComponentDefinition(type) without guarding for
undefined and then accesses tool.description in the filter, which can be
undefined; update the destructuring to safely handle a missing definition (e.g.,
assign from getComponentDefinition(type) ?? {} and default description to an
empty string or perform an explicit null check before destructuring) so that
description is always a string when used in the .filter and avoid runtime
errors.

.sort((a, b) =>
a.name.localeCompare(b.name, undefined, { sensitivity: "base" }),
);
Expand Down
Loading