Skip to content

Commit 510f2c8

Browse files
authored
feat: manual PR fallback and branch-aligned create-pr flow (#69)
* Slack: manual PR fallback with Create PR button (#21) * Add Slack manual PR fallback with Create PR button * Address PR review feedback for manual PR flow * Harden manual PR fallback and artifact parsing * refactor: isolate github provider factory and push-spec builders (#22) * feat: align create-pr head branch with pushed branch (#23) * refactor: isolate github provider factory and push-spec builders * feat: align create-pr branch flow with pushed branch * fix: tighten Slack manual PR artifact detection (#24) * refactor: isolate github provider factory and push-spec builders * feat: align create-pr branch flow with pushed branch * fix: tighten slack manual-pr artifact detection * fix: address provider factory and push-spec default review feedback
1 parent cfc9273 commit 510f2c8

19 files changed

Lines changed: 1185 additions & 130 deletions

File tree

packages/control-plane/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ The control plane provides:
7070
| `/sessions/:id/archive` | POST | Archive session |
7171
| `/sessions/:id/unarchive` | POST | Unarchive session |
7272

73+
### Create PR Payload
74+
75+
`POST /sessions/:id/pr` accepts:
76+
77+
- `title` (required)
78+
- `body` (required)
79+
- `baseBranch` (optional)
80+
- `headBranch` (optional)
81+
82+
When `headBranch` is omitted, control-plane resolves it from session state and finally falls back to
83+
the generated `open-inspect/<session>` branch.
84+
7385
### Repositories
7486

7587
| Endpoint | Method | Description |
@@ -187,6 +199,10 @@ The system uses two types of GitHub tokens:
187199
| GitHub App Token | Clone, push | Yes (ephemeral) | All repos where App is installed |
188200
| User OAuth Token | Create PRs | No (server-only) | User's accessible repos |
189201

202+
If a `create-pr` request is triggered by a participant without a user OAuth token (for example,
203+
Slack-created sessions), the control-plane still pushes the branch with the GitHub App token and
204+
returns a manual GitHub `pull/new` URL instead of failing the request.
205+
190206
### Why This Matters
191207

192208
- **No per-user repo access validation**: When a session is created, the system does not verify that

packages/control-plane/src/router.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,12 +835,26 @@ async function handleCreatePR(
835835
title: string;
836836
body: string;
837837
baseBranch?: string;
838+
headBranch?: string;
838839
};
839840

840-
if (!body.title || !body.body) {
841+
if (
842+
typeof body.title !== "string" ||
843+
typeof body.body !== "string" ||
844+
body.title.trim().length === 0 ||
845+
body.body.trim().length === 0
846+
) {
841847
return error("title and body are required");
842848
}
843849

850+
if (body.baseBranch != null && typeof body.baseBranch !== "string") {
851+
return error("baseBranch must be a string");
852+
}
853+
854+
if (body.headBranch != null && typeof body.headBranch !== "string") {
855+
return error("headBranch must be a string");
856+
}
857+
844858
const doId = env.SESSION.idFromName(sessionId);
845859
const stub = env.SESSION.get(doId);
846860

@@ -854,6 +868,7 @@ async function handleCreatePR(
854868
title: body.title,
855869
body: body.body,
856870
baseBranch: body.baseBranch,
871+
headBranch: body.headBranch,
857872
}),
858873
},
859874
ctx

0 commit comments

Comments
 (0)