Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3dd8045
Every open pull request has a record and one state, read by the merge…
nambok Dec 5, 2026
da7e4e7
Format the pull requests route
nambok Dec 5, 2026
9ef4f5d
Keep each pull request's history, change log and nightly percentiles …
nambok Dec 5, 2026
afe30c7
Every pull request, whoever wrote it: history backfill and health sig…
nambok Dec 5, 2026
053806e
The org's pull requests in one answer: GET /api/prs/overview (#988)
nambok Dec 5, 2026
43e3196
Answer the review: the gate never waits on what GitHub does not requi…
nambok Dec 5, 2026
8692271
Merge the org overview's read API (#988) into the pull requests view
nambok Dec 5, 2026
9f0e4ea
Merge main into the pull requests view
nambok Dec 5, 2026
29dc156
For you: one person's own page, linked by them, never by email
nambok Dec 5, 2026
7173abb
Merge remote-tracking branch 'origin/pull-requests-view' into for-you…
nambok Dec 5, 2026
fcdc9d0
Jira app 7.1.0: what a site lacks without For you's sprint, link and …
nambok Dec 5, 2026
13ca67d
For you: the privacy case reads request shapes and path literals only…
nambok Dec 6, 2026
ff4b31f
Jira app: Forge bridge 7 and UI Kit 12, prosemirror-view held at the …
nambok Dec 6, 2026
961cc69
Jira app: React 18, the one UI Kit runs on, so the link screen has a …
nambok Dec 6, 2026
cb2ca0d
For you: an approved plan is coded as shown
nambok Dec 6, 2026
95c7933
Merge remote-tracking branch 'origin/main' into for-you-page
nambok Dec 6, 2026
86de848
Jira link: a strict, size-limited request with no field it doesn't know
nambok Dec 6, 2026
cd381bd
Merge remote-tracking branch 'origin/main' into for-you-page
nambok Dec 6, 2026
a9695a4
For you: the real plan and steps, Nudge, tests read from the repo, se…
nambok Dec 6, 2026
fff6395
Merge remote-tracking branch 'origin/for-you-page' into for-you-real
nambok Dec 6, 2026
3e3b676
For you's privacy case reads the code's use-up with its expiry
nambok Dec 6, 2026
cec46e7
For you's privacy case reads the code's use-up with its expiry
nambok Dec 6, 2026
8966b6c
Merge remote-tracking branch 'origin/for-you-page' into for-you-real
nambok Dec 6, 2026
950dc2a
Deliveries: the Jira link sent at once is a timed relay record
nambok Dec 6, 2026
dfa6c64
Jira link: axum reads the body into the strict request, at most 2 KiB
nambok Dec 6, 2026
9eebaff
Jira link route: the body limit by a named constant, so the route rea…
nambok Dec 6, 2026
6c5e8ff
Merge for-you-page (#990): the strict typed link request, relayed and…
nambok Dec 6, 2026
bc36310
Merge remote-tracking branch 'origin/for-you-page' into for-you-real
nambok Dec 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/scripts/test_forge_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ def test_behind_lists_each_site_by_number_with_what_it_lacks(self):
for f in ["full comment reading", "mentions", "in-place edits", "threaded replies", "issue type", "extended issue fields"]:
self.assertIn(f, names)
self.assertEqual(fr.missing_on_major(features, 5), names)
self.assertEqual(fr.missing_on_major(features, 6), [])
self.assertEqual(sorted(fr.missing_on_major(features, 6)), sorted(["open sprint for For you", "Link my CoderHelm account", "Give to CoderHelm from For you"]))
self.assertEqual(fr.missing_on_major(features, 7), [])
self.assertEqual(fr.missing_on_major(features, None), names)
md, warning = fr.behind_report(["5\tjira\n", "\n", "\tjira\n"], "6.11.0", features)
self.assertIn("- Site 1 (jira): major version 5 (latest 6.11.0). Missing: ", md)
Expand Down
13 changes: 13 additions & 0 deletions coderhelm-jira/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ modules:
function: getSiteUrlHandler
- key: get-issues-trigger
function: getIssuesHandler
# Any issue's "..." menu: a person links their Jira account to their
# CoderHelm user with a one-time code from the For you page (src/link.js).
jira:issueAction:
- key: coderhelm-link-account
title: Link my CoderHelm account
resource: link
render: native
resolver:
function: linkResolver
jira:adminPage:
- key: coderhelm-admin-page
resource: adminPage
Expand All @@ -46,9 +55,13 @@ modules:
handler: release.getIssuesHandler
- key: lifecycleHandler
handler: register.lifecycleHandler
- key: linkResolver
handler: link-resolver.handler
resources:
- key: adminPage
path: resources/admin/build
- key: link
path: src/frontend/link.jsx
permissions:
scopes:
- read:jira-work
Expand Down
4,933 changes: 4,907 additions & 26 deletions coderhelm-jira/package-lock.json

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions coderhelm-jira/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
},
"dependencies": {
"@forge/api": "^7.1.1",
"@forge/bridge": "^7.4.0",
"@forge/react": "^12.6.0",
"@forge/resolver": "^1.8.0",
"@forge/ui": "^1.11.4"
"@forge/ui": "^1.11.4",
"react": "^18.3.1"
},
"overrides": {
"glob": "^14.0.2"
"glob": "^14.0.2",
"prosemirror-view": "^1.42.3"
}
}
63 changes: 63 additions & 0 deletions coderhelm-jira/src/frontend/link.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// The "Link my CoderHelm account" action, in Jira's own UI Kit: a field for
// the code from CoderHelm's For you page and one button. The resolver
// (src/link.js) does the work; this only shows what it says.

