You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature/configurable statusbar icon and color (#91)
* feat: add configurable status bar icon and color options
* Refactor code structure for improved readability and maintainability
* feat: apply background style selection to both status bar items
* feat: add copilot instructions for coding time tracker
* feat: update status bar to use a single item with configurable icon and improved tooltip
# Copilot Instructions for Simple Coding Time Tracker
2
+
3
+
## Project Overview
4
+
VS Code extension that tracks coding time with visualization, health reminders, and git branch/language detection. Version 0.6.7, published to VS Code Marketplace and Open VSX.
5
+
6
+
## Architecture
7
+
8
+
### Core Components (all in `src/`)
9
+
-**extension.ts**: Main entry point; activates on startup; registers commands, event listeners, and manages component lifecycle
10
+
-**timeTracker.ts**: Tracks user activity (cursor, text edits, window focus); monitors git branches; manages inactivity/focus timeouts; coordinates with health notifications
11
+
-**database.ts**: Persists time entries via VS Code's globalState; each entry stores: date, project, timeSpent (minutes), branch, language
- Use `vscode.* event listeners` for activity (onDidChangeTextEditorSelection, onDidChangeTextDocument, onDidChangeWindowState, onDidChangeActiveTextEditor)
64
+
- Always call `this.updateCursorActivity()` on any editor activity
65
+
- Store timers in private fields; clear with `clearTimeout()` / `clearInterval()`; clean up on deactivate
66
+
67
+
### Time Tracking Logic
68
+
-**Cursor inactivity**: 2.5 min default (configurable); reset on any editor activity
69
+
-**Focus timeout**: 3 min default; continues tracking N minutes after VS Code loses focus
70
+
-**Branch changes**: Save current session before starting new one (prevents cross-branch mixing)
71
+
-**Validation**: Reject time entries > 24 hours or <= 0
72
+
73
+
### Language Detection
74
+
`detectLanguageFromFile(filePath)` uses file extension map (~50+ languages); fallback to VS Code's languageId via `detectLanguageFromLanguageId(languageId)`. See [utils.ts](src/utils.ts) for full map.
75
+
76
+
### Database Migrations
77
+
If adding new TimeEntry fields, add migration logic in Database.migrateEntries() to backfill old entries (see branch/language migration pattern).
78
+
79
+
### Webview Communication
80
+
Webviews (summaryView, settingsView) use `webview.postMessage()` to send and `onDidReceiveMessage()` to receive. Commands passed as JSON: `{ command: 'name', data: {...} }`.
81
+
82
+
### Error Handling
83
+
- Wrap async operations in try-catch
84
+
- Use vscode.window.showErrorMessage() for user-facing errors
85
+
- Log via Logger.getInstance().log()
86
+
- Never silently fail on persistence or git operations
<div class="range-info">Supports emojis, text, or VS Code Codicons like $(clock)</div>
333
+
</div>
334
+
335
+
<div class="setting-item">
336
+
<label for="statusBarBackgroundStyle">Status Bar Background</label>
337
+
<div class="description">Choose the background style for the timer: use the default status bar color, a warning highlight, or an error highlight.</div>
0 commit comments