Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@
"windows": {
"command": ".\\scripts\\code.bat"
},
"problemMatcher": []
"problemMatcher": [],
"inSessions": true
},
{
"type": "npm",
Expand Down
48 changes: 46 additions & 2 deletions build/gulpfile.reh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { untar } from './lib/util.ts';
import File from 'vinyl';
import * as fs from 'fs';
import glob from 'glob';
import { promisify } from 'util';
import rceditCallback from 'rcedit';
import { compileBuildWithManglingTask } from './gulpfile.compile.ts';
import { cleanExtensionsBuildTask, compileNonNativeExtensionsBuildTask, compileNativeExtensionsBuildTask, compileExtensionMediaBuildTask } from './gulpfile.extensions.ts';
import { vscodeWebResourceIncludes, createVSCodeWebFileContentMapper } from './gulpfile.vscode.web.ts';
Expand All @@ -35,6 +37,8 @@ import { fetchUrls, fetchGithub } from './lib/fetch.ts';
import jsonEditor from 'gulp-json-editor';


const rcedit = promisify(rceditCallback);

const REPO_ROOT = path.dirname(import.meta.dirname);
const commit = getVersion(REPO_ROOT);
const BUILD_ROOT = path.dirname(REPO_ROOT);
Expand Down Expand Up @@ -422,6 +426,40 @@ function packageTask(type: string, platform: string, arch: string, sourceFolderN
};
}

function patchWin32DependenciesTask(destinationFolderName: string) {
const cwd = path.join(BUILD_ROOT, destinationFolderName);

return async () => {
const deps = (await Promise.all([
promisify(glob)('**/*.node', { cwd }),
promisify(glob)('**/rg.exe', { cwd }),
])).flatMap(o => o);
const packageJsonContents = JSON.parse(await fs.promises.readFile(path.join(cwd, 'package.json'), 'utf8'));
const productContents = JSON.parse(await fs.promises.readFile(path.join(cwd, 'product.json'), 'utf8'));
const baseVersion = packageJsonContents.version.replace(/-.*$/, '');

const patchPromises = deps.map<Promise<unknown>>(async dep => {
const basename = path.basename(dep);

await rcedit(path.join(cwd, dep), {
'file-version': baseVersion,
'version-string': {
'CompanyName': 'Microsoft Corporation',
'FileDescription': productContents.nameLong,
'FileVersion': packageJsonContents.version,
'InternalName': basename,
'LegalCopyright': 'Copyright (C) 2026 Microsoft. All rights reserved',
'OriginalFilename': basename,
'ProductName': productContents.nameLong,
'ProductVersion': packageJsonContents.version,
}
});
});

await Promise.all(patchPromises);
};
}

