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
1 change: 1 addition & 0 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"node-addon-api": "^7.1.0",
"node-pty": "1.1.0-beta30",
"os-locale": "^6.0.2",
"pidtree": "^0.6.0",
"posthog-js": "1.310.1",
"posthog-node": "^5.18.0",
"react": "^19.2.3",
Expand Down
3 changes: 0 additions & 3 deletions apps/desktop/src/lib/trpc/routers/projects/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,6 @@ export const createProjectsRouter = (getWindow: () => BrowserWindow | null) => {
return null;
}

// If we already have the github owner cached, return the avatar URL
if (project.githubOwner) {
console.log(
"[getGitHubAvatar] Using cached owner:",
Expand All @@ -738,7 +737,6 @@ export const createProjectsRouter = (getWindow: () => BrowserWindow | null) => {
};
}

// Fetch the owner from GitHub
console.log(
"[getGitHubAvatar] Fetching owner for:",
project.mainRepoPath,
Expand All @@ -752,7 +750,6 @@ export const createProjectsRouter = (getWindow: () => BrowserWindow | null) => {

console.log("[getGitHubAvatar] Fetched owner:", owner);

// Cache the owner
localDb
.update(projects)
.set({ githubOwner: owner })
Expand Down
6 changes: 4 additions & 2 deletions apps/desktop/src/main/lib/terminal/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export class TerminalManager extends EventEmitter {

this.sessions.set(paneId, session);

portManager.registerSession(session, workspaceId);

// Track terminal opened (only fires once per session creation)
track("terminal_opened", { workspace_id: workspaceId, pane_id: paneId });

Expand Down Expand Up @@ -142,8 +144,8 @@ export class TerminalManager extends EventEmitter {

await closeSessionHistory(session, exitCode);

// Clean up detected ports for this pane
portManager.removePortsForPane(paneId);
// Unregister from port manager (also removes detected ports)
portManager.unregisterSession(paneId);

this.emit(`exit:${paneId}`, exitCode, signal);

Expand Down
34 changes: 34 additions & 0 deletions apps/desktop/src/main/lib/terminal/port-hints.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Lightweight patterns to detect when terminal output suggests a port may have been opened.
* These are used as hints to trigger an immediate process-based scan, not as the source of truth.
*/

const HINT_PATTERNS = [
/localhost:\d{2,5}/i,
/127\.0\.0\.1:\d{2,5}/,
/0\.0\.0\.0:\d{2,5}/,
/https?:\/\/[^:/]+:\d{2,5}/i,
/listening (?:on|at)/i,
/server (?:running|started|is running)/i,
/ready (?:on|at|in)/i,
/started (?:on|at)/i,
/bound to (?:port)?/i,
/development server/i,
/serving (?:on|at)/i,
/next\.?js/i,
/vite/i,
/webpack.*compiled/i,
/express/i,
/fastify/i,
];

/**
* Check if terminal output contains hints that a port may have been opened.
* This is a lightweight check - false positives are acceptable since we verify
* with actual process scanning.
*/
export function containsPortHint(data: string): boolean {
if (data.length < 10) return false;

return HINT_PATTERNS.some((pattern) => pattern.test(data));
}
Loading