import React, { useState } from "react";
import ForgeReconciler, { Box, Button, Form, FormFooter, FormSection, Label, SectionMessage, Stack, Text, Textfield, useForm } from "@forge/react";
import { invoke, view } from "@forge/bridge";

function LinkAccount() {
const { handleSubmit, register, getFieldId } = useForm();
const [result, setResult] = useState(null);
const [busy, setBusy] = useState(false);

const link = async (data) => {
setBusy(true);
try {
setResult(await invoke("linkAccount", { code: data.code }));
} catch (e) {
setResult({ ok: false, message: "CoderHelm couldn't be reached. Try again in a minute." });
} finally {
setBusy(false);
}
};

return (
<Stack space="space.200">
<Text>
Paste the code from CoderHelm's For you page (Connect Jira). CoderHelm then knows this Jira account is yours and shows your sprint there. Only your account id is sent, never your name or email.
</Text>
{result ? (
<SectionMessage appearance={result.ok ? "success" : "error"}>
<Text>{result.message}</Text>
</SectionMessage>
) : null}
{result && result.ok ? (
<Button onClick={() => view.close()}>Close</Button>
) : (
<Form onSubmit={handleSubmit(link)}>
<FormSection>
<Label labelFor={getFieldId("code")}>Code</Label>
<Box>
<Textfield {...register("code", { required: true })} placeholder="ABCD-EFGH-JKMN-PQRS" autoComplete="off" />
</Box>
</FormSection>
<FormFooter>
<Button appearance="subtle" onClick={() => view.close()}>
Cancel
</Button>
<Button appearance="primary" type="submit" isDisabled={busy}>
{busy ? "Linking..." : "Link my account"}
</Button>
</FormFooter>
</Form>
)}
</Stack>
);
}

