Skip to content

chore: sync upstream (db schema reconciliation) - #93

Merged
devsuitup merged 5 commits into
mainfrom
chore/sync-upstream-20260804
Aug 4, 2026
Merged

chore: sync upstream (db schema reconciliation)#93
devsuitup merged 5 commits into
mainfrom
chore/sync-upstream-20260804

Conversation

@devsuitup

Copy link
Copy Markdown
Owner

Merges upstream doctly/switchboard c3c5ee9 (fix(db): ensure required columns by schema inspection, not db_version — author: abassiri).

Fork adaptations:

  • kept our index-addressed migrations v4-v7 (upstream's no-op v4 replacement is inapplicable, our v4-v6 already shipped)
  • extended the reconciliation pass to fork schema: subagent columns + session_metrics table (the upstream regression test's foreign-v5 DB crashed our prepare() on session_metrics without this)
  • adapted the regression test version assertion: 7 fork migrations mean a v5 DB legitimately upgrades to 7; the preserved invariant is never-downgraded

Note: this branch is based on main + PR #92; merge #92 first.

Tests: 401/401 locally on Windows.

abasiri and others added 5 commits August 1, 2026 17:07
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
@devsuitup
devsuitup merged commit fcf9206 into main Aug 4, 2026
7 checks passed
@devsuitup
devsuitup deleted the chore/sync-upstream-20260804 branch August 4, 2026 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants