Skip to content

feat: add copy button to action step header, improve other copy buttons#37744

Merged
silverwind merged 25 commits into
go-gitea:mainfrom
silverwind:copy-step-output
May 21, 2026
Merged

feat: add copy button to action step header, improve other copy buttons#37744
silverwind merged 25 commits into
go-gitea:mainfrom
silverwind:copy-step-output

Conversation

@silverwind
Copy link
Copy Markdown
Member

@silverwind silverwind commented May 17, 2026

  • Adds a copy button to each action step header that copies the step's rendered log output to clipboard.
  • Extract a shared copyToClipboard(target, content) helper in clipboard.ts that adds SVG success/failure feedback.
  • is-loading height for the new helper is sourced from --loading-size.
  • Change actions log timestamp format to include seconds.

The indented-markdown code-block fix has moved to #37748.

copystep copybt

Fixes: #26116


This PR was written with the help of Claude Opus 4.7

Adds a copy button to each action step header that copies the step's
rendered log output to clipboard. For collapsed steps the logs are
fetched on demand via the existing actions-view endpoint.

Along the way:

- Extract a shared `copyToClipboard(target, content)` helper in
  `clipboard.ts` with a re-entry guard and SVG success/failure feedback
  (octicon-check / octicon-x). Migrates `copycontent.ts` and the
  dropzone "Copy link" to use it.
- Wrap indented markdown code blocks in the same `<div class="code-block-container">`
  as the fenced renderer so the existing code-copy button applies to
  both syntaxes.
- Spinner height for the new helper is sourced from `--loading-size`,
  falling back to the previous `min(4em, 66.6%)` for existing callers.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label May 17, 2026
@silverwind silverwind changed the title feat(actions): add copy button to action step header feat(actions): add copy button to action step header, refactor other copy buttons May 17, 2026
@silverwind silverwind changed the title feat(actions): add copy button to action step header, refactor other copy buttons feat: add copy button to action step header, refactor other copy buttons May 17, 2026
@bircni
Copy link
Copy Markdown
Member

bircni commented May 17, 2026

There was also an issue somewhere which requested that...

@silverwind
Copy link
Copy Markdown
Member Author

Was #26116

@silverwind
Copy link
Copy Markdown
Member Author

Wrap indented markdown code blocks the same fenced renderer so the existing code-copy button applies to both syntaxes (pre-existing bug).

FYI this is a problem I encountered while testing the copy buttons. Markdown code block created via indentation were not showing a copy button, now they do. Could potentially extract to another PR.

