Skip to content

Commit 28c4e83

Browse files
committed
Refactor code structure for improved readability and maintainability
1 parent a846942 commit 28c4e83

34 files changed

Lines changed: 1740 additions & 86 deletions

.gitignore

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,10 @@ dist-ssr/
2828
# Tauri
2929
src-tauri/target/
3030
src-tauri/gen/
31-
src-tauri/windows/msix-staging/
3231
src-tauri/windows/out/
32+
# Note: msix-staging/Assets are generated by generate-msix-icons.mjs
3333
src-tauri/windows/msix-staging/timelens.exe
34-
35-
# Icon generation scripts (dev utility only)
36-
generate-icons.mjs
37-
generate-ico-icns.mjs
34+
src-tauri/windows/msix-staging/AppxManifest.xml
3835

3936
# Test
4037
coverage/

CHANGELOG.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,49 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
55

66
---
77

8+
## [1.4.2] - 2026-05-22
9+
10+
### Added
11+
12+
#### Build and Packaging Utilities
13+
14+
- Added multiple icon-processing and troubleshooting scripts for MSIX/taskbar icon workflows, including generation and one-off fix helpers
15+
- Added localized VS Code extension metadata resources for automatic language switching based on user locale
16+
- Added VS Code extension runtime i18n module for dynamic UI/message localization
17+
- Added VS Code extension setup guide for bridge-key configuration and local API connection
18+
- Added packaged VS Code extension artifacts for versions 0.3.0 through 0.3.3
19+
20+
### Changed
21+
22+
#### Windows MSIX Packaging and Assets
23+
24+
- Updated MSIX manifest and staged asset set used for Windows packaging
25+
- Refreshed Store and tile icon assets in all required sizes to improve packaged app icon consistency
26+
- Updated staged Windows executable in MSIX output
27+
- Updated npm scripts and lockfile to support icon generation/build flow integration
28+
- Updated ignore rules to align with the current packaging/output workflow
29+
30+
#### Browser Usage Page
31+
32+
- Added a manual refresh control on the Browser Usage page header
33+
- Added auto-refresh behavior when the app window regains focus while staying on Browser Usage
34+
- Added refresh-related locale strings for Browser Usage in English and Chinese
35+
36+
#### VS Code Extension: Sync, Diagnostics, and Localization
37+
38+
- Updated extension API upload payload serialization to canonical JSON for stable signature verification against the desktop API
39+
- Expanded extension bridge-key UX so key configuration/update remains accessible from extension surfaces
40+
- Improved extension diagnostics with clearer output-channel logging and richer auth-failure prompts/actions
41+
- Localized extension runtime UI/messages and package-contributed labels/descriptions with automatic language selection
42+
- Updated extension README to match current bridge-key auth and setup flow
43+
44+
### Fixed
45+
46+
- Fixed packaged Microsoft Store/taskbar icon presentation issues caused by previous icon asset composition
47+
- Fixed Browser Usage data staleness by allowing explicit refresh and focus-triggered refresh
48+
- Fixed VS Code extension bridge auth mismatches in session upload requests caused by non-canonical request body serialization
49+
- Fixed extension usability gap where users needed an easier path to reconfigure bridge key and inspect sync failures
50+
851
## [1.4.1] - 2026-05-16
952

1053
### Changed

fix-icon.mjs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Fix Windows taskbar icon by removing the blue background
4+
*/
5+
6+
import sharp from 'sharp';
7+
import fs from 'fs';
8+
import path from 'path';
9+
import { fileURLToPath } from 'url';
10+
11+
const __filename = fileURLToPath(import.meta.url);
12+
const __dirname = path.dirname(__filename);
13+
14+
async function main() {
15+
const workspaceRoot = 'c:\\Users\\seans\\Documents\\GitHub\\TimeLens';
16+
const sourceIcon = path.join(workspaceRoot, 'src-tauri', 'icons', 'icon.png');
17+
const outputDir = path.join(workspaceRoot, 'src-tauri', 'windows', 'msix-staging', 'Assets');
18+
const outputIcon = path.join(outputDir, 'Square44x44Logo.png');
19+
20+
console.log('Fixing Windows taskbar icon...');
21+
console.log(`Source: ${sourceIcon}`);
22+
console.log(`Output: ${outputIcon}`);
23+
24+
try {
25+
// Read the source image
26+
const image = sharp(sourceIcon);
27+
const metadata = await image.metadata();
28+
29+
console.log(`Image size: ${metadata.width}x${metadata.height}`);
30+
31+
// Get raw pixel data
32+
const { data } = await image.raw().toBuffer({ resolveWithObject: true });
33+
34+
// Process pixels - remove blue background
35+
for (let i = 0; i < data.length; i += 4) {
36+
const r = data[i];
37+
const g = data[i + 1];
38+
const b = data[i + 2];
39+
40+
// If this pixel is part of the blue background, make it transparent
41+
if (b > r + 20 && b > g + 20 && (r + g + b) < 300) {
42+
data[i + 3] = 0; // Set alpha to 0 (transparent)
43+
} else {
44+
data[i + 3] = 255; // Set alpha to 255 (opaque)
45+
}
46+
}
47+
48+
// Create a new image from the processed pixel data and resize
49+
await sharp(data, {
50+
raw: {
51+
width: metadata.width,
52+
height: metadata.height,
53+
channels: 4
54+
}
55+
})
56+
.resize(44, 44, {
57+
fit: 'inside',
58+
background: { r: 0, g: 0, b: 0, alpha: 0 }
59+
})
60+
.png()
61+
.toFile(outputIcon);
62+
63+
console.log(`\n✓ Successfully created taskbar icon: ${outputIcon}`);
64+
console.log('✓ Blue background has been removed');
65+
console.log('✓ Icon now has a transparent background');
66+
console.log('\nThe taskbar icon will now display correctly in Windows without the blue background.');
67+
68+
} catch (error) {
69+
console.error(`✗ Error: ${error.message}`);
70+
process.exit(1);
71+
}
72+
}
73+
74+
main();

