Update sessions tasks

This commit is contained in:
BeniBenj
2026-03-25 10:22:25 +01:00
parent 0b84fd1b4b
commit 687dc1c8f0
2 changed files with 12 additions and 76 deletions

25
.vscode/tasks.json vendored
View File

@@ -239,26 +239,23 @@
],
"problemMatcher": []
},
{
"label": "Transpile Client",
"type": "npm",
"script": "transpile-client",
"problemMatcher": []
},
{
"label": "Run and Compile Sessions - OSS",
"type": "shell",
"command": "npm run transpile-client && ./scripts/code.sh",
"windows": {
"command": "npm run transpile-client && .\\scripts\\code.bat"
},
"args": [
"--sessions"
],
"dependsOn": ["Transpile Client", "Run Dev Sessions"],
"dependsOrder": "sequence",
"inSessions": true,
"problemMatcher": []
},
{
"label": "Run and Compile Code - OSS",
"type": "shell",
"command": "npm run transpile-client && ./scripts/code.sh",
"windows": {
"command": "npm run transpile-client && .\\scripts\\code.bat"
},
"dependsOn": ["Transpile Client", "Run Dev"],
"dependsOrder": "sequence",
"inSessions": true,
"problemMatcher": []
},
@@ -438,4 +435,4 @@
"isBackground": false
}
]
}
}

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { Disposable, DisposableStore, MutableDisposable } from '../../../../base/common/lifecycle.js';
import { autorun, IObservable, observableValue, transaction } from '../../../../base/common/observable.js';
import { IObservable, observableValue, transaction } from '../../../../base/common/observable.js';
import { joinPath, dirname, isEqual } from '../../../../base/common/resources.js';
import { parse } from '../../../../base/common/jsonc.js';
import { URI } from '../../../../base/common/uri.js';
@@ -127,7 +127,6 @@ export class SessionsConfigurationService extends Disposable implements ISession
private static readonly _PINNED_TASK_LABELS_KEY = 'agentSessions.pinnedTaskLabels';
private readonly _sessionTasks = observableValue<readonly ISessionTaskWithTarget[]>(this, []);
private readonly _fileWatcher = this._register(new MutableDisposable());
private readonly _knownSessionWorktrees = new Map<string, string | undefined>();
private readonly _pinnedTaskLabels: Map<string, string>;
private readonly _pinnedTaskObservables = new Map<string, ReturnType<typeof observableValue<string | undefined>>>();
@@ -145,11 +144,6 @@ export class SessionsConfigurationService extends Disposable implements ISession
) {
super();
this._pinnedTaskLabels = this._loadPinnedTaskLabels();
this._register(autorun(reader => {
const activeSession = this._sessionsManagementService.activeSession.read(reader);
this._handleActiveSessionChange(activeSession);
}));
}
getSessionTasks(session: IActiveSessionItem): IObservable<readonly ISessionTaskWithTarget[]> {
@@ -384,65 +378,10 @@ export class SessionsConfigurationService extends Disposable implements ISession
}
}
private async _readAllTasks(session: IActiveSessionItem): Promise<readonly ITaskEntry[]> {
const result: ITaskEntry[] = [];
// Read workspace tasks
const workspaceUri = this._getTasksJsonUri(session, 'workspace');
if (workspaceUri) {
const workspaceJson = await this._readTasksJson(workspaceUri);
if (workspaceJson.tasks) {
result.push(...workspaceJson.tasks.filter(t => this._isSupportedTask(t)));
}
}
// Read user tasks
const userUri = this._getTasksJsonUri(session, 'user');
if (userUri) {
const userJson = await this._readTasksJson(userUri);
if (userJson.tasks) {
result.push(...userJson.tasks.filter(t => this._isSupportedTask(t)));
}
}
return result;
}
private _isSupportedTask(task: ITaskEntry): boolean {
return !!task.label;
}
private _handleActiveSessionChange(session: IActiveSessionItem | undefined): void {
if (!session) {
return;
}
const sessionKey = session.resource.toString();
const currentWorktree = session.worktree?.toString();
if (!this._knownSessionWorktrees.has(sessionKey)) {
this._knownSessionWorktrees.set(sessionKey, currentWorktree);
return;
}
const previousWorktree = this._knownSessionWorktrees.get(sessionKey);
this._knownSessionWorktrees.set(sessionKey, currentWorktree);
if (!currentWorktree || previousWorktree === currentWorktree) {
return;
}
void this._runWorktreeCreatedTasks(session);
}
private async _runWorktreeCreatedTasks(session: IActiveSessionItem): Promise<void> {
const tasks = await this._readAllTasks(session);
for (const task of tasks) {
if (!task.inSessions || task.runOptions?.runOn !== 'worktreeCreated') {
continue;
}
await this.runTask(task, session);
}
}
private _ensureFileWatch(folder: URI): void {
const tasksUri = joinPath(folder, '.vscode', 'tasks.json');
if (this._watchedResource && this._watchedResource.toString() === tasksUri.toString()) {