Cleanup
This commit is contained in:
@@ -4,13 +4,15 @@
|
||||
|
||||
### 0.1
|
||||
|
||||
* 3-4 sample skills useful in a vault
|
||||
* Versioning and changelog
|
||||
|
||||
### 0.2
|
||||
|
||||
* AGENTS.md initialization
|
||||
* Windows support
|
||||
* 3-4 sample skills useful in a vault
|
||||
|
||||
### 0.3
|
||||
* AGENTS.md initialization
|
||||
|
||||
### 1.0
|
||||
|
||||
|
||||
@@ -39,9 +39,8 @@ export class ProcessManager {
|
||||
}
|
||||
|
||||
getUrl(): string {
|
||||
const baseUrl = `http://${this.settings.hostname}:${this.settings.port}`;
|
||||
const encodedPath = btoa(this.projectDirectory);
|
||||
return `${baseUrl}/${encodedPath}`;
|
||||
return `http://${this.settings.hostname}:${this.settings.port}/${encodedPath}`;
|
||||
}
|
||||
|
||||
async start(): Promise<boolean> {
|
||||
@@ -57,7 +56,6 @@ export class ProcessManager {
|
||||
return this.setError("Project directory (vault) not configured");
|
||||
}
|
||||
|
||||
// Check if server is already running on this port
|
||||
if (await this.checkServerHealth()) {
|
||||
console.log("[OpenCode] Server already running on port", this.settings.port);
|
||||
this.setState("running");
|
||||
@@ -125,19 +123,16 @@ export class ProcessManager {
|
||||
}
|
||||
});
|
||||
|
||||
// Wait for server to be ready
|
||||
const ready = await this.waitForServerOrExit(this.settings.startupTimeout);
|
||||
if (ready) {
|
||||
this.setState("running");
|
||||
return true;
|
||||
}
|
||||
|
||||
// If already in error state from spawn error event, don't overwrite
|
||||
if (this.state === "error") {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Determine appropriate error message based on what happened
|
||||
this.stop();
|
||||
if (this.earlyExitCode !== null) {
|
||||
return this.setError(`Process exited unexpectedly (exit code ${this.earlyExitCode})`);
|
||||
|
||||
@@ -94,20 +94,17 @@ export default class OpenCodePlugin extends Plugin {
|
||||
|
||||
this.processManager.updateProjectDirectory(this.getProjectDirectory());
|
||||
|
||||
// Restart server if it's currently running
|
||||
if (this.getProcessState() === "running") {
|
||||
this.stopServer();
|
||||
await this.startServer();
|
||||
}
|
||||
}
|
||||
|
||||
// Get existing view leaf if any
|
||||
private getExistingLeaf(): WorkspaceLeaf | null {
|
||||
const leaves = this.app.workspace.getLeavesOfType(OPENCODE_VIEW_TYPE);
|
||||
return leaves.length > 0 ? leaves[0] : null;
|
||||
}
|
||||
|
||||
// Activate or create the view
|
||||
async activateView(): Promise<void> {
|
||||
const existingLeaf = this.getExistingLeaf();
|
||||
|
||||
@@ -133,7 +130,6 @@ export default class OpenCodePlugin extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle view visibility
|
||||
async toggleView(): Promise<void> {
|
||||
const existingLeaf = this.getExistingLeaf();
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ function createTestSettings(port: number): OpenCodeSettings {
|
||||
opencodePath: "opencode",
|
||||
projectDirectory: "",
|
||||
startupTimeout: TEST_TIMEOUT_MS,
|
||||
defaultViewLocation: "sidebar",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -63,7 +64,6 @@ describe("ProcessManager", () => {
|
||||
currentManager = new ProcessManager(
|
||||
settings,
|
||||
PROJECT_DIR,
|
||||
PROJECT_DIR,
|
||||
(state) => stateHistory.push(state)
|
||||
);
|
||||
|
||||
@@ -84,7 +84,6 @@ describe("ProcessManager", () => {
|
||||
currentManager = new ProcessManager(
|
||||
settings,
|
||||
PROJECT_DIR,
|
||||
PROJECT_DIR,
|
||||
() => {}
|
||||
);
|
||||
|
||||
@@ -103,7 +102,6 @@ describe("ProcessManager", () => {
|
||||
currentManager = new ProcessManager(
|
||||
settings,
|
||||
PROJECT_DIR,
|
||||
PROJECT_DIR,
|
||||
(state) => stateHistory.push(state)
|
||||
);
|
||||
|
||||
@@ -124,7 +122,6 @@ describe("ProcessManager", () => {
|
||||
currentManager = new ProcessManager(
|
||||
settings,
|
||||
PROJECT_DIR,
|
||||
PROJECT_DIR,
|
||||
(state) => stateHistory.push(state)
|
||||
);
|
||||
|
||||
@@ -145,7 +142,6 @@ describe("ProcessManager", () => {
|
||||
currentManager = new ProcessManager(
|
||||
settings,
|
||||
PROJECT_DIR,
|
||||
PROJECT_DIR,
|
||||
() => {}
|
||||
);
|
||||
|
||||
@@ -174,7 +170,6 @@ describe("ProcessManager", () => {
|
||||
currentManager = new ProcessManager(
|
||||
settings,
|
||||
PROJECT_DIR,
|
||||
PROJECT_DIR,
|
||||
() => {}
|
||||
);
|
||||
|
||||
@@ -205,7 +200,6 @@ describe("ProcessManager", () => {
|
||||
currentManager = new ProcessManager(
|
||||
settings,
|
||||
PROJECT_DIR,
|
||||
PROJECT_DIR,
|
||||
() => {}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user