feat: auto-summarize long requests in Summary View; smarter placeholder text

This commit is contained in:
James 2026-03-14 19:51:59 -04:00
parent c2ddca03b7
commit cec6841938
1 changed files with 18 additions and 14 deletions

View File

@ -415,6 +415,22 @@
return false;
}
// Auto-summarize long request text for Summary View.
// Short text (≤8 words or ≤60 chars) is returned as-is.
// Longer text: extract the first complete sentence; if still long, trim to ~80 chars at a word boundary.
function summarize(text) {
if (!text) return text;
const wordCount = text.trim().split(/\s+/).length;
if (wordCount <= 8 || text.length <= 60) return text;
// Try to find a sentence boundary
const m = text.match(/^(.+?[.!?])(?:\s|$)/);
if (m && m[1].length <= 120) return m[1];
// No clean sentence — trim to ~80 chars at last word boundary
if (text.length <= 80) return text;
const cut = text.lastIndexOf(' ', 80);
return text.substring(0, cut > 20 ? cut : 80) + '…';
}
function renderTree() {
const tbody = document.getElementById('treeBody');
let html = '';
@ -481,19 +497,7 @@
titleHtml += `<div style="color:var(--ds-tx3);font-size:12px;margin-top:2px;line-height:1.4">${escHtml(d.description)}</div>`;
}
} else {
// Show first complete sentence, or full title if short — no arbitrary mid-word cut-off
let displayTitle = title;
if (title.length > 120) {
const sentenceEnd = title.search(/[.!?]\s/);
if (sentenceEnd > 20 && sentenceEnd < 160) {
displayTitle = title.substring(0, sentenceEnd + 1);
} else {
// Break at last word boundary before 120
const cut = title.lastIndexOf(' ', 120);
displayTitle = title.substring(0, cut > 40 ? cut : 120);
}
}
titleHtml = `<a href="/app/requests/${eid}" style="color:var(--ds-tx);text-decoration:none;line-height:1.4" class="hover:underline">${escHtml(displayTitle)}</a>`;
titleHtml = `<a href="/app/requests/${eid}" style="color:var(--ds-tx);text-decoration:none;line-height:1.4" class="hover:underline">${escHtml(summarize(title))}</a>`;
}
// Priority select
@ -552,7 +556,7 @@
if (existing) existing.remove();
const label = type === 'section' ? 'Section name' : 'Request text';
const placeholder = type === 'section' ? 'e.g. Legal, Financial, Operations' : 'e.g. Provide last 3 years audited financials';
const placeholder = type === 'section' ? 'e.g. Legal, Financial, Operations' : 'Enter the full request text — Dealspace will automatically show a concise summary in Summary View';
const tr = document.createElement('tr');
tr.id = 'inlineAddRow';