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
26 changes: 26 additions & 0 deletions .superset/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,32 @@ https://localhost:{\$CADDY_ELECTRIC_PORT} {
CADDYEOF
success "Caddyfile written"

# Generate .superset/ports.json for static port name mapping in the desktop app
if [ -n "${SUPERSET_PORT_BASE:-}" ]; then
local superset_dir
superset_dir="$(dirname "$0")"
cat > "$superset_dir/ports.json" <<PORTSJSON
{
"ports": [
{ "port": $WEB_PORT, "label": "Web" },
{ "port": $API_PORT, "label": "API" },
{ "port": $MARKETING_PORT, "label": "Marketing" },
{ "port": $ADMIN_PORT, "label": "Admin" },
{ "port": $DOCS_PORT, "label": "Docs" },
{ "port": $DESKTOP_VITE_PORT, "label": "Desktop Vite" },
{ "port": $DESKTOP_NOTIFICATIONS_PORT, "label": "Notifications" },
{ "port": $STREAMS_PORT, "label": "Streams" },
{ "port": $STREAMS_INTERNAL_PORT, "label": "Streams Internal" },
{ "port": $ELECTRIC_PORT, "label": "Electric" },
{ "port": $CADDY_ELECTRIC_PORT, "label": "Caddy Electric" },
{ "port": $CODE_INSPECTOR_PORT, "label": "Code Inspector" },
{ "port": $ELECTRIC_PROXY_PORT, "label": "Electric Proxy" }
]
}
PORTSJSON
success "Port name mapping written to .superset/ports.json"
fi

return 0
}

Expand Down
28 changes: 28 additions & 0 deletions apps/desktop/src/lib/trpc/routers/ports/ports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,33 @@ export const createPortsRouter = () => {
};
});
}),

subscribeAllStatic: publicProcedure.subscription(() => {
return observable<{ type: "change"; workspaceId: string }>((emit) => {
const allWorkspaces = localDb.select().from(workspaces).all();
const watchedIds: string[] = [];

for (const workspace of allWorkspaces) {
const workspacePath = getWorkspacePath(workspace);
if (!workspacePath) continue;

staticPortsWatcher.watch(workspace.id, workspacePath);
watchedIds.push(workspace.id);
}

const onChange = (changedWorkspaceId: string) => {
emit.next({ type: "change", workspaceId: changedWorkspaceId });
};

staticPortsWatcher.on("change", onChange);

return () => {
staticPortsWatcher.off("change", onChange);
for (const id of watchedIds) {
staticPortsWatcher.unwatch(id);
}
};
});
}),
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,12 @@ export function usePortsData() {
const { data: allStaticPortsData } =
electronTrpc.ports.getAllStatic.useQuery();

// Subscribe to all static port changes
electronTrpc.ports.subscribeStatic.useSubscription(
{ workspaceId: "" },
{
onData: () => {
utils.ports.getAllStatic.invalidate();
},
// Subscribe to all static port changes across all workspaces
electronTrpc.ports.subscribeAllStatic.useSubscription(undefined, {
onData: () => {
utils.ports.getAllStatic.invalidate();
},
);
});

const { data: initialPorts } = electronTrpc.ports.getAll.useQuery();

Expand Down
Loading