diff --git a/src/app/views/home.test.ts b/src/app/views/home.test.ts index 901fc25..130a218 100644 --- a/src/app/views/home.test.ts +++ b/src/app/views/home.test.ts @@ -554,7 +554,7 @@ describe('renderHome — week overview panel', () => { language === 'en' ? /Mon|Tue|Wed|Thu|Fri|Sat|Sun/g : /[一二三四五六日]/g, ); expect(weekdays).toHaveLength(7); - expect(positions(defined(lines[start + 2]), /▓▓|··|##|\.\./g)).toEqual(weekdays); + expect(positions(defined(lines[start + 2]), /▆▆|··|##|\.\./g)).toEqual(weekdays); expect(positions(defined(lines[start + 3]), /\?\?/g)).toEqual(weekdays); } finally { setLanguage('en'); @@ -583,7 +583,7 @@ describe('renderHome — week overview panel', () => { expect(titleIdx).toBeGreaterThanOrEqual(0); expect(lines[titleIdx + 2]).toContain('Classes'); expect(lines[titleIdx + 3]).toContain('Events'); - expect(lines[titleIdx + 4]).toContain('Scheduled'); + expect(lines[titleIdx + 4]).toContain('Free'); expect(lines[titleIdx + 4]).toContain('Free'); expect(lines[titleIdx + 4]).not.toContain('Not loaded'); }); @@ -604,7 +604,7 @@ describe('renderHome — week overview panel', () => { .trim() .split(/\s+/) .slice(1); - expect(classCells[5]).toBe('▓▓'); + expect(classCells[5]).toBe('▆▆'); expect(classCells[6]).toBe('··'); } finally { process.env['NBTCA_ICON_MODE'] = 'unicode'; @@ -633,7 +633,7 @@ describe('renderHome — week overview panel', () => { .slice(1); const saturday = eventCells[5]; const sunday = eventCells[6]; - expect(saturday).toBe('▓▓'); + expect(saturday).toBe('▆▆'); expect(sunday).toBe('··'); } finally { process.env['NBTCA_ICON_MODE'] = 'unicode'; @@ -707,7 +707,6 @@ describe('renderHome — week overview panel', () => { trans.timetable.weekOverviewTitle, trans.timetable.weekAheadClasses, trans.menu.events, - trans.timetable.weekAheadBusy, trans.timetable.weekAheadFree, ]) { expect(text).toContain(label.replace(/\s/g, '')); @@ -894,8 +893,8 @@ describe('homeView.load()', () => { await homeView.load(ctx); const lines = stripAnsi(homeView.render(ctx).join('\n')).split('\n'); const titleIdx = lines.findIndex((l) => l.includes('Week overview')); - const cells = defined(lines[titleIdx + 3]).match(/▓▓|··/g); - expect(cells).toEqual(['▓▓', '··', '··', '··', '··', '··', '▓▓']); + const cells = defined(lines[titleIdx + 3]).match(/▆▆|··/g); + expect(cells).toEqual(['▆▆', '··', '··', '··', '··', '··', '▆▆']); } finally { vi.useRealTimers(); if (previousTimeZone === undefined) delete process.env.TZ; @@ -915,7 +914,7 @@ describe('homeView.load()', () => { const titleIdx = lines.findIndex((l) => l.includes('Week overview')); expect(titleIdx).toBeGreaterThanOrEqual(0); const eventLine = defined(lines[titleIdx + 3]); - expect(eventLine.match(/▓▓|··/g)).toHaveLength(7); + expect(eventLine.match(/▆▆|··/g)).toHaveLength(7); expect(eventLine).not.toContain('??'); }); }); diff --git a/src/app/views/home.ts b/src/app/views/home.ts index b5f85ee..2db08da 100644 --- a/src/app/views/home.ts +++ b/src/app/views/home.ts @@ -99,9 +99,12 @@ function renderWeekAheadGrid( cols: number, ): string { const trans = t(); - const hasClassChar = pickIcon('▓▓', '##'); + // A lower bar leaves a gap above, so a busy class cell and the event cell below it stay apart. + const hasClassChar = pickIcon('▆▆', '##'); const freeChar = pickIcon('··', '..'); const unknownChar = '??'; + const busyClass = (text: string) => c.brand(text); + const busyEvent = (text: string) => c.success(text); const rowLabelW = Math.max(visualWidth(trans.timetable.weekAheadClasses), visualWidth(trans.menu.events)) + 1; @@ -114,25 +117,30 @@ function renderWeekAheadGrid( visualWidth(space.indent) + rowLabelW + days.length * cellWidth + (days.length - 1) * 2 <= width ? ' ' : ' '; - const classCell = (wd: number): string => (classDays[wd - 1] ? hasClassChar : freeChar); + const classCell = (wd: number): string => + classDays[wd - 1] ? busyClass(hasClassChar) : type.muted(freeChar); const eventCell = (wd: number): string => - eventDays ? (eventDays[wd - 1] ? hasClassChar : freeChar) : unknownChar; + eventDays + ? eventDays[wd - 1] + ? busyEvent(hasClassChar) + : type.muted(freeChar) + : type.muted(unknownChar); const legendText = - `${hasClassChar} ${trans.timetable.weekAheadBusy} ${freeChar} ${trans.timetable.weekAheadFree}` + - (eventDays ? '' : ` ${unknownChar} ${trans.timetable.weekAheadUnknown}`); + `${busyClass(hasClassChar)} ${trans.timetable.weekAheadClasses} ${busyEvent(hasClassChar)} ${trans.menu.events} ${type.muted(freeChar)} ${trans.timetable.weekAheadFree}` + + (eventDays ? '' : ` ${type.muted(unknownChar)} ${trans.timetable.weekAheadUnknown}`); const dayLabels = labels.map((label) => type.hint(padEndV(label, cellWidth))).join(gap); const headerLine = `${space.indent}${padEndV('', rowLabelW)}${dayLabels}`; - const classCells = days.map((wd) => type.body(padEndV(classCell(wd), cellWidth))).join(gap); + const classCells = days.map((wd) => padEndV(classCell(wd), cellWidth)).join(gap); const classLine = `${space.indent}${type.hint(padEndV(trans.timetable.weekAheadClasses, rowLabelW))}${classCells}`; - const eventCells = days.map((wd) => type.body(padEndV(eventCell(wd), cellWidth))).join(gap); + const eventCells = days.map((wd) => padEndV(eventCell(wd), cellWidth)).join(gap); const eventLine = `${space.indent}${type.hint(padEndV(trans.menu.events, rowLabelW))}${eventCells}`; - const legend = `${space.indent}${type.hint(legendText)}`; + const legend = wrappedIndentedLines(legendText, cols, type.hint); - const wideLines = [headerLine, classLine, eventLine, legend]; - if (wideLines.every((line) => visualWidth(line) <= width)) return wideLines.join('\n'); + const grid = [headerLine, classLine, eventLine]; + if (grid.every((line) => visualWidth(line) <= width)) return [...grid, ...legend].join('\n'); const compactHeading = wrappedIndentedLines( `${trans.timetable.weekAheadClasses} / ${trans.menu.events}`, @@ -140,7 +148,7 @@ function renderWeekAheadGrid( type.hint, ); const compactDays = days.flatMap((wd) => { - const row = `${type.hint(weekdayShortLabel(wd))} ${type.body(classCell(wd))} ${type.body(eventCell(wd))}`; + const row = `${type.hint(weekdayShortLabel(wd))} ${classCell(wd)} ${eventCell(wd)}`; return wrappedIndentedLines(row, cols, (value) => value); }); const compactLegend = wrappedIndentedLines(legendText, cols, type.hint); diff --git a/src/core/theme.test.ts b/src/core/theme.test.ts index 71df34e..76a4a22 100644 --- a/src/core/theme.test.ts +++ b/src/core/theme.test.ts @@ -71,6 +71,20 @@ describe('design tokens', () => { expect(space.indent).toBe(' '); }); + it('type.muted uses a fixed gray, not SGR dim', () => { + const level = chalk.level; + try { + chalk.level = 3; + expect(type.muted('x')).toBe('\x1b[38;2;124;133;148mx\x1b[39m'); + chalk.level = 1; + expect(type.muted('x')).toBe(chalk.gray('x')); + chalk.level = 0; + expect(type.muted('x')).toBe('x'); + } finally { + chalk.level = level; + } + }); + it('type.hint returns its text (possibly styled)', () => { expect(stripAnsi(type.hint('go'))).toBe('go'); }); diff --git a/src/core/theme.ts b/src/core/theme.ts index 3df60cd..a040dcd 100644 --- a/src/core/theme.ts +++ b/src/core/theme.ts @@ -103,6 +103,8 @@ export const type = { label: (s: string) => s, body: (s: string) => s, hint: (s: string) => s, + // A fixed mid-gray rather than SGR dim: some palettes render dim text close to invisible. + muted: (s: string) => (chalk.level >= 2 ? chalk.hex('#7c8594')(s) : chalk.gray(s)), active: (s: string) => chalk.bold(c.brand(s)), cursor: (s: string) => chalk.bgHex('#0ea5e9').black(s), }; diff --git a/src/features/calendar-heatmap.test.ts b/src/features/calendar-heatmap.test.ts index 3f38942..cd6012c 100644 --- a/src/features/calendar-heatmap.test.ts +++ b/src/features/calendar-heatmap.test.ts @@ -171,7 +171,7 @@ describe('renderHeatmap', () => { const output = renderHeatmap(makeBuckets('2025-06-09', [0, 1, 2, 3, 4]), today, { color: true, }); - expect(output).toContain(chalk.dim('·')); + expect(output).toContain(chalk.gray('·')); for (const glyph of ['░', '▒', '▓', '█']) expect(output).toContain(chalk.green(glyph)); expect(output).not.toMatch(/\u001b\[38;[25];/); } finally { diff --git a/src/features/calendar-heatmap.ts b/src/features/calendar-heatmap.ts index e50fce5..3732cee 100644 --- a/src/features/calendar-heatmap.ts +++ b/src/features/calendar-heatmap.ts @@ -32,7 +32,7 @@ function levelCell(count: number, useColor: boolean): string { const [unicode, ascii] = LEVEL_GLYPHS[level] ?? LEVEL_GLYPHS[0]; const cell = pickIcon(unicode, ascii); if (!useColor) return cell; - return level === 0 ? c.muted(cell) : c.success(cell); + return level === 0 ? type.muted(cell) : c.success(cell); } interface MonthAnchor { diff --git a/src/features/calendar.test.ts b/src/features/calendar.test.ts index cd5af4b..4687925 100644 --- a/src/features/calendar.test.ts +++ b/src/features/calendar.test.ts @@ -219,8 +219,9 @@ describe('renderEventBrief', () => { expect(at('2026-07-16T20:00:00')).toMatch(/38;2;14;165;233/); expect(at('2026-07-16T20:00:00')).not.toMatch(/\x1b\[1m/); const thisWeek = at('2026-07-18T20:00:00'); - expect(thisWeek.slice(0, thisWeek.indexOf('X'))).not.toMatch(/\x1b\[2m\d/); - expect(at('2026-08-20T20:00:00')).toMatch(/\x1b\[2m0/); + const muted = /\x1b\[38;2;124;133;148m\d/; + expect(thisWeek.slice(0, thisWeek.indexOf('X'))).not.toMatch(muted); + expect(at('2026-08-20T20:00:00')).toMatch(muted); } finally { chalk.level = level; } diff --git a/src/features/calendar.ts b/src/features/calendar.ts index db62798..73a39d4 100644 --- a/src/features/calendar.ts +++ b/src/features/calendar.ts @@ -391,10 +391,10 @@ export function renderEventBriefLines( ? c.brand : proximity === 'week' ? type.body - : c.muted; + : type.muted; const marker = proximity === 'today' ? type.active(pickIcon('●', '*')) : dateStyle(glyph.sep()); const titleStyled = styleTitle(e.title, proximity === 'today' ? type.active : type.body); - const content = `${dateStyle(eventWhen(e))} ${type.hint(dot)} ${titleStyled}${type.hint(recurringMark(e))}`; + const content = `${dateStyle(eventWhen(e))} ${type.muted(dot)} ${titleStyled}${type.muted(recurringMark(e))}`; return hangingLines(marker, content, cols); } diff --git a/src/features/schedule-render.test.ts b/src/features/schedule-render.test.ts index b667d14..937b25d 100644 --- a/src/features/schedule-render.test.ts +++ b/src/features/schedule-render.test.ts @@ -1423,6 +1423,27 @@ describe('renderWeekAgenda', () => { expect(stripAnsi(later.join('\n'))).not.toContain('*'); }); + it('mutes classes that have ended and keeps later ones at full strength', () => { + const level = chalk.level; + chalk.level = 3; + try { + const lines = renderWeekAgenda( + agendaTimetable, + 1, + campusDateTime('2026-09-07', '09:00'), + 80, + undefined, + false, + '2026-09-07', + ); + const muted = '\x1b[38;2;124;133;148m'; + expect(lines.find((line) => line.includes('Math'))).toContain(`${muted}Math`); + expect(lines.find((line) => line.includes('History'))).not.toContain(`${muted}History`); + } finally { + chalk.level = level; + } + }); + it('lists every weekday with its classes and locations', () => { const lines = renderWeekAgenda(agendaTimetable, 1, monday, 80).map(stripAnsi); expect(lines).toHaveLength(8); diff --git a/src/features/schedule-render.ts b/src/features/schedule-render.ts index 1068adb..ef52fb1 100644 --- a/src/features/schedule-render.ts +++ b/src/features/schedule-render.ts @@ -192,9 +192,10 @@ function renderTimeline( cursorPeriod !== undefined && m.startPeriod <= cursorPeriod && cursorPeriod <= m.endPeriod; const connector = i === 0 ? topConnector : midConnector; const marker = isLive ? type.active(pickIcon('▶', '>')) : ' '; - const timeCol = `${marker}${type.hint(startStr)} ${rule}${connector}${rule}`; + const timeStyle = isDone ? type.muted : type.hint; + const timeCol = `${marker}${timeStyle(startStr)} ${type.muted(`${rule}${connector}${rule}`)}`; const styleName = (name: string): string => - isLive ? type.active(name) : isDone ? type.hint(name) : type.body(name); + isLive ? type.active(name) : isDone ? type.muted(name) : type.body(name); const compactStatusText = isDone ? trans.timetable.classDone : minutesLeft; const renderLine = ( @@ -207,8 +208,8 @@ function renderTimeline( const aligned = name === m.courseName; const locationW = aligned && status && location !== undefined ? locationColW : 0; const locationCol = - location || locationW > 0 ? ` ${type.hint(padEndV(location ?? '', locationW))}` : ''; - const statusCol = status ? ` ${type.hint(status)}` : ''; + location || locationW > 0 ? ` ${type.muted(padEndV(location ?? '', locationW))}` : ''; + const statusCol = status ? ` ${isLive ? type.active(status) : type.muted(status)}` : ''; const shownName = aligned && (statusCol || locationCol) ? padEndV(name, nameColW) : name; const content = `${currentTimeCol} ${styleName(shownName)}${locationCol}${statusCol}`; return `${indent}${isCursor ? type.cursor(content) : content}`; @@ -227,7 +228,7 @@ function renderTimeline( return renderLine(clip(m.courseName, courseWidth), status, undefined); } - const compactTimeCol = `${marker}${type.hint(startStr)}`; + const compactTimeCol = `${marker}${timeStyle(startStr)}`; for (const indent of [space.indent, '']) { const courseWidth = Math.floor( width - visualWidth(renderLine('', '', undefined, compactTimeCol, indent)), @@ -250,8 +251,8 @@ function renderTimeline( if (!last) return lines.join('\n'); const lastEnd = periods.find((p) => p.period === last.endPeriod)?.end ?? '23:59'; const endLine = [ - `${space.indent} ${type.hint(lastEnd)} ${rule}${bottomConnector}${rule} ${type.hint(trans.timetable.timelineEnd)}`, - `${space.indent}${type.hint(lastEnd)} ${rule}${bottomConnector}${rule}`, + `${space.indent} ${type.hint(lastEnd)} ${type.muted(`${rule}${bottomConnector}${rule}`)} ${type.muted(trans.timetable.timelineEnd)}`, + `${space.indent}${type.hint(lastEnd)} ${type.muted(`${rule}${bottomConnector}${rule}`)}`, `${space.indent}${type.hint(lastEnd)}`, type.hint(lastEnd), ].find(fits); @@ -414,7 +415,7 @@ export function renderWeekGrid( const emptyGlyph = pickIcon('·', '.'); const sepGlyph = pickIcon('│', '|'); const gap = ` ${sepGlyph} `; - const sep = type.hint(gap); + const sep = type.muted(gap); const { rowHeadW, idealColWidths, totalIdealColW } = weekGridMetrics(timetable, weekNumber, now); const availableForCols = Math.max( 0, @@ -469,10 +470,10 @@ export function renderWeekGrid( locCells.push(starting ? type.body(paddedLoc) : type.hint(paddedLoc)); } else if (starting) { nameCells.push(isToday ? type.active(paddedName) : type.body(paddedName)); - locCells.push(type.hint(paddedLoc)); + locCells.push(type.muted(paddedLoc)); } else { - nameCells.push(type.hint(paddedName)); - locCells.push(type.hint(paddedLoc)); + nameCells.push(type.muted(paddedName)); + locCells.push(type.muted(paddedLoc)); } } const rowHead = type.hint( @@ -482,7 +483,7 @@ export function renderWeekGrid( .map((cell, index) => index === 0 ? cell - : type.hint(gap.slice(index - 1 === widened ? 1 : 0, index === widened ? 2 : 3)) + cell, + : type.muted(gap.slice(index - 1 === widened ? 1 : 0, index === widened ? 2 : 3)) + cell, ) .join(''); lines.push(space.indent + rowHead + nameRow); @@ -490,7 +491,7 @@ export function renderWeekGrid( const next = sorted[i + 1]; if (next && minutesOf(next.start) - minutesOf(p.end) > GAP_THRESHOLD_MINUTES) { - lines.push(space.indent + type.hint(pickIcon('╌', '-').repeat(totalW))); + lines.push(space.indent + type.muted(pickIcon('╌', '-').repeat(totalW))); } }); return lines.join('\n'); @@ -551,10 +552,10 @@ export function renderWeekAgenda( }; const room = Math.max(1, width - visualWidth(head(0))); const nameStyle = (m: TimetableMeeting): ((value: string) => string) => - isSelected(m) ? type.active : isOver(wd, m) ? type.hint : type.body; + isSelected(m) ? type.active : isOver(wd, m) ? type.muted : type.body; if (meetings.length === 0) { - lines.push(`${head(0)}${type.hint(dot)}`); + lines.push(`${head(0)}${type.muted(dot)}`); return; } @@ -590,9 +591,10 @@ export function renderWeekAgenda( ); const body = location && nameW !== undefined - ? `${nameStyle(m)(padEndV(m.courseName, nameW))} ${type.hint(location)}` + ? `${nameStyle(m)(padEndV(m.courseName, nameW))} ${type.muted(location)}` : nameStyle(m)(clip(m.courseName, Math.max(1, nameRoom))); - lines.push(`${head(row)}${type.hint(time)}${body}`); + const timeStyle = isOver(wd, m) && !isSelected(m) ? type.muted : type.hint; + lines.push(`${head(row)}${timeStyle(time)}${body}`); }); }); for (const course of timetable.untimedCourses ?? []) { @@ -675,7 +677,7 @@ function weekStrip(meeting: TimetableMeeting, progress: CourseProgress): string const week = index + 1; const mark = weeks.has(week) ? full : empty; if (week === progress.currentWeek) return type.active(mark); - return weeks.has(week) && week > progress.currentWeek ? type.body(mark) : type.hint(mark); + return weeks.has(week) && week > progress.currentWeek ? type.body(mark) : type.muted(mark); }).join(' '); } diff --git a/src/i18n/index.ts b/src/i18n/index.ts index 465c19a..5801f26 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -350,7 +350,6 @@ export interface Translations { exportSaved: string; weekOverviewTitle: string; weekAheadClasses: string; - weekAheadBusy: string; weekAheadFree: string; weekAheadUnknown: string; termPreviewWeek: string; diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 78c9078..1a3f6cb 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -430,7 +430,6 @@ "exportSaved": "Saved: {path}", "weekOverviewTitle": "Week overview", "weekAheadClasses": "Classes", - "weekAheadBusy": "Scheduled", "weekAheadFree": "Free", "weekAheadUnknown": "Not loaded", "termPreviewWeek": "Week 1 preview", diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json index 424203f..48b79aa 100644 --- a/src/i18n/locales/zh.json +++ b/src/i18n/locales/zh.json @@ -430,7 +430,6 @@ "exportSaved": "已保存:{path}", "weekOverviewTitle": "本周概览", "weekAheadClasses": "课程", - "weekAheadBusy": "有安排", "weekAheadFree": "无安排", "weekAheadUnknown": "尚未加载", "termPreviewWeek": "第一周预览",