fix-taskbar-icon.js

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Fix Windows taskbar icon by removing the blue background
4+
* Creates a transparent version of Square44x44Logo.png
5+
*/
6+
7+
import fs from 'fs';
8+
import path from 'path';
9+
import { fileURLToPath } from 'url';
10+
11+
const __filename = fileURLToPath(import.meta.url);
12+
const __dirname = path.dirname(__filename);
13+
14+
// Try to use sharp for image processing, fall back to Canvas if needed
15+
let processImage;
16+
17+
try {
18+
const sharp = (await import('sharp')).default;
19+
processImage = async (inputPath, outputPath) => {
20+
console.log(`Processing ${path.basename(inputPath)}...`);
21+
22+
const image = sharp(inputPath);
23+
const metadata = await image.metadata();
24+
25+
// Read the image as raw pixel data
26+
const { data, info } = await image.raw().toBuffer({ resolveWithObject: true });
27+
28+
// Process pixels to remove blue background
29+
const newData = Buffer.alloc(data.length);
30+
31+
for (let i = 0; i < data.length; i += 4) {
32+
const r = data[i];
33+
const g = data[i + 1];
34+
const b = data[i + 2];
35+
const a = data[i + 3];
36+
37+
// Check if pixel is part of blue background
38+
// Blue background is darker: b > r+20 and b > g+20 and overall dark
39+
if (b > r + 20 && b > g + 20 && (r + g + b) < 300) {
40+
// Make background transparent
41+
newData[i] = r;
42+
newData[i + 1] = g;
43+
newData[i + 2] = b;
44+
newData[i + 3] = 0; // Transparent
45+
} else {
46+
// Keep the pixel
47+
newData[i] = r;
48+
newData[i + 1] = g;
49+
newData[i + 2] = b;
50+
newData[i + 3] = 255; // Opaque
51+
}
52+
}
53+
54+
// Resize to 44x44 and save
55+
await sharp({
56+
create: {
57+
width: info.width,
58+
height: info.height,
59+
channels: 4,
60+
background: { r: 0, g: 0, b: 0, alpha: 0 }
61+
}
62+
})
63+
.composite([{ input: Buffer.concat([
64+
Buffer.from([...data]),
65+
]), raw: { width: info.width, height: info.height, channels: 4 } }])
66+
.png()
67+
.toFile(outputPath);
68+
};
69+
} catch (e) {
70+
// If sharp is not available, use a different approach
71+
console.warn('sharp not found, will attempt alternative method');
72+
processImage = null;
73+
}
74+
75+
async function fixTaskbarIcon() {
76+
const workspaceRoot = 'c:\\Users\\seans\\Documents\\GitHub\\TimeLens';
77+
const sourceIcon = path.join(workspaceRoot, 'src-tauri', 'icons', 'icon.png');
78+
const outputDir = path.join(workspaceRoot, 'src-tauri', 'windows', 'msix-staging', 'Assets');
79+
const outputIcon = path.join(outputDir, 'Square44x44Logo.png');
80+
81+
// Check if source exists
82+
if (!fs.existsSync(sourceIcon)) {
83+
console.error(`✗ Source icon not found: ${sourceIcon}`);
84+
process.exit(1);
85+
}
86+
87+
if (!fs.existsSync(outputDir)) {
88+
console.error(`✗ Output directory not found: ${outputDir}`);
89+
process.exit(1);
90+
}
91+
92+
console.log('Fixing Windows taskbar icon (Square44x44Logo.png)...');
93+
console.log(`Source: ${sourceIcon}`);
94+
console.log(`Output: ${outputIcon}`);
95+
96+
try {
97+
if (processImage) {
98+
await processImage(sourceIcon, outputIcon);
99+
} else {
100+
// Fallback: try using jimp
101+
try {
102+
const Jimp = require('jimp');
103+
const image = await Jimp.read(sourceIcon);
104+
105+
// Resize to 44x44
106+
image.resize(44, 44);
107+
108+
// Process each pixel to remove blue background
109+
image.forEachPixel((pixel, x, y) => {
110+
const { r, g, b, a } = pixel;
111+
112+
// If blue background, make transparent
113+
if (b > r + 20 && b > g + 20 && (r + g + b) < 300) {
114+
pixel.a = 0; // Transparent
115+
} else {
116+
pixel.a = 255; // Opaque
117+
}
118+
});
119+
120+
await image.write(outputIcon);
121+
console.log(`✓ Created ${outputIcon}`);
122+
} catch (jimpError) {
123+
console.error('Neither sharp nor jimp available. Installing sharp...');
124+
125+
const { execSync } = require('child_process');
126+
try {
127+
execSync('npm install sharp', { stdio: 'inherit', cwd: workspaceRoot });
128+
console.log('sharp installed, please run the script again');
129+
process.exit(0);
130+
} catch (installError) {
131+
console.error('Failed to install sharp:', installError.message);
132+
process.exit(1);
133+
}
134+
}
135+
}
136+
137+
console.log('\n✓ Taskbar icon fixed successfully!');
138+
console.log(' The blue background has been removed and replaced with transparency.');
139+
console.log(' This will display correctly in the Windows taskbar.');
140+
} catch (error) {
141+
console.error('✗ Error:', error.message);
142+
process.exit(1);
143+
}
144+
}
145+
146+
fixTaskbarIcon().catch(err => {
147+
console.error(err);
148+
process.exit(1);
149+
});

0 commit comments

Comments
 (0)