-
Notifications
You must be signed in to change notification settings - Fork 43
Add copy button for dictation instructions in documentation #2250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
| @@ -0,0 +1,22 @@ | |||
| import type { APIRoute } from 'astro'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot could you just use the raw url instead? https://raw.githubusercontent.com/githubnext/gh-aw/main/.github/instructions/dictation.instructions.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to use the raw GitHub URL directly. Removed the custom API endpoint and simplified the implementation. (06a0786)
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
Agentic Changeset Generator triggered by this pull request. |
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>

Overview
This PR adds a "Copy entire file" button next to the dictation instructions link in the Authoring Agentic Workflows documentation page. Users can now easily copy the full contents of the dictation instructions file to their clipboard with a single click.
Implementation
The solution uses a pure Astro component with vanilla JavaScript to avoid SSR/static generation complexities:
1. Copy Button Component (
docs/src/components/CopyEntireFileButton.astro)2. Documentation Update
docs/src/content/docs/tools/agentic-authoring.mdto.mdxto support component importshttps://raw.githubusercontent.com/githubnext/gh-aw/main/.github/instructions/dictation.instructions.mdScreenshot
The button appears inline with the text in the "Dictating Agentic Workflows" section, styled consistently with the Starlight theme.
Technical Notes
Testing
npm run buildcompletes successfullyOriginal prompt
Here’s a concise implementation plan and code to add a “Copy entire file” button next to the instruction link in the dictation documentation, using a React component loaded in Astro Starlight. It will copy the entire contents of dictation.instructions.md.
Overview
Code:
import React, { useState, useCallback } from 'react';
type Props = {
filePath: string; // e.g. '/docs/dictation.instructions.md'
label?: string; // optional button text
};
export default function CopyEntireFileButton({ filePath, label = 'Copy instructions' }: Props) {
const [status, setStatus] = useState<'idle' | 'copying' | 'success' | 'error'>('idle');
const handleCopy = useCallback(async () => {
try {
setStatus('copying');
const res = await fetch(filePath, { cache: 'no-store' });
if (!res.ok) throw new Error(
Failed to fetch file: ${res.status});const text = await res.text();
}, [filePath]);
const textByStatus: Record<typeof status, string> = {
idle: label,
copying: 'Copying…',
success: 'Copied!',
error: 'Error',
};
return (
<button
type="button"
onClick={handleCopy}
aria-label="Copy entire instructions file to clipboard"
title="Copy entire instructions file to clipboard"
disabled={status === 'copying'}
style={{
display: 'inline-flex',
alignItems: 'center',
gap: '0.4rem',
padding: '0.4rem 0.6rem',
borderRadius: '6px',
border: '1px solid var(--sl-color-hairline)',
background: 'var(--sl-color-bg)',
color: 'var(--sl-color-text)',
cursor: 'pointer',
}}
>
{textByStatus[status]}
);
}
a) If dictation.instructions.md is part of the built docs site at a known URL (e.g., /docs/dictation.instructions/), fetch that route’s raw source is tricky since the built page is HTML. Instead, add a raw copy under public, or expose the raw content via an endpoint.
b) Easiest: add a build step that copies the raw source to public for fetch:
If you prefer not to duplicate files, create an Astro endpoint to return the raw source:
// Astro endpoint returning the raw instructions
import type { APIRoute } from 'astro';
import fs from 'node:fs/promises';
import path from 'node:path';
export const GET: APIRoute = async () => {
const file = path.resolve(import.meta.env.PROJECT_ROOT || process.cwd(), 'docs/dictation.instructions.md');
try {
const content = await fs.readFile(file, 'utf8');
return new Response(content, {
status: 200,
headers: { 'Content-Type': 'text/plain; charset=utf-8' },
});
} catch (e) {
return new Response('Not found', { status: 404 });
}
};
In docs/dictation.md (or wherever the dictation page lives):
title: Dictation
Instructions
import CopyEntireFileButton from '@/components/CopyEntireFileButton.tsx';
{/* Place the button next to the instr...
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.