@openchamber/web 1.21.1 → 1.22.1
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/dist/assets/{CodeMirrorCommentWidgets-BGj8TJxW.js → CodeMirrorCommentWidgets-BO_2OW4E.js} +1 -1
- package/dist/assets/DiffView-CNnDxRmO.js +4 -0
- package/dist/assets/DirtyBranchSwitchDialog-jADfXQnR.js +1 -0
- package/dist/assets/FilesView-8wdiG2mj.js +17 -0
- package/dist/assets/GitView-Cv2xH-S6.js +6 -0
- package/dist/assets/{JsonTreeView-CggOsLot.js → JsonTreeView-DUiIpERC.js} +1 -1
- package/dist/assets/LinearIssuesView-CoZ7pQN5.js +1 -0
- package/dist/assets/MarkdownImageGallery-DffjmciG.js +1 -0
- package/dist/assets/MarkdownRendererImpl-DxqdYDAx.js +12 -0
- package/dist/assets/OnboardingScreen-CTZe6HZn.js +1 -0
- package/dist/assets/{PatchDiff-DJYMUiXA.js → PatchDiff-BymkP9JA.js} +1 -1
- package/dist/assets/{PierreDiffViewer-CY2bx_SB.js → PierreDiffViewer-BvwtCxW4.js} +3 -3
- package/dist/assets/{PlanView-PkiOY_9H.js → PlanView-C1qvAm7m.js} +3 -3
- package/dist/assets/SettingsView-xGONHFGS.js +28 -0
- package/dist/assets/{SettingsWindow-oyOm2fHR.js → SettingsWindow-COzgfFxM.js} +1 -1
- package/dist/assets/{ToolOutputDialog-lKyeQTPL.js → ToolOutputDialog-Dlhh_-oe.js} +6 -6
- package/dist/assets/ToolPartDiffPreview-b9joNtXH.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-BP7ebDFF.js → VirtualizedFileDiff-vqW3KKo5.js} +1 -1
- package/dist/assets/WalkthroughView-D-HFgdmM.js +4 -0
- package/dist/assets/{computeVirtualFileMetrics-CZ0xPeaT.js → computeVirtualFileMetrics-DUnyszhW.js} +1 -1
- package/dist/assets/{contextPanelEmbeddedChat-C9abMBTb.js → contextPanelEmbeddedChat-CV-DwAiX.js} +1 -1
- package/dist/assets/{de-CEoCz3j6.js → de-Cv_4FoXm.js} +6 -5
- package/dist/assets/es-BIWNEbnS.js +16 -0
- package/dist/assets/{fr-CS7Csln9.js → fr-SD3OfMHJ.js} +6 -5
- package/dist/assets/index-CHUT_bDS.css +1 -0
- package/dist/assets/index-DDInLQDd.js +40 -0
- package/dist/assets/{index-CaPAjwXQ.js → index-DLiD86ge.js} +1 -1
- package/dist/assets/{isDiffPlainText-ZBvDxhVB.js → isDiffPlainText-TNageFjy.js} +1 -1
- package/dist/assets/{isFilePlainText-DiLRrkJr.js → isFilePlainText-JPmZOYSp.js} +1 -1
- package/dist/assets/{ja-vnwqLcx6.js → ja-D7I9HofF.js} +7 -6
- package/dist/assets/{ko-CXuSfZv5.js → ko-BsVJM_PQ.js} +7 -6
- package/dist/assets/{main-D5RWr6sJ.js → main-DCB4JgVe.js} +2 -2
- package/dist/assets/main-De8Z5w49.js +928 -0
- package/dist/assets/markdownCore-BoQVG5-a.js +3 -0
- package/dist/assets/{miniChat-CqR3icsk.js → miniChat-BtV7N5OF.js} +2 -2
- package/dist/assets/{mobile-RN_UTTlB.js → mobile-DZV_sfX7.js} +2 -2
- package/dist/assets/{patchFileDiff-CjRR5ESs.js → patchFileDiff-Chmiz6hq.js} +4 -4
- package/dist/assets/{pl-BJxry0Mi.js → pl-XR9Bs8Be.js} +6 -5
- package/dist/assets/pt-BR-Due4be8g.js +16 -0
- package/dist/assets/{renderElectronMiniChatApp-1wC94fQK.js → renderElectronMiniChatApp-8tXADjfl.js} +2 -2
- package/dist/assets/renderMobileApp-Cji7Hma5.js +25 -0
- package/dist/assets/runtimeEndpointReset-gWt3Lb5D.js +16 -0
- package/dist/assets/scheduledTasksApi-9e-UX6im.js +1 -0
- package/dist/assets/{shikiHighlight-fGmFkxAM.js → shikiHighlight-CRpCl7UT.js} +1 -1
- package/dist/assets/tr-DBJcAv4y.js +7 -0
- package/dist/assets/uk-COYh2BaN.js +16 -0
- package/dist/assets/{useAppFontEffects-KP8_yiGW.js → useAppFontEffects-CCgvcQ6u.js} +178 -170
- package/dist/assets/useInlineCommentController-BkfXnjNZ.js +2 -0
- package/dist/assets/useRootScrollLock-KzOUytpn.js +1 -0
- package/dist/assets/{vendor-codemirror-language-data-DrTPkHl4.js → vendor-codemirror-language-data-BxpoC5Fp.js} +2 -2
- package/dist/assets/vendor-zod-DVWEh-IS.js +39 -0
- package/dist/assets/{web-components-DOXvU-tB.js → web-components-B6QgbmTo.js} +4 -4
- package/dist/assets/zh-CN-Cjk6lzhc.js +16 -0
- package/dist/assets/{zh-TW-Dv8yyhN1.js → zh-TW-Dk0dOg03.js} +6 -5
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +2 -2
- package/server/index.js +35 -4
- package/server/lib/agent-tool/runtime.js +2 -19
- package/server/lib/dev-tunnel/DOCUMENTATION.md +13 -4
- package/server/lib/dev-tunnel/runtime.js +4 -4
- package/server/lib/dev-tunnel/tunnel.test.js +20 -0
- package/server/lib/dictation/DOCUMENTATION.md +19 -6
- package/server/lib/dictation/local/model-catalog.js +220 -0
- package/server/lib/dictation/local/model-catalog.test.js +42 -0
- package/server/lib/dictation/local/sherpa-tts.js +41 -20
- package/server/lib/dictation/local/worker-process.js +2 -0
- package/server/lib/dictation/runtime.js +4 -0
- package/server/lib/dictation/service.js +27 -4
- package/server/lib/fs/DOCUMENTATION.md +4 -0
- package/server/lib/fs/routes.js +129 -0
- package/server/lib/fs/routes.test.js +219 -0
- package/server/lib/git/DOCUMENTATION.md +3 -1
- package/server/lib/git/routes.js +16 -0
- package/server/lib/git/service.js +97 -17
- package/server/lib/git/service.test.js +153 -0
- package/server/lib/linear/DOCUMENTATION.md +97 -0
- package/server/lib/linear/OAUTH-BROKER-HANDOFF.md +91 -0
- package/server/lib/linear/auth.js +436 -0
- package/server/lib/linear/auth.test.js +242 -0
- package/server/lib/linear/client.js +191 -0
- package/server/lib/linear/index.js +61 -0
- package/server/lib/linear/issues.js +499 -0
- package/server/lib/linear/issues.test.js +512 -0
- package/server/lib/linear/mapping.js +188 -0
- package/server/lib/linear/mapping.test.js +147 -0
- package/server/lib/linear/oauth.js +345 -0
- package/server/lib/linear/oauth.test.js +166 -0
- package/server/lib/linear/parse.js +23 -0
- package/server/lib/linear/routes.js +432 -0
- package/server/lib/linear/routes.test.js +661 -0
- package/server/lib/linear/status-runtime.js +64 -0
- package/server/lib/linear/status-runtime.test.js +167 -0
- package/server/lib/linear/status.js +280 -0
- package/server/lib/linear/status.test.js +271 -0
- package/server/lib/linear/teams.js +72 -0
- package/server/lib/linear/teams.test.js +94 -0
- package/server/lib/mcp-reconnect/DOCUMENTATION.md +55 -0
- package/server/lib/mcp-reconnect/runtime.js +122 -0
- package/server/lib/mcp-reconnect/runtime.test.js +140 -0
- package/server/lib/message-queue/DOCUMENTATION.md +148 -0
- package/server/lib/message-queue/runtime.js +818 -0
- package/server/lib/message-queue/runtime.test.js +426 -0
- package/server/lib/openchamber-sessions/routes.js +102 -0
- package/server/lib/openchamber-sessions/routes.test.js +88 -0
- package/server/lib/opencode/DOCUMENTATION.md +5 -1
- package/server/lib/opencode/core-routes.js +1 -0
- package/server/lib/opencode/feature-routes-runtime.js +5 -0
- package/server/lib/opencode/managed-plugin-config.js +35 -0
- package/server/lib/opencode/settings-runtime.js +2 -2
- package/server/lib/opencode/settings-runtime.test.js +29 -0
- package/server/lib/opencode/shutdown-runtime.js +2 -0
- package/server/lib/opencode/static-routes-runtime.js +3 -3
- package/server/lib/projects/project-config.js +33 -5
- package/server/lib/projects/project-config.test.js +85 -0
- package/server/lib/quota/DOCUMENTATION.md +2 -1
- package/server/lib/quota/credentials/providers.js +4 -0
- package/server/lib/quota/credentials/store.js +1 -1
- package/server/lib/quota/credentials/store.test.js +4 -4
- package/server/lib/quota/providers/exe-dev.js +75 -0
- package/server/lib/quota/providers/exe-dev.test.js +47 -0
- package/server/lib/quota/providers/index.js +7 -0
- package/server/lib/quota/providers/opencode-go.js +1 -0
- package/server/lib/quota/providers/opencode-go.test.js +5 -1
- package/server/lib/quota/routes.js +2 -0
- package/server/lib/relay/DOCUMENTATION.md +1 -1
- package/server/lib/relay/tunnel-host.js +3 -1
- package/server/lib/relay/tunnel-host.test.js +9 -1
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +7 -0
- package/server/lib/security/request-security.js +21 -6
- package/server/lib/security/request-security.test.js +42 -8
- package/server/lib/session-assist/runtime.js +1 -0
- package/server/lib/session-goal/create.js +3 -1
- package/server/lib/session-goal/runtime.js +1 -0
- package/server/lib/small-model/DOCUMENTATION.md +4 -0
- package/server/lib/small-model/call.js +8 -2
- package/server/lib/small-model/call.test.js +23 -0
- package/server/lib/small-model/index.js +2 -1
- package/server/lib/small-model/routes.js +2 -1
- package/server/lib/system-prompt/runtime.js +2 -21
- package/server/lib/terminal/runtime.js +30 -7
- package/server/lib/tts/DOCUMENTATION.md +1 -0
- package/server/lib/tts/language-detect.js +210 -0
- package/server/lib/tts/language-detect.test.js +76 -0
- package/server/lib/tts/routes.js +23 -1
- package/server/lib/tts/routes.test.js +26 -0
- package/server/lib/ui-auth/ui-auth.js +4 -1
- package/server/lib/ui-auth/ui-auth.test.js +16 -0
- package/server/lib/walkthrough/index.js +1 -0
- package/dist/assets/CommitSection-DwGiXyjf.js +0 -1
- package/dist/assets/DiffView-Db6bjVv1.js +0 -4
- package/dist/assets/FilesView-DQOa7Lgz.js +0 -17
- package/dist/assets/GitView-CHzJxTi0.js +0 -6
- package/dist/assets/MarkdownImageGallery-DoZpaHev.js +0 -1
- package/dist/assets/MarkdownRendererImpl-B5Y5xCOz.js +0 -12
- package/dist/assets/OnboardingScreen-C98d69Fp.js +0 -1
- package/dist/assets/SettingsView-D-K3ELCM.js +0 -28
- package/dist/assets/ToolPartDiffPreview-C7kBQNAA.js +0 -8
- package/dist/assets/WalkthroughView-MuJodAHD.js +0 -4
- package/dist/assets/es-DwyXCqaL.js +0 -15
- package/dist/assets/index-CUKcHnUA.css +0 -1
- package/dist/assets/index-DIvDEKE-.js +0 -7
- package/dist/assets/main-DLlfDjQ_.js +0 -926
- package/dist/assets/markdownCore-CcTcLsQF.js +0 -3
- package/dist/assets/pt-BR-DxLmkhdv.js +0 -15
- package/dist/assets/renderMobileApp-ltva2Plg.js +0 -25
- package/dist/assets/runtimeEndpointReset-D6SmNZaP.js +0 -15
- package/dist/assets/scheduledTasksApi-mjMDet_H.js +0 -1
- package/dist/assets/tr-5Mk_hQ2Q.js +0 -6
- package/dist/assets/uk-ClgQjmlw.js +0 -15
- package/dist/assets/useInlineCommentController-HIjtuhxD.js +0 -2
- package/dist/assets/useRootScrollLock-BSiQ5F75.js +0 -1
- package/dist/assets/vendor-zod-BLfBSgBh.js +0 -39
- package/dist/assets/zh-CN-Ba6y8H-i.js +0 -15
|
@@ -3687,6 +3687,35 @@ export async function getBranches(directory) {
|
|
|
3687
3687
|
}
|
|
3688
3688
|
}
|
|
3689
3689
|
|
|
3690
|
+
/**
|
|
3691
|
+
* Counts locally unpushed commits for a small caller-supplied set of local
|
|
3692
|
+
* branches. This deliberately reads only local refs: the branch picker calls
|
|
3693
|
+
* it when opened, never polls, and never fetches a remote behind the user's
|
|
3694
|
+
* back. Unknown, remote, and upstream-less branches are omitted.
|
|
3695
|
+
*/
|
|
3696
|
+
export async function getUnpushedBranchCounts(directory, branchNames) {
|
|
3697
|
+
const { git } = await createRepositoryGitContext(directory);
|
|
3698
|
+
const requested = [...new Set(Array.isArray(branchNames) ? branchNames : [])]
|
|
3699
|
+
.filter((name) => typeof name === 'string' && name.length > 0)
|
|
3700
|
+
.slice(0, 5);
|
|
3701
|
+
if (requested.length === 0) return { counts: {} };
|
|
3702
|
+
|
|
3703
|
+
const local = new Set((await git.branchLocal()).all);
|
|
3704
|
+
const counts = {};
|
|
3705
|
+
await Promise.all(requested.map(async (branch) => {
|
|
3706
|
+
if (!local.has(branch)) return;
|
|
3707
|
+
const upstream = await git.raw(['rev-parse', '--abbrev-ref', '--symbolic-full-name', `${branch}@{upstream}`])
|
|
3708
|
+
.then((value) => value.trim())
|
|
3709
|
+
.catch(() => '');
|
|
3710
|
+
if (!upstream) return;
|
|
3711
|
+
const count = await git.raw(['rev-list', '--count', `${upstream}..${branch}`])
|
|
3712
|
+
.then((value) => Number.parseInt(value.trim(), 10))
|
|
3713
|
+
.catch(() => 0);
|
|
3714
|
+
if (Number.isFinite(count) && count > 0) counts[branch] = count;
|
|
3715
|
+
}));
|
|
3716
|
+
return { counts };
|
|
3717
|
+
}
|
|
3718
|
+
|
|
3690
3719
|
async function getRemoteDefaultBranches(git) {
|
|
3691
3720
|
let defaults = {};
|
|
3692
3721
|
|
|
@@ -4266,6 +4295,7 @@ async function attachGitWorktreeToCandidate(context, candidate, input = {}) {
|
|
|
4266
4295
|
|
|
4267
4296
|
const parsedRemoteStartRef = await resolveRemoteBranchRef(context.primaryWorktree, startRef);
|
|
4268
4297
|
if (parsedRemoteStartRef) {
|
|
4298
|
+
worktreeAddArgs.splice(2, 0, '--no-track');
|
|
4269
4299
|
inferredUpstream = {
|
|
4270
4300
|
remote: parsedRemoteStartRef.remote,
|
|
4271
4301
|
branch: parsedRemoteStartRef.branch,
|
|
@@ -4273,24 +4303,17 @@ async function attachGitWorktreeToCandidate(context, candidate, input = {}) {
|
|
|
4273
4303
|
}
|
|
4274
4304
|
}
|
|
4275
4305
|
|
|
4276
|
-
if (ensureRemoteName && ensureRemoteUrl) {
|
|
4306
|
+
if (mode === 'existing' && ensureRemoteName && ensureRemoteUrl) {
|
|
4277
4307
|
await ensureRemoteWithUrl(context.primaryWorktree, ensureRemoteName, ensureRemoteUrl);
|
|
4278
4308
|
}
|
|
4279
4309
|
|
|
4280
|
-
if (mode === 'new') {
|
|
4281
|
-
const parsedRemoteStartRef = await resolveRemoteBranchRef(context.primaryWorktree, startRef);
|
|
4282
|
-
if (parsedRemoteStartRef) {
|
|
4283
|
-
await fetchRemoteBranchRef(context.primaryWorktree, parsedRemoteStartRef.remote, parsedRemoteStartRef.branch);
|
|
4284
|
-
}
|
|
4285
|
-
}
|
|
4286
|
-
|
|
4287
4310
|
await runGitCommandOrThrow(context.primaryWorktree, worktreeAddArgs, 'Failed to create git worktree');
|
|
4288
4311
|
|
|
4289
4312
|
const upstreamRemote = shouldSetUpstream
|
|
4290
|
-
? String(
|
|
4313
|
+
? String(input?.upstreamRemote || inferredUpstream?.remote || '').trim()
|
|
4291
4314
|
: '';
|
|
4292
4315
|
const upstreamBranch = shouldSetUpstream
|
|
4293
|
-
? String(
|
|
4316
|
+
? String(input?.upstreamBranch || inferredUpstream?.branch || '').trim()
|
|
4294
4317
|
: '';
|
|
4295
4318
|
|
|
4296
4319
|
const bootstrapStatus = setWorktreeBootstrapState(
|
|
@@ -4325,6 +4348,50 @@ async function attachGitWorktreeToCandidate(context, candidate, input = {}) {
|
|
|
4325
4348
|
};
|
|
4326
4349
|
}
|
|
4327
4350
|
|
|
4351
|
+
const prepareWorktreeCreateSource = async (context, input = {}) => {
|
|
4352
|
+
if (input?.mode === 'existing') {
|
|
4353
|
+
return { input, sourceFetchFailed: false };
|
|
4354
|
+
}
|
|
4355
|
+
|
|
4356
|
+
const startRef = normalizeStartRef(input?.startRef);
|
|
4357
|
+
const remoteStartRef = await resolveRemoteBranchRef(context.primaryWorktree, startRef);
|
|
4358
|
+
if (!remoteStartRef) {
|
|
4359
|
+
return { input, sourceFetchFailed: false };
|
|
4360
|
+
}
|
|
4361
|
+
|
|
4362
|
+
const status = await getStatus(context.primaryWorktree, { mode: 'light' }).catch(() => null);
|
|
4363
|
+
const trackingRef = status?.tracking
|
|
4364
|
+
? await resolveRemoteBranchRef(context.primaryWorktree, status.tracking)
|
|
4365
|
+
: null;
|
|
4366
|
+
const canFallbackToLocal = Boolean(
|
|
4367
|
+
status?.current
|
|
4368
|
+
&& status.ahead === 0
|
|
4369
|
+
&& trackingRef?.fullRef === remoteStartRef.fullRef
|
|
4370
|
+
);
|
|
4371
|
+
|
|
4372
|
+
try {
|
|
4373
|
+
await fetchRemoteBranchRef(context.primaryWorktree, remoteStartRef.remote, remoteStartRef.branch);
|
|
4374
|
+
return { input, sourceFetchFailed: false };
|
|
4375
|
+
} catch (error) {
|
|
4376
|
+
if (canFallbackToLocal) {
|
|
4377
|
+
return {
|
|
4378
|
+
input: { ...input, startRef: status.current },
|
|
4379
|
+
sourceFetchFailed: true,
|
|
4380
|
+
};
|
|
4381
|
+
}
|
|
4382
|
+
|
|
4383
|
+
const refExists = await runGitCommand(
|
|
4384
|
+
context.primaryWorktree,
|
|
4385
|
+
['show-ref', '--verify', '--quiet', remoteStartRef.fullRef]
|
|
4386
|
+
);
|
|
4387
|
+
if (!refExists.success) {
|
|
4388
|
+
throw error;
|
|
4389
|
+
}
|
|
4390
|
+
console.warn(`Worktree create: failed to refresh ${remoteStartRef.remote}/${remoteStartRef.branch}, proceeding with the existing remote-tracking ref`);
|
|
4391
|
+
return { input, sourceFetchFailed: false };
|
|
4392
|
+
}
|
|
4393
|
+
};
|
|
4394
|
+
|
|
4328
4395
|
export async function createWorktree(directory, input = {}) {
|
|
4329
4396
|
const mode = input?.mode === 'existing' ? 'existing' : 'new';
|
|
4330
4397
|
const context = await resolveWorktreeProjectContext(directory);
|
|
@@ -4333,10 +4400,18 @@ export async function createWorktree(directory, input = {}) {
|
|
|
4333
4400
|
await assertWorktreeCreatePreflight(directory, input);
|
|
4334
4401
|
}
|
|
4335
4402
|
|
|
4403
|
+
const ensureRemoteName = String(input?.ensureRemoteName || '').trim();
|
|
4404
|
+
const ensureRemoteUrl = String(input?.ensureRemoteUrl || '').trim();
|
|
4405
|
+
if (ensureRemoteName && ensureRemoteUrl) {
|
|
4406
|
+
await ensureRemoteWithUrl(context.primaryWorktree, ensureRemoteName, ensureRemoteUrl);
|
|
4407
|
+
}
|
|
4408
|
+
const prepared = await prepareWorktreeCreateSource(context, input);
|
|
4409
|
+
const preparedInput = prepared.input;
|
|
4410
|
+
|
|
4336
4411
|
await fsp.mkdir(context.worktreeRoot, { recursive: true });
|
|
4337
4412
|
|
|
4338
|
-
const preferredName = String(
|
|
4339
|
-
const preferredBranchName = cleanBranchName(String(
|
|
4413
|
+
const preferredName = String(preparedInput?.worktreeName || preparedInput?.name || '').trim();
|
|
4414
|
+
const preferredBranchName = cleanBranchName(String(preparedInput?.branchName || '').trim());
|
|
4340
4415
|
|
|
4341
4416
|
const candidate = await resolveCandidateDirectory(
|
|
4342
4417
|
context.worktreeRoot,
|
|
@@ -4345,7 +4420,7 @@ export async function createWorktree(directory, input = {}) {
|
|
|
4345
4420
|
context.primaryWorktree
|
|
4346
4421
|
);
|
|
4347
4422
|
|
|
4348
|
-
if (
|
|
4423
|
+
if (preparedInput?.returnAfterDirectoryCreated === true) {
|
|
4349
4424
|
await fsp.mkdir(candidate.directory, { recursive: false });
|
|
4350
4425
|
|
|
4351
4426
|
const bootstrapStatus = setWorktreeBootstrapState(
|
|
@@ -4354,10 +4429,10 @@ export async function createWorktree(directory, input = {}) {
|
|
|
4354
4429
|
WORKTREE_BOOTSTRAP_PHASE_DIRECTORY_CREATED
|
|
4355
4430
|
);
|
|
4356
4431
|
const localBranch = mode === 'existing'
|
|
4357
|
-
? cleanBranchName(String(
|
|
4432
|
+
? cleanBranchName(String(preparedInput?.branchName || preparedInput?.existingBranch || candidate.branch || '').trim())
|
|
4358
4433
|
: candidate.branch;
|
|
4359
4434
|
|
|
4360
|
-
const task = attachGitWorktreeToCandidate(context, candidate,
|
|
4435
|
+
const task = attachGitWorktreeToCandidate(context, candidate, preparedInput).catch(async (error) => {
|
|
4361
4436
|
setWorktreeBootstrapState(
|
|
4362
4437
|
candidate.directory,
|
|
4363
4438
|
WORKTREE_BOOTSTRAP_FAILED,
|
|
@@ -4369,7 +4444,7 @@ export async function createWorktree(directory, input = {}) {
|
|
|
4369
4444
|
});
|
|
4370
4445
|
trackWorktreeBootstrapTask(candidate.directory, task);
|
|
4371
4446
|
|
|
4372
|
-
|
|
4447
|
+
const result = {
|
|
4373
4448
|
head: '',
|
|
4374
4449
|
name: candidate.name,
|
|
4375
4450
|
branch: localBranch,
|
|
@@ -4377,9 +4452,14 @@ export async function createWorktree(directory, input = {}) {
|
|
|
4377
4452
|
directoryCreated: true,
|
|
4378
4453
|
bootstrapStatus,
|
|
4379
4454
|
};
|
|
4455
|
+
if (prepared.sourceFetchFailed) {
|
|
4456
|
+
result.sourceFetchFailed = true;
|
|
4457
|
+
}
|
|
4458
|
+
return result;
|
|
4380
4459
|
}
|
|
4381
4460
|
|
|
4382
|
-
|
|
4461
|
+
const result = await attachGitWorktreeToCandidate(context, candidate, preparedInput);
|
|
4462
|
+
return prepared.sourceFetchFailed ? { ...result, sourceFetchFailed: true } : result;
|
|
4383
4463
|
}
|
|
4384
4464
|
|
|
4385
4465
|
export async function getWorktreeBootstrapStatus(directory) {
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
createWorktree,
|
|
13
13
|
getWorktreeBootstrapStatus,
|
|
14
14
|
getBranches,
|
|
15
|
+
getUnpushedBranchCounts,
|
|
15
16
|
getRangeDiff,
|
|
16
17
|
getStatus,
|
|
17
18
|
getWorktrees,
|
|
@@ -54,6 +55,14 @@ const runGit = (cwd, args) =>
|
|
|
54
55
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
55
56
|
});
|
|
56
57
|
|
|
58
|
+
const readBranchConfig = (cwd, branch, key) => {
|
|
59
|
+
try {
|
|
60
|
+
return runGit(cwd, ['config', '--get', `branch.${branch}.${key}`]).trim();
|
|
61
|
+
} catch {
|
|
62
|
+
return '';
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
57
66
|
/**
|
|
58
67
|
* A repository on `next` whose only remote publishes `defaultBranch` and has it
|
|
59
68
|
* recorded as that remote's HEAD — the shape of every repository whose default
|
|
@@ -854,6 +863,135 @@ describe('createWorktree', () => {
|
|
|
854
863
|
}
|
|
855
864
|
}
|
|
856
865
|
});
|
|
866
|
+
|
|
867
|
+
it('does not auto-track the remote start ref when creating a new branch from it', async () => {
|
|
868
|
+
if (!canRunGit()) return;
|
|
869
|
+
|
|
870
|
+
const previousXdgDataHome = process.env.XDG_DATA_HOME;
|
|
871
|
+
const dataHome = createTempDir();
|
|
872
|
+
process.env.XDG_DATA_HOME = dataHome;
|
|
873
|
+
|
|
874
|
+
try {
|
|
875
|
+
const { repository } = createRepositoryWithRemote({ defaultBranch: 'main' });
|
|
876
|
+
|
|
877
|
+
const created = await createWorktree(repository, {
|
|
878
|
+
mode: 'new',
|
|
879
|
+
branchName: 'openchamber/feature',
|
|
880
|
+
worktreeName: 'feature-wt',
|
|
881
|
+
startRef: 'remotes/origin/main',
|
|
882
|
+
setUpstream: true,
|
|
883
|
+
upstreamRemote: 'origin',
|
|
884
|
+
upstreamBranch: 'openchamber/feature',
|
|
885
|
+
});
|
|
886
|
+
|
|
887
|
+
expect(created.branch).toBe('openchamber/feature');
|
|
888
|
+
|
|
889
|
+
await expect.poll(
|
|
890
|
+
() => getWorktreeBootstrapStatus(created.path).then((status) => status.status === 'ready' || status.status === 'failed'),
|
|
891
|
+
{ timeout: 5_000 }
|
|
892
|
+
).toBe(true);
|
|
893
|
+
|
|
894
|
+
expect(readBranchConfig(created.path, 'openchamber/feature', 'remote')).toBe('');
|
|
895
|
+
expect(readBranchConfig(created.path, 'openchamber/feature', 'merge')).toBe('');
|
|
896
|
+
} finally {
|
|
897
|
+
if (previousXdgDataHome === undefined) {
|
|
898
|
+
delete process.env.XDG_DATA_HOME;
|
|
899
|
+
} else {
|
|
900
|
+
process.env.XDG_DATA_HOME = previousXdgDataHome;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}, 30_000);
|
|
904
|
+
|
|
905
|
+
it('falls back to the remote start ref for upstream tracking when no explicit keys are given', async () => {
|
|
906
|
+
if (!canRunGit()) return;
|
|
907
|
+
|
|
908
|
+
const previousXdgDataHome = process.env.XDG_DATA_HOME;
|
|
909
|
+
const dataHome = createTempDir();
|
|
910
|
+
process.env.XDG_DATA_HOME = dataHome;
|
|
911
|
+
|
|
912
|
+
try {
|
|
913
|
+
const { repository } = createRepositoryWithRemote({ defaultBranch: 'main' });
|
|
914
|
+
|
|
915
|
+
const created = await createWorktree(repository, {
|
|
916
|
+
mode: 'new',
|
|
917
|
+
branchName: 'openchamber/fallback-wt',
|
|
918
|
+
worktreeName: 'fallback-wt',
|
|
919
|
+
startRef: 'remotes/origin/main',
|
|
920
|
+
setUpstream: true,
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
await expect.poll(
|
|
924
|
+
() => readBranchConfig(created.path, 'openchamber/fallback-wt', 'merge'),
|
|
925
|
+
{ timeout: 5_000 }
|
|
926
|
+
).toBe('refs/heads/main');
|
|
927
|
+
expect(readBranchConfig(created.path, 'openchamber/fallback-wt', 'remote')).toBe('origin');
|
|
928
|
+
} finally {
|
|
929
|
+
if (previousXdgDataHome === undefined) {
|
|
930
|
+
delete process.env.XDG_DATA_HOME;
|
|
931
|
+
} else {
|
|
932
|
+
process.env.XDG_DATA_HOME = previousXdgDataHome;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
}, 30_000);
|
|
936
|
+
|
|
937
|
+
it('falls back to the tracked local branch when the source fetch fails', async () => {
|
|
938
|
+
if (!canRunGit()) return;
|
|
939
|
+
|
|
940
|
+
const previousXdgDataHome = process.env.XDG_DATA_HOME;
|
|
941
|
+
const dataHome = createTempDir();
|
|
942
|
+
process.env.XDG_DATA_HOME = dataHome;
|
|
943
|
+
|
|
944
|
+
try {
|
|
945
|
+
const { repository } = createRepositoryWithRemote({ defaultBranch: 'main' });
|
|
946
|
+
runGit(repository, ['branch', '--set-upstream-to=origin/main', 'next']);
|
|
947
|
+
runGit(repository, ['remote', 'set-url', 'origin', '/nonexistent/openchamber-unreachable.git']);
|
|
948
|
+
|
|
949
|
+
const created = await createWorktree(repository, {
|
|
950
|
+
mode: 'new',
|
|
951
|
+
branchName: 'openchamber/stale-ref-wt',
|
|
952
|
+
worktreeName: 'stale-ref-wt',
|
|
953
|
+
startRef: 'remotes/origin/main',
|
|
954
|
+
});
|
|
955
|
+
|
|
956
|
+
expect(created.branch).toBe('openchamber/stale-ref-wt');
|
|
957
|
+
expect(created.sourceFetchFailed).toBe(true);
|
|
958
|
+
const expectedHead = runGit(repository, ['rev-parse', 'next']).trim();
|
|
959
|
+
expect(runGit(created.path, ['rev-parse', 'HEAD']).trim()).toBe(expectedHead);
|
|
960
|
+
} finally {
|
|
961
|
+
if (previousXdgDataHome === undefined) {
|
|
962
|
+
delete process.env.XDG_DATA_HOME;
|
|
963
|
+
} else {
|
|
964
|
+
process.env.XDG_DATA_HOME = previousXdgDataHome;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
}, 30_000);
|
|
968
|
+
|
|
969
|
+
it('rejects creation from a remote start ref that was never fetched and cannot be fetched', async () => {
|
|
970
|
+
if (!canRunGit()) return;
|
|
971
|
+
|
|
972
|
+
const previousXdgDataHome = process.env.XDG_DATA_HOME;
|
|
973
|
+
const dataHome = createTempDir();
|
|
974
|
+
process.env.XDG_DATA_HOME = dataHome;
|
|
975
|
+
|
|
976
|
+
try {
|
|
977
|
+
const { repository } = createRepositoryWithRemote({ defaultBranch: 'main' });
|
|
978
|
+
runGit(repository, ['update-ref', '-d', 'refs/remotes/origin/main']);
|
|
979
|
+
runGit(repository, ['remote', 'set-url', 'origin', '/nonexistent/openchamber-unreachable.git']);
|
|
980
|
+
|
|
981
|
+
await expect(createWorktree(repository, {
|
|
982
|
+
mode: 'new',
|
|
983
|
+
branchName: 'openchamber/never-fetched-wt',
|
|
984
|
+
worktreeName: 'never-fetched-wt',
|
|
985
|
+
startRef: 'remotes/origin/main',
|
|
986
|
+
})).rejects.toThrow(/does not appear to be a git repository|Could not read from remote repository/i);
|
|
987
|
+
} finally {
|
|
988
|
+
if (previousXdgDataHome === undefined) {
|
|
989
|
+
delete process.env.XDG_DATA_HOME;
|
|
990
|
+
} else {
|
|
991
|
+
process.env.XDG_DATA_HOME = previousXdgDataHome;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}, 30_000);
|
|
857
995
|
});
|
|
858
996
|
|
|
859
997
|
// ---------------------------------------------------------------------------
|
|
@@ -1498,6 +1636,21 @@ describe.runIf(canRunGit())('getBranches', () => {
|
|
|
1498
1636
|
});
|
|
1499
1637
|
});
|
|
1500
1638
|
|
|
1639
|
+
describe.runIf(canRunGit())('getUnpushedBranchCounts', () => {
|
|
1640
|
+
it('counts only commits ahead of a locally known upstream', async () => {
|
|
1641
|
+
const { repository } = createRepositoryWithRemote();
|
|
1642
|
+
runGit(repository, ['branch', '--set-upstream-to=origin/react', 'next']);
|
|
1643
|
+
fs.writeFileSync(path.join(repository, 'ahead.txt'), 'ahead\n');
|
|
1644
|
+
runGit(repository, ['add', 'ahead.txt']);
|
|
1645
|
+
runGit(repository, ['commit', '-m', 'ahead']);
|
|
1646
|
+
runGit(repository, ['checkout', '-b', 'no-upstream']);
|
|
1647
|
+
|
|
1648
|
+
await expect(getUnpushedBranchCounts(repository, ['next', 'no-upstream', 'remotes/origin/react'])).resolves.toEqual({
|
|
1649
|
+
counts: { next: 1 },
|
|
1650
|
+
});
|
|
1651
|
+
});
|
|
1652
|
+
});
|
|
1653
|
+
|
|
1501
1654
|
describe.runIf(canRunGit())('getRangeDiff', () => {
|
|
1502
1655
|
it('resolves a base that exists only on a remote other than origin', async () => {
|
|
1503
1656
|
const { repository } = createRepositoryWithRemote({ remoteName: 'upstream', defaultBranch: 'react' });
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Linear Module Documentation
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This module owns Linear OAuth, issue lookup, Linear-team-to-project mapping, issue status updates, and session status comments on Linear issues. Credentials live on the OpenChamber server, so web, desktop, and a phone paired to that host share them. You can store more than one Linear workspace; exactly one is current. Issue list, mapping, and new OAuth default to the current workspace. Session status comments use the workspace that started the session. The right-hand context panel lists issues for the current workspace, can switch workspace, filters the list, shows a read-only card, changes status or closes the issue, and starts a session or worktree. Start session stays visible in a footer while the issue card scrolls. The chat picker lists issues and attaches them to a message. New Worktree can also start from a Linear issue in the currently active project. A session started from a Linear issue can post started/completed/failure comments, each with an OpenChamber session link. Those comments are opt-in and only appear when this server has a publicly reachable address.
|
|
6
|
+
|
|
7
|
+
VS Code omits Linear (`RuntimeAPIs.linear` is optional). Hide Linear UI when the API is missing.
|
|
8
|
+
|
|
9
|
+
## Entrypoints and structure
|
|
10
|
+
|
|
11
|
+
- `packages/web/server/lib/linear/index.js`: public server entrypoint. `routes.js` loads it lazily with `await import('./index.js')`.
|
|
12
|
+
- `packages/web/server/lib/linear/routes.js`: Express registration for the public callback, `/api/linear/auth/*`, `/api/linear/issues/*`, `/api/linear/mapping`, and `/api/linear/session-status`.
|
|
13
|
+
- `packages/web/server/lib/linear/auth.js`: auth file, client id, scopes, redirect URI.
|
|
14
|
+
- `packages/web/server/lib/linear/oauth.js`: authorization-code + PKCE S256, public callback broker handoff, refresh, revoke.
|
|
15
|
+
- `packages/web/server/lib/linear/client.js`: GraphQL helper, viewer/organization lookup, and access-token refresh. GraphQL errors prefer `extensions.userPresentableMessage` / validation constraints over the generic `Argument Validation Error` label. User-facing Linear errors set `LinearApiError.userError`. Requests send `public-file-urls-expire-in: 3600` so file URLs in issue descriptions and comments are temporarily readable in the panel.
|
|
16
|
+
- `packages/web/server/lib/linear/issues.js`: list/search/get issues, team workflow states, `issueUpdate`, and `commentCreate`. Parses identifiers and Linear URLs. `issueUpdate` resolves identifiers to UUIDs first because Linear's mutation does not accept `ENG-12`. List/get include `state.id`, `priority` (0–4), and labels (`id`, `name`, sanitized hex `color`) so the panel can show them and update status.
|
|
17
|
+
- `packages/web/server/lib/linear/teams.js`: list Linear teams for mapping UI.
|
|
18
|
+
- `packages/web/server/lib/linear/mapping.js`: persist default and per-team OpenChamber project paths. Separate from the auth file so disconnect does not wipe maps.
|
|
19
|
+
- `packages/web/server/lib/linear/status.js`: persist per-session started/completed/failure flags and post the matching Linear comment with an open-session URL. Posts nothing unless the user opted in and the session origin is public; `isPublicSessionOrigin` rejects loopback, private LAN, carrier-grade NAT, link-local and single-label hosts. The dedupe file keeps the newest 500 sessions.
|
|
20
|
+
- `packages/web/server/lib/linear/status-runtime.js`: on the OpenCode event hub, first `session.status` idle after started posts completed once; `session.error` (except abort) posts failure once.
|
|
21
|
+
- `packages/web/src/api/linear.ts`: web client wrapper. Electron and hosted/Capacitor mobile reuse it. VS Code omits `linear`.
|
|
22
|
+
|
|
23
|
+
## Public routes
|
|
24
|
+
|
|
25
|
+
- `GET /linear/oauth/callback`: public fallback for an explicitly configured direct redirect URI. The built-in flow uses the stable callback broker instead, because desktop and self-hosted instances may have private or dynamic addresses.
|
|
26
|
+
- `GET /api/linear/auth/status`: connected flag, current user/organization/scope, and `workspaces` (id, name, current, user, authorizedAt). Never returns tokens. A 401 on the current workspace drops that workspace only; if another remains, status returns that one instead of disconnected. Identity refresh does not bump `authorizedAt`.
|
|
27
|
+
- `POST /api/linear/auth/start`: returns `{ authorizationUrl, expiresIn, scope }`. Body may include `origin: "desktop"` so the callback page can raise the desktop window. The authorize URL uses `prompt=consent` so Add workspace can pick a different Linear org. Completing OAuth stores or replaces that org and makes it current.
|
|
28
|
+
- `POST /api/linear/auth/activate`: body `{ organizationId }`. Makes that stored workspace current. 400 if the id is missing, 404 if it is not stored.
|
|
29
|
+
- `DELETE /api/linear/auth`: revokes the current workspace refresh token when present, then drops that workspace only. Other stored workspaces stay. Mapping is kept.
|
|
30
|
+
- `GET /api/linear/issues/list?query=&cursor=&status=&assignee=&teamId=&priority=`: issues from the current workspace. Omitted `status` is incomplete states (same as the chat picker). The panel sends `all`, `backlog`, `todo` (Linear `unstarted`), `started` (In Progress, excluding the In Review name), `inReview` (state name In Review), `completed` (Done), `canceled` (excluding the Duplicate name), or `duplicate` (state type or name Duplicate). `assignee` is `any` (default) or `me`. `teamId` limits the list to that Linear team. `priority` is `all` (default), `none`, `urgent`, `high`, `medium`, or `low`. An identifier or Linear URL returns that issue even if it is completed and ignores the other filters. Each issue includes `state.id` when Linear sends it, plus `priority` (0 none through 4 low) and `labels`. Never returns tokens.
|
|
31
|
+
- `GET /api/linear/issues/get?id=`: one issue by UUID or identifier, including description, comments, team, `state.id`, priority, and labels.
|
|
32
|
+
- `GET /api/linear/issues/states?teamId=`: workflow states for that Linear team (`id`, `name`, `type`, `position`), ordered like Linear's workflow: type (backlog, unstarted, started, completed, canceled) then position. Missing `teamId` is 400. Linear not-found or validation errors are 400 with Linear's presentable message. Disconnected is `{ connected: false }` with HTTP 200.
|
|
33
|
+
- `POST /api/linear/issues/update`: body `{ id, stateId }`. `id` may be a UUID, identifier, or Linear URL; identifiers are resolved before `issueUpdate` because Linear's mutation requires a UUID. Returns the updated issue. Closing an issue is this same call with the team's first `type: completed` state. Missing `id` or `stateId` is 400. Linear validation (for example a non-UUID `stateId`) is 400 with Linear's presentable message. A GraphQL 401 clears that workspace only. Disconnected is `{ connected: false }` with HTTP 200.
|
|
34
|
+
- `GET /api/linear/mapping`: stored default project plus live Linear teams with their mapped paths. Missing file is empty mapping. Malformed file is 500, not empty success. Disconnected is `{ connected: false }` with HTTP 200.
|
|
35
|
+
- `PUT /api/linear/mapping`: replace default project and per-team paths. Body `{ defaultProjectPath, teamProjectPaths }`. Failed write does not touch tokens. Disconnected is `{ connected: false }` and does not save.
|
|
36
|
+
- `GET /api/linear/preferences`: `{ sessionComments }`. `PUT /api/linear/preferences` with body `{ sessionComments: boolean }` replaces it and returns the stored value. A non-boolean body is 400. The preference is server-side because the event hub posts completed/failure without going through the interface.
|
|
37
|
+
- `POST /api/linear/session-status`: post a started/completed/failure comment on the linked Linear issue. Body `{ kind, sessionId, issueIdentifier?, sessionOrigin? }`. `started` requires `issueIdentifier`. `completed` and `failure` reuse the stored issue and open URL from `started`. Each kind posts at most once per session. Answers in this order: disconnected is `{ connected: false }` with HTTP 200; comments turned off is `skipped: 'disabled'`; a `sessionOrigin` nobody else can reach is `skipped: 'origin-not-public'`. `sessionOrigin` must be `http` or `https` with no path, and must resolve to a public host — loopback, private LAN and desktop deep links post no comment at all rather than a link only its author can open. Comment bodies are one markdown link: `[OpenChamber session started](url)` so Linear keeps the `?session=` query. The comment carries no issue or session title: it already sits on the issue, and titles routinely contain brackets that would break the link. Invalid body is 400.
|
|
38
|
+
|
|
39
|
+
`POST /api/linear/auth/start`, `PUT /api/linear/mapping`, `POST /api/linear/issues/update`, and `POST /api/linear/session-status` parse JSON on the route (`16kb`). They are not on the `/api` 50mb allowlist.
|
|
40
|
+
|
|
41
|
+
Disconnected list/get/states/update/mapping/session-status return `{ connected: false }` with HTTP 200 so the picker and panel can show an empty state. Missing `id` on get is 400. Missing `teamId` on states is 400.
|
|
42
|
+
|
|
43
|
+
## Auth storage and config
|
|
44
|
+
|
|
45
|
+
- Auth storage: `~/.config/openchamber/linear-auth.json` (or `$OPENCHAMBER_DATA_DIR/linear-auth.json`). Shape is `{ workspaces: [ { accessToken, refreshToken, user, organization, workspaceId, current, authorizedAt, ... } ] }`. `workspaceId` is the Linear organization id, or `user:<id>` when there is no org, or `legacy` for a migrated token with neither. A legacy single-object file is rewritten to this list on read. Reconnecting the same org replaces that slot.
|
|
46
|
+
- Mapping storage: `~/.config/openchamber/linear-mapping.json` (same data dir). Shape is `{ workspaces: { [workspaceId]: { defaultProjectPath, teamProjectPaths } } }`. Reads and writes use the current workspace slice. A legacy flat file is wrapped under the current workspace id on read. Disconnect does not wipe maps. Writes are atomic and file mode is `0o600`.
|
|
47
|
+
- Session status storage: `~/.config/openchamber/linear-session-status.json` (same data dir). Writes are atomic and file mode is `0o600`. Dedupes started/completed/failure per OpenChamber session id.
|
|
48
|
+
- Writes are atomic and file mode is `0o600`.
|
|
49
|
+
- Client ID: `OPENCHAMBER_LINEAR_CLIENT_ID` -> `settings.json` `linearClientId` -> baked-in public default.
|
|
50
|
+
- Client secret: `OPENCHAMBER_LINEAR_CLIENT_SECRET` -> `settings.json` `linearClientSecret`. Optional with PKCE. Do not commit a secret.
|
|
51
|
+
- Scopes: `OPENCHAMBER_LINEAR_SCOPES` -> `settings.json` `linearScopes` -> `read,write,comments:create`.
|
|
52
|
+
- Session comments: `settings.json` `linearSessionComments`, boolean, absent means off. Written only through `PUT /api/linear/preferences`.
|
|
53
|
+
- Broker URL: `OPENCHAMBER_LINEAR_BROKER_URL` -> `settings.json` `linearBrokerUrl` -> `https://api.openchamber.dev/v1/oauth/linear`.
|
|
54
|
+
- Redirect URI: `OPENCHAMBER_LINEAR_REDIRECT_URI` -> `settings.json` `linearRedirectUri` -> `<broker-url>/callback`. Setting an explicit redirect URI bypasses the broker for custom/self-hosted OAuth applications.
|
|
55
|
+
|
|
56
|
+
Linear requires an exact callback match. The built-in application registers `https://api.openchamber.dev/v1/oauth/linear/callback`; the broker holds only the short-lived authorization code. The local OpenChamber server keeps the claim secret and PKCE verifier, exchanges the code for tokens locally, then acknowledges the handoff. Custom brokers must expose `/start`, `/callback`, `/poll`, and `/complete` with the same contract.
|
|
57
|
+
|
|
58
|
+
## OAuth contract
|
|
59
|
+
|
|
60
|
+
- Authorization code + PKCE S256. Linear has no device flow.
|
|
61
|
+
- The broker stores hashes of OAuth state and a separate claim secret for ten minutes. It never receives the PKCE verifier or Linear tokens. The local status polling path claims a completed broker result and persists tokens on the OpenChamber server.
|
|
62
|
+
- Access tokens expire in 24 hours. Refresh tokens rotate; persist the new refresh token from every successful refresh. Concurrent refreshes share one in-flight promise per workspace.
|
|
63
|
+
- `invalid_grant` / 401 on refresh clears that workspace only so a dead token cannot loop. If it was the last workspace, status becomes disconnected.
|
|
64
|
+
- A GraphQL 401 after a valid-looking token also clears that workspace. A network failure while a token is stored does not: status stays connected with the last known user.
|
|
65
|
+
|
|
66
|
+
## Project mapping
|
|
67
|
+
|
|
68
|
+
OpenChamber has projects (directories), not accounts or organizations. Mapping is how create-session (picker and the right-hand panel) picks a directory:
|
|
69
|
+
|
|
70
|
+
1. If the issue's Linear team has a project path, use that.
|
|
71
|
+
2. Otherwise use the default project path.
|
|
72
|
+
3. If neither is set, the UI tells the user to map the team in Settings → Integrations. It does not fall back to the currently active project.
|
|
73
|
+
|
|
74
|
+
A worktree started from the panel or picker is created in that mapped project. New Worktree from Git is different: it stays in the currently active project.
|
|
75
|
+
|
|
76
|
+
## Shared UI
|
|
77
|
+
|
|
78
|
+
- `RuntimeAPIs.linear` is optional. Hide Linear settings, the chat picker, and the panel when it is missing (VS Code).
|
|
79
|
+
- Store: `packages/ui/src/stores/useLinearAuthStore.ts`. App start refreshes it from `App.tsx` and `MobileApp.tsx`, not `VSCodeApp`.
|
|
80
|
+
- Settings: first-party section on the Integrations page. Connect opens the authorization URL and polls status until the workspace list or current `authorizedAt` changes, so Add workspace is not treated as done just because a workspace was already connected. When connected, map a default project and optional per-team projects for the current workspace. Other stored workspaces appear in a list with Switch to. Disconnect removes the current workspace only. The panel can also switch the current workspace when more than one is stored.
|
|
81
|
+
- Context panel: desktop/web right-hand rail surface `linear` (`packages/ui/src/components/views/LinearIssuesView.tsx`). Singleton like git/pr. The rail icon is hidden until a Linear workspace is connected; disconnecting while the panel is open closes it. List/search defaults to all issues; the status filter is All, Backlog, To Do, In Progress, In Review, Done, Canceled, and Duplicate, matching the card status order. Identifier/URL still finds completed. Status, assignee, team, and priority filters persist in `useUIStore` so they survive rail switches. Non-default list filters and search tint the filter icon `text-primary`, same as the context rail; one control clears them, not the workspace switch. Changing those filters keeps the previous list until the next page arrives and does not disable the filter row. On a narrow panel search and the filters other than status drop to icons; status keeps its label. The card shows priority and labels. Comments render as an avatar timeline matching the pull request panel, so both context surfaces read alike; comment authors carry `avatarUrl`. The card is read-only except status (`issueUpdate`) and Close (first completed workflow state). Start session stays in a footer while the description and comments scroll. Start session / worktree share `startLinearIssueSession` with the picker. No create-issue, no writing comments, no polling. VS Code and the mobile workspace drawer omit this rail.
|
|
82
|
+
- Chat: composer attach menu "Link Linear Issue" attaches body and comments as `linear-issue` context on the next send. Exclusive with a linked GitHub issue or PR. The attached issue is stored on session metadata (`kind: 'linear'`) so work status can show it. Clicking that work-status row opens the Linear rail when Linear is connected on desktop/web; otherwise the Linear URL. Managed Chats do not offer start-from-issue; those sessions have no project directory.
|
|
83
|
+
- Worktree: New Worktree can start from a Linear issue. It uses the currently active project and does not consult team-to-project mapping. GitHub issue/PR and Linear issue are exclusive on that form.
|
|
84
|
+
- Status comments: off until the user turns them on in Settings -> Integrations -> Linear (`LinearSessionComments.tsx`). When on, create-session and worktree-from-Linear post `started` after the session exists. The event hub posts `completed` on the first idle after that, and `failure` on `session.error` except `MessageAbortedError`. Failed comments must not fail session create. Comment bodies are English (they live on Linear) and are one markdown link named `OpenChamber session started` (or completed/failed). Web uses `/?session=<id>` on the current origin; desktop reports the loopback origin its own server listens on, not `openchamber-ui://`. A Linear comment is read by the whole team, so the server posts nothing when that origin is not publicly reachable rather than publishing a link only its author could open. Opening `/?session=` selects that session after the global session list can resolve its directory.
|
|
85
|
+
- Magic prompts: `linear.issue.review.visible` / `.instructions`. Do not reuse the GitHub issue-review templates for Linear.
|
|
86
|
+
|
|
87
|
+
## Notes for contributors
|
|
88
|
+
|
|
89
|
+
The implementation and deployment hand-off for the stable callback broker is
|
|
90
|
+
in [`OAUTH-BROKER-HANDOFF.md`](./OAUTH-BROKER-HANDOFF.md). It records the exact
|
|
91
|
+
Linear redirect URI that must be registered and why the original loopback
|
|
92
|
+
callback could not support packaged desktop or arbitrary self-hosted servers.
|
|
93
|
+
|
|
94
|
+
- Do not log tokens, codes, verifiers, or the client secret.
|
|
95
|
+
- Do not add Linear under Git or as a third-party plugin row.
|
|
96
|
+
- Actor is `user`. Do not enable Linear client-credentials tokens for this flow.
|
|
97
|
+
- One OAuth grant is still one Linear organization. The server stores many grants and keeps one current. Webhooks and inbound Linear issue actions are out of scope until a later change.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Linear OAuth broker hand-off
|
|
2
|
+
|
|
3
|
+
## Required Linear application change
|
|
4
|
+
|
|
5
|
+
Register this exact redirect URI in the Linear OAuth application used by the
|
|
6
|
+
baked-in client ID:
|
|
7
|
+
|
|
8
|
+
`https://api.openchamber.dev/v1/oauth/linear/callback`
|
|
9
|
+
|
|
10
|
+
Linear compares the full redirect URI, including scheme, host, path, and port.
|
|
11
|
+
Deploy the API broker and apply its D1 migration before testing this branch.
|
|
12
|
+
|
|
13
|
+
## Why the original callback failed
|
|
14
|
+
|
|
15
|
+
The first implementation redirected Linear back to the OpenChamber server:
|
|
16
|
+
|
|
17
|
+
`http://127.0.0.1:<listen-port>/linear/oauth/callback`
|
|
18
|
+
|
|
19
|
+
That address is not stable across OpenChamber runtimes:
|
|
20
|
+
|
|
21
|
+
- packaged desktop prefers its stored local port and can select another free
|
|
22
|
+
port when needed;
|
|
23
|
+
- local development and the CLI use different ports;
|
|
24
|
+
- self-hosted servers may sit behind a reverse proxy or have no public inbound
|
|
25
|
+
address at all.
|
|
26
|
+
|
|
27
|
+
Linear requires an exact pre-registered callback. Registering every possible
|
|
28
|
+
desktop or self-hosted address is impossible, and forcing desktop onto one port
|
|
29
|
+
would make startup fail whenever another process owns that port.
|
|
30
|
+
|
|
31
|
+
## New flow
|
|
32
|
+
|
|
33
|
+
The built-in Linear client now uses the stable callback broker in
|
|
34
|
+
`openchamber-website/apps/api`:
|
|
35
|
+
|
|
36
|
+
1. The OpenChamber server generates OAuth state, a PKCE verifier, and a separate
|
|
37
|
+
claim secret.
|
|
38
|
+
2. The broker stores only hashes of state and the claim secret for ten minutes.
|
|
39
|
+
3. Linear sends its authorization code to the stable public callback.
|
|
40
|
+
4. The OpenChamber server polls the broker with state and the claim secret.
|
|
41
|
+
5. The OpenChamber server exchanges the code using the PKCE verifier and stores
|
|
42
|
+
the Linear tokens locally.
|
|
43
|
+
6. After persistence succeeds, OpenChamber acknowledges the hand-off and the
|
|
44
|
+
broker marks it consumed.
|
|
45
|
+
|
|
46
|
+
The broker never receives the PKCE verifier, access token, or refresh token.
|
|
47
|
+
Private Relay is not involved; the local server only needs outbound HTTPS.
|
|
48
|
+
|
|
49
|
+
## Compatibility and configuration
|
|
50
|
+
|
|
51
|
+
- `OPENCHAMBER_LINEAR_BROKER_URL` or `settings.json` `linearBrokerUrl` selects a
|
|
52
|
+
self-hosted broker. The default is
|
|
53
|
+
`https://api.openchamber.dev/v1/oauth/linear`.
|
|
54
|
+
- `OPENCHAMBER_LINEAR_REDIRECT_URI` or `settings.json` `linearRedirectUri`
|
|
55
|
+
bypasses the broker and preserves the direct callback flow for a custom
|
|
56
|
+
Linear OAuth application.
|
|
57
|
+
|
|
58
|
+
## Owning files
|
|
59
|
+
|
|
60
|
+
OpenChamber:
|
|
61
|
+
|
|
62
|
+
- `auth.js`: broker and redirect configuration.
|
|
63
|
+
- `oauth.js`: PKCE, broker registration/poll/acknowledgement, token exchange.
|
|
64
|
+
- `routes.js`: starts authorization and completes broker results during status
|
|
65
|
+
polling.
|
|
66
|
+
|
|
67
|
+
Hosted API, in the `openchamber-website` repository:
|
|
68
|
+
|
|
69
|
+
- `apps/api/src/routes/linear-oauth.ts`
|
|
70
|
+
- `apps/api/migrations/0010_linear_oauth_transactions.sql`
|
|
71
|
+
- `apps/api/LINEAR-OAUTH.md`
|
|
72
|
+
|
|
73
|
+
## Validation
|
|
74
|
+
|
|
75
|
+
OpenChamber focused tests:
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
bunx vitest run \
|
|
79
|
+
packages/web/server/lib/linear/oauth.test.js \
|
|
80
|
+
packages/web/server/lib/linear/auth.test.js \
|
|
81
|
+
packages/web/server/lib/linear/routes.test.js
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Hosted API checks:
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
cd apps/api
|
|
88
|
+
bun test src/routes/linear-oauth.test.ts
|
|
89
|
+
bun run check
|
|
90
|
+
bun run build
|
|
91
|
+
```
|