Fix dead code, isEditing guard, and empty state condition

- Remove unused hashCode function from markdown-text.tsx (leftover from
  removed artifacts feature)
- Include editing state in isEditing check so Cancel button stays visible
  when user clears name/content fields while editing an existing prompt
- Fix empty state message to only show when no items exist in any section
  (pinned, folders, or unfiled), not just when filteredItems is empty
This commit is contained in:
Daniel Han 2026-03-31 13:32:03 +00:00
commit 392c59bdc9
3 changed files with 2 additions and 11 deletions

View file

@ -50,15 +50,6 @@ type CodeFence = {
source: string;
};
function hashCode(str: string): string {
let hash = 0;
for (let i = 0; i < str.length; i++) {
const char = str.charCodeAt(i);
hash = ((hash << 5) - hash + char) | 0;
}
return Math.abs(hash).toString(36);
}
function getMermaidSource(blockContent: string): string | null {
const source = blockContent.match(MERMAID_SOURCE_RE)?.[1]?.trim();
return source && source.length > 0 ? source : null;

View file

@ -88,7 +88,7 @@ export const PromptLibrarySheet: FC<{
);
const items = prompts ?? [];
const isEditing = name !== "" || content !== "";
const isEditing = editing !== null || name !== "" || content !== "";
return (
<Sheet open={open} onOpenChange={onOpenChange}>

View file

@ -448,7 +448,7 @@ export function ThreadSidebar({
<SidebarMenu>
{unfiledItems.map(renderItem)}
</SidebarMenu>
{filteredItems.length === 0 && (
{unfiledItems.length === 0 && pinnedItems.length === 0 && folderedItems.size === 0 && (
<p className="px-2 py-6 text-center text-xs text-muted-foreground">
{debouncedQuery.trim() ? "No matching threads" : "No threads yet"}
</p>