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
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Added

- Persistent sessions for running testcases and stress tester. Whenever the active editor changes, the previous session is saved and restored when the file is opened again
- Ctrl+Enter hotkey to save currently edited textarea
- Ctrl+Enter to append newline instead of sending current online input
- Automatically show notification to check changelog when extension is updated
Expand All @@ -10,9 +11,9 @@

### Changed

- Use native addons to run solutions and enforce limits instead of using child_process. This bypasses the event loop and allows for more accurate limits as well as accurate metrics. Using native addons also means we effectively restrict this extension to only run on Windows, Linux, and macOS, which are the platforms that VSCode supports
- Use native addons to run solutions and enforce limits instead of using child_process. This bypasses the event loop and allows for more accurate limits as well as accurate metrics. Using native addons also means we effectively restrict this extension to only run on Windows, Linux, and macOS. The web platform is excluded.
- Use total CPU time to enforce time limit and a 2x multipler to enforce the wall time
- The extension excludes the web platform support explicitly and will not provide a "universal" VSIX. It would have failed implicity in the past, but now this restriction is enforced to platform specific VSIX.
- Changes are debounced on judge prevent rapid IO bottlenecks
- Trim off trailing whitespaces when requesting full data
- Don't save ongoing running statuses to avoid blocking interacting with testcase on malfunction
- Removed unused save all functionality
Expand Down
76 changes: 74 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,38 @@
"command": "fastolympiccoding.toggleJudgeSettings",
"when": "false"
}
],
"view/item/context": [
{
"command": "fastolympiccoding.listenForCompetitiveCompanion",
"group": "inline",
"when": "view == fastolympiccoding.panel && viewItem == companion-stopped"
},
{
"command": "fastolympiccoding.stopCompetitiveCompanion",
"group": "inline",
"when": "view == fastolympiccoding.panel && viewItem == companion-listening"
},
{
"command": "fastolympiccoding.stopBackgroundTests",
"group": "inline",
"when": "view == fastolympiccoding.panel && viewItem == judge-background-file"
},
{
"command": "fastolympiccoding.stopStressSession",
"group": "inline",
"when": "view == fastolympiccoding.panel && viewItem == stress-background-file"
},
{
"command": "fastolympiccoding.stopAllBackgroundTests",
"group": "inline",
"when": "view == fastolympiccoding.panel && viewItem == judge-background-group"
},
{
"command": "fastolympiccoding.stopAllStressSessions",
"group": "inline",
"when": "view == fastolympiccoding.panel && viewItem == stress-background-group"
}
]
},
"viewsContainers": {
Expand All @@ -84,6 +116,13 @@
"title": "Fast Olympic Coding",
"icon": "$(zap)"
}
],
"panel": [
{
"id": "fastolympiccodingpanel",
"title": "Fast Olympic Coding",
"icon": "$(zap)"
}
]
},
"views": {
Expand All @@ -100,6 +139,13 @@
"type": "webview",
"name": "Stress"
}
],
"fastolympiccodingpanel": [
{
"id": "fastolympiccoding.panel",
"name": "Status",
"icon": "$(zap)"
}
]
},
"configuration": [
Expand Down Expand Up @@ -295,12 +341,14 @@
{
"command": "fastolympiccoding.listenForCompetitiveCompanion",
"title": "Listen for Competitive Companion",
"category": "Fast Olympic Coding"
"category": "Fast Olympic Coding",
"icon": "$(broadcast)"
},
{
"command": "fastolympiccoding.stopCompetitiveCompanion",
"title": "Stop Competitive Companion",
"category": "Fast Olympic Coding"
"category": "Fast Olympic Coding",
"icon": "$(circle-slash)"
},
{
"command": "fastolympiccoding.toggleJudgeSettings",
Expand All @@ -318,6 +366,30 @@
"command": "fastolympiccoding.showChangelog",
"title": "Show Changelog",
"category": "Fast Olympic Coding"
},
{
"command": "fastolympiccoding.stopBackgroundTests",
"title": "Stop",
"category": "Fast Olympic Coding",
"icon": "$(debug-stop)"
},
{
"command": "fastolympiccoding.stopStressSession",
"title": "Stop Stress Test",
"category": "Fast Olympic Coding",
"icon": "$(debug-stop)"
},
{
"command": "fastolympiccoding.stopAllBackgroundTests",
"title": "Stop All Running Tests",
"category": "Fast Olympic Coding",
"icon": "$(circle-slash)"
},
{
"command": "fastolympiccoding.stopAllStressSessions",
"title": "Stop All Stress Sessions",
"category": "Fast Olympic Coding",
"icon": "$(circle-slash)"
}
],
"keybindings": [
Expand Down
35 changes: 13 additions & 22 deletions src/extension/competitiveCompanion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class ProblemQueue {

// Module state
let server: http.Server | undefined;
let statusBarItem: vscode.StatusBarItem | undefined;

let prevSelection: string | undefined;
let prevBatchId: string | undefined;
Expand Down Expand Up @@ -226,23 +225,6 @@ function createRequestHandler(judge: JudgeViewProvider): http.RequestListener {
};
}

/**
* Creates the status bar item for Competitive Companion.
*/
export function createStatusBarItem(context: vscode.ExtensionContext): vscode.StatusBarItem {
statusBarItem = vscode.window.createStatusBarItem(
"fastolympiccoding.listeningForCompetitiveCompanion",
vscode.StatusBarAlignment.Left
);
statusBarItem.name = "Competitive Companion Indicator";
statusBarItem.text = "$(zap)";
statusBarItem.tooltip = "Listening For Competitive Companion";
statusBarItem.hide();
context.subscriptions.push(statusBarItem);

return statusBarItem;
}

/**
* Starts listening for Competitive Companion connections.
*/
Expand All @@ -259,7 +241,7 @@ export function createListener(judgeViewProvider: JudgeViewProvider): void {
const port = config.get<number>("port")!;
const logger = getLogger("competitive-companion");
logger.info(`Listener started on port ${port}`);
statusBarItem?.show();
_onDidChangeListening.fire(true);
});
server.once("error", (error) => {
const logger = getLogger("competitive-companion");
Expand All @@ -270,7 +252,7 @@ export function createListener(judgeViewProvider: JudgeViewProvider): void {
});
server.once("close", () => {
server = undefined;
statusBarItem?.hide();
_onDidChangeListening.fire(false);
});

const config = vscode.workspace.getConfiguration("fastolympiccoding");
Expand All @@ -282,6 +264,15 @@ export function createListener(judgeViewProvider: JudgeViewProvider): void {
* Stops listening for Competitive Companion connections.
*/
export function stopCompetitiveCompanion(): void {
server?.close();
server = undefined;
if (server) {
server.close();
server = undefined;
}
}

export function isListening(): boolean {
return server !== undefined;
}

const _onDidChangeListening = new vscode.EventEmitter<boolean>();
export const onDidChangeListening = _onDidChangeListening.event;
58 changes: 53 additions & 5 deletions src/extension/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import * as path from "node:path";
import * as vscode from "vscode";

import { compile, clearCompileCache } from "./utils/runtime";
import {
createStatusBarItem,
createListener,
stopCompetitiveCompanion,
} from "./competitiveCompanion";
import { createListener, stopCompetitiveCompanion } from "./competitiveCompanion";
import { registerRunSettingsCommands } from "./runSettingsCommands";
import {
initializeRunSettingsWatcher,
Expand All @@ -17,10 +13,13 @@ import {
import { initLogging } from "./utils/logging";
import JudgeViewProvider from "./providers/JudgeViewProvider";
import StressViewProvider from "./providers/StressViewProvider";
import PanelViewProvider from "./providers/PanelViewProvider";
import { showChangelog } from "./changelog";
import { createStatusBarItem } from "./statusBar";

let judgeViewProvider: JudgeViewProvider;
let stressViewProvider: StressViewProvider;
let panelViewProvider: PanelViewProvider;

type Dependencies = Record<string, string[]>;

Expand Down Expand Up @@ -76,6 +75,15 @@ function registerViewProviders(context: vscode.ExtensionContext): void {
context.subscriptions.push(
vscode.window.registerWebviewViewProvider(stressViewProvider.getViewId(), stressViewProvider)
);

// Panel tree view in panel area (bottom)
panelViewProvider = new PanelViewProvider(context, judgeViewProvider, stressViewProvider);
context.subscriptions.push(
vscode.window.createTreeView("fastolympiccoding.panel", {
treeDataProvider: panelViewProvider,
showCollapseAll: false,
})
);
}

function registerDocumentContentProviders(context: vscode.ExtensionContext): void {
Expand Down Expand Up @@ -246,6 +254,46 @@ function registerCommands(context: vscode.ExtensionContext): void {
context.subscriptions.push(
vscode.commands.registerCommand("fastolympiccoding.showChangelog", () => showChangelog(context))
);

context.subscriptions.push(
vscode.commands.registerCommand("fastolympiccoding.showPanel", () => {
vscode.commands.executeCommand("fastolympiccoding.panel.focus");
})
);

context.subscriptions.push(
vscode.commands.registerCommand(
"fastolympiccoding.stopBackgroundTests",
(item: { filePath?: string }) => {
if (item?.filePath) {
void judgeViewProvider.stopBackgroundTasksForFile(item.filePath);
}
}
)
);

context.subscriptions.push(
vscode.commands.registerCommand(
"fastolympiccoding.stopStressSession",
(item: { filePath?: string }) => {
if (item?.filePath) {
stressViewProvider.stopStressSession(item.filePath);
}
}
)
);

context.subscriptions.push(
vscode.commands.registerCommand("fastolympiccoding.stopAllStressSessions", () => {
stressViewProvider.stopAll();
})
);

context.subscriptions.push(
vscode.commands.registerCommand("fastolympiccoding.stopAllBackgroundTests", () => {
void judgeViewProvider.stopAllBackgroundTasks();
})
);
}

export function activate(context: vscode.ExtensionContext): void {
Expand Down
Loading