fix(electrobun): 7 bug fixes + 3 partial features completed
Bugs fixed: - Agent retry: clear dead session on failed start (was non-recoverable) - seqId persist: save seq_id column in agent_messages, migrate existing DBs - Window frame save: wire resize event listener to saveWindowFrame() - Diagnostics counters: real RPC call counter via withRpcCounting() proxy Partial features completed: - Search auto-seed: rebuildIndex() on startup + indexMessage() on save - Notifications: removed 3 hardcoded demo entries, start empty - Agent cost streaming: emitCostIfChanged() on every message batch New: src/bun/rpc-stats.ts (RPC call + dropped event counters)
This commit is contained in:
parent
0dd402e282
commit
66dce7ebae
8 changed files with 139 additions and 47 deletions
|
|
@ -29,6 +29,7 @@ import { createRemoteHandlers } from "./handlers/remote-handlers.ts";
|
|||
import { createGitHandlers } from "./handlers/git-handlers.ts";
|
||||
import { createProviderHandlers } from "./handlers/provider-handlers.ts";
|
||||
import { createMiscHandlers } from "./handlers/misc-handlers.ts";
|
||||
import { incrementRpcCallCount, incrementDroppedEvents } from "./rpc-stats.ts";
|
||||
|
||||
/** Current app version — sourced from electrobun.config.ts at build time. */
|
||||
const APP_VERSION = "0.0.1";
|
||||
|
|
@ -74,7 +75,7 @@ const rpcRef: { send: Record<string, (...args: unknown[]) => void> } = { send: {
|
|||
const ptyHandlers = createPtyHandlers(ptyClient);
|
||||
const filesHandlers = createFilesHandlers();
|
||||
const settingsHandlers = createSettingsHandlers(settingsDb);
|
||||
const agentHandlers = createAgentHandlers(sidecarManager, sessionDb, rpcRef);
|
||||
const agentHandlers = createAgentHandlers(sidecarManager, sessionDb, rpcRef, searchDb);
|
||||
const btmsgHandlers = createBtmsgHandlers(btmsgDb, rpcRef);
|
||||
const bttaskHandlers = createBttaskHandlers(bttaskDb, rpcRef);
|
||||
const searchHandlers = createSearchHandlers(searchDb);
|
||||
|
|
@ -89,24 +90,42 @@ const miscHandlers = createMiscHandlers({
|
|||
// Window ref — handlers use closure; set after mainWindow creation
|
||||
let mainWindow: BrowserWindow;
|
||||
|
||||
// ── RPC counter wrapper ─────────────────────────────────────────────────────
|
||||
|
||||
/** Wrap each handler to increment the RPC call counter on every invocation. */
|
||||
function withRpcCounting<T extends Record<string, (...args: unknown[]) => unknown>>(handlers: T): T {
|
||||
const wrapped: Record<string, (...args: unknown[]) => unknown> = {};
|
||||
for (const [key, fn] of Object.entries(handlers)) {
|
||||
wrapped[key] = (...args: unknown[]) => {
|
||||
incrementRpcCallCount();
|
||||
return fn(...args);
|
||||
};
|
||||
}
|
||||
return wrapped as T;
|
||||
}
|
||||
|
||||
// ── RPC definition ─────────────────────────────────────────────────────────
|
||||
|
||||
const allHandlers = withRpcCounting({
|
||||
...ptyHandlers,
|
||||
...filesHandlers,
|
||||
...settingsHandlers,
|
||||
...agentHandlers,
|
||||
...btmsgHandlers,
|
||||
...bttaskHandlers,
|
||||
...searchHandlers,
|
||||
...pluginHandlers,
|
||||
...remoteHandlers,
|
||||
...gitHandlers,
|
||||
...providerHandlers,
|
||||
...miscHandlers,
|
||||
});
|
||||
|
||||
const rpc = BrowserView.defineRPC<PtyRPCSchema>({
|
||||
maxRequestTime: 120_000,
|
||||
handlers: {
|
||||
requests: {
|
||||
...ptyHandlers,
|
||||
...filesHandlers,
|
||||
...settingsHandlers,
|
||||
...agentHandlers,
|
||||
...btmsgHandlers,
|
||||
...bttaskHandlers,
|
||||
...searchHandlers,
|
||||
...pluginHandlers,
|
||||
...remoteHandlers,
|
||||
...gitHandlers,
|
||||
...providerHandlers,
|
||||
...miscHandlers,
|
||||
...allHandlers,
|
||||
|
||||
// GTK native drag/resize — delegates to window manager (zero CPU)
|
||||
"window.beginResize": ({ edge }: { edge: string }) => {
|
||||
|
|
@ -202,13 +221,6 @@ relayClient.onStatus((machineId, status, error) => {
|
|||
// ── App window ────────────────────────────────────────────────────────────
|
||||
|
||||
async function getMainViewUrl(): Promise<string> {
|
||||
// TEMPORARY: load resize test stub via Vite dev server (keeps RPC bridge)
|
||||
const RESIZE_TEST = false; // DISABLED — real app mode
|
||||
if (RESIZE_TEST) {
|
||||
const testUrl = DEV_SERVER_URL + "/resize-test.html";
|
||||
console.log(`[RESIZE_TEST] Loading stub via Vite: ${testUrl}`);
|
||||
return testUrl;
|
||||
}
|
||||
const channel = await Updater.localInfo.channel();
|
||||
if (channel === "dev") {
|
||||
try {
|
||||
|
|
@ -224,6 +236,14 @@ async function getMainViewUrl(): Promise<string> {
|
|||
|
||||
connectToDaemon();
|
||||
|
||||
// Partial 1: Seed FTS5 search index on startup
|
||||
try {
|
||||
searchDb.rebuildIndex();
|
||||
console.log("[search] FTS5 index seeded on startup");
|
||||
} catch (err) {
|
||||
console.error("[search] Failed to seed FTS5 index:", err);
|
||||
}
|
||||
|
||||
const url = await getMainViewUrl();
|
||||
|
||||
const savedX = Number(settingsDb.getSetting("win_x") ?? 100);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue