claude-code-session-manager 0.142.0 → 0.144.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/README.md +22 -107
  3. package/dist/assets/AppSettings-Z68gQiVE.js +2 -0
  4. package/dist/assets/{History-DpZuJXi1.js → History-C3E6y_7t.js} +2 -2
  5. package/dist/assets/HomeClaudeConfig-Yd1vXzBn.js +5 -0
  6. package/dist/assets/{Panel-BjdJjhqt.js → Panel-CnfWs46Z.js} +1 -1
  7. package/dist/assets/ProjectClaudeConfig-CP0Wsg-H.js +26 -0
  8. package/dist/assets/Scheduler-D8un7N3B.js +16 -0
  9. package/dist/assets/{SkillReferenceGraph-Cqyu4mef.js → SkillReferenceGraph-DRtZV1Al.js} +1 -1
  10. package/dist/assets/{Skills-vv0noNVI.js → Skills-Bg5O2Hyn.js} +23 -23
  11. package/dist/assets/{TiptapBody-CXi8Pvut.js → TiptapBody-BdzoBmqu.js} +27 -27
  12. package/dist/assets/{Toggle-CiYCWLjh.js → Toggle-Dt5K1OXt.js} +1 -1
  13. package/dist/assets/{VoiceButton-4NKKd1sC.js → VoiceButton-CTLyRgdF.js} +1 -1
  14. package/dist/assets/{historyTotals-DDunb8Ch.js → historyTotals-B2_KWBga.js} +1 -1
  15. package/dist/assets/{index-Cn5E9958.js → index-446b69rr.js} +715 -714
  16. package/dist/assets/{index-DVHIHoJf.css → index-BJ5TJvmz.css} +1 -1
  17. package/dist/index.html +2 -2
  18. package/dist-web/app.css +1 -1
  19. package/dist-web/app.js +438 -435
  20. package/package.json +6 -4
  21. package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
  22. package/plugins/session-manager-dev/skills/builder/SKILL.md +5 -0
  23. package/plugins/session-manager-dev/skills/develop/SKILL.md +23 -16
  24. package/plugins/session-manager-dev/skills/maintaining-md-network/SKILL.md +16 -2
  25. package/plugins/session-manager-dev/skills/maintaining-md-network/weekly-consolidation.md +87 -0
  26. package/scripts/README.md +1 -0
  27. package/scripts/scheduler-mcp-server.cjs +381 -6
  28. package/src/main/adminRouteRegistry.cjs +16 -0
  29. package/src/main/agentLibrary.cjs +60 -11
  30. package/src/main/agentsIpc.cjs +19 -0
  31. package/src/main/build-info.json +4 -4
  32. package/src/main/chatRunner.cjs +214 -7
  33. package/src/main/config.cjs +5 -1
  34. package/src/main/health.cjs +92 -14
  35. package/src/main/index.cjs +16 -4
  36. package/src/main/ipcSchemas.cjs +61 -1
  37. package/src/main/lib/claude/agentArmory.cjs +128 -0
  38. package/src/main/lib/claude/agentModelResolve.cjs +3 -2
  39. package/src/main/lib/claude/agentSnapshot.cjs +24 -3
  40. package/src/main/lib/claude/builtinTools.cjs +110 -0
  41. package/src/main/lib/claude/environmentProfiles.cjs +1 -1
  42. package/src/main/lib/claude/headlessMcpServers.cjs +138 -0
  43. package/src/main/lib/claude/jobSandboxPolicy.cjs +8 -2
  44. package/src/main/lib/claude/personaToolScope.cjs +77 -6
  45. package/src/main/lib/demo-video-kit/cast.md +10 -1
  46. package/src/main/lib/demo-video-kit/character.cjs +77 -21
  47. package/src/main/lib/demo-video-kit/kind-tiktok.md +5 -1
  48. package/src/main/lib/demo-video-kit/projectSounds.cjs +191 -0
  49. package/src/main/lib/demo-video-kit/seedKit.cjs +3 -3
  50. package/src/main/lib/demo-video-kit/sound.cjs +166 -9
  51. package/src/main/lib/demo-video-kit/standalone.cjs +231 -0
  52. package/src/main/lib/epic/activeIndexMerge.cjs +5 -0
  53. package/src/main/lib/epic/artifactRetention.cjs +55 -9
  54. package/src/main/lib/epic/artifactStore.cjs +78 -35
  55. package/src/main/lib/epic/delegationReadiness.cjs +10 -3
  56. package/src/main/lib/epic/epicDepsSync.cjs +66 -0
  57. package/src/main/lib/epic/epicEventLog.cjs +45 -1
  58. package/src/main/lib/epic/epicOutsideRead.cjs +38 -1
  59. package/src/main/lib/epic/epicSettle.cjs +48 -4
  60. package/src/main/lib/epic/epicSpawnPlan.cjs +3 -1
  61. package/src/main/lib/epic/epicStateEmitter.cjs +248 -0
  62. package/src/main/lib/epic/epicValidationHook.cjs +22 -3
  63. package/src/main/lib/epic/planReviewInput.cjs +123 -0
  64. package/src/main/lib/epic/restorableSessions.cjs +1 -0
  65. package/src/main/lib/epic/scriptStartedBy.cjs +71 -0
  66. package/src/main/lib/externalContract.cjs +24 -1
  67. package/src/main/lib/feedback-remote/autoStartedSession.cjs +1 -1
  68. package/src/main/lib/feedback-remote/createdProjects.cjs +291 -0
  69. package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +24 -2
  70. package/src/main/lib/feedback-remote/crossProjectReply.cjs +96 -8
  71. package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +54 -3
  72. package/src/main/lib/feedback-remote/pendingReplies.cjs +22 -0
  73. package/src/main/lib/feedback-remote/projectCreate.cjs +415 -0
  74. package/src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs +94 -4
  75. package/src/main/lib/feedback-remote/replyClaims.cjs +168 -0
  76. package/src/main/lib/feedback-remote/serviceMcpSession.cjs +29 -1
  77. package/src/main/lib/feedback-remote/serviceMcpTools.cjs +43 -2
  78. package/src/main/lib/feedback-remote/servicePairLocalRoutes.cjs +91 -0
  79. package/src/main/lib/feedback-remote/servicePairings.cjs +47 -7
  80. package/src/main/lib/feedback-remote/serviceStdioBridge.cjs +99 -1
  81. package/src/main/lib/git/gitWorktree.cjs +8 -0
  82. package/src/main/lib/git/runtimeStateUntrack.cjs +15 -1
  83. package/src/main/lib/git/worktreeDeps.cjs +119 -10
  84. package/src/main/lib/mcpToolCatalog.cjs +144 -12
  85. package/src/main/lib/mcpToolsProbe.cjs +19 -2
  86. package/src/main/lib/opsOwnership.cjs +113 -28
  87. package/src/main/lib/packs/packCatalog.cjs +98 -5
  88. package/src/main/lib/persona-macro/agentPersonaSchema.cjs +6 -0
  89. package/src/main/lib/persona-macro/builtinMacros.cjs +6 -4
  90. package/src/main/lib/persona-macro/personaFrontmatterSchema.cjs +9 -0
  91. package/src/main/lib/persona-macro/personaLoadout.cjs +58 -0
  92. package/src/main/lib/persona-macro/personaMerge.cjs +11 -3
  93. package/src/main/lib/persona-macro/personaUpgrade.cjs +96 -0
  94. package/src/main/lib/persona-macro/projectVideoToolCheck.cjs +1 -1
  95. package/src/main/lib/persona-macro/shippedPersonaSeeds.cjs +140 -0
  96. package/src/main/lib/prd/prdCreate.cjs +395 -229
  97. package/src/main/lib/prd/prdCriteria.cjs +7 -4
  98. package/src/main/lib/prd/prdFrontmatter.cjs +5 -2
  99. package/src/main/lib/prd/prdMcpReachWarnings.cjs +44 -0
  100. package/src/main/lib/prd/prdSandboxWarnings.cjs +49 -0
  101. package/src/main/lib/process/peerChatSession.cjs +165 -0
  102. package/src/main/lib/project-pages/videoPressLines.cjs +145 -0
  103. package/src/main/lib/project-pages/videoScriptPress.cjs +266 -0
  104. package/src/main/lib/project-pages/videoScriptRunRoute.cjs +371 -0
  105. package/src/main/lib/project-pages/videoScriptSwitchIpc.cjs +49 -0
  106. package/src/main/lib/project-pages/videoScriptSwitchRoute.cjs +173 -0
  107. package/src/main/lib/promptSessionSchema.cjs +2 -0
  108. package/src/main/lib/scheduler/baselineGate.cjs +31 -2
  109. package/src/main/lib/scheduler/criteriaChecks.cjs +164 -20
  110. package/src/main/lib/scheduler/heldSchedulerTurns.cjs +238 -0
  111. package/src/main/lib/scheduler/jobMemoryStats.cjs +13 -2
  112. package/src/main/lib/scheduler/planRecordHarvest.cjs +215 -55
  113. package/src/main/lib/scheduler/planReleaseRoute.cjs +110 -0
  114. package/src/main/lib/scheduler/planReviewSchema.cjs +182 -0
  115. package/src/main/lib/scheduler/planReviewStats.cjs +63 -0
  116. package/src/main/lib/scheduler/planReviewStore.cjs +128 -0
  117. package/src/main/lib/scheduler/prdOutcomeRecord.cjs +60 -2
  118. package/src/main/lib/scheduler/queueStore.cjs +16 -0
  119. package/src/main/lib/scheduler/rcaReport.cjs +79 -15
  120. package/src/main/lib/scheduler/sandboxEnvironmentLimit.cjs +141 -0
  121. package/src/main/lib/scheduler/scheduleJobSchema.cjs +15 -0
  122. package/src/main/lib/scheduler/schedulerPaths.cjs +9 -0
  123. package/src/main/lib/scheduler/slotsRoute.cjs +101 -87
  124. package/src/main/lib/scheduler/upgradeDrain.cjs +32 -5
  125. package/src/main/lib/scheduler/usageHoldRoute.cjs +97 -0
  126. package/src/main/lib/scheduler/validatorVerdictSchema.cjs +28 -7
  127. package/src/main/lib/tasks/memoryConsolidation.cjs +123 -39
  128. package/src/main/lib/tasks/mitigationReview.cjs +21 -1
  129. package/src/main/lib/tasks/taskAdminRoutes.cjs +104 -17
  130. package/src/main/lib/tasks/taskLedger.cjs +2 -2
  131. package/src/main/lib/tasks/taskRun.cjs +3 -1
  132. package/src/main/lib/tasks/weeklyConsolidationInputs.cjs +178 -0
  133. package/src/main/lib/telemetry/auditEvents.cjs +21 -24
  134. package/src/main/lib/telemetry/auditLog.cjs +6 -2
  135. package/src/main/lib/util/atomicFs.cjs +2 -2
  136. package/src/main/projectPages.cjs +22 -14
  137. package/src/main/promptSessionEvents.cjs +16 -1
  138. package/src/main/pty.cjs +14 -2
  139. package/src/main/queueOps.cjs +1 -1
  140. package/src/main/runVerify.cjs +4 -3
  141. package/src/main/scheduler/planReviewHold.cjs +140 -0
  142. package/src/main/scheduler/prdParser.cjs +1 -0
  143. package/src/main/scheduler/reviewLadder.cjs +2 -0
  144. package/src/main/scheduler/utilizationHold.cjs +101 -6
  145. package/src/main/scheduler.cjs +1055 -107
  146. package/src/main/seedAgentPersonas.cjs +11 -6
  147. package/src/main/seedStatus.cjs +1 -1
  148. package/src/main/templates/PRD_AUTHORING.md +22 -2
  149. package/src/main/webRemote.cjs +47 -7
  150. package/src/preload/api.d.ts +118 -2
  151. package/src/preload/apiSurface.json +42 -0
  152. package/src/preload/index.cjs +11 -0
  153. package/src/seed/agents/architect.md +28 -43
  154. package/src/seed/agents/demo-video-builder.md +15 -8
  155. package/src/seed/agents/dev-lead.md +3 -1
  156. package/src/seed/agents/md-network-curator.md +27 -0
  157. package/src/seed/agents/plan-reviewer.md +47 -0
  158. package/src/seed/agents/validator.md +21 -19
  159. package/dist/assets/AppSettings-BcZgIvvY.js +0 -2
  160. package/dist/assets/HomeClaudeConfig-D32ZJtU-.js +0 -3
  161. package/dist/assets/ProjectClaudeConfig-BTClYV6i.js +0 -26
  162. package/dist/assets/Scheduler-DPobKx1Z.js +0 -16
@@ -14,7 +14,7 @@
14
14
  "name": "session-manager-dev",
15
15
  "source": "./plugins/session-manager-dev",
16
16
  "description": "Default end-to-end development skillset — pairs with the session-manager scheduler to form a develop → queue → validate → release loop.",
17
- "version": "0.4.4",
17
+ "version": "0.4.5",
18
18
  "category": "development",
19
19
  "strict": false
20
20
  }
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # claude-code-session-manager
2
2
 
3
- > A free desktop app for Claude Code. Each piece of work is a session with its own agent, mission and copy of the repo. Queued work runs on its own, within your plan's usage limits. It is checked before it counts as done. Agents drive the app through an MCP server with <!-- gen:mcp-tool-count -->50<!-- /gen:mcp-tool-count --> tools and a plugin with <!-- gen:skill-count -->4<!-- /gen:skill-count --> skills. It runs on your machine. MIT license.
3
+ > A free desktop app for Claude Code. Each piece of work is a session with its own agent, mission and copy of the repo. Queued work runs on its own, within your plan's usage limits. It is checked before it counts as done. Agents drive the app through an MCP server with <!-- gen:mcp-tool-count -->55<!-- /gen:mcp-tool-count --> tools and a plugin with <!-- gen:skill-count -->4<!-- /gen:skill-count --> skills.
4
4
 
5
5
  ## Facts
6
6
 
@@ -10,22 +10,18 @@
10
10
  | Run | `npx claude-code-session-manager@latest` |