ForgeReconciler.render(
<React.StrictMode>
<LinkAccount />
</React.StrictMode>,
);
106 changes: 106 additions & 0 deletions coderhelm-jira/src/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,118 @@ function issueOf(raw, links) {
/** The most issues one "what is waiting on me" read returns, of each kind. */
const MAX_MINE = 15;

// ── The person's open sprint (CoderHelm's For you page) ─────────────────────

/** The most sprint issues one read returns. */
const MAX_SPRINT = 50;
/** The characters of a description sent back (the fit checklist reads it). */
const MAX_DESCRIPTION_CHARS = 4000;

/**
* The JQL for "my open sprint": the person's unfinished issues in every open
* sprint, in board order. The app runs as itself (asApp), where
* currentUser() would be the app, so the account id is written in; it is
* checked to be an account id first, so it can't end the string.
*/
function sprintJql(accountId) {
const id = String(accountId || "");
if (!/^[A-Za-z0-9:-]{8,128}$/.test(id)) return null;
return `assignee = "${id}" AND sprint in openSprints() AND statusCategory != Done ORDER BY rank ASC`;
}

/**
* The site's story point and sprint fields, from GET /rest/api/3/field.
* Their ids differ per site (customfield_10016 on one, 10026 on another), so
* they are found by their type: Jira Software's story points (or a number
* field named "Story points" / "Story point estimate") and its sprint field.
*/
function fieldIds(fields) {
const list = Array.isArray(fields) ? fields : [];
const custom = (f) => (f && f.schema && f.schema.custom) || "";
const points =
list.find((f) => custom(f).endsWith(":jsw-story-points")) ||
list.find((f) => /^story points?( estimate)?$/i.test(String((f && f.name) || "").trim()) && f.schema && f.schema.type === "number") ||
null;
const sprint = list.find((f) => custom(f) === "com.pyxis.greenhopper.jira:gh-sprint") || null;
return { points: points ? points.id : null, sprint: sprint ? sprint.id : null };
}

/** The open sprint an issue is in (the active one when it is in several). */
function openSprintOf(value) {
const all = (Array.isArray(value) ? value : []).filter((s) => s && typeof s === "object");
const open = all.filter((s) => s.state === "active");
const s = open[0] || all.find((x) => x.state === "future") || null;
if (!s) return null;
return { id: s.id || null, name: String(s.name || ""), state: String(s.state || ""), end_date: String(s.endDate || "") };
}

/** One sprint issue as the fit checklist reads it. */
function sprintIssueOf(raw, ids) {
Comment thread
coderhelm[bot] marked this conversation as resolved.
Resolved
const f = (raw && raw.fields) || {};
const pts = ids && ids.points ? f[ids.points] : null;
return {
key: raw.key,
summary: f.summary || "",
type: (f.issuetype && f.issuetype.name) || "",
status: (f.status && f.status.name) || "",
status_category: (f.status && f.status.statusCategory && f.status.statusCategory.key) || "",
priority: (f.priority && f.priority.name) || "",
assignee_id: accountIdOf(f.assignee),
labels: Array.isArray(f.labels) ? f.labels.filter((l) => typeof l === "string").slice(0, 30) : [],
components: (Array.isArray(f.components) ? f.components : []).map((c) => (c && c.name) || "").filter(Boolean).slice(0, 10),
points: typeof pts === "number" && Number.isFinite(pts) ? pts : null,
description: adfText(f.description).trim().slice(0, MAX_DESCRIPTION_CHARS),
sprint: ids && ids.sprint ? openSprintOf(f[ids.sprint]) : null,
updated: f.updated || "",
};
}

/**
* What "Give to CoderHelm" may do to an issue, checked before any call: a
* real key, the team's trigger label (letters, digits and : / . _ -), and
* the giver's account id. `null` when any is wrong.
*/
function giveRequest(give) {
const key = String((give && give.key) || "");
const label = String((give && give.label) || "");
const accountId = String((give && give.account_id) || "");
if (!/^[A-Z][A-Z0-9_]{0,19}-\d{1,7}$/.test(key)) return null;
if (!/^[A-Za-z0-9_:\/.-]{1,100}$/.test(label)) return null;
if (!/^[A-Za-z0-9:-]{8,128}$/.test(accountId)) return null;
return { key, label, accountId };
}

/**
* The label updates that make Jira send the change CoderHelm starts on: an
* add, or (when the label is already there, from an earlier run) a remove
* then an add, since an unchanged label sends no event.
*/
function labelSteps(labels, label) {
const has = (Array.isArray(labels) ? labels : []).includes(label);
return has ? [{ remove: label }, { add: label }] : [{ add: label }];
}

/** The fields a sprint read asks Jira for. */
function sprintFields(ids) {
const base = ["summary", "issuetype", "status", "priority", "assignee", "labels", "components", "description", "updated"];
return [...base, ...[ids && ids.points, ids && ids.sprint].filter(Boolean)];
}

module.exports = {
adfText,
adfMentions,
jqlFor,
mineJql,
issueOf,
sprintJql,
giveRequest,
labelSteps,
fieldIds,
openSprintOf,
sprintIssueOf,
sprintFields,
MAX_SPRINT,
MAX_DESCRIPTION_CHARS,
MAX_SEARCH,
MAX_MINE,
MAX_ISSUE_COMMENTS,
Expand Down
12 changes: 12 additions & 0 deletions coderhelm-jira/src/link-resolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// The resolver behind "Link my CoderHelm account" (manifest: linkResolver).
// The work and its tests are in link.js; this file only wires it to Forge.

const Resolver = require("@forge/resolver").default;
const { linkAccount } = require("./link");

const resolver = new Resolver();

// `context.accountId` is the person who opened the action, set by Forge.
resolver.define("linkAccount", ({ payload, context }) => linkAccount(payload, context));

exports.handler = resolver.getDefinitions();
110 changes: 110 additions & 0 deletions coderhelm-jira/src/link.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
// "Link my CoderHelm account": a person proves which Jira account is theirs.
//
// CoderHelm's For you page shows a person their own sprint, and starts work
// on a ticket with them as its owner. For that it must know which Jira
// account belongs to which CoderHelm user, and an email match can't tell:
// Atlassian lets people hide their email, and work and sign-in emails often
// differ. So the link is made by the person, from both sides at once:
//
// 1. On CoderHelm's For you page they ask for a one-time code (it is
// signed for their team and works for fifteen minutes).
// 2. Here, from any issue's "..." menu, they open "Link my CoderHelm
// account" and paste it.
// 3. This resolver sends the code with the account id Forge gives for the
// person who opened the action (`context.accountId`: Forge sets it, the
// person can't type another one) to CoderHelm, proven by the site's
// Forge secret like every event the app sends.
//
// CoderHelm then stores which CoderHelm user that Jira account is. Nothing
// about the person (no name, no email) is sent: only the account id and the
// code. Unlinking is on the For you page.

/** The Forge SDK, loaded when first used, so this file (and its tests) load without it. */
function forge() {
return require("@forge/api");
}

const { GATEWAY_URL } = require("./gateway");
const { versionFields } = require("./version");

/** A code as CoderHelm shows it (ABCD-EFGH-JKMN-PQRS), typed loosely. */
function cleanCode(raw) {
const code = String(raw || "")
.toUpperCase()
.replace(/[^0-9A-Z]/g, "");
return code.length === 16 ? code : null;
}

/** The body sent to CoderHelm: the team's proof, the account and the code. */
function linkBody(config, accountId, code, getAppContext) {
return {
coderhelm: {
team_id: config.teamId,
forge_secret: config.forgeSecret,
...versionFields(getAppContext),
},
account_id: accountId,
code,
};
}

/** What the person reads after CoderHelm answered `status` with `body`. */
function linkResult(status, body) {
const said = body && typeof body.message === "string" ? body.message : "";
if (status === 200) {
return { ok: true, message: said || "Linked. Your sprint shows on CoderHelm's For you page." };
}
if (status === 410 || status === 404) {
return { ok: false, message: said || "That code has expired or was already used. Make a new one on the For you page." };
}
if (status === 409) {
return { ok: false, message: said || "This Jira account is already linked to another CoderHelm user." };
}
if (status === 400) {
return { ok: false, message: said || "That isn't a CoderHelm code. Copy it again from the For you page." };
}
if (status === 403 || status === 401) {
return { ok: false, message: "CoderHelm didn't recognize this Jira site. Ask your Jira admin to check the app's settings." };
}
return { ok: false, message: `CoderHelm couldn't link the account right now (${status}). Try again in a minute.` };
}

/**
* Links the account of the person who opened the action. `deps` are the
* Forge pieces, passed in by tests.
*/
async function linkAccount(payload, context, deps = {}) {
const storage = deps.storage || forge().storage;
const fetch = deps.fetch || forge().fetch;
const accountId = String((context && context.accountId) || "");
if (!/^[A-Za-z0-9:-]{8,128}$/.test(accountId)) {
return { ok: false, message: "Jira didn't say who you are. Open the action from an issue while signed in." };
}
const code = cleanCode(payload && payload.code);
if (!code) {
return { ok: false, message: "That isn't a CoderHelm code. It has 16 letters and numbers, like ABCD-EFGH-JKMN-PQRS." };
}
const config = await storage.get("coderhelm-config");
if (!config || !config.teamId || !config.forgeSecret) {
return { ok: false, message: "This Jira site isn't connected to CoderHelm yet. Ask your Jira admin to set it up." };
}
try {
const res = await fetch(`${GATEWAY_URL}/webhooks/jira-link`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(linkBody(config, accountId, code, deps.getAppContext)),
});
let body = null;
try {
body = await res.json();
} catch (_) {
body = null;
}
return linkResult(res.status, body);
} catch (e) {
console.error("Link my CoderHelm account failed:", e);
return { ok: false, message: "CoderHelm couldn't be reached. Try again in a minute." };
}
}

module.exports = { cleanCode, linkBody, linkResult, linkAccount };
Loading