inplan 0.1.11 → 0.1.12

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.
package/app/main/index.js CHANGED
@@ -8,7 +8,8 @@ import { resolve, basename, relative, dirname, join, isAbsolute } from "path";
8
8
  import { createHash, verify, createPublicKey } from "crypto";
9
9
  import { homedir } from "os";
10
10
  import { homedir as homedir$1 } from "node:os";
11
- import { randomUUID } from "node:crypto";
11
+ import { randomUUID, randomBytes } from "node:crypto";
12
+ import { createServer } from "node:http";
12
13
  import __cjs_mod__ from "node:module";
13
14
  const __filename = import.meta.filename;
14
15
  const __dirname = import.meta.dirname;
@@ -721,6 +722,7 @@ const PUBLIC_KEY = "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAVP11te5E7xzNJ4re
721
722
  const SCHEME = "inplan-plugin";
722
723
  const cacheDir = () => join$1(process.env.INPLAN_HOME || join$1(homedir$1(), ".inplan"), "plugin-cache");
723
724
  let state = null;
725
+ let resolvedBundle = null;
724
726
  function setStatusSession(file, session2) {
725
727
  try {
726
728
  const { statusPath } = docPaths(file);
@@ -748,14 +750,17 @@ function pluginInfo() {
748
750
  async function startDesktopPlugin(file, getToken) {
749
751
  await stopDesktopPlugin();
750
752
  try {
751
- const token = await getToken();
752
- const bundle = await resolveDesktopPlugin({ apiBase: PLUGIN_HTTP, token, cacheDir: cacheDir(), publicKey: PUBLIC_KEY });
753
- const mainName = bundle?.entries.main;
754
- const rendererName = bundle?.entries.renderer;
755
- if (!bundle || !mainName || !rendererName || !bundle.files[mainName] || !bundle.files[rendererName]) return;
756
- const mod = await import(pathToFileURL(bundle.files[mainName]).href);
757
- const started = await mod.start(file);
758
- state = { file, session: started.session, rendererPath: bundle.files[rendererName], stop: () => started.stop() };
753
+ if (!resolvedBundle) {
754
+ const token = await getToken();
755
+ const bundle = await resolveDesktopPlugin({ apiBase: PLUGIN_HTTP, token, cacheDir: cacheDir(), publicKey: PUBLIC_KEY });
756
+ const mainName = bundle?.entries.main;
757
+ const rendererName = bundle?.entries.renderer;
758
+ if (!bundle || !mainName || !rendererName || !bundle.files[mainName] || !bundle.files[rendererName]) return;
759
+ const mod = await import(pathToFileURL(bundle.files[mainName]).href);
760
+ resolvedBundle = { mod, rendererPath: bundle.files[rendererName] };
761
+ }
762
+ const started = await resolvedBundle.mod.start(file);
763
+ state = { file, session: started.session, rendererPath: resolvedBundle.rendererPath, stop: () => started.stop() };
759
764
  setStatusSession(file, started.session);
760
765
  process.stderr.write(`[inplan] desktop plugin active for ${file}
761
766
  `);
@@ -774,6 +779,79 @@ async function stopDesktopPlugin() {
774
779
  });
775
780
  }
776
781
  }
782
+ function startCloudSignIn(cloudBase, timeoutMs = 5 * 6e4) {
783
+ return new Promise((resolveStart) => {
784
+ const state2 = randomBytes(16).toString("hex");
785
+ let settled = false;
786
+ let listening = false;
787
+ let timer = null;
788
+ let resolveDone;
789
+ const done = new Promise((res) => {
790
+ resolveDone = res;
791
+ });
792
+ const finish = (result) => {
793
+ if (settled) return;
794
+ settled = true;
795
+ if (timer) clearTimeout(timer);
796
+ try {
797
+ server.close();
798
+ } catch {
799
+ }
800
+ resolveDone(result);
801
+ };
802
+ const CORS = { "access-control-allow-origin": "*", "access-control-allow-methods": "POST, OPTIONS", "access-control-allow-headers": "content-type" };
803
+ const server = createServer((req, res) => {
804
+ const reqUrl = new URL(req.url ?? "/", "http://127.0.0.1");
805
+ if (reqUrl.pathname !== "/cb") {
806
+ res.writeHead(404);
807
+ res.end();
808
+ return;
809
+ }
810
+ if (req.method === "OPTIONS") {
811
+ res.writeHead(204, CORS);
812
+ res.end();
813
+ return;
814
+ }
815
+ if (req.method !== "POST") {
816
+ res.writeHead(405, CORS);
817
+ res.end();
818
+ return;
819
+ }
820
+ let body = "";
821
+ req.on("data", (chunk) => {
822
+ body += chunk;
823
+ if (body.length > 1e6) req.destroy();
824
+ });
825
+ req.on("end", () => {
826
+ let creds = {};
827
+ try {
828
+ creds = JSON.parse(body || "{}");
829
+ } catch {
830
+ }
831
+ const { state: echoed, url, anon, refresh, email } = creds;
832
+ if (echoed !== state2 || !url || !anon || !refresh) {
833
+ res.writeHead(400, { ...CORS, "content-type": "application/json" });
834
+ res.end('{"ok":false}');
835
+ return;
836
+ }
837
+ res.writeHead(200, { ...CORS, "content-type": "application/json" });
838
+ res.end('{"ok":true}');
839
+ finish({ url, anon, refresh, email: email ?? void 0 });
840
+ });
841
+ });
842
+ server.on("error", () => {
843
+ finish(null);
844
+ if (!listening) resolveStart(null);
845
+ });
846
+ server.listen(0, "127.0.0.1", () => {
847
+ listening = true;
848
+ const port = server.address().port;
849
+ const authUrl = `${cloudBase}/cli-auth?port=${port}&state=${encodeURIComponent(state2)}`;
850
+ timer = setTimeout(() => finish(null), timeoutMs);
851
+ resolveStart({ authUrl, done, cancel: () => finish(null) });
852
+ });
853
+ });
854
+ }
777
855
  const __dirname$1 = dirname$1(fileURLToPath(import.meta.url));
778
856
  registerPluginScheme();
779
857
  const pluginToken = () => runCli(["token"]).then((r) => {
@@ -809,7 +887,8 @@ let quitFallbackTimer = null;
809
887
  const QUIT_CONFIRM_TIMEOUT_MS = 8e3;
810
888
  const navHistory = [];
811
889
  let navIdx = -1;
812
- function runCli(args) {
890
+ let activeSignIn = null;
891
+ function runCli(args, extraEnv) {
813
892
  return new Promise((res) => {
814
893
  const cli = process.env.INPLAN_CLI;
815
894
  if (!cli) {
@@ -819,7 +898,8 @@ function runCli(args) {
819
898
  execFile(
820
899
  process.execPath,
821
900
  [cli, ...args],
822
- { env: { ...process.env, ELECTRON_RUN_AS_NODE: "1" } },
901
+ { env: { ...process.env, ...extraEnv, ELECTRON_RUN_AS_NODE: "1" } },
902
+ // RUN_AS_NODE last: never overridable
823
903
  (err, stdout, stderr) => {
824
904
  const code = err && typeof err.code === "number" ? Number(err.code) : err ? 1 : 0;
825
905
  res({ code, stdout, stderr });
@@ -868,17 +948,19 @@ async function readProfile() {
868
948
  }
869
949
  const user = id.name ? { name: id.name, ...id.email ? { email: id.email } : {} } : null;
870
950
  const actions = [];
951
+ let who = {};
952
+ try {
953
+ who = JSON.parse((await runCli(["whoami"])).stdout.trim() || "{}");
954
+ } catch {
955
+ }
871
956
  if (cloudLinkEnabled) {
872
- let who = {};
873
- try {
874
- who = JSON.parse((await runCli(["whoami"])).stdout.trim() || "{}");
875
- } catch {
876
- }
877
957
  if (who.signedIn) {
878
958
  actions.push({ id: "collaborate", label: "Collaborate on Cloud", primary: true }, { id: "signout", label: "Sign out", danger: true });
879
959
  } else {
880
960
  actions.push({ id: "signin", label: "Sign in…" });
881
961
  }
962
+ } else if (who.signedIn) {
963
+ actions.push({ id: "signout", label: "Sign out", danger: true });
882
964
  }
883
965
  return { user, agentLocation: null, actions, identitySource: id.source ?? null };
884
966
  }
@@ -952,7 +1034,7 @@ async function refreshPluginAndView(file) {
952
1034
  await stopDesktopPlugin();
953
1035
  await startDesktopPlugin(file, pluginToken);
954
1036
  if (!win || !session) return;
955
- if (pluginInfo()) win.webContents.reload();
1037
+ if (pluginInfo()) win.webContents.send("plugin:reactivate");
956
1038
  else win.webContents.send("doc:navigated", session.load());
957
1039
  }
958
1040
  function quitNow(reason) {
@@ -1132,6 +1214,7 @@ ${body.replace(/\s*$/, "")}
1132
1214
  sendNavState();
1133
1215
  }
1134
1216
  });
1217
+ ipcMain.handle("nav:get", () => ({ canBack: navIdx > 0, canForward: navIdx < navHistory.length - 1 }));
1135
1218
  ipcMain.handle("nav:go", (_e, dir) => {
1136
1219
  const target = dir === "back" ? navIdx - 1 : navIdx + 1;
1137
1220
  if (target < 0 || target >= navHistory.length) return;
@@ -1168,6 +1251,7 @@ ${body.replace(/\s*$/, "")}
1168
1251
  await runCli(["profile", "set", "--name", name, ...identity.email && identity.email.trim() ? ["--email", identity.email.trim()] : []]);
1169
1252
  win?.webContents.send("profile:changed");
1170
1253
  });
1254
+ ipcMain.handle("cloud:signin-cancel", () => activeSignIn?.cancel());
1171
1255
  ipcMain.handle("profile:action", async (_e, id) => {
1172
1256
  if (id === "collaborate") {
1173
1257
  await collaborateOnCloud();
@@ -1176,13 +1260,30 @@ ${body.replace(/\s*$/, "")}
1176
1260
  win?.webContents.send("profile:changed");
1177
1261
  void i18n.bootstrap();
1178
1262
  } else if (id === "signin") {
1179
- dialog.showMessageBoxSync(win, {
1180
- type: "info",
1181
- message: "Sign in to inplan.ai",
1182
- detail: "Run `inplan login` in your terminal to connect this app to your inplan.ai account, then reopen this menu."
1183
- });
1184
- win?.webContents.send("profile:changed");
1185
- void i18n.bootstrap();
1263
+ activeSignIn?.cancel();
1264
+ const handoff = await startCloudSignIn(CLOUD_BASE);
1265
+ if (!handoff) {
1266
+ if (win && !win.isDestroyed()) dialog.showMessageBoxSync(win, { type: "error", message: "Couldn't start sign-in.", detail: "Please try again." });
1267
+ return;
1268
+ }
1269
+ activeSignIn = handoff;
1270
+ win?.webContents.send("cloud:signin-open", { url: handoff.authUrl });
1271
+ const creds = await handoff.done;
1272
+ if (activeSignIn !== handoff) return;
1273
+ activeSignIn = null;
1274
+ win?.webContents.send("cloud:signin-close");
1275
+ if (creds) {
1276
+ const r = await runCli(["login", ...creds.email ? ["--email", creds.email] : []], {
1277
+ INPLAN_SUPABASE_URL: creds.url,
1278
+ INPLAN_SUPABASE_ANON_KEY: creds.anon,
1279
+ INPLAN_REFRESH_TOKEN: creds.refresh
1280
+ });
1281
+ if (r.code !== 0 && win && !win.isDestroyed()) {
1282
+ dialog.showMessageBoxSync(win, { type: "error", message: "Couldn't complete sign-in.", detail: r.stderr.trim() || "Please try again." });
1283
+ }
1284
+ win?.webContents.send("profile:changed");
1285
+ void i18n.bootstrap();
1286
+ }
1186
1287
  }
1187
1288
  });
1188
1289
  ipcMain.handle("i18n:get", () => i18n.getSnapshot());
@@ -107,9 +107,17 @@ const api = {
107
107
  },
108
108
  navigate: (dir) => ipcRenderer.invoke("nav:go", dir),
109
109
  onNavState: (cb) => {
110
+ let active = true;
110
111
  const h = (_e, s) => cb(s);
111
112
  ipcRenderer.on("nav:state", h);
112
- return () => ipcRenderer.removeListener("nav:state", h);
113
+ void ipcRenderer.invoke("nav:get").then((s) => {
114
+ if (active && s) cb(s);
115
+ }).catch(() => {
116
+ });
117
+ return () => {
118
+ active = false;
119
+ ipcRenderer.removeListener("nav:state", h);
120
+ };
113
121
  },
114
122
  onNavigated: (cb) => {
115
123
  const h = (_e, payload) => cb(payload);
@@ -125,6 +133,22 @@ const api = {
125
133
  },
126
134
  applyUpdate: () => ipcRenderer.invoke("app:apply-update"),
127
135
  restartApp: () => ipcRenderer.invoke("app:restart"),
136
+ // Cloud sign-in overlay: main asks the renderer to show the /cli-auth page in an in-app modal
137
+ // (onOpen), tears it down when the handoff settles (onClose), and `cancel` lets a backdrop
138
+ // dismiss abort the handoff.
139
+ cloudSignIn: {
140
+ onOpen: (cb) => {
141
+ const h = (_e, p) => cb(p.url);
142
+ ipcRenderer.on("cloud:signin-open", h);
143
+ return () => ipcRenderer.removeListener("cloud:signin-open", h);
144
+ },
145
+ onClose: (cb) => {
146
+ const h = () => cb();
147
+ ipcRenderer.on("cloud:signin-close", h);
148
+ return () => ipcRenderer.removeListener("cloud:signin-close", h);
149
+ },
150
+ cancel: () => void ipcRenderer.invoke("cloud:signin-cancel")
151
+ },
128
152
  // First-run tour: durable flag from ~/.inplan (read synchronously so the very first
129
153
  // render decides without a flash); `setOnboarded` persists it on finish/skip.
130
154
  onboarded: ipcRenderer.sendSync("onboarding:get"),
@@ -132,3 +156,8 @@ const api = {
132
156
  };
133
157
  contextBridge.exposeInMainWorld("api", api);
134
158
  contextBridge.exposeInMainWorld("__inplanPlugin", () => ipcRenderer.invoke("plugin:info"));
159
+ contextBridge.exposeInMainWorld("__inplanOnReactivate", (cb) => {
160
+ const h = () => cb();
161
+ ipcRenderer.on("plugin:reactivate", h);
162
+ return () => ipcRenderer.removeListener("plugin:reactivate", h);
163
+ });
@@ -36,7 +36,12 @@ body {
36
36
  -webkit-font-smoothing: antialiased;
37
37
  text-rendering: optimizeLegibility;
38
38
  }
39
- .ap-app { display: flex; flex-direction: column; height: 100%; }
39
+ /* Clamp the shell to the viewport so ONLY the inner panes scroll (preview / rail / source).
40
+ `height:100%` resolves to auto when an embedder (e.g. the web host) mounts us in a parent
41
+ without a definite height — the shell then grows to its full content height and the whole
42
+ page scrolls, carrying the top bar + banners off-screen. `100dvh` (with a 100vh fallback)
43
+ is self-clamping regardless of the parent, and `overflow:hidden` stops any shell-level scroll. */
44
+ .ap-app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
40
45
  .ap-loading { padding: 2rem; color: var(--muted); }
41
46
 
42
47
  /* top bar */
@@ -88,7 +93,11 @@ body {
88
93
  .ap-profile-section .ap-settings-row { padding: 6px 10px; }
89
94
  .ap-profile-section .ap-settings-hint { padding: 0 10px 2px; }
90
95
  /* Toggle switch (shared: profile settings + review-diff hunks). */
91
- .ap-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
96
+ /* position:relative CONTAINS the visually-hidden absolute input (below) within the switch.
97
+ Without it the input's containing block is the document, so deep in a tall pane (e.g. a long
98
+ review diff) clicking a toggle focuses an input resolved far down the page → the browser scrolls
99
+ the whole webview to it (off the fixed-height app shell, into white). */
100
+ .ap-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; position: relative; }
92
101
  .ap-switch.disabled { opacity: 0.5; cursor: default; }
93
102
  .ap-switch-row { display: flex; justify-content: space-between; width: 100%; }
94
103
  .ap-profile-section .ap-switch-row { padding: 6px 10px; font-size: 13px; }
@@ -115,7 +124,10 @@ body {
115
124
  .ap-agent-local { background: #2bb673; } /* agent on your machine */
116
125
  .ap-agent-off { background: var(--danger); } /* no agent connected */
117
126
  .ap-agent-pie { width: 13px; height: 13px; border-radius: 50%; flex: 0 0 auto; }
118
- .ap-agent-menu { position: absolute; top: 34px; left: 0; z-index: 40; width: 220px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 8px; }
127
+ /* Anchor to the trigger's RIGHT edge (it sits on the right of the topbar) so the 220px menu opens
128
+ leftward and stays on-screen — left:0 made it overflow off the right of the viewport, clipping the
129
+ item labels. Mirrors .ap-profile-menu. */
130
+ .ap-agent-menu { position: absolute; top: 34px; right: 0; z-index: 40; width: 220px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 8px; }
119
131
  .ap-agent-detail { font-size: 12px; padding: 2px 6px 6px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
120
132
  .ap-agent-quota { font-size: 11px; color: var(--muted); margin-top: 2px; }
121
133
  .ap-agent-policy { display: flex; flex-direction: column; gap: 2px; }
@@ -124,6 +136,13 @@ body {
124
136
  .ap-policy-dot { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--line-strong); flex: 0 0 auto; }
125
137
  .ap-agent-policy-opt.active { color: inherit; font-weight: 600; }
126
138
  .ap-agent-policy-opt.active .ap-policy-dot { background: var(--accent); border-color: var(--accent); }
139
+ /* "Wait for my local agent" → the copy-pasteable command for a local agent to serve this doc. */
140
+ .ap-agent-localcmd { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
141
+ .ap-agent-localcmd-hint { font-size: 11px; color: var(--muted); padding: 0 6px 5px; }
142
+ .ap-agent-localcmd-row { display: flex; align-items: stretch; gap: 6px; }
143
+ .ap-agent-localcmd-msg { flex: 1; min-width: 0; font-size: 11px; line-height: 1.45; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; color: var(--fg); user-select: text; -webkit-user-select: text; }
144
+ .ap-agent-localcmd-copy { flex: 0 0 auto; border: 1px solid var(--line-strong); background: var(--bg); border-radius: 6px; padding: 0 9px; font: inherit; font-size: 11px; cursor: pointer; color: var(--fg); }
145
+ .ap-agent-localcmd-copy:hover { background: var(--accent-soft); }
127
146
 
128
147
  .ap-topbar button, .ap-tabs button { font: inherit; }
129
148
  .ap-topbar > button { border: 1px solid var(--line-strong); background: var(--bg); border-radius: 7px; padding: 4px 12px; cursor: pointer; color: var(--fg); }
@@ -139,6 +158,9 @@ body {
139
158
  .ap-iconbtn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: 1px solid var(--line-strong); background: var(--bg); border-radius: 7px; color: var(--fg); cursor: pointer; transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease; }
140
159
  .ap-iconbtn:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
141
160
  .ap-iconbtn:disabled { opacity: 0.4; cursor: default; }
161
+ /* A toggle icon button that's currently "on" (e.g. an open side panel). */
162
+ .ap-iconbtn.active { background: var(--accent); border-color: var(--accent); color: #fbfaf6; }
163
+ .ap-iconbtn-fallback { font-size: 13px; font-weight: 600; line-height: 1; }
142
164
  .ap-iconbtn .ap-dirty { position: absolute; top: 2px; right: 2px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); border: 1.5px solid var(--bg); }
143
165
  .ap-iconbtn--primary { width: auto; gap: 6px; font-weight: 500; }
144
166
  /* Scoped to beat the more-specific `.ap-topbar > button` rule above (the primary is a
@@ -157,7 +179,27 @@ body {
157
179
  .ap-banner-reload { background: #f6ecdd; }
158
180
 
159
181
  /* main layout */
160
- .ap-main { flex: 1; display: flex; min-height: 0; }
182
+ .ap-main { flex: 1; display: flex; min-height: 0; position: relative; }
183
+ /* "Bump" handle on the preview's top-left that reveals a host side panel (e.g. the TOC). */
184
+ .ap-sidepanel-bump {
185
+ position: absolute; top: 12px; left: 0; z-index: 20;
186
+ display: inline-flex; align-items: center; justify-content: center;
187
+ width: 20px; height: 38px; padding: 0;
188
+ border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 9px 9px 0;
189
+ background: var(--bg); color: var(--fg); cursor: pointer; opacity: 0.55;
190
+ box-shadow: 0 2px 8px -4px rgba(28, 26, 23, 0.4);
191
+ transition: opacity 0.14s ease, color 0.14s ease, background 0.14s ease, width 0.14s ease;
192
+ }
193
+ .ap-sidepanel-bump:hover { opacity: 1; width: 24px; background: var(--accent-soft); color: var(--accent); }
194
+ .ap-sidepanel-bump svg { width: 15px; height: 15px; }
195
+ /* Host-injected side panel (e.g. the cloud table of contents): a left sidebar that pushes the
196
+ content over and slides in from the left. The host renders its content; we own the frame. */
197
+ .ap-sidepanel { flex: 0 0 248px; min-width: 0; display: flex; flex-direction: column; min-height: 0; overflow: hidden; border-right: 1px solid var(--line); background: var(--paper); animation: ap-sidepanel-in 0.54s ease; }
198
+ @keyframes ap-sidepanel-in { from { flex-basis: 0; opacity: 0; } to { flex-basis: 248px; opacity: 1; } }
199
+ /* Fold-out: mirror the open animation's duration so closing matches unfolding (kept mounted ~540ms). */
200
+ .ap-sidepanel.ap-sidepanel--closing { animation: ap-sidepanel-out 0.54s ease forwards; pointer-events: none; }
201
+ @keyframes ap-sidepanel-out { from { flex-basis: 248px; opacity: 1; } to { flex-basis: 0; opacity: 0; } }
202
+ @media (prefers-reduced-motion: reduce) { .ap-sidepanel, .ap-sidepanel.ap-sidepanel--closing { animation: none; } }
161
203
  .ap-preview { flex: 1; min-width: 0; overflow: auto; padding: 28px 36px; border-right: 1px solid var(--line); background: var(--bg); }
162
204
  .ap-rendered { max-width: 760px; }
163
205
  .ap-rendered h1, .ap-rendered h2, .ap-rendered h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; line-height: 1.15; }
@@ -266,11 +308,22 @@ input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outlin
266
308
  /* Quit-confirmation modal (shared desktop + web). */
267
309
  .ap-modal-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(28, 26, 23, 0.28); }
268
310
  .ap-modal { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 18px 20px; min-width: 320px; max-width: 440px; }
311
+ /* Cloud sign-in: a dimmed overlay over the whole editor, dismissed by clicking the backdrop. */
312
+ .ap-signin-backdrop { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; background: rgba(28, 26, 23, 0.42); }
313
+ .ap-signin-panel { width: 460px; max-width: 92vw; height: 720px; max-height: 88vh; background: var(--bg); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 24px 64px -16px rgba(28, 26, 23, 0.5); overflow: hidden; }
314
+ .ap-signin-frame { width: 100%; height: 100%; border: 0; display: block; }
315
+ /* Editor error-boundary fallback — keeps a pane's crash from blanking the whole app. */
316
+ .ap-editor-error { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; padding: 24px; height: 100%; overflow: auto; }
317
+ .ap-editor-error-title { font-weight: 600; font-size: 14px; margin: 0; color: var(--ink, #1c1a17); }
318
+ .ap-editor-error-msg { font-family: var(--mono, ui-monospace, monospace); font-size: 12px; margin: 0; color: var(--danger, #a3331f); white-space: pre-wrap; overflow-wrap: anywhere; }
319
+ .ap-editor-error-retry { font: inherit; font-size: 13px; padding: 5px 14px; border: 1px solid var(--line, #e6dfce); border-radius: 7px; background: var(--bg, #fff); cursor: pointer; }
269
320
  .ap-newdoc { min-width: 420px; }
270
321
  .ap-newdoc-title { font-weight: 600; font-size: 15px; margin-bottom: 14px; }
271
322
  .ap-newdoc-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
272
323
  .ap-newdoc-field input { font: inherit; font-size: 13px; color: var(--fg); padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--bg); }
273
324
  .ap-newdoc-field input:focus { outline: none; border-color: var(--accent); }
325
+ .ap-newdoc-prompt { font: inherit; font-size: 13px; color: var(--fg); padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--bg); resize: vertical; min-height: 52px; }
326
+ .ap-newdoc-prompt:focus { outline: none; border-color: var(--accent); }
274
327
  .ap-newdoc-path { display: flex; gap: 8px; align-items: stretch; }
275
328
  .ap-newdoc-path input { flex: 1; }
276
329
  .ap-newdoc-actions { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-top: 4px; }
@@ -379,12 +432,39 @@ input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outlin
379
432
  /* Review "next" top-aligns the focused hunk (block:"start"); keep a little gap from the pane top. */
380
433
  .ap-ihunk, .ap-hunk { scroll-margin-top: 12px; }
381
434
  .ap-ihunk { border: 1px solid var(--line); border-radius: 9px; margin: 12px 0; overflow: hidden; }
382
- .ap-ihunk-bar { display: flex; align-items: center; gap: 6px; padding: 4px 10px; background: #f3eee1; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
383
- .ap-ihunk-bar button { font: inherit; border: 1px solid var(--line-strong); background: var(--bg); border-radius: 6px; padding: 2px 10px; cursor: pointer; }
384
- .ap-ihunk-bar button.on { background: var(--accent); color: #fbfaf6; border-color: var(--accent); }
435
+ /* Shared per-hunk control bar (both panes): change label · spacer · pencil · "will be …" · switch. */
436
+ .ap-hunk-bar { display: flex; align-items: center; gap: 8px; font-family: var(--sans); font-size: 12px; color: var(--muted); }
437
+ .ap-ihunk .ap-hunk-bar { padding: 4px 10px; background: #f3eee1; border-bottom: 1px solid var(--line); } /* preview: tinted header strip */
438
+ .ap-hunk .ap-hunk-bar { margin-bottom: 4px; } /* source: plain row */
439
+ .ap-hunk-n { font-weight: 500; }
440
+ .ap-willbe { font-size: 11px; }
441
+ .ap-ihunk.accepted .ap-willbe, .ap-hunk.accepted .ap-willbe { color: #2e7d4f; }
442
+ .ap-ihunk.rejected .ap-willbe, .ap-hunk.rejected .ap-willbe { color: var(--danger); }
443
+ .ap-hunk-edit { display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line-strong); background: var(--bg); border-radius: 6px; padding: 2px; cursor: pointer; color: var(--muted); }
444
+ .ap-hunk-edit:hover, .ap-hunk-edit.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
445
+ .ap-hunk-edit svg { width: 13px; height: 13px; display: block; }
446
+ /* Tri-state accept/reject-all switch: two end buttons + a thumb that sits L/centre/R. */
447
+ .ap-tri { display: inline-flex; align-items: center; gap: 6px; }
448
+ .ap-tri-end { font: inherit; font-size: 12px; border: 1px solid var(--line-strong); background: var(--bg); border-radius: 6px; padding: 3px 9px; cursor: pointer; color: var(--muted); }
449
+ .ap-tri-end:disabled { opacity: 0.5; cursor: default; }
450
+ .ap-tri-accept[aria-pressed="true"] { background: #2e9e5b; border-color: #2e9e5b; color: #fbfaf6; }
451
+ .ap-tri-reject[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: #fbfaf6; }
452
+ .ap-tri-track { position: relative; width: 34px; height: 18px; border-radius: 999px; background: var(--line-strong); flex: 0 0 auto; }
453
+ .ap-tri-thumb { position: absolute; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.25); transition: left 0.15s ease; }
454
+ .ap-tri--accept .ap-tri-track { background: #2e9e5b; }
455
+ .ap-tri--reject .ap-tri-track { background: var(--danger); }
456
+ .ap-tri--accept .ap-tri-thumb { left: 2px; }
457
+ .ap-tri--mixed .ap-tri-thumb { left: 10px; }
458
+ .ap-tri--reject .ap-tri-thumb { left: 18px; }
459
+ .ap-tri.disabled { opacity: 0.5; }
385
460
  .ap-ihunk-del { background: #fbeae6; padding: 3px 12px; }
386
461
  .ap-ihunk-del :where(p, h1, h2, h3, h4, li, blockquote) { text-decoration: line-through; }
387
462
  .ap-ihunk-add { background: #e9f3ec; padding: 3px 12px; }
463
+ /* Inline edit of a hunk's proposed text (the pencil). */
464
+ .ap-ihunk-edit { background: #e9f3ec; padding: 6px 12px; display: flex; flex-direction: column; gap: 6px; }
465
+ .ap-ihunk-edit-ta { width: 100%; resize: vertical; font-family: var(--mono); font-size: 12px; line-height: 1.5; border: 1px solid var(--accent); border-radius: 6px; padding: 6px 8px; background: var(--bg); color: var(--fg); }
466
+ .ap-ihunk-edit-ta:focus { outline: none; box-shadow: 0 0 0 2px var(--accent-soft); }
467
+ .ap-ihunk-edit-actions { display: flex; justify-content: flex-end; gap: 8px; }
388
468
  .ap-ihunk.rejected .ap-ihunk-add { opacity: 0.4; }
389
469
  .ap-ihunk.accepted .ap-ihunk-del { opacity: 0.5; }
390
470
  .ap-ihunk.focused { outline: 2px solid var(--accent); outline-offset: 1px; }
@@ -400,8 +480,6 @@ input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outlin
400
480
  .ap-hunk { border-left: 3px solid var(--line); margin: 8px 0; padding-left: 8px; }
401
481
  .ap-hunk.accepted { border-left-color: #2e9e5b; }
402
482
  .ap-hunk.rejected { border-left-color: var(--danger); opacity: 0.7; }
403
- .ap-hunk-toggle { display: flex; align-items: center; font-family: var(--sans); font-size: 12px; margin-bottom: 4px; }
404
- .ap-hunk-toggle .ap-switch { gap: 8px; }
405
483
  .ap-diff-same { color: var(--muted); margin: 0; white-space: pre-wrap; }
406
484
  .ap-diff-del { background: #fbeae6; color: #8a1c10; margin: 0; white-space: pre-wrap; }
407
485
  .ap-diff-add { background: #e9f3ec; color: #18643a; margin: 0; white-space: pre-wrap; }
@@ -414,11 +492,13 @@ input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outlin
414
492
  .ap-status-msg, .ap-thinking { color: var(--fg); font-weight: 500; }
415
493
  /* Relayed agent messages: latest as a clickable chip; popup is a scrollable history. */
416
494
  .ap-agentmsg { position: relative; min-width: 0; }
417
- .ap-agentmsg-latest { max-width: 42ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; font: inherit; color: var(--accent); background: var(--accent-soft); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; cursor: pointer; }
418
- .ap-agentmsg-latest:hover { border-color: var(--accent); }
419
- .ap-agentmsg-pop { position: absolute; bottom: 28px; left: 0; z-index: 50; width: 680px; max-width: 92vw; max-height: 320px; display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow); }
495
+ .ap-agentmsg-latest { max-width: 42ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; font: inherit; color: var(--accent); background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 6px; padding: 2px 8px; cursor: pointer; box-shadow: var(--shadow-sm); }
496
+ .ap-agentmsg-latest:hover { background: var(--bg); border-color: var(--accent-press); }
497
+ /* The history window: a stronger drop shadow + a faint accent ring so it reads as a raised
498
+ panel above the status bar (the plain --shadow let it blend into the page). */
499
+ .ap-agentmsg-pop { position: absolute; bottom: 28px; left: 0; z-index: 50; width: 680px; max-width: 92vw; max-height: 320px; display: flex; flex-direction: column; background: var(--bg); border: 1px solid var(--accent); border-radius: 10px; box-shadow: 0 18px 48px -12px rgba(28, 26, 23, 0.5), 0 0 0 4px var(--accent-soft); }
420
500
  .ap-agentmsg-pop--right { left: auto; right: 0; } /* history chip sits on the right of the bar */
421
- .ap-agentmsg-head { font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); color: var(--fg); }
501
+ .ap-agentmsg-head { font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); color: var(--accent); background: var(--accent-soft); border-radius: 10px 10px 0 0; }
422
502
  .ap-agentmsg-list { overflow-y: auto; padding: 6px; }
423
503
  .ap-agentmsg-item { padding: 7px 8px; border-radius: 7px; }
424
504
  .ap-agentmsg-item + .ap-agentmsg-item { border-top: 1px solid var(--line); }