refactor: quitar cursivas de descripciones y añadir saltos entre grupos

Co-authored-by: aider (openrouter/openai/gpt-5) <aider@aider.chat>
pull/1/head
borja 2 months ago
parent fe5a8d29cb
commit 12d18322ff

@ -239,7 +239,7 @@ export class CommandService {
const rendered = items.map((t) => { const rendered = items.map((t) => {
const isOverdue = t.due_date ? t.due_date < todayYMD : false; const isOverdue = t.due_date ? t.due_date < todayYMD : false;
const datePart = t.due_date ? `${isOverdue ? `${ICONS.warn} ` : ''}${ICONS.date} ${formatDDMM(t.due_date)}` : ''; const datePart = t.due_date ? `${isOverdue ? `${ICONS.warn} ` : ''}${ICONS.date} ${formatDDMM(t.due_date)}` : '';
return `- ${codeId(t.id)} _${t.description || '(sin descripción)'}_${datePart}${ICONS.unassigned} sin responsable`; return `- ${codeId(t.id)} ${t.description || '(sin descripción)'}${datePart}${ICONS.unassigned} sin responsable`;
}); });
const total = TaskService.countGroupUnassigned(context.groupId); const total = TaskService.countGroupUnassigned(context.groupId);
@ -288,9 +288,15 @@ export class CommandService {
: `${t.assignees!.length > 1 ? '👥' : '👤'} ${names.join(', ')}`; : `${t.assignees!.length > 1 ? '👥' : '👤'} ${names.join(', ')}`;
const isOverdue = t.due_date ? t.due_date < todayYMD : false; const isOverdue = t.due_date ? t.due_date < todayYMD : false;
const datePart = t.due_date ? `${isOverdue ? `${ICONS.warn} ` : ''}${ICONS.date} ${formatDDMM(t.due_date)}` : ''; const datePart = t.due_date ? `${isOverdue ? `${ICONS.warn} ` : ''}${ICONS.date} ${formatDDMM(t.due_date)}` : '';
return `- ${codeId(t.id)} _${t.description || '(sin descripción)'}_${datePart}${owner}`; return `- ${codeId(t.id)} ${t.description || '(sin descripción)'}${datePart}${owner}`;
})); }));
sections.push(...rendered); sections.push(...rendered);
sections.push('');
}
// Quitar línea en blanco final si procede
if (sections.length > 0 && sections[sections.length - 1] === '') {
sections.pop();
} }
const totalMy = TaskService.countUserPending(context.sender); const totalMy = TaskService.countUserPending(context.sender);
@ -298,7 +304,7 @@ export class CommandService {
sections.push(`… y ${totalMy - myItems.length} más`); sections.push(`… y ${totalMy - myItems.length} más`);
} }
} else { } else {
sections.push('No tienes tareas pendientes.'); sections.push(italic('No tienes tareas pendientes.'));
} }
// En contexto de grupo: mantener compatibilidad mostrando solo "sin responsable" del grupo actual // En contexto de grupo: mantener compatibilidad mostrando solo "sin responsable" del grupo actual
@ -309,11 +315,12 @@ export class CommandService {
const groupName = GroupSyncService.activeGroupsCache.get(context.groupId) || context.groupId; const groupName = GroupSyncService.activeGroupsCache.get(context.groupId) || context.groupId;
const unassigned = TaskService.listGroupUnassigned(context.groupId, LIMIT); const unassigned = TaskService.listGroupUnassigned(context.groupId, LIMIT);
if (unassigned.length > 0) { if (unassigned.length > 0) {
if (sections.length && sections[sections.length - 1] !== '') sections.push('');
sections.push(`${groupName} — Sin responsable`); sections.push(`${groupName} — Sin responsable`);
const renderedUnassigned = unassigned.map((t) => { const renderedUnassigned = unassigned.map((t) => {
const isOverdue = t.due_date ? t.due_date < todayYMD : false; const isOverdue = t.due_date ? t.due_date < todayYMD : false;
const datePart = t.due_date ? `${isOverdue ? `${ICONS.warn} ` : ''}${ICONS.date} ${formatDDMM(t.due_date)}` : ''; const datePart = t.due_date ? `${isOverdue ? `${ICONS.warn} ` : ''}${ICONS.date} ${formatDDMM(t.due_date)}` : '';
return `- ${codeId(t.id)} _${t.description || '(sin descripción)'}_${datePart}${ICONS.unassigned} sin responsable`; return `- ${codeId(t.id)} ${t.description || '(sin descripción)'}${datePart}${ICONS.unassigned} sin responsable`;
}); });
sections.push(...renderedUnassigned); sections.push(...renderedUnassigned);
@ -337,11 +344,12 @@ export class CommandService {
gid; gid;
if (unassigned.length > 0) { if (unassigned.length > 0) {
if (sections.length && sections[sections.length - 1] !== '') sections.push('');
sections.push(`${groupName} — Sin responsable`); sections.push(`${groupName} — Sin responsable`);
const renderedUnassigned = unassigned.map((t) => { const renderedUnassigned = unassigned.map((t) => {
const isOverdue = t.due_date ? t.due_date < todayYMD : false; const isOverdue = t.due_date ? t.due_date < todayYMD : false;
const datePart = t.due_date ? `${isOverdue ? `${ICONS.warn} ` : ''}${ICONS.date} ${formatDDMM(t.due_date)}` : ''; const datePart = t.due_date ? `${isOverdue ? `${ICONS.warn} ` : ''}${ICONS.date} ${formatDDMM(t.due_date)}` : '';
return `- ${codeId(t.id)} _${t.description || '(sin descripción)'}_${datePart}${ICONS.unassigned} sin responsable`; return `- ${codeId(t.id)} ${t.description || '(sin descripción)'}${datePart}${ICONS.unassigned} sin responsable`;
}); });
sections.push(...renderedUnassigned); sections.push(...renderedUnassigned);
@ -407,7 +415,7 @@ export class CommandService {
: `${t.assignees!.length > 1 ? '👥' : '👤'} ${names.join(', ')}`; : `${t.assignees!.length > 1 ? '👥' : '👤'} ${names.join(', ')}`;
const isOverdue = t.due_date ? t.due_date < todayYMD : false; const isOverdue = t.due_date ? t.due_date < todayYMD : false;
const datePart = t.due_date ? `${isOverdue ? `${ICONS.warn} ` : ''}${ICONS.date} ${formatDDMM(t.due_date)}` : ''; const datePart = t.due_date ? `${isOverdue ? `${ICONS.warn} ` : ''}${ICONS.date} ${formatDDMM(t.due_date)}` : '';
return `- ${codeId(t.id)} _${t.description || '(sin descripción)'}_${datePart}${owner}`; return `- ${codeId(t.id)} ${t.description || '(sin descripción)'}${datePart}${owner}`;
})); }));
const total = TaskService.countGroupPending(context.groupId); const total = TaskService.countGroupPending(context.groupId);
@ -426,7 +434,7 @@ export class CommandService {
if (items.length === 0) { if (items.length === 0) {
return [{ return [{
recipient: context.sender, recipient: context.sender,
message: 'No tienes tareas pendientes.' message: italic('No tienes tareas pendientes.')
}]; }];
} }
@ -458,9 +466,15 @@ export class CommandService {
: `${t.assignees!.length > 1 ? '👥' : '👤'} ${names.join(', ')}`; : `${t.assignees!.length > 1 ? '👥' : '👤'} ${names.join(', ')}`;
const isOverdue = t.due_date ? t.due_date < todayYMD : false; const isOverdue = t.due_date ? t.due_date < todayYMD : false;
const datePart = t.due_date ? `${isOverdue ? `${ICONS.warn} ` : ''}${ICONS.date} ${formatDDMM(t.due_date)}` : ''; const datePart = t.due_date ? `${isOverdue ? `${ICONS.warn} ` : ''}${ICONS.date} ${formatDDMM(t.due_date)}` : '';
return `- ${codeId(t.id)} _${t.description || '(sin descripción)'}_${datePart}${owner}`; return `- ${codeId(t.id)} ${t.description || '(sin descripción)'}${datePart}${owner}`;
})); }));
sections.push(...rendered); sections.push(...rendered);
sections.push('');
}
// Quitar línea en blanco final si procede
if (sections.length > 0 && sections[sections.length - 1] === '') {
sections.pop();
} }
if (total > items.length) { if (total > items.length) {
@ -511,14 +525,14 @@ export class CommandService {
const due = res.task?.due_date ? `${ICONS.date} ${formatDDMM(res.task?.due_date)}` : ''; const due = res.task?.due_date ? `${ICONS.date} ${formatDDMM(res.task?.due_date)}` : '';
return [{ return [{
recipient: context.sender, recipient: context.sender,
message: ` ${codeId(id)} ya estaba completada — _${res.task?.description || '(sin descripción)'}_${due}` message: ` ${codeId(id)} ya estaba completada — ${res.task?.description || '(sin descripción)'}${due}`
}]; }];
} }
const due = res.task?.due_date ? `${ICONS.date} ${formatDDMM(res.task?.due_date)}` : ''; const due = res.task?.due_date ? `${ICONS.date} ${formatDDMM(res.task?.due_date)}` : '';
return [{ return [{
recipient: context.sender, recipient: context.sender,
message: `${ICONS.complete} ${codeId(id)} completada — _${res.task?.description || '(sin descripción)'}_${due}` message: `${ICONS.complete} ${codeId(id)} completada — ${res.task?.description || '(sin descripción)'}${due}`
}]; }];
} }
@ -571,7 +585,7 @@ export class CommandService {
} }
const lines = [ const lines = [
`${ICONS.take} Has tomado ${codeId(id)}`, italic(`${ICONS.take} Has tomado ${codeId(id)}`),
`${res.task?.description || '(sin descripción)'}`, `${res.task?.description || '(sin descripción)'}`,
res.task?.due_date ? `${ICONS.date} ${formatDDMM(res.task?.due_date)}` : '' res.task?.due_date ? `${ICONS.date} ${formatDDMM(res.task?.due_date)}` : ''
].filter(Boolean); ].filter(Boolean);
@ -789,7 +803,7 @@ export class CommandService {
? `${ICONS.unassigned} sin responsable${groupName ? ` (${groupName})` : ''}` ? `${ICONS.unassigned} sin responsable${groupName ? ` (${groupName})` : ''}`
: `${assignmentUserIds.length > 1 ? '👥' : '👤'} ${assignedDisplayNames.join(', ')}`; : `${assignmentUserIds.length > 1 ? '👥' : '👤'} ${assignedDisplayNames.join(', ')}`;
const ackLines = [ const ackLines = [
`${ICONS.create} ${codeId(taskId)} _${description || '(sin descripción)'}_`, `${ICONS.create} ${codeId(taskId)} ${description || '(sin descripción)'}`,
dueFmt ? `${ICONS.date} ${dueFmt}` : null, dueFmt ? `${ICONS.date} ${dueFmt}` : null,
ownerPart ownerPart
].filter(Boolean); ].filter(Boolean);

@ -93,8 +93,8 @@ test('listar “mis” por defecto en DM con /t ver', async () => {
const msg = responses[0].message; const msg = responses[0].message;
expect(msg).toContain('Test Group'); expect(msg).toContain('Test Group');
expect(msg).toContain('Group 2'); expect(msg).toContain('Group 2');
expect(msg).toMatch(/- `\d{4}` _G1 Task_/); expect(msg).toMatch(/- `\d{4}` G1 Task/);
expect(msg).toMatch(/- `\d{4}` _G2 Task_/); expect(msg).toMatch(/- `\d{4}` G2 Task/);
}); });
test('completar tarea: camino feliz, ya completada y no encontrada', async () => { test('completar tarea: camino feliz, ya completada y no encontrada', async () => {
@ -311,8 +311,9 @@ describe('CommandService', () => {
expect(responses[0].recipient).toBe('1234567890'); expect(responses[0].recipient).toBe('1234567890');
// Debe empezar con "📝 `0001` " // Debe empezar con "📝 `0001` "
expect(responses[0].message).toMatch(/^📝 `\d{4}` /); expect(responses[0].message).toMatch(/^📝 `\d{4}` /);
// Debe contener la descripción en cursiva compacta // Debe mostrar la descripción en texto plano (sin cursiva)
expect(responses[0].message).toContain('_Test task_'); expect(responses[0].message).toContain(' Test task');
expect(responses[0].message).not.toContain('_Test task_');
// No debe usar el texto antiguo "Tarea <id> creada" // No debe usar el texto antiguo "Tarea <id> creada"
expect(responses[0].message).not.toMatch(/Tarea \d+ creada/); expect(responses[0].message).not.toMatch(/Tarea \d+ creada/);
}); });

Loading…
Cancel
Save