Skip to content

Commit 746b2e4

Browse files
feat(web): cited sources as a reference list ([n] title, page)
1 parent 1971c9c commit 746b2e4

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

web/app/chat.jsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,17 +147,17 @@ function AiMessage({ msg, onCite, onFig, paperTitle, pendingLabel }) {
147147
)}
148148
</div>
149149
{done && !msg.error && cited.length > 0 && (
150-
<div className="answer-figs rise">
151-
{cited.slice(0, 6).map((c) => (
152-
<button key={c.id} className="answer-fig" title="View cited source"
150+
<div className="answer-sources rise">
151+
<div className="src-head">Sources</div>
152+
{cited.map((c) => (
153+
<button key={c.id} className="src-row" title="View source"
153154
onClick={() => onFig({
154155
chunk_id: c.id, paper: c.paper, page: c.page, pages: [c.page],
155156
kind: c.kind, bbox: c.bbox || null, text: c.quote || "", page_cite: !!c.page_cite,
156157
})}>
157-
<div className="answer-fig-img" style={{ height: 92 }}>
158-
<img src={window.RAG.pageImageUrl(c.paper, c.page)} alt={`page ${c.page}`} loading="lazy" />
159-
</div>
160-
<div className="cap"><b>[{c.n}] p.{c.page}</b> {previewQuote(c.quote || "", 56)}</div>
158+
<span className="src-n">[{c.n}]</span>
159+
<span className="src-title">{previewQuote(paperTitle ? paperTitle(c.paper) : c.paper, 80)}</span>
160+
<span className="src-page">{c.kind === "visual" && <Icon name="image" size={11} />} p.{c.page}</span>
161161
</button>
162162
))}
163163
</div>

web/app/styles.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,21 @@ body {
552552
.answer-fig-img { overflow: hidden; background: #fdfdfb; }
553553
.answer-fig-img img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
554554

555+
/* Cited-sources reference list under an answer (paper-style [n] title · p.N). */
556+
.answer-sources { display: flex; flex-direction: column; gap: 1px; margin: 14px 0 2px; }
557+
.answer-sources .src-head { font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 5px; }
558+
.src-row {
559+
display: flex; align-items: baseline; gap: 9px; width: 100%; text-align: left;
560+
padding: 5px 9px; border: none; border-left: 2px solid var(--border); background: none;
561+
border-radius: 0 7px 7px 0; cursor: pointer; color: var(--text-dim); font-size: 12.5px;
562+
font-family: inherit; transition: background .12s, border-color .12s, color .12s;
563+
}
564+
.src-row:hover { background: var(--border-soft); color: var(--text); border-left-color: var(--accent-line); }
565+
.src-n { font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--accent); flex: none; }
566+
.src-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
567+
.src-page { font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--text-faint); flex: none; display: inline-flex; align-items: center; gap: 4px; }
568+
.src-page .ico { color: var(--visual); }
569+
555570
.ai-foot { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
556571
.metric { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-faint); }
557572
.metric b { font-family: "IBM Plex Mono", monospace; color: var(--text-dim); font-weight: 500; }

0 commit comments

Comments
 (0)