main: boot the daemon at the last project, not HOME (T-352)
Confirmed root cause of the sidebar failure: a desktop launch starts in HOME, which isn't a git repo, so resolveWorkspaceRoot returns HOME and the daemon's pql/git/files all target HOME. pql then finds a stale ~/.pql/pql.db (left from earlier HOME-workdir runs) and errors "pql.db is from an earlier schema" — exactly what the sidebars showed. A manual refresh worked only because by then the workspace had swapped to the repo. (Verified directly: `cd $HOME && pql ticket list` reproduces the schema error against ~/.pql/pql.db.) Settings confirmed the user is in the picker path (no startupSticky on any recent), so nothing auto-opens the repo at boot and the daemon sits on HOME until the project is opened. Fix: resolve the startup workspace before boot — prefer the launch CWD when it's a git repo, else fall back to app.lastProject (the repo). The daemon now points at the real workspace from its first request, so the sidebars load immediately without depending on swap/refetch timing. The ProjectOpened refetch and swap serialization from 2.3.x stay in place for genuine mid-session project switches. Pure resolveStartupWorkspace() helper is unit-tested; app boot green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+17
-1
@@ -83,6 +83,22 @@ Future<void> main() async {
|
||||
final appDir = await _resolveAppDir();
|
||||
final themes = await _loadBundledThemes();
|
||||
|
||||
// Resolve the workspace to boot the daemon at. A desktop launch starts in
|
||||
// HOME (not a git repo), so atCwd would point pql/git/files at HOME — where
|
||||
// pql hits a stale ~/.pql/pql.db and the sidebars error on first load. Boot
|
||||
// at the last project instead so the daemon targets the real repo from the
|
||||
// first request. (T-352)
|
||||
Directory startupWorkRoot = resolveWorkspaceRoot(Directory.current);
|
||||
if (!kIsWeb) {
|
||||
final bootSettings = SettingsStore(appDir: appDir);
|
||||
await bootSettings.load();
|
||||
startupWorkRoot = resolveStartupWorkspace(
|
||||
cwdRoot: startupWorkRoot,
|
||||
lastProject: bootSettings.get<String>('app.lastProject'),
|
||||
isGitRepo: (d) => Directory('${d.path}/.git').existsSync(),
|
||||
);
|
||||
}
|
||||
|
||||
// Resolve toolchain + boot daemon inline — same as Linux.
|
||||
// With proper signing (Developer ID), no sandbox or isolate needed.
|
||||
final toolchain = Toolchain();
|
||||
@@ -297,7 +313,7 @@ Future<void> main() async {
|
||||
daemonBus = events;
|
||||
kernelArrangement = arrangement;
|
||||
kernelPanels = panels;
|
||||
final workRoot = FilesService.atCwd(events: _BusEventSink(events)).root;
|
||||
final workRoot = startupWorkRoot;
|
||||
final dispatcher = buildDispatcher(events, toolchain, workRoot, arrangement, panels);
|
||||
// Build the client at the workspace's socket path. The
|
||||
// server is started below (swapIpcServer) which the
|
||||
|
||||
Reference in New Issue
Block a user