Skip to content

Commit 72c61a9

Browse files
committed
Set stable CLSID before setAppUserModelId on Windows so COM routing works [2]
1 parent 169f044 commit 72c61a9

3 files changed

Lines changed: 35 additions & 18 deletions

File tree

‎app/src/app-env.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ export default class AppEnvConstructor {
138138

139139
// Shortcut phased out in April 2026, remove in June/July 2026
140140
if (this.isMainWindow() && process.platform === 'win32') {
141-
this.fixStaleWin32LaunchOnSystemStart();
141+
setTimeout(() => {
142+
this.fixStaleWin32LaunchOnSystemStart();
143+
}, 1000);
142144
}
143145
}
144146

@@ -166,7 +168,8 @@ export default class AppEnvConstructor {
166168
if (exists) {
167169
fs.unlink(shortcutPath, () => {});
168170
const { SystemStartService } = require('mailspring-exports');
169-
SystemStartService.configureToLaunchOnSystemStart();
171+
const service = new SystemStartService();
172+
service.configureToLaunchOnSystemStart();
170173
}
171174
}
172175
// This ties window.onerror and process.uncaughtException,handledRejection

‎app/src/browser/main.js‎

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if (typeof process.setFdLimit === 'function') {
1616
process.setFdLimit(1024);
1717
}
1818

19-
const setupConfigDir = (args) => {
19+
const setupConfigDir = args => {
2020
let dirname = 'Mailspring';
2121
if (args.devMode) {
2222
dirname = 'Mailspring-dev';
@@ -42,7 +42,7 @@ const setupConfigDir = (args) => {
4242
return configDirPath;
4343
};
4444

45-
const setupCompileCache = (configDirPath) => {
45+
const setupCompileCache = configDirPath => {
4646
const compileCache = require('../compile-cache');
4747
return compileCache.setHomeDirectory(configDirPath);
4848
};
@@ -59,13 +59,16 @@ const setupErrorLogger = (args = {}) => {
5959
return errorLogger;
6060
};
6161

62-
const declareOptions = (argv) => {
62+
const declareOptions = argv => {
6363
const optimist = require('optimist');
6464
const options = optimist(argv);
6565
options.usage(
6666
`Mailspring\n\nUsage: mailspring [options] [recipient] [attachment]\n\nRun Mailspring: The open source extensible email client\n\n\`mailspring mailto:johndoe@example.com\` to compose an e-mail to johndoe@example.com.\n\`mailspring ./attachment.txt\` to compose an e-mail with a text file attached.\n\`mailspring --dev\` to start the client in dev mode.\n\`mailspring --test\` to run unit tests.`
6767
);
68-
options.alias('d', 'dev').boolean('d').describe('d', 'Run in development mode.');
68+
options
69+
.alias('d', 'dev')
70+
.boolean('d')
71+
.describe('d', 'Run in development mode.');
6972
options
7073
.alias('t', 'test')
7174
.boolean('t')
@@ -82,8 +85,14 @@ const declareOptions = (argv) => {
8285
options.boolean('enable-crashpad');
8386
options.boolean('allow-file-access-from-files');
8487
options.boolean('source-app-id');
85-
options.alias('h', 'help').boolean('h').describe('h', 'Print this usage message.');
86-
options.alias('l', 'log-file').string('l').describe('l', 'Log all test output to file.');
88+
options
89+
.alias('h', 'help')
90+
.boolean('h')
91+
.describe('h', 'Print this usage message.');
92+
options
93+
.alias('l', 'log-file')
94+
.string('l')
95+
.describe('l', 'Log all test output to file.');
8796
options
8897
.alias('c', 'config-dir-path')
8998
.string('c')
@@ -99,12 +108,18 @@ const declareOptions = (argv) => {
99108
'f',
100109
'Override the default file regex to determine which tests should run (defaults to "-spec.(js|jsx|es6|es)$" )'
101110
);
102-
options.alias('v', 'version').boolean('v').describe('v', 'Print the version.');
103-
options.alias('b', 'background').boolean('b').describe('b', 'Start Mailspring in the background');
111+
options
112+
.alias('v', 'version')
113+
.boolean('v')
114+
.describe('v', 'Print the version.');
115+
options
116+
.alias('b', 'background')
117+
.boolean('b')
118+
.describe('b', 'Start Mailspring in the background');
104119
return options;
105120
};
106121

107-
const parseCommandLine = (argv) => {
122+
const parseCommandLine = argv => {
108123
const pkg = require('../../package.json');
109124
const version = `${pkg.version}-${pkg.commitHash}`;
110125

@@ -191,7 +206,7 @@ const parseCommandLine = (argv) => {
191206
};
192207
};
193208

194-
const extractMailtoLink = (mailtoLink) => {
209+
const extractMailtoLink = mailtoLink => {
195210
console.log(mailtoLink);
196211

197212
// Handle links in the form mailto:test@example.com?attach=file:///path/to/file.txt
@@ -277,10 +292,9 @@ const start = () => {
277292
// into the Start Menu shortcut. Without this, action/reply notification
278293
// events are silently dropped (COM server is never registered).
279294
app.setToastActivatorCLSID('{E6AD16B0-2830-48E7-9DB7-439152FA917B}');
295+
app.setAppUserModelId('com.squirrel.mailspring.mailspring');
280296
}
281297

282-
app.setAppUserModelId('com.squirrel.mailspring.mailspring');
283-
284298
// Set the app name explicitly for Linux to ensure the system tray icon
285299
// gets a unique ID. Without this, all Electron apps share the same
286300
// StatusNotifierItem ID on Linux, causing their tray visibility settings
@@ -381,7 +395,7 @@ const start = () => {
381395
.replace('app.asar', 'app.asar.unpacked'),
382396
{ allowFileAccess: true }
383397
)
384-
.catch((err) => console.error(`Error loading language detection extension: ${err}`));
398+
.catch(err => console.error(`Error loading language detection extension: ${err}`));
385399

386400
session.defaultSession.webRequest.onBeforeSendHeaders(o365Filter, (details, callback) => {
387401
delete details.requestHeaders['Origin'];
@@ -406,9 +420,8 @@ const start = () => {
406420
});
407421

408422
// eslint-disable-next-line
409-
const Application = require(
410-
path.join(options.resourcePath, 'src', 'browser', 'application')
411-
).default;
423+
const Application = require(path.join(options.resourcePath, 'src', 'browser', 'application'))
424+
.default;
412425
global.application = new Application();
413426
global.application.start(options);
414427

‎app/src/browser/windows-updater.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ exports.handleSquirrelInstall = app => {
301301
iconIndex: 0,
302302
description: 'The best email app for people and teams at work',
303303
appUserModelId: 'com.squirrel.mailspring.mailspring',
304+
toastActivatorClsid: '{E6AD16B0-2830-48E7-9DB7-439152FA917B}',
304305
};
305306

306307
try {

0 commit comments

Comments
 (0)