fix: code review cleanup - schema sync, type safety, null handling

- Sync KnowledgeLink schema with migration (add displayText, positionStart, positionEnd, resolved)
- Make targetId optional to support unresolved links
- Fix null handling in graph.service.ts (skip unresolved links)
- Add explicit types to frontend components (remove implicit any)
- Remove unused WikiLink import
- Add null-safe statusInfo check in EntryCard
This commit is contained in:
Jason Woltje
2026-01-29 23:36:41 -06:00
parent 26a334c677
commit 652ba50a19
8 changed files with 1369 additions and 24 deletions

View File

@@ -46,7 +46,7 @@ export default function EntryPage() {
setEditContent(data.content);
setEditStatus(data.status);
setEditVisibility(data.visibility);
setEditTags(data.tags.map((tag) => tag.id));
setEditTags(data.tags.map((tag: { id: string }) => tag.id));
} catch (err) {
setError(err instanceof Error ? err.message : "Failed to load entry");
} finally {
@@ -82,7 +82,7 @@ export default function EntryPage() {
editStatus !== entry.status ||
editVisibility !== entry.visibility ||
JSON.stringify(editTags.sort()) !==
JSON.stringify(entry.tags.map((t) => t.id).sort());
JSON.stringify(entry.tags.map((t: { id: string }) => t.id).sort());
setHasUnsavedChanges(changed);
}, [entry, isEditing, editTitle, editContent, editStatus, editVisibility, editTags]);
@@ -158,7 +158,7 @@ export default function EntryPage() {
setEditContent(entry.content);
setEditStatus(entry.status);
setEditVisibility(entry.visibility);
setEditTags(entry.tags.map((tag) => tag.id));
setEditTags(entry.tags.map((tag: { id: string }) => tag.id));
setIsEditing(false);
setHasUnsavedChanges(false);
}
@@ -250,7 +250,7 @@ export default function EntryPage() {
</span>
{/* Tags */}
{entry.tags.map((tag) => (
{entry.tags.map((tag: { id: string; name: string; color: string | null }) => (
<span
key={tag.id}
className="px-3 py-1 rounded-full text-xs font-medium bg-gray-200 dark:bg-gray-700 text-gray-700 dark:text-gray-300"

View File

@@ -40,7 +40,7 @@ export default function KnowledgePage() {
// Filter by tag
if (selectedTag !== "all") {
filtered = filtered.filter((entry) =>
entry.tags.some((tag) => tag.slug === selectedTag)
entry.tags.some((tag: { slug: string }) => tag.slug === selectedTag)
);
}
@@ -51,7 +51,7 @@ export default function KnowledgePage() {
(entry) =>
entry.title.toLowerCase().includes(query) ||
entry.summary?.toLowerCase().includes(query) ||
entry.tags.some((tag) => tag.name.toLowerCase().includes(query))
entry.tags.some((tag: { name: string }) => tag.name.toLowerCase().includes(query))
);
}

View File

@@ -61,7 +61,7 @@ export function EntryCard({ entry }: EntryCardProps) {
{/* Tags */}
{entry.tags && entry.tags.length > 0 && (
<div className="flex flex-wrap gap-1.5 mb-3">
{entry.tags.map((tag) => (
{entry.tags.map((tag: { id: string; name: string; color: string | null }) => (
<span
key={tag.id}
className="inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium"
@@ -79,10 +79,12 @@ export function EntryCard({ entry }: EntryCardProps) {
{/* Metadata row */}
<div className="flex flex-wrap items-center gap-3 text-xs text-gray-500">
{/* Status */}
<span className={`inline-flex items-center gap-1 px-2 py-1 rounded-full ${statusInfo.className}`}>
<span>{statusInfo.icon}</span>
<span>{statusInfo.label}</span>
</span>
{statusInfo && (
<span className={`inline-flex items-center gap-1 px-2 py-1 rounded-full ${statusInfo.className}`}>
<span>{statusInfo.icon}</span>
<span>{statusInfo.label}</span>
</span>
)}
{/* Visibility */}
<span className="inline-flex items-center gap-1">