Repository navigation
Move the open-project and pages-session logic out of the IPC files (#114) - #122
Merged
Merged
Conversation
) Which project is open, the trail, and the two queues that order sends and writes lived inside projects-ipc.ts and pages-ipc.ts, welded to ipcMain, so none of it could run without Electron and none of it had a test. open-project.ts now holds which project is open: the fallback to the most recently opened one, requireProject, and the callback when the open project changes, including when it is removed. It takes only the five registry calls it uses. pages-session.ts holds the trail, the publish queue and the write queue, and is handed the clock and a broadcast instead of reaching for BrowserWindow. Neither imports electron. The IPC files are now only their channels: arguments are checked as they arrive and handed on. What only Electron can do stays there: the directory picker, shell, the block menu, the image scheme, and sending to windows. index.ts builds both and passes them in. Arguments are now checked before a write joins the queue rather than in its turn, so a malformed write is refused at once instead of after the writes ahead of it. The renderer sees the same rejection. The new tests cover the fallback, opening and removing, the reachability check, that requireProject settles which project when called, that writes are recorded in arrival order so one may name the block before it, that a refused write does not hold up the next, that a write lands on the project open when it was sent, and that each write's state is sent before its reply. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes #114.
What changed
Which project is open (
app/src/main/features/projects/open-project/open-project.ts):openId, the fallback to the most recently opened project,requireProjectand the "open project changed" callback move here fromprojects-ipc.ts, along withopen(id)andremove(id). It takes aRegistryof only the five store calls it uses, and imports nothing fromelectron.The pages session (
app/src/main/features/projects/pages/pages-session/pages-session.ts): the trail, thepublishqueue, the write queue (writesbefore, nowwrite) and theOpentype move here frompages-ipc.ts. It is handed the clock and abroadcast(state)instead of looping overBrowserWindow.getAllWindows()itself, and imports nothing fromelectron.The IPC files are now only their channels.
registerProjectIpc(store, openProject)andregisterPageIpc(session)check arguments as they arrive and hand them on. What only Electron can do stays there: the directory picker,shell, the block menu, the image scheme, andbroadcastPages, which sends to every window.index.tsbuildscreateOpenProject(store, () => pages.resetTrail())andcreatePagesSession(open, now, broadcastPages)and passes them to the tworegister…Ipccalls. The wiring is otherwise unchanged.app/CLAUDE.mdpoints at the new files, and says that an IPC file is only its channels.For the reviewer
requireis still called as the write arrives, so where a write lands is settled the same way as before.publishcalls that overlap broadcast in the order they were asked". Each publish reads the trail and the state after its ownawait, so two that overlap send the same state, and no test can tell the order apart. The publish queue is unchanged. The write-order tests cover what it protects.pages.show()reply reaches the renderer a few milliseconds before itspages:changedstate, against the guarantee inPagesApi. It reproduces on the code frommaintoo. That is being looked into separately.mainafter Write an AGENTS.md at the top of a ledger (#63) #121 (ledger: write an AGENTS.md at the root of a new ledger #63). It merged cleanly, includingapp/CLAUDE.md.Tests
open-project.test.ts(9 tests, stub registry):requireProjectsettles which project at the moment it is calledpages-session.test.ts(7 tests, in-memory view over the realpagesFold, with a gate to hold writes in flight):requirein the write's turn instead of on arrival fails one test, and removing the write queue fails two.--user-data-dirand scratch project folders), everypages:*andprojects:*channel was called throughwindow.pbnotes:pbnotes-image://npm test(155 tests across all workspaces),npm run typecheckandnpm run lintpass.🤖 Generated with Claude Code