/**
* @param product The parsed product.json file contents
*/
Expand Down Expand Up @@ -466,12 +504,18 @@ function tweakProductForServerWeb(product: typeof import('../product.json')) {
const sourceFolderName = `out-vscode-${type}${dashed(minified)}`;
const destinationFolderName = `vscode-${type}${dashed(platform)}${dashed(arch)}`;

const serverTaskCI = task.define(`vscode-${type}${dashed(platform)}${dashed(arch)}${dashed(minified)}-ci`, task.series(
const packageTasks: task.Task[] = [
compileNativeExtensionsBuildTask,
gulp.task(`node-${platform}-${arch}`) as task.Task,
util.rimraf(path.join(BUILD_ROOT, destinationFolderName)),
packageTask(type, platform, arch, sourceFolderName, destinationFolderName)
));
];

if (platform === 'win32') {
packageTasks.push(patchWin32DependenciesTask(destinationFolderName));
}

const serverTaskCI = task.define(`vscode-${type}${dashed(platform)}${dashed(arch)}${dashed(minified)}-ci`, task.series(...packageTasks));
gulp.task(serverTaskCI);

const serverTask = task.define(`vscode-${type}${dashed(platform)}${dashed(arch)}${dashed(minified)}`, task.series(
Expand Down
14 changes: 10 additions & 4 deletions build/gulpfile.vscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,12 +623,16 @@ function patchWin32DependenciesTask(destinationFolderName: string) {
const cwd = path.join(path.dirname(root), destinationFolderName);

return async () => {
const deps = await glob('**/*.node', { cwd, ignore: 'extensions/node_modules/@parcel/watcher/**' });
const deps = (await Promise.all([
glob('**/*.node', { cwd, ignore: 'extensions/node_modules/@parcel/watcher/**' }),
glob('**/rg.exe', { cwd }),
glob('**/*explorer_command*.dll', { cwd }),
])).flatMap(o => o);
const packageJson = JSON.parse(await fs.promises.readFile(path.join(cwd, versionedResourcesFolder, 'resources', 'app', 'package.json'), 'utf8'));
const product = JSON.parse(await fs.promises.readFile(path.join(cwd, versionedResourcesFolder, 'resources', 'app', 'product.json'), 'utf8'));
const baseVersion = packageJson.version.replace(/-.*$/, '');

await Promise.all(deps.map(async dep => {
const patchPromises = deps.map<Promise<unknown>>(async dep => {
const basename = path.basename(dep);

await rcedit(path.join(cwd, dep), {
Expand All @@ -638,13 +642,15 @@ function patchWin32DependenciesTask(destinationFolderName: string) {
'FileDescription': product.nameLong,
'FileVersion': packageJson.version,
'InternalName': basename,
'LegalCopyright': 'Copyright (C) 2022 Microsoft. All rights reserved',
'LegalCopyright': 'Copyright (C) 2026 Microsoft. All rights reserved',
'OriginalFilename': basename,
'ProductName': product.nameLong,
'ProductVersion': packageJson.version,
}
});
}));
});

await Promise.all(patchPromises);
};
}

Expand Down
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ tar = "0.4.38"
[build-dependencies]
serde = { version="1.0.163", features = ["derive"] }
serde_json = "1.0.96"
winresource = "0.1"

[target.'cfg(windows)'.dependencies]
winreg = "0.50.0"
Expand Down
51 changes: 51 additions & 0 deletions cli/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fn main() {
let files = enumerate_source_files().expect("expected to enumerate files");
ensure_file_headers(&files).expect("expected to ensure file headers");
apply_build_environment_variables();
apply_win32_version_resources();
}

fn camel_case_to_constant_case(key: &str) -> String {
Expand Down Expand Up @@ -148,6 +149,56 @@ fn apply_build_environment_variables() {
};
}

fn apply_win32_version_resources() {
if env::var("CARGO_CFG_TARGET_OS").as_deref() != Ok("windows") {
return;
}

let repo_dir = env::current_dir().unwrap().join("..");
let package_json = read_json_from_path::<PackageJson>(&repo_dir.join("package.json"));

let product_json_path = match env::var("VSCODE_CLI_PRODUCT_JSON") {
Ok(v) => {
if cfg!(windows) {
PathBuf::from_str(&v.replace('/', "\\")).unwrap()
} else {
PathBuf::from_str(&v).unwrap()
}
}
Err(_) => repo_dir.join("product.json"),
};

let product: HashMap<String, Value> = read_json_from_path(&product_json_path);
let name_long = product
.get("nameLong")
.and_then(|v| v.as_str())
.unwrap_or("Code - OSS");
let application_name = product
.get("applicationName")
.and_then(|v| v.as_str())
.unwrap_or("code");
let exe_name = format!("{application_name}.exe");

let base_version = package_json.version.split('-').next().unwrap_or("0.0.0");
let version_parts: Vec<&str> = base_version.split('.').collect();
let major: u64 = version_parts.first().and_then(|v| v.parse().ok()).unwrap_or(0);
let minor: u64 = version_parts.get(1).and_then(|v| v.parse().ok()).unwrap_or(0);
let patch: u64 = version_parts.get(2).and_then(|v| v.parse().ok()).unwrap_or(0);

let mut res = winresource::WindowsResource::new();
res.set("ProductName", name_long);
res.set("FileDescription", name_long);
res.set("CompanyName", "Microsoft Corporation");
res.set("LegalCopyright", "Copyright (C) 2026 Microsoft. All rights reserved");
res.set("FileVersion", &package_json.version);
res.set("ProductVersion", &package_json.version);
res.set("InternalName", &exe_name);
res.set("OriginalFilename", &exe_name);
res.set_version_info(winresource::VersionInfo::FILEVERSION, (major << 48) | (minor << 16) | patch);
res.set_version_info(winresource::VersionInfo::PRODUCTVERSION, (major << 48) | (minor << 16) | patch);
res.compile().expect("failed to compile Windows resources");
}

fn ensure_file_headers(files: &[PathBuf]) -> Result<(), io::Error> {
let mut ok = true;

Expand Down
6 changes: 6 additions & 0 deletions src/vs/code/electron-main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { app, Details, GPUFeatureStatus, powerMonitor, protocol, session, Sessio
import { addUNCHostToAllowlist, disableUNCAccessRestrictions } from '../../base/node/unc.js';
import { validatedIpcMain } from '../../base/parts/ipc/electron-main/ipcMain.js';
import { hostname, release } from 'os';
import { initWindowsVersionInfo } from '../../base/node/windowsVersion.js';
import { VSBuffer } from '../../base/common/buffer.js';
import { toErrorMessage } from '../../base/common/errorMessage.js';
import { Event } from '../../base/common/event.js';
Expand Down Expand Up @@ -1431,6 +1432,11 @@ export class CodeApplication extends Disposable {

private afterWindowOpen(instantiationService: IInstantiationService): void {

// Accurate Windows version info
if (isWindows) {
initWindowsVersionInfo();
}

// Windows: mutex
this.installMutex();

Expand Down
6 changes: 1 addition & 5 deletions src/vs/code/electron-main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { IProcessEnvironment, isLinux, isMacintosh, isWindows, OS } from '../../
import { cwd } from '../../base/common/process.js';
import { rtrim, trim } from '../../base/common/strings.js';
import { Promises as FSPromises } from '../../base/node/pfs.js';
import { initWindowsVersionInfo } from '../../base/node/windowsVersion.js';
import { ProxyChannel } from '../../base/parts/ipc/common/ipc.js';
import { Client as NodeIPCClient } from '../../base/parts/ipc/common/ipc.net.js';
import { connect as nodeIPCConnect, serve as nodeIPCServe, Server as NodeIPCServer, XDG_RUNTIME_DIR } from '../../base/parts/ipc/node/ipc.net.js';
Expand Down Expand Up @@ -283,10 +282,7 @@ class CodeMain {
stateService.init(),

// Configuration service
configurationService.initialize(),

// Accurate Windows version info.
isWindows ? initWindowsVersionInfo() : Promise.resolve()
configurationService.initialize()
]);

// Initialize user data profiles after initializing the state
Expand Down
6 changes: 6 additions & 0 deletions src/vs/sessions/common/contextkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
import { localize } from '../../nls.js';
import { RawContextKey } from '../../platform/contextkey/common/contextkey.js';

//#region < --- Welcome --- >

export const SessionsWelcomeCompleteContext = new RawContextKey<boolean>('sessionsWelcomeComplete', false, localize('sessionsWelcomeComplete', "Whether the sessions welcome setup is complete"));

//#endregion

//#region < --- Chat Bar --- >

export const ActiveChatBarContext = new RawContextKey<string>('activeChatBar', '', localize('activeChatBar', "The identifier of the active chat bar panel"));
Expand Down
23 changes: 8 additions & 15 deletions src/vs/sessions/contrib/chat/browser/chat.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Codicon } from '../../../../base/common/codicons.js';
import { KeyCode, KeyMod } from '../../../../base/common/keyCodes.js';
import { ServicesAccessor } from '../../../../editor/browser/editorExtensions.js';
import { localize, localize2 } from '../../../../nls.js';
import { Action2, MenuRegistry, registerAction2 } from '../../../../platform/actions/common/actions.js';
import { Action2, registerAction2 } from '../../../../platform/actions/common/actions.js';
import { Schemas } from '../../../../base/common/network.js';
import { URI } from '../../../../base/common/uri.js';
import { IOpenerService } from '../../../../platform/opener/common/opener.js';
Expand Down Expand Up @@ -48,9 +48,10 @@ export class OpenSessionWorktreeInVSCodeAction extends Action2 {
title: localize2('openInVSCode', 'Open in VS Code'),
icon: Codicon.vscodeInsiders,
menu: [{
id: Menus.OpenSubMenu,
id: Menus.TitleBarRight,
group: 'navigation',
order: 2,
order: 10,
when: IsAuxiliaryWindowContext.toNegated()
}]
});
}
Expand Down Expand Up @@ -126,9 +127,10 @@ export class OpenSessionInTerminalAction extends Action2 {
title: localize2('openInTerminal', "Open Terminal"),
icon: Codicon.terminal,
menu: [{
id: Menus.OpenSubMenu,
id: Menus.TitleBarRight,
group: 'navigation',
order: 1,
order: 9,
when: IsAuxiliaryWindowContext.toNegated()
}]
});
}
Expand Down Expand Up @@ -167,16 +169,7 @@ export class OpenSessionInTerminalAction extends Action2 {

registerAction2(OpenSessionInTerminalAction);

// Register the split button menu item that combines Open in VS Code and Open in Terminal
MenuRegistry.appendMenuItem(Menus.TitleBarRight, {
submenu: Menus.OpenSubMenu,
isSplitButton: { togglePrimaryAction: true },
title: localize2('open', "Open..."),
icon: Codicon.folderOpened,
group: 'navigation',
order: 9,
when: IsAuxiliaryWindowContext.toNegated()
});




Expand Down
Loading
Loading