Skip to content

Commit 06d3171

Browse files
workaround bug (#6)
Co-authored-by: Franz the Dog <franz@cutedogs.org>
2 parents eac49a0 + 17bf026 commit 06d3171

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/generator/workflow.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,18 @@ function stepToYaml(step: GhaStep): Record<string, unknown> {
2828
}
2929

3030
/**
31-
* Builds the claude-code-action step.
31+
* Workaround for https://github.com/anthropics/claude-code-action/issues/944
32+
* When track_progress is disabled (labeled events), claude-code-action does not
33+
* post a PR comment automatically. This suffix instructs Claude to post one itself.
3234
*/
35+
const LABELED_EVENT_COMMENT_SUFFIX =
36+
"\n\n${{ github.event.action == 'labeled' && format(" +
37+
"'Since this run was triggered by a label event, automatic progress tracking is disabled. " +
38+
"After completing the task, you MUST post your full response as a PR comment. " +
39+
"Write your response to /tmp/claude-response.md, then run: " +
40+
"gh pr comment {0} --repo {1} --body-file /tmp/claude-response.md', " +
41+
"github.event.pull_request.number, github.repository) || '' }}";
42+
3343
/**
3444
* Default tools that are always allowed. These are all safe, non-mutating
3545
* tools (no permission required) plus scoped Bash patterns for git/gh.
@@ -90,8 +100,8 @@ function buildActionStep(
90100
const withBlock: Record<string, unknown> = {
91101
anthropic_api_key: "${{ secrets.ANTHROPIC_API_KEY }}",
92102
github_token: "${{ secrets.GITHUB_TOKEN }}",
93-
track_progress: true,
94-
prompt,
103+
track_progress: "${{ github.event.action != 'labeled' }}",
104+
prompt: prompt + LABELED_EVENT_COMMENT_SUFFIX,
95105
};
96106

97107
const toolArgs = `--allowedTools '${allowedTools.join(",")}'`;

test/generator/workflow.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ describe("generateWorkflow", () => {
5252
(s: any) => s.uses === "anthropics/claude-code-action@v1"
5353
);
5454
expect(actionStep).toBeTruthy();
55-
expect(actionStep.with.prompt).toBe("Review this code");
55+
expect(actionStep.with.prompt).toStartWith("Review this code");
56+
expect(actionStep.with.prompt).toContain("gh pr comment");
57+
expect(actionStep.with.prompt).toContain("github.event.action == 'labeled'");
5658
expect(actionStep.with.github_token).toBe("${{ secrets.GITHUB_TOKEN }}");
57-
expect(actionStep.with.track_progress).toBe(true);
59+
expect(actionStep.with.track_progress).toBe("${{ github.event.action != 'labeled' }}");
5860
// default allowed tools passed via a single --allowedTools flag (comma-separated)
5961
const args: string = actionStep.with.claude_args;
6062
const match = args.match(/--allowedTools '([^']+)'/);
@@ -140,7 +142,7 @@ describe("generateWorkflow", () => {
140142
const actionStep = jobs.task.steps.find(
141143
(s: any) => s.uses === "anthropics/claude-code-action@v1"
142144
);
143-
expect(actionStep.with.prompt).toBe("Review this code");
145+
expect(actionStep.with.prompt).toStartWith("Review this code");
144146
expect(actionStep.with.claude_args).toContain("--append-system-prompt 'Be helpful.'");
145147
expect(actionStep.with.claude_args).toContain("--allowedTools");
146148
});

0 commit comments

Comments
 (0)