@lunny lunny added the type/enhancement An improvement of existing functionality label May 17, 2026
Moved to its own PR (go-gitea#37748) since it's an independent bug fix.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
@silverwind
Copy link
Copy Markdown
Member Author

markdown code blocks

Extracted to #37748

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a “copy step output” control to the Actions job step header and consolidates various copy-to-clipboard behaviors behind a shared copyToClipboard() helper that provides inline SVG success/failure feedback and a consistent loading spinner size.

Changes:

  • Add a copy button to each Actions job step header that copies either rendered logs (expanded) or fetched logs (collapsed).
  • Refactor existing copy interactions (file content copy, dropzone attachment markdown link copy, global data-clipboard-* handler) to use a shared copyToClipboard() helper with icon feedback.
  • Adjust loading spinner CSS to support btn-octicon and allow the spinner size to be driven by --loading-size.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
web_src/js/features/repo-actions.ts Passes the new copyStepOutput locale string into the Actions view Vue app.
web_src/js/features/dropzone.ts Replaces ad-hoc clipboard+tooltip copy with the new copyToClipboard() helper.
web_src/js/features/copycontent.ts Refactors file content copying (including image conversion) to use copyToClipboard() with loading handling.
web_src/js/features/clipboard.ts Introduces copyToClipboard() with loading + SVG feedback, and wires it into the global data-clipboard-* click handler.
web_src/js/components/ActionRunJobView.vue Adds the per-step “copy output” button and implements on-demand log fetching for collapsed steps.
web_src/css/modules/animations.css Ensures .btn-octicon.is-loading hides children; makes loading spinner height configurable via --loading-size.
templates/repo/actions/view_component.tmpl Provides data-locale-copy-step-output to the Actions view container.
templates/base/head_script.tmpl Removes global i18n.copy_success / i18n.copy_error entries.
options/locale/locale_en-US.json Adds the copy_step_output translation string.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread web_src/js/features/clipboard.ts Outdated
Comment thread web_src/js/components/ActionRunJobView.vue Outdated
The render path skips both `hidden` and `endgroup` commands (only
`group` emits a summary line). The fetch path was skipping only
`hidden`, so copying from a collapsed step produced extra blank lines.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
@silverwind silverwind changed the title feat: add copy button to action step header, refactor other copy buttons feat: add copy button to action step header, improve other copy buttons May 18, 2026
@lunny
Copy link
Copy Markdown
Member

lunny commented May 18, 2026

Should it copy the timestamp if it displayed?

@bircni
Copy link
Copy Markdown
Member

bircni commented May 18, 2026

Should it copied the timestamp if it displayed?

No I dont see a use case for that

@lunny lunny added this to the 1.27.0 milestone May 18, 2026
@silverwind
Copy link
Copy Markdown
Member Author

silverwind commented May 18, 2026

Should it copy the timestamp if it displayed?

It might be useful for timing-related issues, I'm undecided.

Comment thread web_src/js/components/ActionRunJobView.vue Outdated
@wxiaoguang

This comment was marked as resolved.

@wxiaoguang wxiaoguang marked this pull request as draft May 18, 2026 07:19
@silverwind
Copy link
Copy Markdown
Member Author

If it's for machine parsing, then yes, raw with timestamp might be better.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels May 18, 2026
@wxiaoguang
Copy link
Copy Markdown
Contributor

Do the new change look good to you? If any doesn't look good, feel free to revert or reset.

Comment thread web_src/js/utils/time.ts Outdated
@silverwind
Copy link
Copy Markdown
Member Author

Not sure I like this copyTextToClipboard. It's precise which could be beneficial but I don't see why we couldn't just expose ClippieContent on all functions (accept blob + array formats).

@wxiaoguang
Copy link
Copy Markdown
Contributor

Not sure I like this copyTextToClipboard. It's precise which could be beneficial but I don't see why we couldn't just expose ClippieContent on all functions (accept blob + array formats).

Renamed it to copyContentToClipboard

@wxiaoguang wxiaoguang marked this pull request as ready for review May 20, 2026 16:40
@wxiaoguang
Copy link
Copy Markdown
Contributor

#37744 (comment)

noting this TODO I spotted for me later.

Is this still WIP?

@silverwind silverwind marked this pull request as draft May 20, 2026 22:33
@silverwind
Copy link
Copy Markdown
Member Author

Yes will fix and re-review those functions.

silverwind and others added 2 commits May 21, 2026 02:30
Use the browser's resolved hourCycle (collapsed to h12/h23) instead of the
hour12 boolean, so the "Show timestamps" output matches what <relative-time> renders.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
The bare primitive takes the unqualified copyToClipboard; the DOM/feedback
variant becomes copyToClipboardWithFeedback, so callers see the difference.

Co-Authored-By: Claude (Opus 4.7) <noreply@anthropic.com>
@silverwind
Copy link
Copy Markdown
Member Author

Functions renamed:

  • copyToClipboard just copies, no feedback
  • copyToClipboardWithFeedback copies with feedback and target is required

I think that's the cleanest option by far.

@silverwind silverwind marked this pull request as ready for review May 21, 2026 00:43
@silverwind
Copy link
Copy Markdown
Member Author

@wxiaoguang looking good?

@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label May 21, 2026
@silverwind silverwind enabled auto-merge (squash) May 21, 2026 07:12
@GiteaBot
Copy link
Copy Markdown
Collaborator

@silverwind please fix the merge conflicts. 🍵

@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label May 21, 2026
* origin/main:
  style: misc UI fixes (go-gitea#37691)
  ci: shard tests and reduce redundant work (go-gitea#37618)
  chore: simplify issue and pull request templates (go-gitea#37799)

# Conflicts:
#	web_src/js/components/ActionRunJobView.vue
@silverwind silverwind added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label May 21, 2026
@silverwind silverwind merged commit b7e95cc into go-gitea:main May 21, 2026
24 checks passed
@silverwind silverwind deleted the copy-step-output branch May 21, 2026 07:39
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quick copy for action log?

6 participants