DPlex
Copilot instructions19 starsChanged 7 months agoMITView on GitHub
DPlex is an Electron + React terminal multiplexer that manages AI CLI tool sessions (Copilot CLI, Claude Code, etc.). It uses electron-vite with three process targets: AI tools are abstracted behind SessionProvider interface (src/main/services/providers/types.ts). To add a new AI CLI tool: No other files need changes. The provider handles: session discovery, active session detection, close/delete, resume command generation, and session resolution by PID/CWD. ProviderRegistry aggregates operations across all providers. IPC handlers in main/index.ts delegate to the registry. Zustand stores (no…
- Commits and pushes
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
17 rules. About 0 are common, 7 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 30
Create a class implementing SessionProvider in src/main/services/providers/
- Distinctive: line 33
No other files need changes.
- Very specific: line 54
When a command is provided (AI session), the PTY runs as a login shell with exec replacement: [shell] -l -c "exec <command>".
- Very specific: line 66
Session active detection: Check for inuse.<PID>.lock files, then verify PID is alive via process.kill(pid, 0).
- Distinctive: line 67
Do not commit or push to git without explicit user approval: Always wait for the user to confirm before running git commit or git push.
- Very specific: line 68
Status colors: Use CSS custom properties (var(--dplex-status-*)) defined in settingsStore.ts via applyCssVarsSync().
- Very specific: line 69
Hover backgrounds: Always use hover:bg-[var(--dplex-hover)] — never hover:bg-white/5 or hover:bg-white/10 which are invisible on light …
- Very specific: line 70
Testing policy: After each change, run relevant automated tests before finishing work.
- Distinctive: line 71
Regression prevention: Every new behavior must include or update relevant tests so regressions are caught in CI.
- Distinctive: line 75
After every major change (project refactors, new features, architectural changes — not minor styling tweaks or few-line fixes), …
- Distinctive: line 93
Wait for both reviews to complete, then fix all genuine issues before committing.
- Very specific: line 98
Before every push to main (or any release branch), bump the version in package.json according to Semantic Versioning and add a matching …
- Very specific: line 120
Update package.json's version field.
- Distinctive: line 124
Add the comparison link at the bottom of the file.
- Very specific: line 128
After pushing a release-worthy version (anything that should ship to end users), suggest tagging the commit vX.Y.Z so the release workflow …
- Distinctive: line 155
Performance entries: must just name the area that got faster (e.g.
- Very specific: line 158
Don't over-organize: If a release has only a handful of bullets, don't pad it.
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
DPlex — Copilot Instructions
Build & Run
npm run dev # Start Electron app in dev mode (hot reload)
npm run build # Typecheck + build (runs typecheck:node && typecheck:web first)
npm run lint # ESLint across entire project
npm run typecheck # TypeScript check only (no build)
npm run test:unit # Run unit tests (Vitest)
npm run test:e2e # Run Electron end-to-end tests (Playwright)
npm run test:monkey # Run randomized monkey tests (Playwright)
npm run test:all # Run all testsArchitecture
DPlex is an Electron + React terminal multiplexer that manages AI CLI tool sessions (Copilot CLI, Claude Code, etc.). It uses electron-vite with three process targets:
Process Boundaries
- Main process (
src/main/) — Node.js. PTY management vianode-pty, session discovery from filesystem, settings persistence. All file system and process operations live here. - Preload (
src/preload/index.ts) — IPC bridge. DefinesDplexAPIinterface exposed aswindow.dplex. This is the sole contract between main and renderer — every new IPC channel must be added to both the type definition and the implementation in this file. - Renderer (
src/renderer/) — React + Tailwind CSS v4. No direct Node.js or filesystem access; everything goes throughwindow.dplex.*IPC calls.
Provider System (AI Tool Abstraction)
AI tools are abstracted behind SessionProvider interface (src/main/services/providers/types.ts). To add a new AI CLI tool:
- Create a class implementing
SessionProviderinsrc/main/services/providers/ - Register it in
createDefaultRegistry()inproviders/index.ts
No other files need changes. The provider handles: session discovery, active session detection, close/delete, resume command generation, and session resolution by PID/CWD.
ProviderRegistry aggregates operations across all providers. IPC handlers in main/index.ts delegate to the registry.
State Management
Zustand stores (no Redux). Four stores, each owning a specific domain:
- terminalStore — Terminal tabs, editor groups, split layout tree. Auto-persists AI session tabs to disk via debounced save. The layout is a recursive
LayoutNodetree (group | split). - projectStore — Project list, drag-and-drop ordering, active session tracking (event-driven via provider watchers; no polling).
- sessionStore — Session history list (discovered from providers), search/filter.
- settingsStore — App settings with immediate persistence.
Terminal Lifecycle
Terminals are not destroyed when switching tabs. The terminalRegistry.ts service maintains a global Map<string, TerminalEntry> outside React's lifecycle. xterm.js DOM elements are attached/detached from containers as tabs activate — this preserves scrollback and running processes.
The useTerminal hook handles: PTY creation, IPC wiring (data/exit events), resize observation, and session ID resolution (with retry logic for slow-starting AI tools).
PTY Creation
When a command is provided (AI session), the PTY runs as a login shell with exec replacement: [shell] -l -c "exec <command>". This ensures PATH is configured but the shell process is replaced — there is no shell to fall back to when the AI tool exits.
Workspace Persistence
AI session tabs are serialized to sessions.json in the Electron userData directory. On quit, saveWorkspaceSync (synchronous IPC) ensures reliable save. On restore, session tabs are recreated with their original command and CWD, and session IDs are re-resolved by PID after PTY creation.
Conventions
- CSS: Tailwind utility classes with CSS custom properties for theming (
var(--dplex-text),var(--dplex-bg), etc.). Theme definitions live inservices/themes.ts. - IPC pattern: Main defines handlers via
ipcMain.handle/ipcMain.on. Preload wraps them in typed functions. Renderer callswindow.dplex.*. Always update all three when adding new IPC channels. - Icons:
lucide-reactexclusively. - No
asyncin Zustand actions that callers expect to be synchronous — use.then()internally if you need async IPC, otherwise click handlers and Zustand subscriptions may silently swallow errors. - Session active detection: Check for
inuse.<PID>.lockfiles, then verify PID is alive viaprocess.kill(pid, 0). This is provider-specific logic inside each provider class. - Do not commit or push to git without explicit user approval. Always wait for the user to confirm before running
git commitorgit push. - Status colors: Use CSS custom properties (
var(--dplex-status-*)) defined insettingsStore.tsviaapplyCssVarsSync(). Never hardcode status colors — they adapt for light/dark theme contrast. UseSTATUS_ACTIVE_COLORandSTATUS_ACTIVE_BGfromutils/statusColors.tsfor active badges. - Hover backgrounds: Always use
hover:bg-[var(--dplex-hover)]— neverhover:bg-white/5orhover:bg-white/10which are invisible on light themes. - Testing policy: After each change, run relevant automated tests before finishing work. At minimum run
npm run test:unitfor logic changes and the affected Playwright suite (npm run test:e2e/npm run test:monkey) for UI or integration changes. - Regression prevention: Every new behavior must include or update relevant tests so regressions are caught in CI.
Code Review Policy
After every major change (project refactors, new features, architectural changes — not minor styling tweaks or few-line fixes), automatically run a deep dual-model code review before committing. The same procedure applies whenever the user explicitly asks to "run a code review" (or similar wording).
- Launch two parallel code-review agents using the
tasktool withagent_type: "code-review":- One with
model: "claude-opus-4.7" - One with
model: "gpt-5.5"
- One with
- Both reviews must cover all of the following:
- Dead code — unused imports, variables, functions, classes, types, exports, IPC handlers, and anything else that is no longer referenced
- Duplicate code — near-identical logic across files that should be extracted into a shared helper/module for reuse
- Memory leaks — event listener cleanup, subscription management, timer/interval cleanup, React effect cleanup, PTY/watcher disposal
- Security — XSS vectors, unsafe eval, prototype pollution, path traversal, shell injection, exposure of secrets
- Race conditions — async conflicts, stale closures, missing cancellation
- Performance — unnecessary re-renders, missing memoization, O(n²) loops, redundant polling mechanisms, irrelevant or duplicated file watching, non-optimized queries/IPC round-trips
- Best practices — verify established patterns and idioms are followed; call out anti-patterns
- Cross-platform support — no implementation that only works on one OS. The project must support macOS, Windows, and Linux. Flag hardcoded path separators, shell invocations, signals, env vars, or APIs that don't work on all three.
- Correctness — logic errors, edge cases, null/undefined handling, type safety
- Clean, reusable, maintainable code — consistent patterns, clear naming, appropriate abstractions, DRY
- File size & separation of concerns — no oversized files mixing multiple unrelated areas. Each file should own a single, well-defined area. Split files that handle multiple concerns into isolated, area-specific files/classes.
- Design patterns — proper separation of concerns, DRY, extensibility
- Wait for both reviews to complete, then fix all genuine issues before committing.
- Report a summary of findings and fixes to the user.
Versioning and Changelog Policy
Before every push to main (or any release branch), bump the version in
package.json according to Semantic Versioning and
add a matching entry to CHANGELOG.md. Skip the bump only when the user
explicitly says so (e.g. "don't bump the version", "infra-only commit",
"WIP push"); otherwise treat it as part of every push.
Bump rules:
- PATCH (
0.1.0 → 0.1.1) — bug fixes, internal refactors, doc-only or CI-only changes, dependency bumps without behavior changes, performance improvements with no API change. - MINOR (
0.1.0 → 0.2.0) — new user-visible features, new providers, new IPC channels, new settings, new keyboard shortcuts. Anything a user would notice or write a release note about. - MAJOR (
0.x → 1.0, then1.x → 2.0) — breaking changes to user data formats, IPC contracts, settings shape, or provider interfaces. Pre-1.0 (0.x.y), per semver, breaking changes can land in MINOR bumps — but call them out explicitly in the changelog.
Workflow before pushing:
- Determine the appropriate bump from the staged changes.
- Update
package.json'sversionfield. - Update
CHANGELOG.md:- Move the relevant entries from
[Unreleased]into a new dated section (## [x.y.z] — YYYY-MM-DD). - Add the comparison link at the bottom of the file.
- Re-create an empty
[Unreleased]section above it.
- Move the relevant entries from
- Include the version bump in the same commit as the changes (don't make a separate "bump version" commit unless the user requests one).
- After pushing a release-worthy version (anything that should ship to
end users), suggest tagging the commit
vX.Y.Zso the release workflow publishes signed binaries to GitHub Releases.
The changelog is maintained by the agent as part of the same commit — the user should not have to remember to update it.
Changelog content rules (customer-facing)
The changelog is read by end users, not contributors. Write every entry from the user's point of view: what they will notice, not what was changed in the code.
- Use these sections only, in this order, omitting any that have
no entries for the release:
### Features— new user-visible capabilities### Improvements— refinements to existing behavior or UI### Bug Fixes— things that were broken and now work### Performance— single-line mentions of areas that got faster or smoother (no implementation detail)
- Do not include sections like
Internal,Refactor,Refinements,Review-driven,Chores, orSecurityunless they describe something the user actually experiences. - Each entry is one short bullet (ideally one line, max two). Lead with the user benefit; cut implementation details, file names, store/IPC names, CSS variable names, line counts, and code-review attribution. No "we replaced X with Y" — the user doesn't care.
- Performance entries must just name the area that got faster (e.g. "Faster Git changes panel updates", "Smoother sidebar resizing"). No timings, watcher names, or debounce values.
- Don't over-organize. If a release has only a handful of bullets,
don't pad it. A 3-line
### Bug Fixesis fine. - No internal jargon. Replace store / hook / IPC channel names with the user-facing surface (e.g. "Sessions sidebar", "Git panel", "project context menu", "command palette").
- The same rules apply to entries staged under
[Unreleased].
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