11
11
  | Installers | Mac `.dmg` and `.zip` (`arm64`, `x64`). Windows `.exe` (`x64`, `arm64`). Linux `AppImage` (`x64`). Get them from [GitHub Releases](https://github.com/StanislavBG/claude-code-session-manager/releases/latest). |
12
12
  | Needs | The Claude Code CLI, installed and signed in with your own account. `git`. Node <!-- gen:node-floor -->22.12.0<!-- /gen:node-floor --> or newer, for `npx` only. |
13
- | npx platforms | Linux and macOS. On Windows, use the installer. |
14
13
  | MCP server | `session-manager-scheduler`. It uses stdio. The app adds it for you. It needs the app running. |
15
- | Plugin | `session-manager-dev@session-manager` |
16
14
  | Agent CLIs | Claude Code is the default. Codex, Gemini CLI, Antigravity CLI, Cursor Agent and OpenCode work in Chat and Terminal only. |
17
15
  | Where state lives | App state: `~/.claude/session-manager/`. Per project: `<repo>/session-manager-operations/`. Session copies: `${XDG_STATE_HOME:-~/.local/state}/session-manager/`. |
18
16
  | Telemetry | Anonymous and on by default. Turn it off with `SM_TELEMETRY=0`. |
19
- | License | MIT |
20
17
 
21
18
  ## Not
22
19
 
23
20
  - It is not a hosted or cloud service. Your sessions and files stay on your machine.
24
21
  - It is not made or backed by Anthropic. One person builds it as open source.
25
- - It does not replace a Claude plan. You need Claude Code, signed in with your own account.
26
- - It has no paid, pro or trial tier. The app and the Field Manual are both free.
22
+ - It does not replace a Claude plan.
23
+ - It has no paid, pro or trial tier.
27
24
  - It is not a team product. It has no support deal or uptime promise.
28
- - It is not a library. You cannot `import` it.
29
25
 
30
26
  ## Features
31
27
 
@@ -115,16 +111,14 @@ A **session** (in code: an Epic) is one unit of work. A **Mission** is the kind
115
111
  | Voice input | Turns speech into text on your machine. Nothing leaves it. | App Settings |
116
112
  | Recording light | A light shows on top of every screen while the mic is on. | Top of window |
117
113
  | Web remote | Drive the app from your phone, or let a paired service send work, through the bilko.run relay. | App Settings |
118
- | Simple mode | `--simple` opens one plain terminal. | Launch flag |
119
- | Command palette | `Cmd-K` or `Ctrl-K` opens a list of commands. | Anywhere |
120
114
 
121
115
  ## Headless surface (for agents)
122
116
 
123
117
  ### MCP server
124
118
 
125
- The MCP server is `session-manager-scheduler`. It lets an agent queue PRDs, read the queue, write Project Home pages and more.
119
+ The MCP server lets an agent queue PRDs, read the queue, write Project Home pages and more.
126
120
 
127
- The app adds it at user scope in `~/.claude.json` on first launch. To add it by hand, run:
121
+ The app adds it at user scope on first launch. To add it by hand, run:
128
122
 
129
123
  ```bash
130
124
  claude mcp add session-manager-scheduler --scope user -- node <app>/scripts/scheduler-mcp-server.cjs
@@ -149,64 +143,10 @@ Recipes:
149
143
  - `hand-finding-to-another-project` — Hand a finding to another project
150
144
  - `reply-to-the-project-that-asked` — Reply to the project that asked
151
145
  - `add-project-video-tool` — Add a project video tool
146
+ - `script-press-demo-video` — Let a project's own script press Demo Video and read the outcome
152
147
  <!-- /gen:mcp-recipes -->
153
148
 
154
- Tools:
155
-
156
- <!-- gen:mcp-tools -->
157
- | Tool | Group | Required args | What it does |
158
- | --- | --- | --- | --- |
159
- | `scheduler_reset_job` | scheduler | `slug` | Reset a stuck job so the scheduler runs it again. |
160
- | `scheduler_pause` | scheduler | — | Pause new job starts for every project on this machine. |
161
- | `scheduler_resume` | scheduler | — | Lift a scheduler pause so jobs start again. |
162
- | `scheduler_list_jobs` | scheduler | — | List queued, running and finished jobs on this machine. |
163
- | `scheduler_create_prd` | scheduler | `title`, `goal`, `acceptanceCriteria`, `implementationNotes`, `gate`, `files` | Queue one PRD (a written work order) in an Epic a human approved. |
164
- | `scheduler_create_prds` | scheduler | `prds` | Queue a whole plan of PRDs in one all-or-nothing call. |
165
- | `scheduler_list_prds` | scheduler | — | List PRDs and their job status, by project, Epic or status. |
166
- | `scheduler_get_prd` | scheduler | `slug` | Read one PRD in full, with its frontmatter. |
167
- | `scheduler_update_prd` | scheduler | `slug` | Edit a PRD that has not run yet or has stopped. |
168
- | `scheduler_archive_prd` | scheduler | `slugs` | Archive PRDs that are done or no longer needed. |
169
- | `scheduler_cancel_job` | scheduler | `slug` | Cancel a job that has not finished. |
170
- | `scheduler_retag_prd` | scheduler | `items` | Change a PRD's group number or time estimate. |
171
- | `chat_send_prompt` | chat | `tabId`, `prompt` | Send a prompt to a session tab that is already open. |
172
- | `feedback_list_projects` | feedback | — | List the other projects on this machine that can take feedback. |
173
- | `feedback_open_session` | feedback | `toCwd`, `fromCwd`, `title`, `motivation`, `acceptanceCriteria`, `body` | Hand a finding to another project as a proposed session there. |
174
- | `feedback_reply` | feedback | `message`, `outcome` | Answer the project that sent this session its feedback. |
175
- | `project_home_write` | project-home | `html` | Write the Overview page of Project Home (same as project_page_write). |
176
- | `project_page_write` | project-home | `pageId`, `title`, one of `html` / `htmlPath` | Write one HTML knowledge page for Project Home. |
177
- | `project_matrix_read` | project-home | — | Read the saved competitor feature matrix and its schema. |
178
- | `project_matrix_write` | project-home | one of `matrix` / `matrixPath` | Save the competitor feature matrix as one JSON object. |
179
- | `project_video_write` | project-home | `videoId`, `title`, `kind`, `lengthS`, `meta`, one of `html` / `htmlPath` | Save one self-contained HTML video for Project Home. |
180
- | `project_demo_video_write` | project-home | one of `html` / `htmlPath` | Save a 30-second or 1-minute demo video (same as project_video_write). |
181
- | `project_character_write` | project-home | `json`, one of `js` / `jsPath` | Save the reusable character used in this project's videos. |
182
- | `project_video_review_write` | project-home | `videoId`, `text`, `imagePaths` | Save a script and images for a human to review a video. |
183
- | `project_video_outcome_write` | project-home | `videoId`, `outcome`, `text` | Record that a video run ended with no video on purpose. |
184
- | `voice_list` | project-home | — | List the voices this project can use for speech. |
185
- | `voice_preview` | project-home | `voiceId`, `text` | Hear one voice say a short line and get the clip path. |
186
- | `customer_feedback_list` | customer-feedback | — | List feedback that users sent to the owner's inbox. |
187
- | `customer_feedback_set_status` | customer-feedback | `id`, `status` | Set the status of one feedback item, with an optional note. |
188
- | `customer_feedback_get` | customer-feedback | `id`, `source` | Read one website feedback report in full, with its image paths. |
189
- | `customer_feedback_submit` | customer-feedback | `goal`, `description`, `tag` | Send feedback about Session Manager to its maintainers. |
190
- | `feedback_widget_create` | feedback-widget | `label`, `allowedOrigins` | Make a feedback widget for a website and get its snippet. |
191
- | `feedback_widget_list` | feedback-widget | — | List this project's website feedback widgets. |
192
- | `feedback_widget_update` | feedback-widget | `boxId` | Change a feedback widget label, sites, or pause it. |
193
- | `feedback_widget_delete` | feedback-widget | `boxId` | Delete a website feedback widget for good. |
194
- | `feedback_widget_snippet` | feedback-widget | `boxId` | Get the one-line snippet for a feedback widget. |
195
- | `macro_list` | macros | — | List this project's saved one-click macros. |
196
- | `macro_save` | macros | `label`, `agentName`, `tag`, `prompt` | Create or change a saved one-click macro (agent, mission, prompt). |
197
- | `macro_delete` | macros | `id` | Delete one saved macro. |
198
- | `epic_list` | epics | `cwd` | List the open sessions of one project and what state each is in. |
199
- | `epic_get` | epics | `cwd`, one of `id` / `externalRef` | Read one session by its id or by the outside reference it was opened with. |
200
- | `agent_list` | agents | — | List the agents you can launch and the model each one runs on. |
201
- | `task_list` | tasks | `cwd` | List a project's Tasks with their status, model and cost. |
202
- | `task_get` | tasks | `cwd`, `id` | Read one Task in full, with its prompt and output. |
203
- | `task_switch_set` | tasks | `enabled`, `humanRequestQuote` | Turn Scripts may run Tasks on or off when the human asks. |
204
- | `scheduler_slots_get` | scheduler | — | See how many sessions may run at once and how many are busy. |
205
- | `scheduler_slots_set` | scheduler | `cap`, `quote` | Raise or lower the session limit when the human asks. |
206
- | `session_manager_help` | help | — | Start here: list every tool, or explain one tool or recipe. |
207
- | `artifact_publish` | artifacts | `path` | Publish a file for review. |
208
- | `artifact_list` | artifacts | — | List stored artifacts. |
209
- <!-- /gen:mcp-tools -->
149
+ The full list of tools, with what each one needs, is in [MCP tools](https://github.com/StanislavBG/claude-code-session-manager/blob/main/session-manager-operations/architecture/mcp-tools.md).
210
150
 
211
151
  Rules the server enforces:
212
152
 
@@ -218,7 +158,7 @@ Rules the server enforces:
218
158
 
219
159
  ### Headless jobs
220
160
 
221
- Each PRD job runs as the PRD's persona, `dev-lead` by default, in its own worktree. It runs the PRD's gate, then commits. Its last line is a verdict such as `SCHEDULER_VERDICT: PASS`.
161
+ Each PRD job runs as the PRD's persona (`dev-lead` by default) in its own worktree, then commits. Its last line is a verdict such as `SCHEDULER_VERDICT: PASS`.
222
162
 
223
163
  ### Scripts
224
164
 
@@ -228,7 +168,7 @@ A script can start a macro with `POST /admin/macros/run`, if a person marked it
228
168
 
229
169
  ### Plugin session-manager-dev
230
170
 
231
- On first launch, the app installs and updates this plugin offline from the bundled `session-manager` marketplace. To skip it, set `SM_SEED_DEV_PLUGIN_DISABLE=1`. To install it outside the app, run:
171
+ The app installs and updates it offline from its bundled `session-manager` marketplace. To install it outside the app, run:
232
172
 
233
173
  ```bash
234
174
  claude plugin marketplace add StanislavBG/claude-code-session-manager
@@ -248,8 +188,6 @@ claude plugin install session-manager-dev@session-manager
248
188
 
249
189
  ### Context packs
250
190
 
251
- A pack adds its skills and rules to one session only.
252
-
253
191
  <!-- list:packs -->
254
192
  | Pack | What it adds | Skills |
255
193
  | --- | --- | --- |
@@ -259,8 +197,6 @@ A pack adds its skills and rules to one session only.
259
197
 
260
198
  ### Agent personas
261
199
 
262
- The app copies these into `~/.claude/agents/` on first launch.
263
-
264
200
  <!-- list:personas -->
265
201
  | Persona | Role |
266
202
  | --- | --- |
@@ -272,6 +208,8 @@ The app copies these into `~/.claude/agents/` on first launch.
272
208
  | `competitive-analyst` | Builds the competitor matrix. |
273
209
  | `competitive-researcher` | Looks up one rival product for the matrix. |
274
210
  | `blender-artist` | Makes 3D game art in Blender. |
211
+ | `plan-reviewer` | Checks a queued plan's PRDs before they run. |
212
+ | `md-network-curator` | Keeps a project's markdown docs short and free of drift. |
275
213
  <!-- /list:personas -->
276
214
 
277
215
  ## Install
@@ -280,8 +218,8 @@ The app copies these into `~/.claude/agents/` on first launch.
280
218
 
281
219
  | Path | How | Needs | Platforms |
282
220
  | --- | --- | --- | --- |
283
- | Installer | Download from [GitHub Releases](https://github.com/StanislavBG/claude-code-session-manager/releases/latest). | Nothing else. The app helps you set up `git` and Claude Code. | macOS, Windows, Linux |
284
- | npx | `npx claude-code-session-manager@latest` | Node per [Facts](#facts), `git`, Claude Code | Linux, macOS |
221
+ | Installer | See Installers in [Facts](#facts). | Nothing else. The app helps you set up `git` and Claude Code. | macOS, Windows, Linux |
222
+ | npx | See Run in [Facts](#facts). | Node per [Facts](#facts), `git`, Claude Code | Linux, macOS |
285
223
  | From source | `git clone`, `npm install`, `npm run dev` | Node, `git`, Claude Code | Linux, macOS |
286
224
 
287
225
  ### What the first launch changes
@@ -293,23 +231,17 @@ The app copies these into `~/.claude/agents/` on first launch.
293
231
  | Personas | `~/.claude/agents/`. Old copies are backed up to `~/.claude/session-manager/persona-backups/`. Files you edited are left alone. | `SM_SEED_AGENT_PERSONAS_DISABLE=1` |
294
232
  | Demo video kit | `~/.claude/session-manager/demo-video-kit/` | `SM_SEED_DEMO_VIDEO_KIT_DISABLE=1` |
295
233
  | Guard hook shims | `~/.claude/session-manager/hooks/`. A project uses them once you accept its setup banner. | Do not accept the banner. |
296
- | App state | `~/.claude/session-manager/` | None |
297
- | Project folder | `<repo>/session-manager-operations/` | None |
298
- | Session worktrees | `$XDG_STATE_HOME/session-manager/`, by default `~/.local/state/session-manager/` | None |
299
- | Telemetry | Sent to bilko.run | `SM_TELEMETRY=0` |
300
234
 
301
- ### Start at login
235
+ It also makes the state folders in [Facts](#facts). They have no off switch.
302
236
 
303
- Off by default. Turn it on in App Settings, Startup.
237
+ ### Start at login
304
238
 
305
- An npx install runs `npx claude-code-session-manager@latest` at each login, or the cached copy if that fails within two minutes. The script is `~/.claude/session-manager/start-at-login.sh`, run by a desktop entry in `~/.config/autostart/` (Linux) or a launch agent in `~/Library/LaunchAgents/` (macOS).
239
+ Off by default. Turn it on in App Settings, Startup. It is not offered in a dev run.
306
240
 
307
- A packaged build uses a login item (macOS, Windows) or the autostart folder (Linux AppImage).
241
+ An npx install runs `npx claude-code-session-manager@latest` at each login, or the cached copy if that fails within two minutes. Its script, `~/.claude/session-manager/start-at-login.sh`, runs from `~/.config/autostart/claude-code-session-manager.desktop` (Linux) or `~/Library/LaunchAgents/run.bilko.session-manager.login.plist` (macOS). A packaged build uses a login item (macOS, Windows) or the autostart folder (Linux AppImage).
308
242
 
309
243
  To remove it, turn the switch off, or delete the script and `claude-code-session-manager.desktop` (Linux) or `run.bilko.session-manager.login.plist` (macOS). On a packaged macOS or Windows build, use login items.
310
244
 
311
- It is not offered for an npx install on Windows, or in a dev run.
312
-
313
245
  ### Check it worked
314
246
 
315
247
  ```bash
@@ -317,13 +249,11 @@ claude mcp get session-manager-scheduler
317
249
  claude plugin list
318
250
  ```
319
251
 
320
- Then have an agent call `session_manager_help` with no args.
321
-
322
252
  ### If it fails
323
253
 
324
254
  | Problem | Fix |
325
255
  | --- | --- |
326
- | Node is too old | Install the Node version in [Facts](#facts) or newer. Or use the installer. |
256
+ | Node is too old | Install the Node in [Facts](#facts), or use the installer. |
327
257
  | The Electron download failed | Try again. Or set `ELECTRON_MIRROR` to a mirror you can reach. |
328
258
  | No `node-pty` build for your platform | macOS: run `xcode-select --install`. Linux: install `build-essential` and `python3`. |
329
259
  | Anything else | Read the logs. Linux: `~/.config/claude-code-session-manager/logs`. macOS: `~/Library/Application Support/claude-code-session-manager/logs`. Windows: `%APPDATA%\claude-code-session-manager\logs`. |
@@ -339,13 +269,10 @@ Then have an agent call `session_manager_help` with no args.
339
269
 
340
270
  ### Env vars
341
271
 
272
+ `SM_TELEMETRY`: see [Facts](#facts). `SM_SEED_*`: see [What the first launch changes](#what-the-first-launch-changes).
273
+
342
274
  | Var | What it does |
343
275
  | --- | --- |
344
- | `SM_TELEMETRY=0` | Turns off telemetry. |
345
- | `SM_SEED_SCHEDULER_MCP_DISABLE=1` | Do not add the MCP server. |
346
- | `SM_SEED_DEV_PLUGIN_DISABLE=1` | Do not install the plugin. |
347
- | `SM_SEED_AGENT_PERSONAS_DISABLE=1` | Do not copy personas. |
348
- | `SM_SEED_DEMO_VIDEO_KIT_DISABLE=1` | Do not copy the demo video kit. |
349
276
  | `SM_WORKTREE_ROOT` | Moves where session and job worktrees are made. |
350
277
  | `SM_SCHEDULER_HOME` | Moves app state away from `~/.claude/session-manager/`. Use it for tests. |
351
278
  | `ELECTRON_MIRROR` | Where `npx` gets Electron from. |
@@ -377,18 +304,7 @@ Your prompts go only to the agent CLI you chose. The app itself talks to:
377
304
 
378
305
  ## Development
379
306
 
380
- ```bash
381
- git clone https://github.com/StanislavBG/claude-code-session-manager
382
- cd claude-code-session-manager
383
- npm install
384
- npm run dev
385
- npm run typecheck
386
- npm run lint
387
- npm run test:unit
388
- npm run test:e2e
389
- ```
390
-
391
- Read [CONTRIBUTING.md](https://github.com/StanislavBG/claude-code-session-manager/blob/main/CONTRIBUTING.md) before you open a PR. Report security bugs as told in [SECURITY.md](https://github.com/StanislavBG/claude-code-session-manager/blob/main/SECURITY.md), not in a public issue. Read [PRD_AUTHORING.md](https://github.com/StanislavBG/claude-code-session-manager/blob/main/src/main/templates/PRD_AUTHORING.md) before you write a PRD.
307
+ Setup and the checks to run (`typecheck`, `lint`, `test:unit`) are in [CONTRIBUTING.md](https://github.com/StanislavBG/claude-code-session-manager/blob/main/CONTRIBUTING.md). Read it before you open a PR. The Electron tests run with `npm run test:e2e`. Report security bugs as told in [SECURITY.md](https://github.com/StanislavBG/claude-code-session-manager/blob/main/SECURITY.md), not in a public issue. Read [PRD_AUTHORING.md](https://github.com/StanislavBG/claude-code-session-manager/blob/main/src/main/templates/PRD_AUTHORING.md) before you write a PRD.
392
308
 
393
309
  Run `npm run readme:build` after you change MCP tools, skills, packs, personas or `engines`. `npm run lint` fails if this page is out of date.
394
310
 
@@ -397,9 +313,8 @@ Run `npm run readme:build` after you change MCP tools, skills, packs, personas o
397
313
  | Link | URL |
398
314
  | --- | --- |
399
315
  | Field Manual | https://bilko.run/manual |
400
- | Product page | https://bilko.run/projects/session-manager/ |
316
+ | Product page | https://bilko.run/products/session-manager |
401
317
  | Source | https://github.com/StanislavBG/claude-code-session-manager |
402
- | Releases | https://github.com/StanislavBG/claude-code-session-manager/releases |
403
318
  | Issues | https://github.com/StanislavBG/claude-code-session-manager/issues |
404
319
  | Buy me a coffee | https://bilko.run/coffee |
405
320
  | Talk to Bilko | https://bilko.run/book?utm_source=session-manager&utm_medium=readme |
@@ -0,0 +1,2 @@
1
+ import{aD as e,w as Je,o as Ge,bB as B,aT as l,ay as qe,_ as Xe,u as Ye,aG as Se,D as Ke,aF as Ze,a3 as Ce,a2 as Ee,a4 as me,b1 as Qe,a1 as et,m as fe,a5 as tt,ai as _e,bc as te,a0 as st,b as se,bA as ge,by as nt,c as W,bg as at,a8 as He,bs as rt,a as it,a7 as ot,bn as lt,bj as ct,e as dt,aU as pt,bF as mt}from"./index-446b69rr.js";import{T as K,S as ut}from"./Toggle-Dt5K1OXt.js";import{V as ft,T as gt}from"./VoiceButton-CTLyRgdF.js";import{P as ht}from"./Panel-CnfWs46Z.js";import"./monaco-editor-BsIlgG7c.js";function xt({open:t,onClose:s,title:n,children:r,variant:i="overlay"}){return e.jsxs(Je,{open:t,onClose:s,size:"xl",fillHeight:!0,noPadding:!0,title:void 0,variant:i,children:[i==="overlay"&&e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-line shrink-0",children:[e.jsx("h2",{className:"text-xs uppercase tracking-wider text-fg-dim",children:n}),e.jsx("button",{type:"button",onClick:s,"aria-label":"Close",className:"px-2 py-0.5 text-fg-dim hover:text-fg hover:bg-bg-hi rounded text-base leading-none",children:"✕"})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsx(Ge,{children:r})})]})}function yt(){const t=B(x=>x.isRecording),s=B(x=>x.levelMeterEnabled),[n,r]=l.useState(0),[i,a]=l.useState(0),c=l.useRef(0);c.current=i;const[p,y]=l.useState(0),[u,h]=l.useState(!1),f=l.useRef(null);if(l.useEffect(()=>{if(!t||!s){r(0),a(0);return}let x=0,w=!1,k=null,N=null;const I=()=>{if(w)return;const S=N??qe();if(!S){x=requestAnimationFrame(I);return}N!==S&&(N=S,k=new Uint8Array(new ArrayBuffer(S.fftSize)));const R=k;S.getByteTimeDomainData(R);let A=0;for(let L=0;L<R.length;L++){const E=R[L]-128;A+=E*E}const P=Math.sqrt(A/R.length)/128,j=P>0?20*Math.log10(P):-60,C=Math.max(0,Math.min(1,(j+60)/60));a(P),r(C),P>=.95&&(h(!0),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>h(!1),150)),x=requestAnimationFrame(I)};x=requestAnimationFrame(I);const g=setInterval(()=>{w||y(Math.round(c.current*100))},250);return()=>{w=!0,cancelAnimationFrame(x),clearInterval(g),f.current&&(clearTimeout(f.current),f.current=null)}},[t,s]),!t||!s)return null;const m=u?"bg-red-500":i>=.7?"bg-amber-400":"bg-green-500";return e.jsx("div",{role:"meter","aria-label":"Microphone input level","aria-valuenow":p,"aria-valuemin":0,"aria-valuemax":100,"data-testid":"mic-level-meter",className:`mx-3 mb-2 h-1 rounded bg-bg overflow-hidden ${u?"ring-1 ring-red-500":""}`,children:e.jsx("div",{className:`h-full ${m} transition-[width] duration-75 ease-out`,style:{width:`${n*100}%`}})})}function bt({open:t,onClose:s,variant:n="overlay"}){return e.jsx(xt,{open:t,onClose:s,title:"Voice / Microphone",variant:n,children:e.jsxs("div",{className:"p-4 space-y-4",children:[e.jsx(kt,{}),e.jsx(Xe,{}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx(ft,{}),e.jsx(Ye,{}),e.jsx(gt,{})]}),e.jsx(jt,{}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx("button",{type:"button",onClick:()=>B.getState().openWizard(),className:"text-xs text-fg-faint hover:text-fg-dim underline","data-testid":"run-mic-check",children:"Run mic check"}),e.jsx(wt,{})]}),e.jsx(yt,{})]})})}function jt(){const t=B(a=>a.isRecording),[s,n]=l.useState(null);if(l.useEffect(()=>{let a=!1;window.api.voice.getHotkeyConfig().then(p=>{a||n(p)}).catch(()=>{});const c=window.api.voice.onHotkeyConfigChanged(p=>n(p));return()=>{a=!0,c()}},[]),t||!s)return null;const r=s.mode==="hold"?"Hold":"Press",i=vt(s.accelerator);return e.jsxs("div",{className:"text-[11px] text-fg-faint",children:[e.jsxs("span",{children:[r," "]}),e.jsx("kbd",{className:"px-1 py-0.5 rounded border border-line bg-bg font-mono text-fg-dim",children:i}),e.jsx("span",{children:" to record"})]})}function vt(t){const s=typeof navigator<"u"&&/Mac/.test(navigator.platform);return t.replace(/CommandOrControl/g,s?"⌘":"Ctrl").replace(/CmdOrCtrl/g,s?"⌘":"Ctrl").replace(/Command/g,"⌘").replace(/Control/g,"Ctrl").replace(/Option/g,s?"⌥":"Alt").replace(/Shift/g,s?"⇧":"Shift")}function wt(){const[t,s]=l.useState(null);if(l.useEffect(()=>{let r=!1;window.api.voice.getHotkeyConfig().then(a=>{r||s(a)}).catch(a=>Se.warn("voice-hotkey","getHotkeyConfig (toggle) failed",{error:String(a)}));const i=window.api.voice.onHotkeyConfigChanged(a=>{s(a)});return()=>{r=!0,i()}},[]),!t)return null;const n=async r=>{if(t.mode===r)return;const i={...t,mode:r};s(i);try{await window.api.voice.setHotkeyConfig(i)}catch(a){Se.warn("voice-hotkey","setHotkeyConfig (toggle) failed",{error:a instanceof Error?a.message:String(a)})}};return e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-fg-faint select-none",title:"Mic hotkey behavior. Tap on/off: press once to start, again to stop. Hold to talk: record only while held (push-to-talk).",children:[e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[e.jsx("input",{type:"radio",name:"hotkey-mode",checked:t.mode==="toggle",onChange:()=>n("toggle"),className:"cursor-pointer","data-testid":"hotkey-mode-toggle"}),e.jsx("span",{children:"Tap on/off"})]}),e.jsxs("label",{className:"flex items-center gap-1 cursor-pointer hover:text-fg-dim",children:[e.jsx("input",{type:"radio",name:"hotkey-mode",checked:t.mode==="hold",onChange:()=>n("hold"),className:"cursor-pointer","data-testid":"hotkey-mode-hold"}),e.jsx("span",{children:"Hold to talk"})]})]})}function kt(){const t=B(a=>a.isRecording),s=B(a=>a.lastTranscript),n=B(a=>a.error),r=B(a=>a.modelStatus),i=B(a=>a.loadingProgress);return n?e.jsxs("div",{className:"text-[11px] text-red-400",title:n,children:["⚠ ",n]}):t?e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-fg-dim border border-line rounded px-2 py-1.5",children:[e.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-red-400 animate-pulse shrink-0"}),e.jsx("span",{className:"truncate",title:s,children:s||"Listening…"})]}):r==="loading"?e.jsxs("div",{className:"text-[11px] text-fg-faint",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{children:"Loading speech model"}),e.jsxs("span",{className:"font-mono",children:[i,"%"]})]}),e.jsx("div",{className:"h-1 rounded bg-bg overflow-hidden",children:e.jsx("div",{className:"h-full bg-accent transition-[width] duration-200",style:{width:`${i}%`}})})]}):null}const Nt=["dark","light","paper"];function St(){const[t,s]=l.useState(Ke),[n,r]=l.useState(!1);l.useEffect(()=>{let c=!1;return Ze().then(p=>{c||(s(p),r(!0))}),()=>{c=!0}},[]);const i=c=>{n&&s(p=>{const y={...p,...c};return Qe(y),y})},a=c=>{i({fontSize:Math.min(Ee,Math.max(Ce,t.fontSize+c))})};return e.jsxs("section",{className:"mb-6","data-testid":"home-terminal-appearance",children:[e.jsxs("div",{className:"flex items-baseline justify-between mb-3",children:[e.jsx("h2",{className:"m-0 font-serif text-[22px] font-medium",children:"Terminal appearance"}),e.jsx("span",{className:"font-mono text-[12px] text-fg-faint",children:"every terminal, this machine"})]}),e.jsxs("div",{className:"border border-line rounded-xl bg-bg-hi px-5 py-4",children:[e.jsxs("p",{className:"mt-0 mb-4 text-[13px] text-fg-dim leading-relaxed",children:["Applies to ",e.jsx("strong",{className:"text-fg",children:"every terminal in the app at once"})," — project Terminal tabs, an Epic’s Terminal view of its session, and the inline permission prompt. It is not per project, per session, or per tab. It does not restyle the app chrome (there is no app theme switch), and the code editor keeps its own separate paper/dark setting in the Editor tab’s Display menu. Stored in"," ",e.jsx("code",{className:"font-mono text-[12px]",children:"~/.claude/session-manager/ui-settings-prefs.json"}),", applied live without restarting a session."]}),e.jsxs("div",{className:"grid gap-5",style:{gridTemplateColumns:"minmax(0,1fr) 220px"},children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-fg-faint mb-1.5",children:"Theme"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:Nt.map(c=>e.jsxs("button",{type:"button",onClick:()=>i({theme:c}),disabled:!n,"aria-pressed":t.theme===c,"data-testid":`terminal-theme-${c}`,className:`px-2 py-2 rounded-lg text-[11px] font-medium border transition-colors disabled:opacity-40 disabled:cursor-not-allowed ${t.theme===c?"bg-bg border-accent text-fg":"bg-bg border-line text-fg-dim hover:text-fg hover:border-fg-faint"}`,children:[e.jsx(Ct,{theme:c}),e.jsx("div",{className:"mt-1.5 capitalize",children:c})]},c))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider text-fg-faint",children:"Font size"}),e.jsxs("span",{className:"font-mono text-[11px] text-fg-dim",children:[t.fontSize,"px"]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>a(-1),disabled:!n||t.fontSize<=Ce,"aria-label":"Decrease font size",className:"flex-1 py-1.5 rounded border border-line bg-bg text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed",children:"−"}),e.jsx("button",{type:"button",onClick:()=>i({fontSize:et}),disabled:!n,className:"flex-1 py-1.5 rounded border border-line bg-bg text-[11px] text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed",children:"reset"}),e.jsx("button",{type:"button",onClick:()=>a(1),disabled:!n||t.fontSize>=Ee,"aria-label":"Increase font size",className:"flex-1 py-1.5 rounded border border-line bg-bg text-fg-dim hover:text-fg hover:border-fg-faint disabled:opacity-40 disabled:cursor-not-allowed",children:"+"})]}),e.jsxs("div",{className:"mt-3 rounded border border-line px-3 py-2 font-mono",style:{background:me[t.theme].background,color:me[t.theme].foreground,fontSize:`${t.fontSize}px`,lineHeight:1.35},"aria-hidden":!0,children:[e.jsx("span",{style:{color:me[t.theme].green},children:"$"})," claude"]})]})]})]})]})}function Ct({theme:t}){const s=me[t];return e.jsxs("div",{"aria-hidden":!0,className:"w-full h-5 rounded border relative overflow-hidden",style:{background:s.background,borderColor:"rgba(0,0,0,0.15)"},children:[e.jsx("div",{style:{position:"absolute",top:3,left:4,width:"40%",height:2,background:s.foreground}}),e.jsx("div",{style:{position:"absolute",top:9,left:4,width:"25%",height:2,background:s.green??s.foreground}}),e.jsx("div",{style:{position:"absolute",top:15,left:4,width:"55%",height:2,background:s.cyan??s.foreground}})]})}const Et=1440*60*1e3;function It(t){if(!t)return"never";const s=new Date(t).getTime();return Number.isNaN(s)?"never":new Date(s).toLocaleString()}function Ie(t){return t?new Date(t).toLocaleString():"never"}function Tt(){return e.jsxs("div",{className:"p-4 max-w-3xl space-y-8 text-sm",children:[e.jsx(Rt,{}),e.jsx("hr",{className:"border-line"}),e.jsx(Pt,{})]})}function Rt(){const[t,s]=l.useState(null),[n,r]=l.useState(null),[i,a]=l.useState(null),[c,p]=l.useState(null),[y,u]=l.useState(!1),[h,f]=l.useState(null),[m,x]=l.useState(null);if(l.useEffect(()=>{let g=!1;return Promise.all([window.api.otel.getConfig(),window.api.otel.status(),window.api.otel.configPath()]).then(([S,R,A])=>{g||(s(S),a(S),r(R),p(A))}).catch(S=>{console.warn("[telemetry] load failed:",S==null?void 0:S.message)}),()=>{g=!0}},[]),!i||!t)return e.jsx(fe,{title:"loading…"});const w=JSON.stringify(i)!==JSON.stringify(t),k=(g,S)=>{f(null),a({...i,[g]:S})},N=async()=>{u(!0),f(null);try{const g=await window.api.otel.setConfig(i);!g.ok&&g.error&&f(g.error),s(g.config),a(g.config),r(g.status),x(Date.now())}catch(g){f(g instanceof Error?g.message:String(g))}finally{u(!1)}},I=()=>{f(null),a(t)};return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"OpenTelemetry export"}),e.jsx("p",{className:"text-fg-dim text-xs leading-relaxed",children:"When enabled, every classified transcript event (tool_use, todo_write, plan, usage, agent_spawn) is mirrored as a 0-duration OTLP/HTTP span. Point this at a local collector (Jaeger, Grafana Tempo, SigNoz, Honeycomb) for cross-session analysis."}),c&&e.jsxs("p",{className:"text-fg-faint text-[11px]",children:["stored at ",e.jsx("span",{className:"font-mono",children:c})]})]}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Export transcripts to OTEL"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Toggle off to disable all span emission immediately."})]}),e.jsx(K,{checked:i.enabled,onChange:g=>k("enabled",g),label:i.enabled?"on":"off"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"OTLP/HTTP traces endpoint"}),e.jsx("input",{type:"text",value:i.endpoint,onChange:g=>k("endpoint",g.target.value),placeholder:"http://localhost:4318/v1/traces",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsxs("span",{className:"text-fg-dim text-xs",children:["Headers (newline-separated ",e.jsx("span",{className:"font-mono",children:"Key: Value"}),")"]}),e.jsx("textarea",{value:i.headers,onChange:g=>k("headers",g.target.value),placeholder:"x-honeycomb-team: YOUR_API_KEY",rows:3,className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("label",{className:"block space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Service name"}),e.jsx("input",{type:"text",value:i.serviceName,onChange:g=>k("serviceName",g.target.value),placeholder:"session-manager",className:"w-full bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"})]}),e.jsxs("div",{className:"flex items-start justify-between gap-3 pt-1",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Include content (PII)"}),e.jsxs("div",{className:"text-fg-faint text-xs leading-relaxed",children:["Adds tool inputs, plan text, and agent prompts to span attributes. Off by default — matches upstream Claude Code's ",e.jsx("span",{className:"font-mono",children:"OTEL_LOG_USER_PROMPTS"})," opt-in."]})]}),e.jsx(K,{checked:i.includeContent,onChange:g=>k("includeContent",g),label:i.includeContent?"on":"off"})]})]}),n&&e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"enabled:"})," ",e.jsx("span",{className:n.enabled?"text-accent":"text-fg-dim",children:String(n.enabled)})]}),n.error&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"error:"})," ",n.error]}),!n.error&&n.enabled&&e.jsx("div",{className:"text-fg-faint",children:"spans batched and exported in the background. Verify by enabling and pointing at a local Jaeger."})]}),e.jsxs("footer",{className:"flex items-center gap-3 pt-2 border-t border-line",children:[e.jsx("button",{onClick:N,disabled:!w||y,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:y?"saving…":"Save"}),e.jsx("button",{onClick:I,disabled:!w||y,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg disabled:opacity-50 disabled:cursor-not-allowed",children:"Revert"}),h&&e.jsx("span",{className:"text-red-400 text-xs",children:h}),!h&&m&&!w&&e.jsx("span",{className:"text-fg-faint text-xs",children:"saved"})]})]})}function Pt(){const[t,s]=l.useState(null),[n,r]=l.useState(null),[i,a]=l.useState("Copy"),[c,p]=l.useState(!1),[y,u]=l.useState(null),[h,f]=l.useState(null),[m,x]=l.useState(null),[w,k]=l.useState(!1),N=()=>{window.api.telemetry.status().then(r).catch(j=>{console.warn("[product-telemetry] status reload failed:",j==null?void 0:j.message)})};if(l.useEffect(()=>{let j=!1;return Promise.all([window.api.telemetry.getConfig(),window.api.telemetry.status()]).then(([C,L])=>{j||(s(C),r(L))}).catch(C=>{console.warn("[product-telemetry] load failed:",C==null?void 0:C.message)}),()=>{j=!0}},[]),!t||!n)return e.jsx(fe,{title:"loading…"});const I=async j=>{f(null);try{const C=await window.api.telemetry.setConfig(j);s(C.config),r(C.status),window.dispatchEvent(new CustomEvent(st,{detail:C.config}))}catch(C){f(C instanceof Error?C.message:String(C))}},g=j=>{I({...t,enabled:j})},S=async()=>{await _e(t.installId)?(a("Copied"),setTimeout(()=>a("Copy"),1500)):te.error("Could not copy install id to the clipboard")},R=async()=>{p(!0),u(null);try{const j=await window.api.telemetry.flushNow();u(`sent ${j.sent.length}, failed ${j.failed.length}`),N()}catch(j){u(j instanceof Error?j.message:String(j))}finally{p(!1)}},A=async()=>{if(w){k(!1);return}try{const j=await window.api.telemetry.recentRecords();x(j),k(!0)}catch(j){console.warn("[product-telemetry] recentRecords failed:",j instanceof Error?j.message:j)}},P=t.lastDailyFlushAt?new Date(t.lastDailyFlushAt).getTime()+Et:null;return e.jsxs("div",{className:"space-y-5","data-testid":"product-telemetry-section",children:[e.jsxs("header",{className:"space-y-1",children:[e.jsx("h2",{className:"text-fg text-base font-medium",children:"Product telemetry (bilko.run)"}),e.jsxs("p",{className:"text-fg-dim text-xs leading-relaxed",children:["Anonymous, strictly non-identifying usage/error reporting that helps improve this app. On by default; switchable off in one click. See"," ",e.jsx("span",{className:"font-mono",children:"session-manager-operations/architecture/telemetry.md"})," for the full data model."]})]}),e.jsx(tt,{cfg:t,onSaved:(j,C)=>{s(j),r(C)}}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-fg",children:"Send anonymous product telemetry"}),e.jsx("div",{className:"text-fg-faint text-xs",children:"Sent on start-up, after an update, and once a day. Strictly anonymous — an install id only, never an email, name, or other identifier."})]}),e.jsx(K,{checked:t.enabled,onChange:g,label:t.enabled?"on":"off"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-fg-dim text-xs",children:"Anonymous install id"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",readOnly:!0,value:t.installId,"aria-label":"Anonymous install identifier",className:"flex-1 bg-bg border border-line rounded px-2 py-1 text-fg font-mono text-xs"}),e.jsx("button",{onClick:S,className:"px-2 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:i})]})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Endpoint"}),e.jsx("div",{className:"font-mono text-fg-dim break-all",children:t.endpoint})]}),e.jsxs("div",{className:"space-y-1 text-xs",children:[e.jsx("div",{className:"text-fg-faint",children:"Send cadence"}),e.jsx("div",{className:"text-fg-dim",children:"on start-up, after an update, and once a day"})]}),h&&e.jsx("div",{className:"text-red-400 text-xs",children:h})]}),n.pendingCount>0&&n.sentCount===0&&e.jsxs("section",{"data-testid":"telemetry-never-delivered-warning",className:"border border-red-400 rounded p-3 text-xs space-y-1 text-red-400",children:[e.jsx("div",{className:"font-medium",children:"Never delivered"}),e.jsxs("div",{className:"leading-relaxed",children:[n.pendingCount," record",n.pendingCount===1?"":"s",' queued but none have ever been sent to bilko.run on this install. Check the endpoint/network, or click "Send now" below.']})]}),e.jsxs("section",{className:"border border-line rounded p-3 text-xs space-y-1.5",children:[e.jsx("div",{className:"text-fg-dim",children:"Runtime status"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"last send:"})," ",Ie(n.lastFlushAt)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"next daily send due:"})," ",It(P?new Date(P).toISOString():null)]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"queued records:"})," ",n.pendingCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"delivered so far:"})," ",n.sentCount]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"de-duplicated:"})," ",n.dedupedAppends]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-fg-faint",children:"evicted:"})," ",n.evictedCount]}),n.lastError&&e.jsxs("div",{className:"text-red-400 break-words",children:[e.jsx("span",{className:"text-fg-faint",children:"last error:"})," ",n.lastError.message," ","(",Ie(n.lastError.at),")"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:R,disabled:c,className:"px-3 py-1 text-xs rounded bg-accent text-bg disabled:opacity-50 disabled:cursor-not-allowed",children:c?"sending…":"Send now"}),y&&e.jsx("span",{className:"text-fg-faint text-xs",children:y})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("button",{onClick:A,className:"px-3 py-1 text-xs rounded border border-line text-fg-dim hover:text-fg",children:w?"Hide last records":"Inspect last records sent"}),w&&e.jsx("pre",{"data-testid":"telemetry-inspector-json",className:"bg-bg border border-line rounded p-2 text-[11px] font-mono overflow-auto max-h-96 whitespace-pre-wrap",children:JSON.stringify(m??[],null,2)})]})]})}function Y({children:t,right:s}){return e.jsxs("div",{className:"flex items-baseline justify-between mb-2.5",children:[e.jsx("span",{className:"text-[11.5px] font-bold uppercase tracking-[0.8px] text-fg-faint",children:t}),s]})}function D({kind:t="soft",icon:s,children:n,onClick:r,disabled:i,testId:a}){return e.jsxs("button",{type:"button","data-testid":a,onClick:r,disabled:i,className:`shrink-0 inline-flex items-center gap-2 rounded-lg px-3.5 py-2 text-[13px] font-semibold transition-colors disabled:opacity-50 ${t==="soft"?"bg-bg-hi border border-line text-fg hover:bg-bg":"text-fg-dim hover:text-fg"}`,children:[s&&e.jsx(se,{name:s,size:15}),n]})}function je({icon:t,title:s,subtitle:n,badge:r,action:i,testId:a}){return e.jsxs("div",{"data-testid":a,className:"flex items-center gap-3.5 bg-bg-hi border border-line rounded-xl px-[18px] py-3.5",children:[e.jsx("span",{className:"w-[34px] h-[34px] rounded-lg bg-bg border border-line grid place-items-center text-fg-dim shrink-0",children:e.jsx(se,{name:t,size:17})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5 mb-0.5",children:[e.jsx("span",{className:"text-sm font-semibold text-fg truncate",children:s}),r]}),e.jsx("div",{className:"font-mono text-[11.5px] text-fg-faint truncate",children:n})]}),i]})}function ve({onClick:t,disabled:s,testId:n,children:r="Revoke"}){return e.jsx("button",{"data-testid":n,onClick:t,disabled:s,className:"shrink-0 rounded-lg border border-line bg-bg text-accent px-3.5 py-1.5 text-[12.5px] font-semibold hover:bg-bg-hi disabled:opacity-50 transition-colors",children:r})}function Te({code:t,onConfirm:s,testId:n,codeTestId:r,confirmTestId:i,peer:a="browser"}){return e.jsxs("div",{"data-testid":n,className:"flex items-start gap-3.5 px-5 py-4 rounded-2xl border border-accent/40 bg-accent/[0.06]",children:[e.jsx("span",{className:"w-[38px] h-[38px] rounded-[11px] shrink-0 grid place-items-center bg-bg-hi text-accent",children:e.jsx(se,{name:"shield",size:20})}),e.jsxs("div",{className:"flex-1 min-w-0 text-sm text-fg",children:[e.jsx("strong",{className:"font-semibold",children:"Verify E2E session."})," Compare this code with the ",a," — they must match.",e.jsx("div",{"data-testid":r,className:"my-2 text-3xl font-mono tracking-[0.3em] text-center text-accent select-all",children:t}),e.jsx("p",{className:"text-[12.5px] text-fg-faint mb-3",children:"If the codes match, confirm below. Mutating commands are blocked until confirmed."}),e.jsx("button",{"data-testid":i,onClick:s,className:"rounded-lg bg-accent text-white px-4 py-2 text-[13px] font-semibold hover:opacity-90 transition-opacity",children:"Codes match — confirm"})]})]})}function At({children:t,testId:s}){return e.jsx("div",{"data-testid":s,className:"bg-bg-hi border border-line rounded-xl p-5 text-center text-[13.5px] text-fg-faint italic font-serif",children:t})}const ue=["feedback_list_projects","feedback_open_session","macro_list","macro_run","epic_get","events_read","project_create"],$t=["project_create"],Re=ue.filter(t=>!$t.includes(t)),Pe={project_create:"Create projects"};function Lt(t){const s=t.replace(/[/\\]+$/,"");return s?`${s}/Projects`:""}const Ae=64,Mt={relay_unsupported:"The bilko.run relay does not accept services yet",device_token_invalid:"Re-pair this desktop with the phone first",rate_limited:"Too many codes this hour"},q=t=>(t==null?void 0:t.message)||String(t),Dt=t=>/^[A-Za-z0-9._\-/~]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`,Ot=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"service";function $e(t){const s=`~/.session-manager-service/${Ot(t.name)}`;return`npx claude-code-session-manager service pair --code ${t.code} --device ${t.deviceId.slice(0,8)} --name ${Dt(t.name)} --state-dir ${s}`}function _t(t){const s=Math.max(0,Math.ceil(t/1e3));return`${Math.floor(s/60)}:${String(s%60).padStart(2,"0")}`}function Ht({pending:t,onConfirm:s,onDeny:n,busy:r}){const[i,a]=l.useState("");return e.jsxs("div",{"data-testid":"remote-service-pending",className:"bg-bg-hi border border-accent/40 rounded-xl px-[18px] py-3.5",children:[e.jsxs("div",{className:"text-sm font-semibold text-fg mb-0.5",children:["Verify ",t.name]}),e.jsx("div",{className:"text-[12.5px] text-fg-faint mb-2.5",children:"Type the 6-digit code the service printed. It must match before the service can call any tool."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{"data-testid":"remote-service-sas-input",value:i,onChange:c=>a(c.target.value.replace(/\D/g,"").slice(0,6)),inputMode:"numeric",maxLength:6,placeholder:"000000",className:"w-[130px] bg-bg border border-line rounded-lg px-3 py-1.5 font-mono text-[18px] tracking-[4px] text-fg"}),e.jsx(D,{testId:"remote-service-sas-confirm",onClick:()=>s(t.pairingId,i),disabled:r||i.length!==6,children:"Confirm"}),e.jsx(D,{testId:"remote-service-sas-deny",kind:"ghost",onClick:()=>n(t.pairingId),disabled:r,children:"Deny"})]}),t.projectRoot&&e.jsxs("div",{"data-testid":`remote-service-project-root-${t.pairingId}`,className:"text-[12px] text-fg-faint mt-2",children:["New projects go in ",e.jsx("span",{className:"font-mono",children:t.projectRoot})]})]})}function Bt({enabled:t,hasDevice:s,refreshKey:n}){const r=ge(o=>o.show),i=nt(o=>o.tabs),a=l.useMemo(()=>Array.from(new Set(i.map(o=>o.cwd))),[i]),[c,p]=l.useState([]),[y,u]=l.useState([]),[h,f]=l.useState([]),[m,x]=l.useState(!1),[w,k]=l.useState(""),[N,I]=l.useState(""),[g,S]=l.useState(Re),[R,A]=l.useState(""),[P,j]=l.useState(!1),[C,L]=l.useState(null),[E,ae]=l.useState(null),[xe,Z]=l.useState(()=>Date.now()),[$,M]=l.useState(null),[re,V]=l.useState(null),F=t&&s,_=l.useCallback(async()=>{try{const o=await window.api.webRemote.servicesList();p(o.services??[]),u(o.pending??[]),f(o.relayOrphans??[])}catch(o){r("error",`Services: ${q(o)}`)}},[r]);l.useEffect(()=>{F&&_()},[F,_,n]),l.useEffect(()=>{!N&&a.length>0&&I(a[0])},[a,N]),l.useEffect(()=>{let o=!1;return window.api.app.homeDir().then(v=>{o||A(T=>T||Lt(v))}).catch(v=>r("error",`Home folder: ${q(v)}`)),()=>{o=!0}},[r]),l.useEffect(()=>{if(!E)return;Z(Date.now());const o=setInterval(()=>Z(Date.now()),1e3);return()=>clearInterval(o)},[E]);const J=()=>{x(!1),k(""),S(Re),L(null),ae(null)},Q=o=>S(v=>v.includes(o)?v.filter(T=>T!==o):ue.filter(T=>T===o||v.includes(T))),U=async()=>{const o=w.trim(),v=g.includes("project_create"),T=R.trim();if(!(!o||!N||g.length===0||v&&!T)){j(!0),L(null);try{const H=await window.api.webRemote.servicePairStart(v?{name:o,homeCwd:N,scope:g,projectRoot:T}:{name:o,homeCwd:N,scope:g});if(!H.ok){const Ne=Mt[H.error];Ne?L(Ne):r("error",`Service pairing: ${H.error}`);return}ae({code:H.code,pairingId:H.pairingId,codeExpiresAt:H.codeExpiresAt,deviceId:H.deviceId,name:o}),await _()}catch(H){r("error",`Service pairing: ${q(H)}`)}finally{j(!1)}}},G=async()=>{if(!E)return;await _e($e(E))?r("info","Pair command copied."):r("error","Could not copy the pair command.")},ye=async(o,v)=>{M(o);try{const T=await window.api.webRemote.serviceConfirmSas(o,v);if(!T.ok){r("error",T.error==="sas_mismatch"?"The code does not match the service.":`Confirm failed: ${T.error}`);return}r("info",`${T.service.name} paired.`),(E==null?void 0:E.pairingId)===o&&J(),await _()}catch(T){r("error",`Confirm failed: ${q(T)}`)}finally{M(null)}},ie=async o=>{M(o);try{const v=await window.api.webRemote.servicePairCancel(o);if(!v.ok){r("error",`Deny failed: ${v.error}`);return}(E==null?void 0:E.pairingId)===o&&J(),await _()}catch(v){r("error",`Deny failed: ${q(v)}`)}finally{M(null)}},d=async o=>{V(null),M(o);try{const v=await window.api.webRemote.serviceRevoke(o);if(!v.ok){r("error",`Revoke failed: ${v.error}`);return}v.relayRevoked||r("warn","Revoked here; the relay could not be reached — revoke its client below when it shows."),await _()}catch(v){r("error",`Revoke failed: ${q(v)}`)}finally{M(null)}},b=async o=>{V(null),M(o);try{const v=await window.api.webRemote.relayClientRevoke(o);if(!v.ok){r("error",`Revoke failed: ${v.error||"unknown error"}`);return}await _()}catch(v){r("error",`Revoke failed: ${q(v)}`)}finally{M(null)}},oe=(o,v,T)=>re===o?e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(ve,{testId:`${v}-confirm`,onClick:T,disabled:$===o,children:"Confirm revoke"}),e.jsx(D,{kind:"ghost",onClick:()=>V(null),children:"cancel"})]}):e.jsx(ve,{testId:v,onClick:()=>V(o),disabled:$===o}),ee=E?E.codeExpiresAt-xe:0,le=g.includes("project_create"),O=!P&&w.trim().length>0&&!!N&&g.length>0&&(!le||R.trim().length>0);return e.jsxs("div",{"data-testid":"remote-services",children:[e.jsx(Y,{children:"Services"}),F?m?E?e.jsxs("div",{"data-testid":"remote-service-code-panel",className:"bg-bg-hi border border-accent/40 rounded-2xl px-6 py-[18px] space-y-2.5",children:[e.jsxs("div",{className:"text-[11.5px] font-bold uppercase tracking-[0.8px] text-fg-faint",children:["One-time code for ",E.name]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{"data-testid":"remote-service-code",className:"font-mono text-[30px] font-semibold tracking-[6px] text-fg select-all",children:E.code}),e.jsx("span",{"data-testid":"remote-service-countdown",className:`text-[12.5px] ${ee>0?"text-fg-faint":"text-accent"}`,children:ee>0?`expires in ${_t(ee)}`:"Code expired — start again"})]}),e.jsx("code",{className:"block font-mono text-[11.5px] text-fg-dim break-all",children:$e(E)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{testId:"remote-service-copy",icon:"copy",onClick:G,children:"Copy command"}),e.jsx(D,{kind:"ghost",onClick:J,children:"done"})]}),e.jsx("div",{className:"text-[12px] text-fg-faint",children:"Run it where the service lives. It prints a 6-digit code; type it below to finish."})]}):e.jsxs("div",{"data-testid":"remote-service-form",className:"bg-bg-hi border border-accent/40 rounded-2xl px-6 py-[18px] space-y-3",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[12px] font-semibold text-fg-dim mb-1",children:"Name"}),e.jsx("input",{"data-testid":"remote-service-name",value:w,maxLength:Ae,onChange:o=>k(o.target.value.slice(0,Ae)),placeholder:"Kiln",className:"w-full bg-bg border border-line rounded-lg px-3 py-1.5 text-[13px] text-fg"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[12px] font-semibold text-fg-dim mb-1",children:"Home project"}),e.jsxs("select",{"data-testid":"remote-service-home",value:N,onChange:o=>I(o.target.value),className:"w-full bg-bg border border-line rounded-lg px-3 py-1.5 text-[13px] text-fg font-mono",children:[a.length===0&&e.jsx("option",{value:"",children:"Open a project tab first"}),a.map(o=>e.jsx("option",{value:o,children:o},o))]})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"text-[12px] font-semibold text-fg-dim mb-1",children:"Tools it may call"}),e.jsx("div",{className:"grid grid-cols-2 gap-1",children:ue.map(o=>e.jsxs("label",{className:"flex items-center gap-2 text-[12.5px] text-fg font-mono",children:[e.jsx("input",{type:"checkbox","data-testid":`remote-service-scope-${o}`,checked:g.includes(o),onChange:()=>Q(o)}),Pe[o]?e.jsxs("span",{className:"font-sans",children:[Pe[o]," ",e.jsxs("span",{className:"font-mono text-fg-faint",children:["(",o,")"]})]}):o]},o))})]}),le&&e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"block text-[12px] font-semibold text-fg-dim mb-1",children:"New projects go in"}),e.jsx("input",{"data-testid":"remote-service-project-root",value:R,onChange:o=>A(o.target.value),placeholder:"~/Projects",className:"w-full bg-bg border border-line rounded-lg px-3 py-1.5 text-[13px] text-fg font-mono"}),e.jsx("span",{className:"block text-[11.5px] text-fg-faint mt-1",children:"The service can create new folders and private GitHub repos here."})]}),C&&e.jsx("div",{"data-testid":"remote-service-error",className:"text-[12.5px] text-accent",children:C}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(D,{testId:"remote-service-start",onClick:U,disabled:!O,children:P?"Starting…":"Start"}),e.jsx(D,{kind:"ghost",onClick:J,disabled:P,children:"cancel"})]})]}):e.jsxs("div",{className:"flex items-center justify-between gap-4 bg-bg-hi border border-line rounded-2xl px-5 py-[18px]",children:[e.jsx("div",{className:"text-[13.5px] text-fg-dim leading-relaxed max-w-[420px]",children:"Let a named service (such as Kiln) drive work in one home project through a scoped set of tools."}),e.jsx(D,{testId:"remote-service-pair",icon:"link",onClick:()=>x(!0),children:"Pair a service…"})]}):e.jsxs("div",{"data-testid":"remote-service-disabled",className:"flex items-center justify-between gap-4 bg-bg-hi border border-line rounded-2xl px-5 py-[18px] opacity-70",children:[e.jsx("div",{className:"text-[13.5px] text-fg-dim leading-relaxed max-w-[420px]",children:t?"Pair a device above first — a service pairs through this desktop’s device.":"Turn on “Allow remote control from the web” above to pair a service."}),e.jsx(D,{testId:"remote-service-pair",icon:"link",onClick:()=>{},disabled:!0,children:"Pair a service…"})]}),F&&y.length>0&&e.jsx("div",{className:"space-y-2 mt-2.5",children:y.map(o=>e.jsx(Ht,{pending:o,onConfirm:ye,onDeny:ie,busy:$===o.pairingId},o.pairingId))}),F&&c.length>0&&e.jsxs("div",{className:"mt-[18px]",children:[e.jsx(Y,{right:e.jsxs("span",{className:"text-[11.5px] text-fg-faint",children:[c.length," paired"]}),children:"Paired services"}),e.jsx("div",{className:"space-y-2",children:c.map(o=>e.jsxs("div",{"data-testid":"remote-service-row",children:[e.jsx(je,{icon:"link",title:o.name,subtitle:`${o.homeCwd} · ${o.scope.length} of ${ue.length} tools · paired${o.pairedVia==="local"?" locally":""} ${new Date(o.pairedAt).toLocaleDateString()}`,action:oe(o.serviceId,"remote-service-revoke",()=>d(o.serviceId))}),o.projectRoot&&e.jsxs("div",{"data-testid":`remote-service-project-root-${o.serviceId}`,className:"text-[12px] text-fg-faint mt-1 px-[18px]",children:["New projects go in ",e.jsx("span",{className:"font-mono",children:o.projectRoot})]})]},o.serviceId))})]}),F&&h.length>0&&e.jsxs("div",{className:"mt-[18px]",children:[e.jsx(Y,{children:"Relay clients without a service"}),e.jsx("div",{className:"space-y-2",children:h.map(o=>e.jsx("div",{"data-testid":"remote-relay-orphan-row",children:e.jsx(je,{icon:"wifi",title:o.clientName||"unnamed client",subtitle:o.clientId,action:oe(o.clientId,"remote-relay-orphan-revoke",()=>b(o.clientId))})},o.clientId))})]})]})}function Le({label:t,hint:s,on:n,onChange:r,warn:i,disabled:a,first:c,testId:p}){return e.jsxs("div",{className:`flex items-center justify-between gap-4 px-[18px] py-[15px] ${c?"":"border-t border-rule"} ${a?"opacity-50":""}`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold text-fg mb-0.5",children:t}),e.jsxs("div",{className:`text-[12.5px] leading-snug flex items-center gap-1.5 ${i?"text-honey-dark":"text-fg-faint"}`,children:[i&&e.jsx("span",{"aria-hidden":!0,children:"⚠"}),s]})]}),e.jsx("span",{"data-testid":p,className:"inline-flex",children:e.jsx(K,{checked:n,onChange:a?()=>{}:r,disabled:a})})]})}function Ft({device:t,online:s,onRevoke:n,revoking:r}){const i=t.lastConnectedAt?new Date(t.lastConnectedAt).toLocaleString():`paired ${new Date(t.issuedAt).toLocaleDateString()}`;return e.jsx(je,{testId:"settings-remote-device",icon:"wifi",title:t.deviceName,badge:s?e.jsx(W,{tone:"default",className:"!text-sage !border-sage/40",children:"online"}):void 0,subtitle:`${t.deviceId} · last seen ${i}`,action:e.jsx(ve,{testId:"settings-remote-revoke",onClick:()=>n(t.deviceId),disabled:r})})}const z=t=>(t==null?void 0:t.message)||String(t);function Ut(){var ie;const t=ge(d=>d.show),[s,n]=l.useState(null),[r,i]=l.useState(!0),[a,c]=l.useState(!1),[p,y]=l.useState(!1),[u,h]=l.useState("idle"),[f,m]=l.useState(""),[x,w]=l.useState(null),[k,N]=l.useState(!1),[I,g]=l.useState([]),[S,R]=l.useState(!1),A=l.useRef(null);l.useEffect(()=>{let d=!1;const b=()=>window.api.webRemote.getStatus().then(O=>{d||n(O)}).catch(()=>{});window.api.webRemote.getStatus().then(O=>{d||(n(O),i(!1))}).catch(O=>{d||(t("error",`Remote status: ${z(O)}`),i(!1))});const oe=window.api.webRemote.onStatus(O=>n(O)),ee=window.api.webRemote.onTokenRevoked(()=>{t("warn","Remote device token was revoked. Re-pair to reconnect."),b()}),le=window.api.webRemote.onRevokedAll(({revokedCount:O})=>{t("info",`Panic: all ${O} device(s) revoked and sessions torn down.`),b()});return()=>{d=!0,oe(),ee(),le()}},[t]),l.useEffect(()=>{if(u!=="enter-otp")return;const d=setTimeout(()=>{var b;return(b=A.current)==null?void 0:b.focus()},50);return()=>clearTimeout(d)},[u]);const P=async()=>n(await window.api.webRemote.getStatus()),j=async()=>{if(s){c(!0);try{const d=s.enabled?await window.api.webRemote.disable():await window.api.webRemote.enable();d&&d.ok===!1&&t("error",d.error||"Failed to change remote state."),await P()}catch(d){t("error",`Failed: ${z(d)}`)}finally{c(!1)}}},C=async()=>{if(s){y(!0);try{const d=s.remoteControlEnabled?await window.api.webRemote.disableControl():await window.api.webRemote.enableControl();d&&d.ok===!1&&t("error",d.error||"Failed to change command writes."),await P()}catch(d){t("error",`Failed: ${z(d)}`)}finally{y(!1)}}},L=async()=>{const d=f.trim().toUpperCase();if(!/^[A-Z0-9]{8}$/.test(d)){t("warn","Pairing code must be 8 alphanumeric characters.");return}h("pairing");try{const b=await window.api.webRemote.pair(d);if(!b.ok){t("error",b.error||"Pairing failed."),h("enter-otp");return}t("info","Device paired successfully."),m(""),h("idle"),await P()}catch(b){t("error",`Pairing error: ${z(b)}`),h("enter-otp")}},E=async d=>{w(d);try{const b=await window.api.webRemote.revokeDevice(d);if(!b.ok){t("error",b.error||"Revoke failed.");return}await P()}catch(b){t("error",`Revoke error: ${z(b)}`)}finally{w(null)}},ae=async()=>{N(!0);try{const d=await window.api.webRemote.revokeAll();d.ok||t("error",d.error||"Panic revoke failed.")}catch(d){t("error",`Panic revoke error: ${z(d)}`)}finally{N(!1)}},xe=async()=>{if(S){R(!1);return}try{const d=await window.api.webRemote.auditTail(100);if(!d.ok){t("error",`Audit log: ${d.error||"unavailable"}`);return}g(d.lines??[]),R(!0)}catch(d){t("error",`Audit log: ${z(d)}`)}},Z=async d=>{try{const b=await window.api.webRemote.confirmSas(d);b!=null&&b.ok||t("error",`SAS confirm failed: ${(b==null?void 0:b.error)??"unexpected state — reconnect the mobile app"}`)}catch(b){t("error",`SAS confirm failed: ${z(b)}`)}};if(r)return e.jsx("div",{className:"p-6 text-fg-faint text-sm",children:"Loading…"});const $=(s==null?void 0:s.enabled)??!1,M=(s==null?void 0:s.remoteControlEnabled)??!1,re=(s==null?void 0:s.connected)??!1,V=(s==null?void 0:s.e2eActive)??!1,F=(s==null?void 0:s.e2eAuthenticated)??!1,_=(s==null?void 0:s.e2eState)??"idle",J=(s==null?void 0:s.pendingSas)??null,Q=((s==null?void 0:s.clients)??[]).filter(d=>d.state==="pending_sas"&&d.pendingSas),U=(s==null?void 0:s.devices)??[],G=$&&re,ye=re?((ie=U.reduce((d,b)=>b.lastConnectedAt&&(!d||(d.lastConnectedAt??"")<b.lastConnectedAt)?b:d,null))==null?void 0:ie.deviceId)??null:null;return e.jsxs("div",{"data-testid":"settings-remote",className:"p-4 max-w-[760px] space-y-[22px]",children:[Q.length>0?Q.map((d,b)=>e.jsxs("div",{"data-testid":"settings-remote-sas-row",children:[Q.length>1&&e.jsxs("div",{className:"text-[12px] font-semibold text-fg-dim mb-1",children:["Browser ",b+1]}),e.jsx(Te,{testId:b===0?"settings-remote-sas":void 0,codeTestId:b===0?"settings-remote-sas-code":void 0,confirmTestId:b===0?"settings-remote-sas-confirm":void 0,code:d.pendingSas,onConfirm:()=>Z(d.key)})]},d.key)):J&&e.jsx(Te,{testId:"settings-remote-sas",codeTestId:"settings-remote-sas-code",confirmTestId:"settings-remote-sas-confirm",code:J,onConfirm:()=>Z()}),_==="failed"&&e.jsxs("div",{className:"flex items-center gap-3.5 px-5 py-4 rounded-2xl border border-[#eccdbe] bg-[#f8e8e0]",children:[e.jsx("span",{className:"w-4 h-4 rounded-full bg-accent text-white grid place-items-center text-[11px] font-bold shrink-0",children:"!"}),e.jsxs("div",{className:"text-[13px] text-[#9a3f1f]",children:[e.jsx("strong",{className:"font-semibold",children:"E2E key exchange failed."})," ",e.jsx("span",{className:"text-fg-dim",children:"The session key could not be established. Reconnect the mobile app to retry."})]})]}),e.jsxs("div",{className:`flex items-center gap-3.5 px-5 py-4 rounded-2xl border ${G?"border-[#e8cdb9] bg-[#f5e9df]":"border-line bg-bg-hi"}`,children:[e.jsx("span",{className:`w-[38px] h-[38px] rounded-[11px] shrink-0 grid place-items-center ${G?"bg-[#f0d9c8] text-accent":"bg-[#e4ebd6] text-sage"}`,children:e.jsx(se,{name:G?"wifi":"shield",size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[14.5px] font-semibold text-fg mb-0.5",children:G?"Remote control is active":$?"Remote control is idle":"Remote control is off"}),e.jsx("div",{className:"text-[13px] text-fg-dim leading-snug",children:G?"A web session can send commands to this machine. Revoke below if unexpected.":$&&(s==null?void 0:s.linkState)==="repair-needed"?"The relay no longer recognises this device. Re-pair it with a new code to reconnect.":$?"The relay is on but no device is connected. Pair a device to begin.":"The relay connection is closed — no remote commands are accepted. Enable it below only when you need it."})]}),V&&F?e.jsx(W,{tone:"default",className:"!text-sage !border-sage/40",children:"E2E authenticated"}):V?e.jsx(W,{tone:"warn",children:"E2E · awaiting SAS"}):e.jsx(W,{tone:"dim",children:"relay only · not E2E yet"})]}),e.jsxs("div",{children:[e.jsx(Y,{children:"Remote control"}),e.jsxs("div",{className:"bg-bg-hi border border-line rounded-2xl overflow-hidden",children:[e.jsx(Le,{first:!0,testId:"settings-remote-enable",label:"Allow remote control from the web",hint:"Master switch. When off, the relay refuses every connection.",on:$,disabled:a,onChange:()=>{a||j()}}),e.jsx(Le,{testId:"settings-remote-control",label:"Allow command writes (pty + scheduler)",hint:M?"A paired device can run shell commands and queue jobs on this machine.":"Paired devices can watch session output but cannot send commands.",warn:M,disabled:!$||p,on:M&&$,onChange:()=>{$&&!p&&C()}})]})]}),e.jsxs("div",{children:[e.jsx(Y,{children:"Pair a device"}),u==="idle"?e.jsxs("div",{className:"flex items-center justify-between gap-4 bg-bg-hi border border-line rounded-2xl px-5 py-[18px]",children:[e.jsxs("div",{"data-testid":"settings-remote-pair-hint",className:"text-[13.5px] text-fg-dim leading-relaxed max-w-[420px]",children:["On your phone open ",e.jsx("strong",{className:"text-fg font-semibold",children:"bilko.run/projects/session-manager"}),", sign in, and tap"," ",e.jsx("strong",{className:"text-fg font-semibold",children:"Generate pairing code"}),". Enter the 8-character code here."]}),e.jsx(D,{testId:"settings-remote-pair-start",kind:"soft",icon:"link",onClick:()=>h("enter-otp"),children:"Pair Device…"})]}):e.jsxs("div",{className:"flex items-center gap-5 bg-bg-hi border border-accent/40 rounded-2xl px-6 py-[22px]",children:[e.jsx("span",{className:"w-[52px] h-[52px] rounded-xl bg-bg border border-line grid place-items-center text-accent shrink-0",children:e.jsx(se,{name:"link",size:24})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11.5px] font-bold uppercase tracking-[0.8px] text-fg-faint mb-2",children:"Enter the code from your phone"}),e.jsx("input",{ref:A,"data-testid":"settings-remote-otp",value:f,onChange:d=>m(d.target.value.toUpperCase().replace(/[^A-Z0-9]/g,"")),onKeyDown:d=>{d.key==="Enter"&&L()},maxLength:8,placeholder:"XXXXXXXX",disabled:u==="pairing",className:"w-full bg-transparent border-0 outline-none font-mono text-[30px] font-semibold tracking-[6px] text-fg placeholder:text-fg-faint/40 disabled:opacity-50"})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(D,{testId:"settings-remote-pair-confirm",kind:"soft",onClick:L,disabled:u==="pairing"||f.length<8,children:u==="pairing"?"Pairing…":"Confirm"}),e.jsx(D,{kind:"ghost",onClick:()=>{h("idle"),m("")},disabled:u==="pairing",children:"cancel"})]})]})]}),e.jsxs("div",{children:[e.jsx(Y,{right:U.length>0?e.jsxs("span",{className:"text-[11.5px] text-fg-faint",children:[U.length," paired"]}):void 0,children:"Paired devices"}),U.length===0?e.jsx(At,{children:"No devices paired yet."}):e.jsx("div",{className:"space-y-2",children:U.map(d=>e.jsx(Ft,{device:d,online:d.deviceId===ye,onRevoke:E,revoking:x===d.deviceId},d.deviceId))})]}),e.jsx(Bt,{enabled:$,hasDevice:U.length>0,refreshKey:((s==null?void 0:s.clients)??[]).map(d=>`${d.key}:${d.state}`).join(",")}),e.jsxs("div",{children:[e.jsx(Y,{right:e.jsx("button",{"data-testid":"settings-remote-audit-toggle",onClick:xe,className:"text-[12px] text-fg-faint hover:text-fg-dim transition-colors",children:S?"Hide":"Show last 100 · 0600, stays on this machine"}),children:"Audit log"}),S&&e.jsx("div",{className:"bg-bg-hi border border-line rounded-xl overflow-auto max-h-64 mb-2",children:I.length===0?e.jsx("p",{className:"p-4 text-[12.5px] text-fg-faint",children:"No entries today."}):e.jsx("pre",{"data-testid":"settings-remote-audit",className:"p-4 text-[12px] text-fg-dim font-mono whitespace-pre-wrap leading-relaxed",children:I.join(`
2
+ `)})}),e.jsxs("p",{className:"text-[12px] text-fg-faint",children:["Full log at"," ",e.jsx("code",{className:"font-mono text-fg-faint",children:"~/.claude/session-manager/logs/remote-audit-YYYY-MM-DD.log"})," ","(0600, never leaves this machine)"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4 bg-[#f8e8e0] border border-[#eccdbe] rounded-2xl px-5 py-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"w-4 h-4 rounded-full bg-accent text-white grid place-items-center text-[11px] font-bold shrink-0",children:"!"}),e.jsx("span",{className:"text-sm font-semibold text-[#9a3f1f]",children:"Panic — disconnect & revoke everything"})]}),e.jsx("div",{className:"text-[12.5px] text-fg-dim leading-snug max-w-[440px]",children:"Tears down every active session and invalidates all paired-device tokens. Devices must re-pair. Use if you suspect compromise."})]}),e.jsx("button",{"data-testid":"settings-remote-revoke-all",onClick:ae,disabled:k,className:"shrink-0 rounded-lg bg-accent text-white px-[18px] py-2 text-[13px] font-semibold hover:opacity-90 disabled:opacity-50 transition-opacity",children:k?"Revoking…":"Revoke all"})]})]})}const ce="px-2 py-1 rounded border border-line text-xs text-fg hover:bg-bg-hi disabled:opacity-50";function zt(){const t=at(),s=ge(p=>p.show),n=async p=>{try{const u=await p();u&&u.ok===!1&&s("error",u.error??"Update action failed")}catch(y){s("error",y instanceof Error?y.message:String(y))}};if(!t)return null;const{state:r}=t,i=r==="unsupported",a=t.latest?`v${t.latest}`:"—",c=()=>{window.confirm("Installing now will stop all running jobs and terminals. Continue?")&&n(()=>window.api.updater.install(!0))};return e.jsxs("section",{"data-testid":"settings-updates",className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-fg text-xs font-medium",children:"Updates"}),e.jsxs("div",{className:"text-fg-dim text-xs flex gap-4",children:[e.jsxs("span",{children:["Current v",t.current]}),e.jsxs("span",{children:["Latest ",a]})]})]}),i?e.jsx("p",{className:"text-fg-faint text-[11px]",children:"Auto-update runs only in the installed Windows app or the Linux AppImage. npx builds update via npx."}):e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(K,{checked:t.enabled,onChange:p=>void n(()=>window.api.updater.setEnabled(p)),label:"Update automatically"}),e.jsx("button",{type:"button","data-testid":"updates-check",className:ce,disabled:r==="checking"||r==="downloading",onClick:()=>void n(()=>window.api.updater.check()),children:"Check for updates"})]}),r==="checking"&&e.jsx("p",{className:"text-fg-dim text-xs",children:"Checking…"}),r==="downloading"&&e.jsxs("p",{className:"text-fg-dim text-xs",children:["Downloading… ",t.progress!=null?`${Math.round(t.progress)}%`:""]}),r==="ready"&&e.jsxs("button",{type:"button","data-testid":"updates-install",className:ce,onClick:()=>void n(()=>window.api.updater.install(!1)),children:["Restart to install v",t.latest]}),r==="deferred"&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-fg-dim text-xs",children:["Waiting for ",t.busyReason??"work"," to finish"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",className:ce,onClick:c,children:"Install now"}),e.jsx("button",{type:"button",className:ce,onClick:()=>void n(()=>window.api.updater.cancelDeferred()),children:"Cancel"})]})]}),r==="error"&&e.jsx("p",{className:"text-red-400 text-xs",children:t.error})]})}function Wt(t){return t?t.supported?t.starts==="npx"?"Runs npx claude-code-session-manager@latest at login, so it starts the newest release.":t.starts==="app"?"Starts the installed app at login.":t.reason??"":t.reason??"Start at login is not available here.":"Checking…"}function Vt(){const[t,s]=l.useState(null),[n,r]=l.useState(!1);l.useEffect(()=>{let c=!0;return window.api.loginItem.status().then(p=>{c&&s(p)}).catch(p=>te.error(p instanceof Error?p.message:String(p))),()=>{c=!1}},[]);const i=async c=>{r(!0);try{const p=await window.api.loginItem.setEnabled(c);p.ok?s(p.status):te.error(p.error)}catch(p){te.error(p instanceof Error?p.message:String(p))}finally{r(!1)}},a=(t==null?void 0:t.supported)===!0;return e.jsxs("section",{"data-testid":"settings-start-at-login",className:"space-y-1",children:[e.jsx(K,{checked:(t==null?void 0:t.enabled)===!0,onChange:c=>void i(c),disabled:!a||n,label:"Start at login"}),e.jsx("p",{"data-testid":"start-at-login-desc",className:"text-fg-faint text-[11px]",children:Wt(t)})]})}const Jt=[{key:"maxAgeDays",label:"Run logs: keep for",unit:"days",min:3,max:3650},{key:"runsArchiveDays",label:"Runs archive: keep for",unit:"days",min:1,max:3650},{key:"auditLogMonths",label:"Audit log: keep for",unit:"months",min:1,max:120},{key:"reservedMarkersKeep",label:"Reserved markers: keep",unit:"markers",min:1,max:1e5}],Gt="w-24 px-2 py-1 rounded border border-line bg-transparent text-xs text-fg";function Me(t,s){return s==="maxAgeDays"?t.runLogs.maxAgeDays:t[s]}function qt(t,s){return t==="maxAgeDays"?{runLogs:{maxAgeDays:s}}:{[t]:s}}function Be(t){if(!Number.isFinite(t)||t<=0)return"0 B";const s=["B","KB","MB","GB","TB"];let n=0,r=t;for(;r>=1024&&n<s.length-1;)r/=1024,n++;return`${n===0?r:r.toFixed(1)} ${s[n]}`}function be(t,s,n){return`${t}: ${Be(s)} in ${n.toLocaleString("en-US")} files`}function Xt(){const t=ge(m=>m.show),[s,n]=l.useState(null),[r,i]=l.useState({}),[a,c]=l.useState(null),p=l.useCallback(m=>t("error",m instanceof Error?m.message:String(m)),[t]),y=l.useCallback(async()=>{try{c(await window.api.opsRetention.preview())}catch(m){p(m)}},[p]);l.useEffect(()=>{let m=!0;return window.api.opsRetention.get().then(x=>{m&&n(x)}).catch(x=>{m&&p(x)}),y(),()=>{m=!1}},[p,y]);const u=async m=>{if(!s)return;const x=r[m.key];if(x===void 0)return;const w=Number(x);if(i(N=>{const{[m.key]:I,...g}=N;return g}),x.trim()===""||!Number.isFinite(w))return;const k=Math.min(m.max,Math.max(m.min,Math.round(w)));if(k!==Me(s,m.key))try{n(await window.api.opsRetention.set(qt(m.key,k))),await y()}catch(N){p(N)}},h=a?a.runLogs.bytes+a.runsArchive.bytes+a.tmp.bytes:0,f=a?a.runLogs.files+a.runsArchive.entries+a.tmp.files:0;return e.jsxs("section",{"data-testid":"settings-ops-retention",className:"border border-line rounded p-3 space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-fg text-xs font-medium",children:"Ops data retention"}),e.jsx("p",{className:"text-fg-faint text-[11px]",children:"How long the daily sweep keeps scheduler and audit data. Machine-wide."})]}),s&&e.jsxs("div",{className:"space-y-2",children:[Jt.map(m=>e.jsxs("label",{className:"flex items-center gap-2 text-xs text-fg-dim",children:[e.jsx("span",{className:"w-48",children:m.label}),e.jsx("input",{type:"number","data-testid":`ops-retention-${m.key}`,className:Gt,min:m.min,max:m.max,value:r[m.key]??String(Me(s,m.key)),onChange:x=>i(w=>({...w,[m.key]:x.target.value})),onBlur:()=>void u(m)}),e.jsx("span",{className:"text-fg-faint",children:m.unit})]},m.key)),e.jsx("p",{className:"text-fg-dim text-xs",children:"Archived transcripts: kept forever"})]}),a&&e.jsxs("div",{"data-testid":"ops-retention-preview",className:"space-y-1 text-xs text-fg-dim",children:[e.jsxs("div",{className:"text-fg",children:["Current policy would free ",Be(h)," in ",f.toLocaleString("en-US")," files"]}),e.jsx("div",{children:be("Run logs",a.runLogs.bytes,a.runLogs.files)}),e.jsx("div",{children:be("Runs archive",a.runsArchive.bytes,a.runsArchive.entries)}),e.jsx("div",{children:be("Stale temp files",a.tmp.bytes,a.tmp.files)}),e.jsx("p",{className:"text-fg-faint text-[11px]",children:"Nothing is deleted until the daily sweep runs."})]})]})}const he=[{id:"project",label:"Project & Tab",realm:"machine",blurb:"A PROJECT is a cwd; a TAB is one open project.",tone:{chip:"bg-bg-elev text-fg-dim",border:"border-line",dot:"bg-fg-faint"}},{id:"epic",label:"Epic (PromptSession)",realm:"project",blurb:"The central aggregate root — one unit of work, one claude session.",tone:{chip:"bg-accent-muted text-accent-dark",border:"border-accent",dot:"bg-accent"}},{id:"scheduler",label:"Scheduler",realm:"project",blurb:"PRDs + the headless jobs that execute them.",tone:{chip:"bg-butter/30 text-honey-dark",border:"border-honey",dot:"bg-honey"}},{id:"agents",label:"Agents & Taxonomy",realm:"machine",blurb:"The ACTOR and MISSION halves of AIM.",tone:{chip:"bg-sage/20 text-sage-dark",border:"border-sage",dot:"bg-sage"}},{id:"memory",label:"Memory",realm:"machine",blurb:"Workspace, cross-project, and per-agent memory.",tone:{chip:"bg-hive-teal/20 text-hive-teal",border:"border-hive-teal",dot:"bg-hive-teal"}},{id:"transcript",label:"Transcript & Usage",realm:"machine",blurb:"The Claude CLI's own JSONL, classified events, and billing.",tone:{chip:"bg-bg-hi text-fg-dim",border:"border-rule",dot:"bg-fg-dim"}},{id:"brief",label:"Project Home & Publishing",realm:"project",blurb:"The synthesized Brief, generated pages, and bilko.run publish state.",tone:{chip:"bg-accent-muted/60 text-accent-dark",border:"border-accent-muted",dot:"bg-accent-muted"}},{id:"config",label:"Machine Config",realm:"machine",blurb:"Settings, layout, and the single-writer ownership map.",tone:{chip:"bg-line text-fg-faint",border:"border-rule",dot:"bg-fg-faint"}}];function Fe(t){const s=he.find(n=>n.id===t);if(!s)throw new Error(`unknown ErdGroupId: ${t}`);return s}const ne=[{id:"project",name:"Project",aka:"cwd — Main Project",group:"project",store:{path:"identity only, no record of its own — folded at read time from ~/.claude/projects/<encoded>",format:"in-memory",definedIn:"src/renderer/lib/knownProjectAggregate.ts (aggregateProjectsByCwd) "},summary:"A folder whose cwd never resolved from transcript content is DROPPED, never guessed — the naive decode once reported 2044 phantom projects.",fields:[{name:"cwd",type:"string",key:"pk",note:"resolved working directory — the project's identity"},{name:"name",type:"string",note:"display name: the cwd's last path segment"},{name:"encoded",type:"string",note:"representative transcript folder (most recently active)"},{name:"encodedIds",type:"string[]",note:"every ~/.claude/projects/<encoded> folder that resolved to this cwd"},{name:"sessionCount",type:"number"},{name:"sizeBytes",type:"number"},{name:"lastSession",type:"number"}]},{id:"tab",name:"PersistedTab",aka:"TAB",group:"project",store:{path:"~/.claude/session-manager/tabs.json",format:"json",definedIn:"src/main/sessionsStore.cjs "},summary:"One TAB per project — extra sessions within a project are Epics, not tabs.",fields:[{name:"id",type:"string",key:"pk"},{name:"sessionId",type:"string"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"label",type:"string"},{name:"presetId",type:"string | null"}]},{id:"epic",name:"PromptSession",aka:"EPIC",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/active-index.json -> sessions[id]",format:"json",writer:"epics",definedIn:"src/main/lib/epic/epicMint.cjs (ensureEpic) + src/renderer/state/promptSessions.ts "},summary:"The central aggregate root — created in exactly ONE place, a human pressing New Epic.",fields:[{name:"id",type:"string",key:"pk"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"goalText",type:"string",note:"the original top-level prompt text that started this goal"},{name:"claudeSessionId",type:"string",note:"independently minted — never shared with any tab.sessionId"},{name:"status",type:"'proposed' | 'active' | 'completed'"},{name:"createdAt",type:"string"},{name:"completedAt",type:"string | null"},{name:"resumedFromId",type:"string",optional:!0,key:"fk",ref:"epic.id"},{name:"tag",type:"TicketTag",optional:!0,key:"fk",ref:"tag.tag"},{name:"openingPrompt",type:"string | null",optional:!0},{name:"source",type:"EpicSource",optional:!0,note:"{ producer, prdSlug?, runId?, sourceTabId?, fromCwd?, fromEpicId? }"},{name:"agentType",type:"string",optional:!0,key:"fk",ref:"agentPersona.name"},{name:"model",type:"string",optional:!0,note:"per-Epic model override; absent = the persona model"},{name:"effort",type:"string",optional:!0,note:"per-Epic effort override; absent = the persona effort"},{name:"developLoop",type:"false",optional:!0,note:"false = started with the develop loop off; absent = on"},{name:"restoredSession",type:"true",optional:!0,note:"claudeSessionId adopted from an existing CLI session"},{name:"agentCli",type:"string",optional:!0,note:"agent CLI running the session; absent = Claude Code; fixed for the session"},{name:"agentCliModel",type:"string",optional:!0,note:"model string passed to agentCli; absent = its default"},{name:"sections",type:"EpicIntakeSection[]",optional:!0},{name:"worktree",type:"{ dir, branch, baseCwd, status, conflictReason? }",optional:!0,note:"own git worktree on branch 'sm-epic/<id>' when Active"}],notes:["SINGLE-CREATOR LAW, fail-closed in epicMint.cjs — the New Epic IPC handler and crossProjectFeedback.cjs are the only mint authorities.","Every Epic is born proposed; nothing is created directly as active.","EPIC : claude-session is 1:1 — Chat and Terminal are two VIEWS over one session.","Title + objective are fixed for the life of the session — iterate in follow-up messages, don't repurpose."]},{id:"epicEvent",name:"PromptSessionEvent",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/active-index.json -> events[]",format:"json",writer:"epics",definedIn:"src/renderer/state/promptSessions.ts + src/main/lib/epic/activeIndexMerge.cjs "},summary:"One step in an Epic's Prompt → PRD → Response → ... → Closed chain.",fields:[{name:"id",type:"string",key:"pk"},{name:"promptSessionId",type:"string",key:"fk",ref:"epic.id"},{name:"kind",type:"'prompt' | 'prd_created' | 'response' | 'closed'"},{name:"causedByEventId",type:"string | null",key:"fk",ref:"epicEvent.id",note:"must be the session's current tail event — a chain, not a tree"},{name:"at",type:"string"},{name:"prdSlug",type:"string",optional:!0,key:"fk",ref:"prd.slug"},{name:"text",type:"string",optional:!0},{name:"outcome",type:"'completed' | 'failed' | 'needs_review'",optional:!0},{name:"validation",type:"'unvalidated' | 'validating' | 'verified' | 'refuted'",optional:!0}]},{id:"epicTranscriptTurn",name:"PromptSessionTranscriptTurn",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/transcripts/<epicId>.jsonl",format:"jsonl",writer:"epics",definedIn:"src/main/promptSessionTranscript.cjs "},summary:"The durable per-Epic transcript store, kept alongside the CLI's own JSONL as a fallback source of turns.",fields:[{name:"v",type:"1"},{name:"epicId",type:"string",key:"fk",ref:"epic.id"},{name:"eventId",type:"string | null",key:"fk",ref:"epicEvent.id"},{name:"role",type:"'user' | 'assistant'"},{name:"at",type:"string"},{name:"text",type:"string"}]},{id:"epicArchive",name:"PromptSessionArchive",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/<epicId>.json",format:"json",writer:"epics",definedIn:"src/renderer/state/promptSessions.ts (promptSessionArchivePath) "},summary:"On-disk archive written once at completion — freezes the Epic, its events, and its transcript.",fields:[{name:"session",type:"PromptSession"},{name:"events",type:"PromptSessionEvent[]"},{name:"transcript",type:"string"},{name:"archivedAt",type:"string"},{name:"durableTurns",type:"Array<{ role, text, at }>",optional:!0}]},{id:"epicWorktreeConfig",name:"EpicWorktreeConfig",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/epic-worktree-config.json",format:"json",writer:"epics",definedIn:"src/main/lib/epic/epicWorktreeProjectConfig.cjs "},summary:"Per-project 'disable Epic worktree isolation' toggle, read by gitWorktree.cjs's isWorktreeDisabled('epic', cwd) on every worktree creation attempt.",fields:[{name:"disabled",type:"boolean"}],notes:["One-shot migration from the legacy machine-wide ~/.claude/session-manager/epic-worktree-project-config.json map, keyed by project cwd — that file is left in place, never deleted."]},{id:"exchange",name:"Exchange",group:"epic",store:{path:"<cwd>/session-manager-operations/prompt-sessions/exchanges.jsonl",format:"jsonl",writer:"epics",definedIn:"src/main/exchanges.cjs "},summary:"One durable NDJSON record per completed terminal-chat exchange, appended off the hot path.",fields:[{name:"ts",type:"string"},{name:"sessionId",type:"string",key:"fk",ref:"epic.claudeSessionId",note:"the tab's claude session id"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"prompt",type:"string"},{name:"result",type:"string"},{name:"summary",type:"string",note:"produced by the shared Haiku summarizer"},{name:"model",type:"string"},{name:"degraded",type:"string",optional:!0,note:"set when summarization failed — the exchange itself is never dropped"},{name:"promptId",type:"string",optional:!0,key:"fk",ref:"prd.slug",note:"originating PromptTicket.id when dispatched from the per-tab queue; forward-only, never backfilled"}],notes:["Written via raw fs O_APPEND (not config.cjs writeJson) for atomicity across concurrent writers — assertOpsWrite is called explicitly since raw fs bypasses the normal enforcement point.","Historical rows from before this store existed remain, untouched and unmigrated, in the old global ~/.claude/knowledge-log/exchanges/<encodeCwd(cwd)>.jsonl."]},{id:"prd",name:"PRD",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/epics/<epicId>/prds/<slug>.md",format:"markdown",writer:"scheduler",definedIn:"src/main/lib/prd/prdLocations.cjs + scheduler_create_prd MCP tool "},summary:"PRD authoring is API-only via the scheduler_create_prd MCP tool — a PRD joins an EXISTING Epic and never conjures one.",fields:[{name:"slug",type:"string",key:"pk",note:"<nn>-<kebab-title>.md filename stem"},{name:"title",type:"string"},{name:"cwd",type:"string",key:"fk",ref:"project.cwd"},{name:"epicId",type:"string | null",key:"fk",ref:"epic.id",note:"derived from the PRD's DIRECTORY — fact on disk"},{name:"sourcePromptId",type:"string",optional:!0,key:"fk",ref:"epic.id",note:"frontmatter intent — can disagree with epicId"},{name:"sourceTabId",type:"string",optional:!0},{name:"estimateMinutes",type:"number"},{name:"tag",type:"'feature' | 'bug' | 'discussion' | 'build' | 'project-home-builder' | 'art' | 'portfolio'",optional:!0,key:"fk",ref:"tag.tag"},{name:"dependsOn",type:"string[]",optional:!0,key:"fk",ref:"prd.slug",note:"the SOLE ordering primitive"},{name:"goal",type:"string"},{name:"acceptanceCriteria",type:"string[]"},{name:"implementationNotes",type:"string"},{name:"outOfScope",type:"string[]",optional:!0},{name:"createdVia",type:"string",optional:!0},{name:"issuedAt",type:"string",optional:!0}],notes:["Flat scheduler/prds/ is RETIRED — auto-consolidated into prds-archived/ on every reconcile() pass.","epicId is derived from the DIRECTORY (fact on disk) while sourcePromptId is frontmatter intent and can disagree."]},{id:"scheduleJob",name:"ScheduleJob",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/queue.json -> jobs[]",format:"json",writer:"scheduler",definedIn:"src/main/lib/scheduler/queueStore.cjs + src/main/lib/scheduler/scheduleJobSchema.cjs "},summary:"dependsOn is the SOLE ordering primitive — parallelGroup is a display hint, never a barrier.",fields:[{name:"slug",type:"string",key:"pk",note:"shared identity with the PRD it executes"},{name:"title",type:"string"},{name:"cwd",type:"string | null",key:"fk",ref:"project.cwd"},{name:"parallelGroup",type:"number"},{name:"estimateMinutes",type:"number | null"},{name:"bodyPreview",type:"string"},{name:"status",type:"'pending' | 'running' | 'investigating' | 'completed' | 'failed' | 'needs_review' | 'quarantined'"},{name:"runId",type:"string | null",key:"fk",ref:"runLog.runId"},{name:"startedAt",type:"string | null"},{name:"finishedAt",type:"string | null"},{name:"exitCode",type:"number | null"},{name:"error",type:"string | null"},{name:"sessionId",type:"string",optional:!0},{name:"runtime",type:"ScheduleJobRuntime",optional:!0,note:"{ pid, runId, startedAt, sessionId?, cwd? }"},{name:"verifierVerdict",type:"string",optional:!0},{name:"dependsOn",type:"string[]",optional:!0,key:"fk",ref:"prd.slug"},{name:"originSessionId",type:"string | null",optional:!0,key:"fk",ref:"epic.id"},{name:"sourceTabId",type:"string | null",optional:!0},{name:"sourcePromptId",type:"string | null",optional:!0,key:"fk",ref:"epic.id"},{name:"epicId",type:"string | null",optional:!0,key:"fk",ref:"epic.id",note:"authoritative — derived from the PRD directory"},{name:"statusHistory",type:"ScheduleJobStatusHistoryEntry[]",optional:!0}],notes:["Every launch must take a slot from lib/scheduler/sessionSlots.cjs — the single machine-wide concurrency limit.","--model is always pinned on every claude -p call site.","A job in needs_review is a QUESTION routed back to the authoring Epic and never creates work on its own."]},{id:"scheduleJobStatusHistory",name:"ScheduleJobStatusHistoryEntry",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/queue.json -> jobs[].statusHistory[]",format:"json",writer:"scheduler",definedIn:"src/main/lib/scheduler/scheduleJobTransitions.cjs "},summary:"Bounded trail (~20 entries) of accepted status transitions for one ScheduleJob.",fields:[{name:"from",type:"string | null"},{name:"to",type:"string"},{name:"reason",type:"string | null"},{name:"source",type:"string | null"},{name:"at",type:"string"}]},{id:"scheduleHistoryEntry",name:"Schedule history entry",group:"scheduler",store:{path:"<cwd>/session-manager-operations/scheduler/state/history.jsonl",format:"jsonl",writer:"scheduler",definedIn:"src/main/lib/scheduler/queueStore.cjs "},summary:"Terminal jobs aged out of queue.json land here, one JSON object per line.",fields:[{name:"slug",type:"string",key:"fk",ref:"prd.slug"},{name:"status",type:"ScheduleJobStatus"},{name:"finishedAt",type:"string | null"},{name:"epicId",type:"string | null",optional:!0,key:"fk",ref:"epic.id"},{name:"runId",type:"string | null",optional:!0,key:"fk",ref:"runLog.runId"}]},{id:"scheduleConfig",name:"ScheduleConfig",group:"scheduler",store:{path:"~/.claude/session-manager/scheduler-machine.json",format:"json",writer:"scheduler",definedIn:"src/main/lib/scheduler/schedulerConfig.cjs + src/main/lib/scheduler/queueStore.cjs "},summary:"Machine-level auto-fire policy and utilization gate (scheduler-machine.json, not per-project queue.json).",fields:[{name:"enabled",type:"boolean",note:"legacy on/off, kept for v0.4 backwards compat"},{name:"offsetMinutes",type:"number"},{name:"defaultCwd",type:"string",key:"fk",ref:"project.cwd"},{name:"firePolicy",type:"'manual' | 'when-available'"},{name:"utilizationThreshold",type:"number"},{name:"schemaVersion",type:"1"}]},{id:"runLog",name:"Run log",group:"scheduler",store:{path:"~/.claude/session-manager/scheduled-plans/runs/<runId>/",format:"directory",definedIn:"src/main/scheduler.cjs (RUNS_DIR) "},summary:"One directory per headless claude -p invocation — stdout/stderr/exit capture for a ScheduleJob's run.",fields:[{name:"runId",type:"string",key:"pk"}]},{id:"agentPersona",name:"AgentPersona",aka:"ACTOR",group:"agents",store:{path:"~/.claude/agents/<name>.md",format:"markdown",definedIn:"src/main/agentLibrary.cjs + src/main/lib/persona-macro/agentPersonaSchema.cjs "},summary:"One global persona. The action/actionLabel frontmatter keys are retired legacy fields — no longer a live concept.",fields:[{name:"name",type:"string",key:"pk"},{name:"description",type:"string | null"},{name:"tools",type:"string[]"},{name:"model",type:"string | null",note:"wins over the Settings default for this Epic"},{name:"color",type:"string | null"},{name:"tags",type:"AgentPersonaTag[]",key:"fk",ref:"tag.tag"},{name:"projects",type:"string[]",key:"fk",ref:"project.cwd",note:"'*' means every project"},{name:"effort",type:"string | null",optional:!0,note:"per-Epic carve-out like model — persona frontmatter wins over the Settings default"},{name:"title",type:"string | null",optional:!0},{name:"path",type:"string"},{name:"body",type:"string"},{name:"overridingProjects",type:"string[]"}]},{id:"tag",name:"Tag",aka:"MISSION — EpicTag",group:"agents",store:{path:"src/renderer/lib/tagLibrary.ts (TAG_LIBRARY)",format:"code",definedIn:"src/renderer/lib/tagLibrary.ts + src/renderer/lib/agentTagDefs.ts "},summary:"The closed 7-tag union — Epic creation is agentType (who) + tag (what), two independent selections.",fields:[{name:"tag",type:"'feature' | 'bug' | 'discussion' | 'build' | 'project-home-builder' | 'art' | 'portfolio'",key:"pk"},{name:"label",type:"string"},{name:"description",type:"string"},{name:"developEagerness",type:"'expected-default' | 'available-not-assumed'"},{name:"developsVia",type:"string"}]},{id:"macro",name:"Macro",aka:"HOT KEY",group:"agents",store:{path:"~/.claude/session-manager/macros.json",format:"json",writer:"src/main/lib/persona-macro/macroLibrary.cjs",definedIn:"src/main/lib/persona-macro/macroLibrary.cjs "},summary:"A saved (agent, tag, prompt) hot key — machine-local library; a Sessions hot key is shown per project, a Project Home tool in every project; pressing it is the same act as New Session.",fields:[{name:"id",type:"string",key:"pk"},{name:"label",type:"string"},{name:"agentName",type:"string",key:"fk",ref:"agentPersona.name"},{name:"tag",type:"TicketTag",key:"fk",ref:"tag.tag"},{name:"prompt",type:"string"},{name:"projects",type:"string[]",key:"fk",ref:"project.cwd"},{name:"surface",type:"string"},{name:"builtin",type:"boolean",optional:!0},{name:"builtinVersion",type:"number",optional:!0},{name:"createdAt",type:"string"},{name:"updatedAt",type:"string"},{name:"inputs",type:"MacroInput[]",optional:!0},{name:"autoStartTargets",type:"string[]",optional:!0,key:"fk",ref:"project.cwd"}]},{id:"memoryEntry",name:"MemoryEntry",group:"memory",store:{path:"~/.claude/projects/<encodedCwd>/memory/<name>.md",format:"markdown",definedIn:"src/main/memoryTool.cjs "},summary:"One workspace memory file, semantically organized by topic.",fields:[{name:"name",type:"string",key:"pk"},{name:"path",type:"string"},{name:"mtimeMs",type:"number"},{name:"bytes",type:"number"},{name:"workspace",type:"string",key:"fk",ref:"project.cwd",note:"carried on MemoryListResult, denormalized here — the directory this entry lives under"}]},{id:"memoryCluster",name:"MemoryCluster",group:"memory",store:{path:"<cwd>/session-manager-operations/memory-clusters/clusters.json",format:"json",writer:"memory-clusters",definedIn:"src/main/memoryAggregate.cjs "},summary:"Derived grouping of related MemoryEntry files, computed and cached per workspace.",fields:[{name:"id",type:"string",key:"pk"},{name:"name",type:"string"},{name:"summary",type:"string"},{name:"memberSlugs",type:"string[]",key:"fk",ref:"memoryEntry.name"},{name:"links",type:"MemoryClusterLink[]",note:"{ from, to, label? }"}]},{id:"agentMemoryEntry",name:"AgentMemoryEntry",group:"memory",store:{path:"~/.claude/agent-memory/<agent>/ | .claude/agent-memory/<agent>/ | .claude/agent-memory-local/<agent>/",format:"directory",definedIn:"src/main/lib/memoryDirResolve.cjs (resolveAgentMemoryDir)"},summary:"Per-subagent memory in Claude Code's native agent-memory directories (user, project, local scope), keyed by agent name — markdown files with a MEMORY.md index.",fields:[{name:"agent",type:"string",key:"pk",ref:"agentPersona.name",note:"directory name under the scope root"},{name:"scope",type:"'user' | 'project' | 'local'",note:"selects which agent-memory root resolveAgentMemoryDir returns"},{name:"files",type:"markdown[]",note:"topic files plus MEMORY.md index, read live from disk"}]},{id:"claudeTranscript",name:"Claude transcript",group:"transcript",store:{path:"~/.claude/projects/<encodedCwd>/<sessionUuid>.jsonl",format:"jsonl",definedIn:"written by the Claude Code CLI; tailed by src/main/transcripts.cjs "},summary:"The CLI's own append-only transcript — Session Manager only tails and classifies it, never writes it.",fields:[{name:"sessionUuid",type:"string",key:"pk"},{name:"encodedCwd",type:"string",key:"fk",ref:"project.cwd"}]},{id:"transcriptEvent",name:"TranscriptEvent",group:"transcript",store:{path:"in-memory ring buffer, broadcast as transcript:event:<tabId>",format:"in-memory",definedIn:"src/main/transcripts.cjs -> src/renderer/state/live.ts "},summary:"Classified, bounded-preview view over one raw transcript line — never the source of truth.",fields:[{name:"kind",type:"TranscriptEventKind"},{name:"data",type:"unknown"},{name:"raw",type:"unknown"},{name:"previewText",type:"string"},{name:"ref",type:"TranscriptEventRef | null",note:"{ filePath, byteOffset, byteLength }"},{name:"tabId",type:"string",key:"fk",ref:"tab.id"}]},{id:"historyRollupDay",name:"History rollup day",group:"transcript",store:{path:"~/.claude/session-manager/history-rollup.jsonl",format:"jsonl",definedIn:"src/main/lib/historyRollup.cjs "},summary:"One finalized day-per-project analytics row (History tab is analytics/cost/charts only).",fields:[{name:"date",type:"string",key:"pk"},{name:"projectCwd",type:"string",key:"fk",ref:"project.cwd"},{name:"promptCount",type:"number"},{name:"inputTokens",type:"number"},{name:"outputTokens",type:"number"},{name:"estimatedCostUsd",type:"number"}]},{id:"billingUsage",name:"UsageSnapshot",group:"transcript",store:{path:"~/.claude/session-manager/billing-cache.json",format:"json",definedIn:"src/main/usage.cjs (CACHE_PATH) "},summary:"Cached rolling-window utilization percentages from the account's billing API.",fields:[{name:"five_hour",type:"UsageWindow | null"},{name:"seven_day",type:"UsageWindow | null"},{name:"seven_day_sonnet",type:"UsageWindow | null"},{name:"seven_day_opus",type:"UsageWindow | null"},{name:"seven_day_oauth_apps",type:"UsageWindow | null"},{name:"extra_usage",type:"{ is_enabled, monthly_limit, used_credits, utilization, currency } | null"}]},{id:"projectBrief",name:"ProjectBrief",group:"brief",store:{path:"<cwd>/session-manager-operations/project-brief/brief.json",format:"json",writer:"project-home",definedIn:"src/main/projectBrief.cjs "},summary:"The synthesized project Brief — generated, with a hand-edit escape hatch.",fields:[{name:"version",type:"number"},{name:"synthesizedAt",type:"string"},{name:"editedAt",type:"string | null"},{name:"model",type:"string"},{name:"purpose",type:"string"},{name:"what",type:"string[]"},{name:"areas",type:"ProjectBriefArea[]",note:"{ name, files, note, epic, heat }"},{name:"scope",type:"ProjectBriefScopeEntry[]",note:"{ when, kind, text, src }"},{name:"conventions",type:"string[]"},{name:"pins",type:"{ what: boolean; conventions: boolean }"},{name:"pinned",type:"{ what: string[] | null; conventions: string[] | null }"}]},{id:"projectPages",name:"ProjectPagesOutput",group:"brief",store:{path:"<cwd>/session-manager-operations/project-pages/ (knowledge/<id>/, videos/<id>/, videos/_character/)",format:"directory",writer:"project-home",definedIn:"src/main/lib/feedback-remote/projectHomeAdminRoutes.cjs (pages, videos and character routes)"},summary:"The Project Home library: Knowledge Pages and Video Pages, each a folder holding index.html + meta.json.",fields:[{name:"html",type:"string | null"},{name:"mtimeMs",type:"number | null"}]},{id:"settingsScope",name:"Settings (scoped)",group:"config",store:{path:"~/.claude/settings.json + <cwd>/.claude/settings.json + <cwd>/.claude/settings.local.json",format:"json",definedIn:"src/main/config.cjs + src/renderer/state/config.ts + src/renderer/lib/mergeScopes.ts "},summary:"Substrate, not per-Epic curation — model is the one field carved out per-Epic (persona wins over Settings).",fields:[{name:"scope",type:"'system' | 'project' | 'local'",key:"pk"},{name:"cwd",type:"string",optional:!0,key:"fk",ref:"project.cwd"},{name:"model",type:"string",optional:!0}]},{id:"layoutEnvelope",name:"LayoutEnvelope",group:"config",store:{path:"~/.claude/session-manager/workbench-layout.json",format:"json",definedIn:"src/main/layoutStore.cjs + src/renderer/state/layout.ts "},summary:"Persisted dockview panel layout, pruned against the live panel registry on hydrate.",fields:[{name:"version",type:"number"},{name:"panels",type:"string[]",key:"fk",ref:"tab.id"},{name:"dockview",type:"Record<string, unknown>",note:"opaque SerializedDockview blob"}]},{id:"opsNamespace",name:"Ops namespace ownership",aka:"the SINGLE-WRITER LAW",group:"config",store:{path:"src/main/lib/opsOwnership.cjs (OWNERS)",format:"code",definedIn:"src/main/lib/opsOwnership.cjs (assertOpsWrite) "},summary:"Fail-closed — a new top-level ops folder must land in OWNERS (or the deliberately-unowned list) in the same PR that creates it.",fields:[{name:"namespace",type:"string",key:"pk",note:"e.g. 'prompt-sessions', 'scheduler', 'project-brief'"},{name:"writer",type:"string",note:"e.g. 'epics', 'scheduler', 'project-home'"}]},{id:"mcpServerRegistry",name:"MCP server registry",aka:"mcpServers",group:"config",store:{path:"~/.claude.json -> mcpServers",format:"json",definedIn:"src/renderer/components/tabs/McpServers.tsx "},summary:"User-scope MCP server config — no single writer, since both the claude CLI and this app read/write the same file.",fields:[{name:"name",type:"string",key:"pk"},{name:"type",type:"'stdio' | 'http' | 'sse' | 'ws' | 'streamable-http'",optional:!0},{name:"command",type:"string",optional:!0},{name:"args",type:"string[]",optional:!0},{name:"url",type:"string",optional:!0},{name:"env",type:"Record<string, string>",optional:!0},{name:"headers",type:"Record<string, string>",optional:!0},{name:"alwaysLoad",type:"boolean",optional:!0},{name:"enabled",type:"boolean",optional:!0},{name:"disabledTools",type:"string[]",optional:!0}]},{id:"pluginRegistry",name:"Installed plugins manifest",aka:"installed_plugins.json",group:"config",store:{path:"~/.claude/plugins/installed_plugins.json",format:"json",definedIn:"src/renderer/components/tabs/Plugins.tsx "},summary:'Registry of installed plugin versions, keyed by "<name>@<marketplace>" — written by `claude plugin install`, read-only in the Plugins screen.',fields:[{name:"pluginKey",type:"string",key:"pk",note:"<name>@<marketplace>"},{name:"scope",type:"string"},{name:"installPath",type:"string"},{name:"version",type:"string"},{name:"installedAt",type:"string"},{name:"lastUpdated",type:"string"},{name:"gitCommitSha",type:"string",optional:!0}]},{id:"systemPrompt",name:"User CLAUDE.md",aka:"~/.claude/CLAUDE.md",group:"config",store:{path:"~/.claude/CLAUDE.md",format:"markdown",definedIn:"src/renderer/components/tabs/SystemPrompt.tsx "},summary:"The real ~/.claude/CLAUDE.md the claude CLI loads into every session it starts on this machine, in every project — edited here as plain markdown.",fields:[{name:"content",type:"string"},{name:"imports",type:"string[]",note:"@-imported files, listed in a left rail"}]},{id:"skillsAndCommands",name:"Skills & Commands",group:"config",store:{path:"~/.claude/skills/**/SKILL.md + ~/.claude/commands/*.md (and the <cwd>/.claude equivalents for project scope)",format:"directory",definedIn:"src/renderer/components/tabs/Skills.tsx "},summary:"User- and project-scope skill/command markdown files, each editable in place.",fields:[{name:"kind",type:"'skills' | 'commands'"},{name:"scope",type:"'user' | 'project'"},{name:"name",type:"string",key:"pk"},{name:"path",type:"string",note:"absolute path to the editable markdown file"},{name:"dir",type:"string | null",note:"skill directory, if applicable"},{name:"disabled",type:"boolean",note:"skills only — disable-model-invocation: true frontmatter"},{name:"description",type:"string",optional:!0}]},{id:"mcpStatusProbe",name:"MCP status probe",group:"config",store:{path:"in-memory result of `claude mcp list`, never persisted",format:"in-memory",definedIn:"src/main/mcpStatus.cjs (runProbe) "},summary:"Read-only, non-polling live connection probe — models an in-memory-only shape honestly, the same way transcriptEvent does.",fields:[{name:"ok",type:"boolean"},{name:"servers",type:"McpServerStatus[]",note:"{ name, target, transport, status }"},{name:"error",type:"string",optional:!0},{name:"checkedAt",type:"number"}]},{id:"appPrefs",name:"App preferences",aka:"app-prefs / ui-settings-prefs / ui-chrome-prefs",group:"config",store:{path:"~/.claude/session-manager/app-prefs.json + ~/.claude/session-manager/ui-settings-prefs.json + ~/.claude/session-manager/ui-chrome-prefs.json",format:"json",definedIn:"src/renderer/lib/appPrefs.ts (app-prefs.json) + src/renderer/lib/uiSettingsPrefs.ts (ui-settings-prefs.json) + src/renderer/state/uiChromePrefs.ts (ui-chrome-prefs.json) "},summary:"Three small machine-level renderer-owned pref files, read/written through window.api.config — distinct from scheduler-machine.json.",fields:[{name:"openToHomeOnLaunch",type:"boolean",optional:!0,note:"app-prefs.json — read by layout.ts at boot"},{name:"uiSettings",type:"Record<string, unknown>",optional:!0,note:"ui-settings-prefs.json — Settings page UI state"},{name:"uiChrome",type:"Record<string, unknown>",optional:!0,note:"ui-chrome-prefs.json — app chrome UI state"}]},{id:"uiPrefs",name:"UiPrefs",aka:"ui-prefs/prefs.json",group:"config",store:{path:"<cwd>/session-manager-operations/ui-prefs/prefs.json",format:"json",writer:"ui-prefs",definedIn:"src/renderer/lib/uiPrefs.ts "},summary:"Per-project UI state that used to live in scattered global/localStorage keys — one file per project keeps it scoped to the project it belongs to by construction (PRD 1398/1399).",fields:[{name:"fileTreeExpanded",type:"string[]",optional:!0,note:"FileTree.tsx — expanded folder paths in the Files sidebar"},{name:"hiddenCompletedSlugs",type:"string[]",optional:!0,note:'SchedulePanel.tsx — "Clear completed" hides, renderer-side only'},{name:"queueFilterStatus",type:"string",optional:!0,note:"SchedulePanel.tsx — the queue's status filter chip"},{name:"epicPins",type:"Record<string, boolean>",optional:!0,key:"fk",ref:"epic.id",note:"epicsPrefs.ts — pinned-to-top Epic ids, keyed by epicId (moved off the global epics-prefs.json)"},{name:"chatVerbosityPerEpic",type:"Record<string, ChatVerbosity>",optional:!0,key:"fk",ref:"epic.id",note:"chatPrefs.ts — per-Epic verbosity overrides, keyed by epicId (moved off the global chat-prefs.json)"},{name:"editorSession",type:"{ openFiles: string[]; activeFilePath: string | null; viewModeByPath: Record<string, string> }",optional:!0,note:"editor.ts — the Editor scene's structural tab strip only; buffers/baselines/dirty are never persisted (PRD 1400)"}]}];function ke(t){const s=ne.find(n=>n.id===t);if(!s)throw new Error(`unknown ErdEntity id: ${t}`);return s}const Ue=[{from:"tab",to:"project",cardinality:"N-1",label:"belongs to"},{from:"epic",to:"project",cardinality:"N-1",label:"belongs to"},{from:"epic",to:"tag",cardinality:"N-1",label:"mission",optional:!0},{from:"epic",to:"agentPersona",cardinality:"N-1",label:"actor",optional:!0},{from:"epic",to:"epic",cardinality:"N-1",label:"resumed from",optional:!0},{from:"epic",to:"claudeTranscript",cardinality:"1-1",label:"1:1 session"},{from:"epicEvent",to:"epic",cardinality:"N-1",label:"belongs to"},{from:"epicEvent",to:"epicEvent",cardinality:"N-1",label:"caused by",optional:!0},{from:"epicEvent",to:"prd",cardinality:"N-1",label:"about",optional:!0},{from:"epicTranscriptTurn",to:"epic",cardinality:"N-1",label:"belongs to"},{from:"epicTranscriptTurn",to:"epicEvent",cardinality:"N-1",label:"labeled by",optional:!0},{from:"epicArchive",to:"epic",cardinality:"1-1",label:"freezes"},{from:"exchange",to:"epic",cardinality:"N-1",label:"session for",optional:!0},{from:"exchange",to:"project",cardinality:"N-1",label:"belongs to"},{from:"prd",to:"epic",cardinality:"N-1",label:"joins (directory fact)"},{from:"prd",to:"epic",cardinality:"N-1",via:"sourcePromptId",label:"authored from (frontmatter intent)",optional:!0},{from:"prd",to:"project",cardinality:"N-1",label:"belongs to"},{from:"prd",to:"tag",cardinality:"N-1",label:"mission",optional:!0},{from:"scheduleJob",to:"prd",cardinality:"1-1",label:"executes"},{from:"scheduleJob",to:"prd",cardinality:"N-N",via:"dependsOn",label:"depends on",optional:!0},{from:"scheduleJob",to:"epic",cardinality:"N-1",label:"belongs to",optional:!0},{from:"scheduleJob",to:"runLog",cardinality:"N-1",label:"ran as",optional:!0},{from:"scheduleJob",to:"scheduleJob",cardinality:"N-N",via:"dependsOn",label:"depends on (self)",optional:!0},{from:"scheduleJobStatusHistory",to:"scheduleJob",cardinality:"N-1",label:"transitions of"},{from:"scheduleHistoryEntry",to:"prd",cardinality:"N-1",label:"archives"},{from:"scheduleHistoryEntry",to:"epic",cardinality:"N-1",label:"belongs to",optional:!0},{from:"scheduleHistoryEntry",to:"runLog",cardinality:"N-1",label:"ran as",optional:!0},{from:"scheduleConfig",to:"project",cardinality:"1-1",label:"configures"},{from:"agentPersona",to:"tag",cardinality:"N-N",label:"tagged with"},{from:"agentPersona",to:"project",cardinality:"N-N",label:"scoped to"},{from:"memoryEntry",to:"project",cardinality:"N-1",label:"workspace"},{from:"memoryCluster",to:"memoryEntry",cardinality:"1-N",label:"clusters"},{from:"agentMemoryEntry",to:"agentPersona",cardinality:"N-1",label:"belongs to"},{from:"transcriptEvent",to:"tab",cardinality:"N-1",label:"classified for"},{from:"transcriptEvent",to:"claudeTranscript",cardinality:"N-1",label:"classified from"},{from:"claudeTranscript",to:"project",cardinality:"N-1",label:"belongs to"},{from:"historyRollupDay",to:"project",cardinality:"N-N",label:"aggregates"},{from:"billingUsage",to:"scheduleConfig",cardinality:"1-N",label:"gates when-available firing"},{from:"projectBrief",to:"project",cardinality:"1-1",label:"describes"},{from:"projectBrief",to:"epic",cardinality:"N-1",via:"areas[].epic",label:"traces to",optional:!0},{from:"projectPages",to:"project",cardinality:"1-1",label:"generated for"},{from:"settingsScope",to:"project",cardinality:"N-1",label:"scoped to",optional:!0},{from:"layoutEnvelope",to:"tab",cardinality:"1-N",label:"panels for"},{from:"opsNamespace",to:"epic",cardinality:"1-N",label:"governs writes"},{from:"opsNamespace",to:"prd",cardinality:"1-N",label:"governs writes"},{from:"opsNamespace",to:"projectBrief",cardinality:"1-N",label:"governs writes"}];function ze(t){return Ue.filter(s=>s.from===t||s.to===t)}function Yt(t){const s=new Set;for(const n of ze(t)){const r=n.from===t?n.to:n.from;r!==t&&s.add(r)}return[...s]}function Kt(t){switch(t){case"1-1":return"1—1";case"1-N":return"1—N";case"N-1":return"N—1";case"N-N":return"N—N"}}const De=220,we=7,Zt=44,Qt=16,es=10,ts=96,ss=28,de=24;function ns(t){const s=Math.min(t,we)+(t>we?1:0);return Zt+s*Qt+es}function as(t){const s=t.x+t.w,n=t.y+t.h*.35,r=t.y+t.h*.65,i=s+48;return{d:`M ${s} ${n} C ${i} ${n}, ${i} ${r}, ${s} ${r}`,mx:i,my:(n+r)/2}}function rs(t=ne,s=Ue){const n=he.map(u=>u.id).filter(u=>t.some(h=>h.group===u)),r=[],i=new Map;n.forEach((u,h)=>{const f=de+h*(De+ts);let m=de;for(const x of t){if(x.group!==u)continue;const w=ns(x.fields.length),k={id:x.id,group:u,x:f,y:m,w:De,h:w};r.push(k),i.set(x.id,k),m+=w+ss}});const a=new Set(t.map(u=>u.id)),c=[];for(const u of s){if(!a.has(u.from)||!a.has(u.to))continue;const h=i.get(u.from),f=i.get(u.to);if(!h||!f)continue;if(u.from===u.to){const A=as(h);c.push({relation:u,...A});continue}const m=h.x<f.x,x=m?h.x+h.w:h.x,w=h.y+h.h/2,k=m?f.x:f.x+f.w,N=f.y+f.h/2,I=Math.max(40,Math.abs(k-x)/2),g=x+(m?I:-I),S=k+(m?-I:I),R=`M ${x} ${w} C ${g} ${w}, ${S} ${N}, ${k} ${N}`;c.push({relation:u,d:R,mx:(x+k)/2,my:(w+N)/2})}const p=r.reduce((u,h)=>Math.max(u,h.x+h.w),0),y=r.reduce((u,h)=>Math.max(u,h.y+h.h),0);return{boxes:r,edges:c,width:p+de,height:y+de}}const is=[{key:"diagram",label:"Diagram"},{key:"tables",label:"Tables"}];function os(){const[t,s]=l.useState("diagram"),[n,r]=l.useState(null),[i,a]=l.useState(()=>new Set),c=l.useMemo(()=>ne.filter(f=>!i.has(f.group)),[i]),p=l.useMemo(()=>rs(c),[c]),y=f=>{a(m=>{const x=new Set(m);return x.has(f)?x.delete(f):x.add(f),x}),r(null)},u=n?ke(n):null,h=f=>c.some(m=>m.id===f);return e.jsx(ht,{toolbar:e.jsxs(e.Fragment,{children:[e.jsx(He,{options:is,active:t,onChange:s}),e.jsx(cs,{hiddenGroups:i,onToggle:y}),e.jsxs("span",{className:"ml-auto text-fg-faint",children:[ne.length," entities"]})]}),children:t==="diagram"?e.jsxs("div",{className:"h-full flex",children:[e.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:e.jsx(ds,{layout:p,selectedId:n,onSelect:f=>r(m=>m===f?null:f)})}),e.jsx("div",{className:"w-96 shrink-0 border-l border-line overflow-y-auto",children:u?e.jsx(ms,{entity:u,onSelectRelated:f=>h(f)?r(f):void 0}):e.jsx(fe,{title:"select an entity",hint:"click a box in the diagram to see its storage, fields, and relations"})})]}):e.jsx(us,{})})}const ls=l.memo(os);function cs({hiddenGroups:t,onToggle:s}){return e.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:he.map(n=>{const r=t.has(n.id);return e.jsxs("button",{onClick:()=>s(n.id),title:`${n.blurb} (${n.realm})`,className:`flex items-center gap-1 px-1.5 py-0.5 rounded border text-[10.5px] ${r?"border-line text-fg-faint opacity-50":"border-line text-fg-dim hover:text-fg"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${n.tone.dot}`}),n.label,e.jsx("span",{className:"text-fg-faint",children:n.realm})]},n.id)})})}function ds({layout:t,selectedId:s,onSelect:n}){const r=l.useMemo(()=>s?new Set(Yt(s)):null,[s]),i=a=>!!s&&(a.relation.from===s||a.relation.to===s);return t.boxes.length===0?e.jsx(fe,{title:"no entities in view",hint:"toggle a group in the legend to show its entities"}):e.jsxs("div",{className:"relative p-4",style:{width:t.width+32,height:t.height+32},children:[e.jsxs("svg",{width:t.width,height:t.height,className:"absolute left-4 top-4 overflow-visible",children:[t.edges.map(a=>{const c=i(a);return e.jsx("path",{"data-testid":`erd-edge-${a.relation.from}-${a.relation.to}`,d:a.d,fill:"none",className:c?"stroke-accent":"stroke-line",strokeWidth:c?2:1,opacity:s&&!c?.25:1},`${a.relation.from}-${a.relation.to}-${a.relation.label}`)}),t.edges.map(a=>i(a)?e.jsx("text",{x:a.mx,y:a.my,textAnchor:"middle",className:"fill-fg-dim text-[10px]",children:a.relation.label},`label-${a.relation.from}-${a.relation.to}-${a.relation.label}`):null)]}),t.boxes.map(a=>e.jsx(ps,{box:a,selected:a.id===s,dimmed:!!s&&a.id!==s&&!(r!=null&&r.has(a.id)),onClick:()=>n(a.id)},a.id))]})}function ps({box:t,selected:s,dimmed:n,onClick:r}){const i=ke(t.id),a=Fe(t.group),c=i.fields.slice(0,we),p=i.fields.length-c.length;return e.jsxs("button",{type:"button","data-testid":`erd-box-${t.id}`,onClick:r,className:`absolute text-left rounded border overflow-hidden bg-bg-hi ${s?"border-accent ring-1 ring-accent":"border-line"} ${n?"opacity-30":""}`,style:{left:t.x,top:t.y,width:t.w,height:t.h},children:[e.jsxs("div",{className:"px-2 py-1 border-b border-line flex items-center gap-1.5",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${a.tone.dot}`}),e.jsx("span",{className:"text-[11px] font-semibold text-fg truncate",children:i.name})]}),i.aka&&e.jsx("div",{className:"px-2 pt-0.5 text-[9.5px] text-fg-faint truncate",children:i.aka}),e.jsxs("div",{className:"px-2 py-0.5",children:[c.map(y=>e.jsxs("div",{className:"text-[9.5px] font-mono text-fg-dim truncate flex items-center gap-1",children:[y.key&&e.jsx("span",{className:"text-fg-faint",children:y.key}),e.jsx("span",{className:"truncate",children:y.name})]},y.name)),p>0&&e.jsxs("div",{className:"text-[9.5px] text-fg-faint italic",children:["+",p," more"]})]})]})}function We({fields:t}){return e.jsxs("table",{className:"w-full text-[11px] font-mono",children:[e.jsx("thead",{className:"text-fg-faint uppercase tracking-wide text-[9.5px]",children:e.jsxs("tr",{className:"border-b border-line",children:[e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"name"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"type"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"key"}),e.jsx("th",{className:"text-left font-normal px-2 py-1",children:"note"})]})}),e.jsx("tbody",{children:t.map(s=>e.jsxs("tr",{className:"border-b border-line/50",children:[e.jsxs("td",{className:"px-2 py-1 text-fg",children:[s.name,s.optional&&e.jsx("span",{className:"text-fg-faint",children:"?"})]}),e.jsx("td",{className:"px-2 py-1 text-fg-dim",children:s.type}),e.jsx("td",{className:"px-2 py-1",children:s.key&&e.jsxs(W,{tone:s.key==="pk"?"accent":"dim",children:[s.key,s.ref?` → ${s.ref}`:""]})}),e.jsx("td",{className:"px-2 py-1 text-fg-faint",children:s.note})]},s.name))})]})}function Ve({entity:t}){return e.jsxs("div",{className:"space-y-1 text-[11px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"path"}),e.jsx("span",{className:"font-mono text-fg-dim break-all",children:t.store.path})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"format"}),e.jsx("span",{className:"font-mono text-fg-dim",children:t.store.format})]}),t.store.writer&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"writer"}),e.jsxs(W,{tone:"accent",children:["single-writer: ",t.store.writer]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-fg-faint w-20 shrink-0",children:"definedIn"}),e.jsx("span",{className:"font-mono text-fg-dim break-all",children:t.store.definedIn})]})]})}function ms({entity:t,onSelectRelated:s}){const n=Fe(t.group),r=ze(t.id);return e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${n.tone.dot}`}),e.jsx("span",{className:"text-sm font-semibold text-fg",children:t.name})]}),t.aka&&e.jsx("div",{className:"text-[10.5px] text-fg-faint",children:t.aka}),e.jsx(W,{tone:"dim",className:"mt-1",children:n.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:t.summary}),e.jsxs("div",{children:[e.jsx(pe,{children:"storage"}),e.jsx(Ve,{entity:t})]}),e.jsxs("div",{children:[e.jsx(pe,{children:"fields"}),e.jsx(We,{fields:t.fields})]}),t.notes&&t.notes.length>0&&e.jsxs("div",{children:[e.jsx(pe,{children:"notes"}),e.jsx("ul",{className:"list-disc pl-4 space-y-0.5 text-xs text-fg-dim",children:t.notes.map(i=>e.jsx("li",{children:i},i))})]}),e.jsxs("div",{children:[e.jsx(pe,{children:"relations"}),r.length===0?e.jsx("div",{className:"text-xs text-fg-faint italic",children:"no relations"}):e.jsx("ul",{className:"space-y-1",children:r.map(i=>{const a=i.from===t.id?i.to:i.from,c=ke(a);return e.jsxs("li",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:"font-mono text-fg-faint w-10 shrink-0",children:Kt(i.cardinality)}),e.jsx("span",{className:"text-fg-dim",children:i.label}),i.via&&e.jsxs("span",{className:"font-mono text-[10px] text-fg-faint",children:["via ",i.via]}),e.jsx("button",{type:"button",onClick:()=>s(a),className:"ml-auto text-accent hover:underline font-mono",children:c.name})]},`${i.from}-${i.to}-${i.label}`)})})]})]})}function pe({children:t}){return e.jsx("div",{className:"text-[10.5px] uppercase tracking-wide text-fg-faint mb-1 font-mono",children:t})}function us(){return e.jsx("div",{className:"p-4 space-y-6",children:he.map(t=>{const s=ne.filter(n=>n.group===t.id);return s.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${t.tone.dot}`}),e.jsx("span",{className:"text-xs font-semibold text-fg",children:t.label}),e.jsx("span",{className:"text-[10.5px] text-fg-faint",children:t.realm})]}),e.jsx("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-3",children:s.map(n=>e.jsxs("div",{className:"border border-line rounded bg-bg-hi p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-fg",children:n.name}),n.aka&&e.jsx("span",{className:"text-[10.5px] text-fg-faint",children:n.aka})]}),e.jsx(W,{tone:"dim",className:"mt-1",children:t.label})]}),e.jsx("div",{className:"text-xs text-fg-dim leading-relaxed",children:n.summary}),e.jsx(Ve,{entity:n}),e.jsx(We,{fields:n.fields}),n.notes&&n.notes.length>0&&e.jsx("ul",{className:"list-disc pl-4 space-y-0.5 text-xs text-fg-dim",children:n.notes.map(r=>e.jsx("li",{children:r},r))})]},n.id))})]},t.id)})})}const Oe=[{key:"voice",label:"Voice"},{key:"appearance",label:"Appearance"},{key:"telemetry",label:"Telemetry"},{key:"remote",label:"Web remote"},{key:"updates",label:"Updates & retention"},{key:"startup",label:"Startup"},{key:"storage",label:"Storage map"}],fs={compact:"Compact",roomy:"Roomy"},gs=".claude/session-manager";function hs({files:t}){const s=lt();return e.jsx("div",{className:"flex flex-wrap gap-2 px-4 pt-3","data-testid":"app-settings-chips",children:t.map(n=>{const r=n.path.startsWith("~/")?s?s+n.path.slice(1):null:n.path;return r?e.jsx(ut,{path:r,keyPath:n.keyPath},n.path):null})})}function xs(){const[t,s]=l.useState(!1),[n,r]=l.useState(!1);l.useEffect(()=>{let a=!0;return pt().then(c=>{a&&s(c.openToHomeOnLaunch===!0)}),()=>{a=!1}},[]);const i=async a=>{s(a),r(!0);try{await mt({openToHomeOnLaunch:a})}catch{s(!a),te.error('Failed to save "Open to Home on launch" — try again.')}finally{r(!1)}};return e.jsxs("div",{className:"p-4 max-w-3xl space-y-3 text-sm",children:[e.jsx(K,{checked:t,onChange:i,disabled:n,label:"Open to Home on launch"}),e.jsx(Vt,{})]})}function ys(){const{density:t,setDensity:s}=ct();return e.jsxs("div",{className:"p-4 max-w-3xl space-y-5 text-sm",children:[e.jsx(St,{}),e.jsxs("section",{className:"border border-line rounded p-3 space-y-1",children:[e.jsx("span",{className:"text-fg-dim text-xs",children:"Density"}),e.jsx(dt,{options:["compact","roomy"],value:t,onChange:n=>s(n),labels:fs}),e.jsx("span",{className:"text-fg-faint text-[11px]",children:"Compact tightens spacing across the app's chrome; Roomy is the default."})]})]})}const X=(t,s)=>({path:`~/${gs}/${t}`,keyPath:s}),bs={voice:[X("voice.json")],appearance:[{path:ot,keyPath:["terminal"]},X("ui-chrome-prefs.json")],telemetry:[X("telemetry.json"),X("otel.json")],remote:[X("web-remote.json")],updates:[X("updater.json"),X("ops-retention.json")],startup:[{path:it,keyPath:["openToHomeOnLaunch"]}],storage:[]};function Ss(){const[t,s]=l.useState("voice");return rt("app-settings",n=>{Oe.some(r=>r.key===n)&&s(n)}),e.jsxs("div",{className:"flex flex-col h-full min-h-0","data-testid":"app-settings",children:[e.jsx("div",{className:"flex items-center px-4 pt-3",children:e.jsx(He,{options:Oe,active:t,onChange:s})}),e.jsx(hs,{files:bs[t]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-auto","data-testid":`app-settings-${t}`,children:[t==="voice"&&e.jsx(bt,{open:!0,onClose:()=>{},variant:"page"}),t==="appearance"&&e.jsx(ys,{}),t==="telemetry"&&e.jsx(Tt,{}),t==="remote"&&e.jsx(Ut,{}),t==="updates"&&e.jsxs("div",{className:"p-4 max-w-3xl space-y-5",children:[e.jsx(zt,{}),e.jsx(Xt,{})]}),t==="startup"&&e.jsx(xs,{}),t==="storage"&&e.jsx(ls,{})]})]})}export{Ss as AppSettings};