Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (round 6): validate path params, aria-label delete, drop unused question arg

Adam Eivyfa826258bfb2
diff --git a/client/src/pages/Ask.jsx b/client/src/pages/Ask.jsx
index 8a978ef29e..4779138cba 100644
--- a/client/src/pages/Ask.jsx
+++ b/client/src/pages/Ask.jsx
@@ -88,6 +88,7 @@ function Sidebar({ conversations, activeId, onPick, onNew, onDelete, loading, st
type="button"
onClick={() => onDelete(c.id)}
className="absolute right-2 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 text-gray-500 hover:text-port-error transition-opacity"
+ aria-label={`Delete conversation: ${c.title}`}
title="Delete conversation"
>
<Trash2 size={14} />
@@ -191,7 +192,7 @@ export default function Ask() {
// conversation it belongs to. Brand-new conversations transition through
// `/ask` → `/ask/<id>` once the server's `open` event arrives — that
// self-navigation must NOT cancel the stream, so we compare against the
- // ref the stream populates. On unmount, abort unconditionally.
+ // ref the stream populates.
useEffect(() => {
const streamConvId = streamingConvIdRef.current;
if (streamConvId && conversationId && streamConvId !== conversationId) {
@@ -199,18 +200,11 @@ export default function Ask() {
abortRef.current = null;
streamingConvIdRef.current = null;
}
- return () => {
- // Only abort on real unmount, not on every conversationId change.
- // Detect unmount by checking that React isn't going to re-run the
- // effect — easiest signal: the ref is still populated *and* the
- // component will tear down (cleanup runs once on unmount when deps
- // are stable; we rely on the conditional above to handle in-route
- // switches).
- };
}, [conversationId]);
+ // Separately, kill any in-flight stream on real unmount so we don't leak
+ // a fetch + state-update closure into a torn-down tree.
useEffect(() => () => {
- // True unmount cleanup — kill any leftover stream.
abortRef.current?.abort();
abortRef.current = null;
streamingConvIdRef.current = null;
diff --git a/server/routes/ask.js b/server/routes/ask.js
index 5420c8d6b8..c2edd00b10 100644
--- a/server/routes/ask.js
+++ b/server/routes/ask.js
@@ -51,20 +51,23 @@ router.get('/', asyncHandler(async (_req, res) => {
}));
router.get('/:id', asyncHandler(async (req, res) => {
- const conv = await convs.getConversation(String(req.params.id));
+ const id = validateRequest(idSchema, String(req.params.id));
+ const conv = await convs.getConversation(id);
if (!conv) throw new ServerError('Conversation not found', { status: 404, code: 'NOT_FOUND' });
res.json({ conversation: conv });
}));
router.delete('/:id', asyncHandler(async (req, res) => {
- const removed = await convs.deleteConversation(String(req.params.id));
+ const id = validateRequest(idSchema, String(req.params.id));
+ const removed = await convs.deleteConversation(id);
if (!removed) throw new ServerError('Conversation not found', { status: 404, code: 'NOT_FOUND' });
res.json({ ok: true });
}));
router.post('/:id/promote', asyncHandler(async (req, res) => {
+ const id = validateRequest(idSchema, String(req.params.id));
const { promoted } = validateRequest(promoteBodySchema, req.body ?? {});
- const conv = await convs.setPromoted(String(req.params.id), promoted);
+ const conv = await convs.setPromoted(id, promoted);
if (!conv) throw new ServerError('Conversation not found', { status: 404, code: 'NOT_FOUND' });
res.json({ conversation: conv });
}));
diff --git a/server/services/askService.js b/server/services/askService.js
index c28dba2a38..51976a632b 100644
--- a/server/services/askService.js
+++ b/server/services/askService.js
@@ -194,7 +194,7 @@ async function retrieveGoals(queryTokens) {
return rankAndCap(ranked, 'goal');
}
-async function retrieveCalendar(question, queryTokens, timeWindow) {
+async function retrieveCalendar(queryTokens, timeWindow) {
if (!queryTokens.length) return [];
const now = Date.now();
const days = Number(timeWindow?.days) || CALENDAR_DEFAULT_DAYS;
@@ -235,7 +235,7 @@ export async function gatherSources(question, { timeWindow, maxSources = 12 } =
retrieveBrainNotes(question, queryTokens),
retrieveAutobiography(queryTokens),
retrieveGoals(queryTokens),
- retrieveCalendar(question, queryTokens, timeWindow),
+ retrieveCalendar(queryTokens, timeWindow),
]);
const all = [