mirror of
https://gh-proxy.org/https://github.com/klinsmaya/multica.git
synced 2026-11-08 17:36:45 +08:00
* feat(pr): move issues to a workspace-chosen status when their PRs merge (MUL-7726) The merge automation completed an issue only when a PR said "Closes MUL-1", so the workspace switch mostly did nothing: most PRs are linked by title or branch and never completed anything. The workspace now picks what a merge does, in settings.pr_merge_status: "none", or the key of a started or done status (custom ones included, Blocked excluded). Absent means Done. When every linked PR is merged, the issue moves to that status. A closing keyword only links. - Decision: terminal, triage, "none", the per-issue switch and a new at_target state (the issue already has the target) come before the PR states, so the issue page only speaks when a merge would move the issue. The response adds target_status. - MoveIssueFromPullRequests replaces CompleteIssueFromPullRequests and writes the target status. The target is resolved through the delivery's shared catalog read (Resolver.WritableCategory). An archived or unknown choice, or a failed read, fails closed to no write. - Close intent is no longer synced or read. The column stays. - Migration 551 pins "none" on existing workspaces whose history shows a merge never moved every issue: auto-complete switched off, or a linked PR whose merges were not all keyword merges. Workspaces with no links, or with only keyword merges, keep the Done default. Replays are harmless. - CLI: `multica issue pr-automation <id> on|off` lets an agent keep one issue where it is. The multica-platform skill describes the new rule. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: multica-agent <[email protected]> * feat(views): choose the status merged PRs move an issue to on the GitHub page (MUL-7726) - Settings → Integrations → GitHub → Features: "After PRs merge, move the issue to" picks Don't change, or a started or done status, custom ones included and Blocked excluded. It replaces the read-only auto-complete row. The self-hosted Git page shows the same setting. The statuses page drops its switch, and a badge on the target status now links to the setting. - Issue sidebar: the line under the PR list names the target status ("Moves to In Review when #19 merges"). It says nothing when the workspace leaves status alone, when the issue already has the target, or on an older backend's no_close_intent. The per-issue switch reads "Keep status when PRs merge" and is hidden when it would change nothing. The menu opens the GitHub setting. The link hint only shows while auto-link is on. - core: derivePRMergeStatus replaces derivePRAutoCompleteEnabled; the auto_complete schema adds target_status and the at_target state. - Copy in 5 languages. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: multica-agent <[email protected]> * docs: describe the workspace-chosen status for merged PRs (MUL-7726) GitHub integration, self-hosted Git, issues and environment variable pages (4-5 languages) now say that the workspace picks what a merge does: Done by default, another started or done status, or no change. They also say that a closing keyword only links, and how to keep one issue's status. The troubleshooting entries explain what a missing line under the PR list means. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: multica-agent <[email protected]> * refactor(pr): keep the merge automation out of agents' instructions (MUL-7726) Agents don't act on what a merge does to an issue, so they don't need a command for it or a rule to learn. Drop `multica issue pr-automation`, and cut the multica-platform skill down to how PRs get linked: no merge rule, no auto_complete field guide, no "the server moves it to done" note. People still keep one issue's status from its Pull requests menu, and the docs now point there. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: multica-agent <[email protected]> * fix(pr): keep the retired auto-complete switch working for old desktop clients (MUL-7726) Review of #8862: an admin on a desktop client from before this change can still flip "Complete issues when their PRs merge". The client saved pr_auto_complete_enabled = false, and the save looked successful, but the server only read pr_merge_status, so merges kept moving issues to Done. - Settings writes: a flip of the retired switch becomes a choice (off → none, on → Done). An old client that echoes a chosen target without flipping the switch leaves the target alone. Every write mirrors the switch from the effective choice (false for none, absent otherwise), so old clients show the right state. - Reads: without pr_merge_status, the retired switch decides (off → none, else Done), on the server and in derivePRMergeStatus. This also covers settings written by a pod that predates the change during rollout. - Migration 551 sets the switch off on the workspaces it pins to none. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-authored-by: multica-agent <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: multica-agent <[email protected]>
97 lines
3.6 KiB
SQL
97 lines
3.6 KiB
SQL
-- =====================
|
|
-- PR auto-complete (MUL-7429)
|
|
-- =====================
|
|
|
|
-- name: GetIssuePRAutoCompleteDisabled :one
|
|
SELECT EXISTS (
|
|
SELECT 1 FROM issue_pr_automation
|
|
WHERE issue_id = $1 AND auto_complete_disabled
|
|
)::boolean AS disabled;
|
|
|
|
-- name: SetIssuePRAutoCompleteDisabled :exec
|
|
INSERT INTO issue_pr_automation (
|
|
issue_id, workspace_id, auto_complete_disabled, updated_by_type, updated_by_id
|
|
) VALUES (
|
|
$1, $2, $3, sqlc.narg('updated_by_type'), sqlc.narg('updated_by_id')
|
|
)
|
|
ON CONFLICT (issue_id) DO UPDATE SET
|
|
auto_complete_disabled = EXCLUDED.auto_complete_disabled,
|
|
updated_by_type = EXCLUDED.updated_by_type,
|
|
updated_by_id = EXCLUDED.updated_by_id,
|
|
updated_at = now();
|
|
|
|
-- name: IsPullRequestExcludedFromIssue :one
|
|
SELECT EXISTS (
|
|
SELECT 1 FROM issue_pull_request_exclusion
|
|
WHERE issue_id = $1 AND pull_request_id = $2
|
|
)::boolean AS excluded;
|
|
|
|
-- name: ExcludePullRequestFromIssue :exec
|
|
INSERT INTO issue_pull_request_exclusion (
|
|
issue_id, pull_request_id, workspace_id, excluded_by_type, excluded_by_id
|
|
) VALUES (
|
|
$1, $2, $3, sqlc.narg('excluded_by_type'), sqlc.narg('excluded_by_id')
|
|
)
|
|
ON CONFLICT (issue_id, pull_request_id) DO UPDATE SET
|
|
excluded_by_type = EXCLUDED.excluded_by_type,
|
|
excluded_by_id = EXCLUDED.excluded_by_id,
|
|
created_at = now();
|
|
|
|
-- name: DeletePullRequestExclusion :exec
|
|
DELETE FROM issue_pull_request_exclusion
|
|
WHERE issue_id = $1 AND pull_request_id = $2;
|
|
|
|
-- name: ListIssueLinkedPullRequestStates :many
|
|
-- Every PR linked to the issue across GitHub and self-hosted providers, for
|
|
-- the merge decision. Ordered by number so reasons read stably.
|
|
SELECT pr.id, 'github'::text AS provider, pr.pr_number, pr.state
|
|
FROM github_pull_request pr
|
|
JOIN issue_pull_request ipr ON ipr.pull_request_id = pr.id
|
|
WHERE ipr.issue_id = $1
|
|
UNION ALL
|
|
SELECT pr.id, pr.provider AS provider, pr.pr_number, pr.state
|
|
FROM vcs_pull_request pr
|
|
JOIN issue_vcs_pull_request ipr ON ipr.pull_request_id = pr.id
|
|
WHERE ipr.issue_id = $1
|
|
ORDER BY pr_number;
|
|
|
|
-- name: MoveIssueFromPullRequests :one
|
|
-- Conditional status write for the PR merge automation. It lands only if the
|
|
-- issue is still in the status the decision saw (two merges racing move it
|
|
-- once), is not already in the target, and the linked PRs are still all merged
|
|
-- when the write runs (a PR linked between the decision and this statement
|
|
-- keeps the issue where it is). Repositions and clears a duplicate mark like
|
|
-- UpdateIssueStatus does; the target is never cancelled.
|
|
UPDATE issue AS i SET
|
|
status = sqlc.arg('target_status')::text,
|
|
duplicate_of_issue_id = NULL,
|
|
position = (
|
|
SELECT COALESCE(MIN(target.position), 0) - 1
|
|
FROM issue AS target
|
|
WHERE target.workspace_id = i.workspace_id
|
|
AND target.status = sqlc.arg('target_status')::text
|
|
),
|
|
revision = i.revision + 1,
|
|
last_activity_at = GREATEST(COALESCE(i.last_activity_at, i.updated_at), now()),
|
|
updated_at = now()
|
|
WHERE i.id = $1
|
|
AND i.workspace_id = $2
|
|
AND i.status = sqlc.arg('expected_status')::text
|
|
AND i.status <> sqlc.arg('target_status')::text
|
|
AND EXISTS (
|
|
SELECT 1 FROM issue_pull_request ipr WHERE ipr.issue_id = i.id
|
|
UNION ALL
|
|
SELECT 1 FROM issue_vcs_pull_request ipr WHERE ipr.issue_id = i.id
|
|
)
|
|
AND NOT EXISTS (
|
|
SELECT 1 FROM issue_pull_request ipr
|
|
JOIN github_pull_request pr ON pr.id = ipr.pull_request_id
|
|
WHERE ipr.issue_id = i.id AND pr.state <> 'merged'
|
|
)
|
|
AND NOT EXISTS (
|
|
SELECT 1 FROM issue_vcs_pull_request ipr
|
|
JOIN vcs_pull_request pr ON pr.id = ipr.pull_request_id
|
|
WHERE ipr.issue_id = i.id AND pr.state <> 'merged'
|
|
)
|
|
RETURNING i.*;
|