mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-27 06:15:15 +00:00
fix(raycast): display zero relevance scores (#1710)
This commit is contained in:
parent
bbe05bd9e4
commit
8b24b3aaf6
2 changed files with 10 additions and 4 deletions
3
apps/raycast-extension/src/relevance-score.ts
Normal file
3
apps/raycast-extension/src/relevance-score.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
export function formatRelevanceScore(score: number | undefined) {
|
||||
return score === undefined ? undefined : `${Math.round(score * 100)}%`
|
||||
}
|
||||
|
|
@ -8,9 +8,10 @@ import {
|
|||
Toast,
|
||||
getSelectedText,
|
||||
} from "@raycast/api"
|
||||
import { usePromise } from "@raycast/utils"
|
||||
import { useState, useEffect } from "react"
|
||||
import { searchMemories, type SearchResult } from "./api"
|
||||
import { usePromise } from "@raycast/utils"
|
||||
import { formatRelevanceScore } from "./relevance-score"
|
||||
import { withSupermemory } from "./withSupermemory"
|
||||
|
||||
const extractContent = (memory: SearchResult) => {
|
||||
|
|
@ -144,6 +145,7 @@ function Command() {
|
|||
) : (
|
||||
searchResults.map((memory) => {
|
||||
const content = extractContent(memory)
|
||||
const relevanceScore = formatRelevanceScore(memory.score)
|
||||
const url = extractUrl(memory)
|
||||
return (
|
||||
<List.Item
|
||||
|
|
@ -153,8 +155,8 @@ function Command() {
|
|||
subtitle={{ value: truncateContent(content), tooltip: content }}
|
||||
accessories={[
|
||||
{ text: formatDate(memory.createdAt) },
|
||||
...(memory.score
|
||||
? [{ text: `${Math.round(memory.score * 100)}%` }]
|
||||
...(relevanceScore !== undefined
|
||||
? [{ text: relevanceScore }]
|
||||
: []),
|
||||
]}
|
||||
actions={
|
||||
|
|
@ -188,6 +190,7 @@ function Command() {
|
|||
|
||||
function MemoryDetail({ memory }: { memory: SearchResult }) {
|
||||
const content = extractContent(memory)
|
||||
const relevanceScore = formatRelevanceScore(memory.score)
|
||||
const url = extractUrl(memory)
|
||||
|
||||
const markdown = `
|
||||
|
|
@ -199,7 +202,7 @@ ${content}
|
|||
|
||||
**Created:** ${new Date(memory.createdAt).toLocaleString()}
|
||||
${url ? `**URL:** ${url}` : ""}
|
||||
${memory.score ? `**Relevance:** ${Math.round(memory.score * 100)}%` : ""}
|
||||
${relevanceScore !== undefined ? `**Relevance:** ${relevanceScore}` : ""}
|
||||
`
|
||||
|
||||
return (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue