Skip to content

Commit eecfedd

Browse files
committed
feat: integrate tag management into session data and enhance tag display in navigation
1 parent 857dc7c commit eecfedd

File tree

4 files changed

+55
-9
lines changed

4 files changed

+55
-9
lines changed

src/core/pomodoro-timer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,13 +1862,17 @@ export class PomodoroTimer {
18621862
const startHour = Math.max(0, Math.floor(startTotalMinutes / 60));
18631863
const startMinute = Math.max(0, startTotalMinutes % 60);
18641864

1865+
// Get current tags from TagManager
1866+
const currentTags = window.tagManager ? window.tagManager.getCurrentTags() : [];
1867+
18651868
const sessionData = {
18661869
id: `timer_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`,
18671870
session_type: 'focus',
18681871
duration: durationMinutes,
18691872
start_time: `${startHour.toString().padStart(2, '0')}:${startMinute.toString().padStart(2, '0')}`,
18701873
end_time: `${endHour.toString().padStart(2, '0')}:${endMinute.toString().padStart(2, '0')}`,
18711874
notes: this.currentTask && this.currentTask.trim() ? this.currentTask.trim() : null,
1875+
tags: currentTags, // Include current tags from TagManager
18721876
created_at: now.toISOString()
18731877
};
18741878

src/managers/navigation-manager.js

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,9 +1563,26 @@ export class NavigationManager {
15631563

15641564
// Get session tags (if tag system is available)
15651565
const tags = await this.getSessionTags(session.id);
1566-
const tagsHtml = tags.length > 0
1567-
? tags.map(tag => `<span class="session-tag">${tag.name}</span>`).join('')
1568-
: '<span class="text-muted">-</span>';
1566+
let tagsHtml;
1567+
1568+
if (tags.length === 0) {
1569+
tagsHtml = '<span class="text-muted">-</span>';
1570+
} else if (tags.length === 1) {
1571+
// Single tag - show normally
1572+
tagsHtml = `<span class="session-tag">${tags[0].name}</span>`;
1573+
} else {
1574+
// Multiple tags - show first + count indicator with tooltip
1575+
const firstTag = tags[0];
1576+
const remainingCount = tags.length - 1;
1577+
const allTagNames = tags.map(tag => tag.name).join(', ');
1578+
1579+
tagsHtml = `
1580+
<div class="session-tags-compact" title="${allTagNames}">
1581+
<span class="session-tag">${firstTag.name}</span>
1582+
<span class="session-tag-count">+${remainingCount}</span>
1583+
</div>
1584+
`;
1585+
}
15691586

15701587
// Create type badge
15711588
const typeBadge = `<span class="session-type-badge ${session.session_type}">${session.session_type}</span>`;
@@ -1589,10 +1606,19 @@ export class NavigationManager {
15891606
}
15901607

15911608
async getSessionTags(sessionId) {
1592-
// If tag system is available, get tags for this session
1593-
if (window.tagManager) {
1609+
// Get tags directly from session data
1610+
if (window.sessionManager) {
15941611
try {
1595-
return await window.tagManager.getSessionTags(sessionId);
1612+
// Find the session in all dates
1613+
for (const dateString in window.sessionManager.sessions) {
1614+
const dateSessions = window.sessionManager.sessions[dateString];
1615+
if (dateSessions) {
1616+
const session = dateSessions.find(s => s.id === sessionId);
1617+
if (session && session.tags) {
1618+
return session.tags;
1619+
}
1620+
}
1621+
}
15961622
} catch (error) {
15971623
console.log('Tags not available for session:', sessionId);
15981624
}

src/styles/calendar.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,24 @@
739739
font-weight: 500;
740740
}
741741

742+
.session-tags-compact {
743+
display: flex;
744+
align-items: center;
745+
gap: 0.25rem;
746+
cursor: help;
747+
}
748+
749+
.session-tag-count {
750+
display: inline-block;
751+
padding: 0.125rem 0.375rem;
752+
background: var(--bg-secondary);
753+
color: var(--text-muted);
754+
border-radius: 6px;
755+
font-size: 0.625rem;
756+
font-weight: 500;
757+
border: 1px solid var(--border-color);
758+
}
759+
742760
.session-actions {
743761
display: flex;
744762
gap: 0.5rem;

src/styles/timer.css

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
cursor: pointer;
5353
position: relative;
5454
transition: background-color 0.2s ease;
55-
gap: 8px;
55+
gap: 4px;
5656
}
5757

5858

@@ -62,13 +62,11 @@
6262

6363
.tag-dropdown-arrow {
6464
font-size: 18px;
65-
opacity: 0.7;
6665
transition: transform 0.2s ease, opacity 0.2s ease;
6766
}
6867

6968
.timer-status.active .tag-dropdown-arrow {
7069
transform: rotate(180deg);
71-
opacity: 1;
7270
}
7371

7472
.tag-dropdown-menu {

0 commit comments

Comments
 (0)