chore: sync upstream (db schema reconciliation) - #93
Merged
Conversation
A DB already migrated to a higher db_version by a parallel branch's build skips this branch's version-numbered migrations, so the v4 fileMtime ALTER never ran and every prepare() referencing it crashed the app at startup. Replace the v4 migration with a reconciliation pass that inspects PRAGMA table_info and adds missing columns regardless of version, clearing the session cache when fileMtime is introduced so stale mtime-based times get re-indexed. Errors are not swallowed so transient failures retry on next launch. Adds a regression test seeding a foreign db_version-5 database and asserting startup reconciles it instead of crashing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Lines were skipping: the cursor landed one row lower than expected after a TUI redraw. Root cause is a width disagreement — the shell wraps its output for the width it believes in, xterm re-wraps against another, and the TUI's next cursor move is off by the wrapped line. Three sources of that disagreement, closed here: 1. The PTY was spawned at a hard-coded 120x30 and only learned the real geometry from the first terminal-resize IPC, so every session started desynchronised. The renderer now measures its container before asking for the spawn and passes the result through open-terminal; pty-size.js normalises it and falls back to 120x30 when the measure failed. Measuring needs the container laid out, which it is not (display:none until showSession), hence the transient .measuring class: display:block + visibility:hidden, real layout, no paint, removed before createTerminalEntry returns. 2. Refits only ran on window resize, tab switch and session focus. A geometry change from wake-from-sleep, a DPI change or a move to another monitor produced none of those and left the mismatch standing. Added a per-container ResizeObserver (debounced 80 ms, disconnected in destroySession) plus visibilitychange and window focus as a free event-driven net. 3. Every refit re-sent a resize even when nothing had changed. The last size handed to the PTY is now remembered per session and only a real delta produces IPC — which is what makes the new hooks free. No polling timer anywhere: proposeDimensions() reads the DOM, and running that on an interval for every open terminal would cost real CPU at idle. When the geometry does not move, this change adds one DOM measurement per session creation and nothing else. The one deliberate unconditional resize is syncPtySizeAfterOpen: the main process arms its reattach nudge on the first terminal-resize it sees, and with the spawn size already correct no organic resize may ever arrive. Tests: pty-size.test.js (normalisation, out-of-range fallbacks) and terminal-resize-sync.test.js (pre-spawn measurement, dedup, observer wiring and teardown). The jsdom harness is extracted from terminal-manager-lifecycle.test.js and shared.
resolveWorktreePath only matched forward slashes, so on Windows a worktree cwd was never collapsed back to its parent repo. The regex now accepts both separators. Test-side fixes for Windows runs: - ipc-path-validator: resolve the fake project roots so they carry the drive letter, matching what the validator compares against. - trigger-watcher: realpath the mkdtemp sandbox — os.tmpdir() can return an 8.3 short name and fs.watch on it trips a libuv assertion that kills the test process.
Upstream c3c5ee9 stops trusting db_version for required columns and reconciles the schema by PRAGMA table_info inspection. Fork adaptation: - keep our index-addressed migrations v4-v7 (upstream replaced its own v4 with a no-op; inapplicable here since our v4-v6 already shipped) - extend the reconciliation block to the fork schema: subagent columns and the session_metrics table, which a foreign-version DB skips the same way (witnessed: the upstream regression test seeded a v5 DB and our prepare() on session_metrics crashed) - adapt the regression test: with 7 fork migrations a v5 DB legitimately upgrades to 7; the invariant kept is never-downgraded
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merges upstream doctly/switchboard c3c5ee9 (fix(db): ensure required columns by schema inspection, not db_version — author: abassiri).
Fork adaptations:
Note: this branch is based on main + PR #92; merge #92 first.
Tests: 401/401 locally on Windows.