Skip to content

Commit 3b79303

Browse files
rfayclaude
andauthored
feat: improve issue visibility across Drupal workspace flow (#32)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 927b5f0 commit 3b79303

File tree

5 files changed

+146
-68
lines changed

5 files changed

+146
-68
lines changed

docs/drupal-issue.html

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>Drupal Issue Picker — DDEV Coder Workspaces</title>
6+
<title>Drupal Core Issue Picker — DDEV Coder Workspaces</title>
7+
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
78
<style>
89
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
910

@@ -274,12 +275,12 @@
274275
<header>
275276
<a href="/">DDEV Coder Workspaces</a>
276277
<span class="sep">/</span>
277-
<span class="title">Drupal Issue Picker</span>
278+
<span class="title">Drupal Core Issue Picker</span>
278279
</header>
279280

280281
<div class="page">
281-
<h1>Drupal Issue Picker</h1>
282-
<p class="subtitle">Enter a Drupal.org issue URL or number to launch a pre-configured workspace.</p>
282+
<h1>Drupal Core Issue Picker</h1>
283+
<p class="subtitle">Enter a Drupal core issue URL or number to launch a pre-configured workspace.</p>
283284

284285
<div class="input-row">
285286
<input type="text" id="issue-input"
@@ -448,7 +449,27 @@ <h2>Notes</h2>
448449
'https://git.drupalcode.org/api/v4/projects/' + encodedProject + '/repository/branches?per_page=100'
449450
);
450451
if (branchResp.status === 404) {
451-
setStatus('No issue fork exists for #' + nid + ' yet. To work on this issue, visit the issue page on drupal.org and click "Get push access" to create a fork, then come back here.', 'info');
452+
// Distinguish: issue doesn't exist vs. issue exists but no fork yet
453+
try {
454+
const checkResp = await fetch('https://www.drupal.org/api-d7/node/' + nid + '.json');
455+
if (!checkResp.ok) {
456+
setStatus('Issue #' + nid + ' does not exist on drupal.org. Check the issue number and try again.', 'error');
457+
} else {
458+
// Verify the response is actually a valid node (not a redirect or error page)
459+
let nodeData;
460+
try { nodeData = await checkResp.json(); } catch (_) { nodeData = null; }
461+
const projectName = nodeData && nodeData.field_project && nodeData.field_project.machine_name;
462+
if (!nodeData || String(nodeData.nid) !== String(nid)) {
463+
setStatus('Issue #' + nid + ' does not exist on drupal.org. Check the issue number and try again.', 'error');
464+
} else if (projectName && projectName !== 'drupal') {
465+
setStatus('Issue #' + nid + ' is a ' + projectName + ' issue, not a Drupal core issue. At this time this picker only supports Drupal core.', 'error');
466+
} else {
467+
setStatus('No issue fork exists for #' + nid + ' yet. To work on this issue, visit the issue page on drupal.org and click "Get push access" to create a fork, then come back here.', 'info');
468+
}
469+
}
470+
} catch (_) {
471+
setStatus('Issue #' + nid + ' does not appear to exist on drupal.org. Check the issue number and try again.', 'error');
472+
}
452473
document.getElementById('load-btn').disabled = false;
453474
return;
454475
}
@@ -486,8 +507,15 @@ <h2>Notes</h2>
486507
const preferred = branches.find(b => b.name.startsWith(nid + '-'));
487508
if (preferred) branchSelect.value = preferred.name;
488509

489-
// Set issue title
490-
document.getElementById('issue-title-text').textContent = '#' + nid + ': ' + title;
510+
// Set issue title with clickable link
511+
const titleEl = document.getElementById('issue-title-text');
512+
titleEl.innerHTML = '';
513+
const issueLink = document.createElement('a');
514+
issueLink.href = 'https://www.drupal.org/project/drupal/issues/' + nid;
515+
issueLink.target = '_blank';
516+
issueLink.textContent = '#' + nid + ': ' + title;
517+
issueLink.style.cssText = 'color: inherit; text-decoration: underline;';
518+
titleEl.appendChild(issueLink);
491519

492520
// Store and display detected Drupal version
493521
currentDrupalMajor = drupalMajor;

docs/favicon.svg

Lines changed: 1 addition & 0 deletions
Loading

docs/index.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>DDEV Coder Workspaces — Drupal Core Development</title>
7+
<link rel="icon" type="image/svg+xml" href="/favicon.svg">
78
<style>
89
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
910

@@ -262,8 +263,8 @@ <h2>Drupal issue development</h2>
262263
<div class="template-cards">
263264
<div class="template-card">
264265
<div class="info">
265-
<h3>Drupal Issue Picker</h3>
266-
<p>Enter a Drupal.org issue number — auto-selects branch and launches a workspace with the issue fork checked out</p>
266+
<h3>Drupal Core Issue Picker</h3>
267+
<p>Enter a Drupal.org core issue number — auto-selects branch and launches a workspace with the issue fork checked out</p>
267268
</div>
268269
<a class="btn" href="drupal-issue" style="background:#7c5af0;color:#fff;border-radius:8px;padding:0.6rem 1rem;font-size:0.9rem;font-weight:600;text-decoration:none;white-space:nowrap;">Open Picker</a>
269270
</div>

docs/user/quickstart.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ ddev ssh
6868

6969
The fastest way: use the **[Drupal Issue Picker](https://start.coder.ddev.com/drupal-issue)**. Paste a drupal.org issue URL or bare issue number — it fetches the available branches, lets you pick one, and opens a pre-configured workspace with the issue branch already checked out and all Composer dependencies resolved for that branch.
7070

71+
When working on an issue, the workspace surfaces issue info in several places:
72+
73+
- **Workspace resource page** — the `issue_url` metadata item links directly to the drupal.org issue
74+
- **`~/WELCOME.txt`** — shows the issue number, title, and URL
75+
- **Drupal site name** — set to `#NNNN: issue title` during install (visible in the site header)
76+
7177
To push your changes back:
7278

7379
```bash

drupal-core/template.tf

Lines changed: 101 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ data "coder_parameter" "issue_branch" {
8585
order = 2
8686
}
8787

88+
8889
data "coder_parameter" "drupal_version" {
8990
name = "drupal_version"
9091
display_name = "Drupal Version"
@@ -146,7 +147,9 @@ data "coder_workspace_owner" "me" {}
146147
locals {
147148
# Determine workspace home path
148149
# Sysbox Strategy: Use standard /home/coder
149-
workspace_home = "/home/coder"
150+
workspace_home = "/home/coder"
151+
issue_fork_clean = trimprefix(data.coder_parameter.issue_fork.value, "drupal-")
152+
issue_url = local.issue_fork_clean != "" ? "https://www.drupal.org/project/drupal/issues/${local.issue_fork_clean}" : ""
150153
}
151154

152155
locals {
@@ -310,62 +313,7 @@ resource "coder_agent" "main" {
310313
# Copy files from /home/coder-files to /home/coder
311314
# The volume mount at /home/coder overrides image contents, but /home/coder-files is outside the mount
312315
echo "Copying files from /home/coder-files to ~/..."
313-
if [ -d /home/coder-files ]; then
314-
315-
316-
# Create Drupal-specific welcome message
317-
if [ ! -f ~/WELCOME.txt ]; then
318-
cat > ~/WELCOME.txt << 'WELCOME_EOF'
319-
╔═══════════════════════════════════════════════════════════════╗
320-
║ Welcome to Drupal Core Development ║
321-
╚═══════════════════════════════════════════════════════════════╝
322-
323-
This workspace uses joachim-n/drupal-core-development-project
324-
for a professional Drupal core development setup.
325-
326-
🌐 ACCESS YOUR SITE
327-
Click "DDEV Web" in the Coder dashboard
328-
Or run: ddev launch
329-
330-
🔐 ADMIN CREDENTIALS
331-
Username: admin
332-
Password: admin
333-
One-time link: ddev drush uli
334-
335-
📁 PROJECT STRUCTURE
336-
/home/coder/drupal-core # Project root
337-
/home/coder/drupal-core/repos/drupal # Drupal core git clone
338-
/home/coder/drupal-core/web # Web docroot
339-
340-
🛠️ USEFUL COMMANDS
341-
ddev drush status # Check Drupal status
342-
ddev drush uli # Get admin login link
343-
ddev logs # View container logs
344-
ddev ssh # SSH into web container
345-
ddev describe # Show project details
346-
ddev composer require ... # Add dependencies
347-
348-
📚 DOCUMENTATION
349-
Quickstart: https://github.com/ddev/coder-ddev/blob/main/docs/user/quickstart.md
350-
DDEV: https://docs.ddev.com/
351-
Drupal: https://www.drupal.org/docs
352-
Drupal API: https://api.drupal.org/
353-
Project Template: https://github.com/joachim-n/drupal-core-development-project
354-
355-
📋 SETUP STATUS
356-
~/SETUP_STATUS.txt # Setup completion status
357-
/tmp/drupal-setup.log # Detailed setup logs
358-
359-
💡 TROUBLESHOOTING
360-
If setup failed, check the status and log files above.
361-
You can manually run setup steps from the log.
362-
363-
Good luck with your Drupal core development!
364-
WELCOME_EOF
365-
chown coder:coder ~/WELCOME.txt 2>/dev/null || true
366-
echo "✓ Created Drupal-specific welcome message"
367-
fi
368-
else
316+
if [ ! -d /home/coder-files ]; then
369317
echo "Warning: /home/coder-files not found in image"
370318
fi
371319
@@ -573,13 +521,89 @@ STATUS_HEADER
573521
ISSUE_FORK="$${ISSUE_FORK#drupal-}" # strip leading "drupal-" if user provided it
574522
ISSUE_BRANCH="${data.coder_parameter.issue_branch.value}"
575523
INSTALL_PROFILE="${data.coder_parameter.install_profile.value}"
524+
525+
# Fetch issue title from drupal.org API at runtime (best-effort; empty string on failure)
526+
ISSUE_TITLE=""
527+
if [ -n "$ISSUE_FORK" ]; then
528+
ISSUE_TITLE=$(curl -sf "https://www.drupal.org/api-d7/node/$${ISSUE_FORK}.json" 2>/dev/null | jq -r '.title // ""' 2>/dev/null || echo "")
529+
fi
576530
USING_ISSUE_FORK=false
577531
SETUP_FAILED=false
578532
if [ -n "$ISSUE_FORK" ] || [ -n "$ISSUE_BRANCH" ]; then
579533
USING_ISSUE_FORK=true
580534
log_setup "Issue fork mode: ISSUE_FORK=$ISSUE_FORK ISSUE_BRANCH=$ISSUE_BRANCH INSTALL_PROFILE=$INSTALL_PROFILE"
581535
fi
582536
537+
# Log issue link early so it's visible at the top of the agent logs
538+
if [ -n "$ISSUE_FORK" ]; then
539+
log_setup "🔗 Issue: https://www.drupal.org/project/drupal/issues/$ISSUE_FORK"
540+
if [ -n "$ISSUE_TITLE" ]; then
541+
log_setup " Title: $ISSUE_TITLE"
542+
fi
543+
fi
544+
545+
# Create Drupal-specific welcome message (first run only, now that issue info is available)
546+
if [ ! -f ~/WELCOME.txt ]; then
547+
{
548+
cat << 'WELCOME_STATIC'
549+
╔═══════════════════════════════════════════════════════════════╗
550+
║ Welcome to Drupal Core Development ║
551+
╚═══════════════════════════════════════════════════════════════╝
552+
553+
This workspace uses joachim-n/drupal-core-development-project
554+
for a professional Drupal core development setup.
555+
556+
🌐 ACCESS YOUR SITE
557+
Click "DDEV Web" in the Coder dashboard
558+
Or run: ddev launch
559+
560+
🔐 ADMIN CREDENTIALS
561+
Username: admin
562+
Password: admin
563+
One-time link: ddev drush uli
564+
565+
📁 PROJECT STRUCTURE
566+
/home/coder/drupal-core # Project root
567+
/home/coder/drupal-core/repos/drupal # Drupal core git clone
568+
/home/coder/drupal-core/web # Web docroot
569+
570+
🛠️ USEFUL COMMANDS
571+
ddev drush status # Check Drupal status
572+
ddev drush uli # Get admin login link
573+
ddev logs # View container logs
574+
ddev ssh # SSH into web container
575+
ddev describe # Show project details
576+
ddev composer require ... # Add dependencies
577+
578+
📚 DOCUMENTATION
579+
Quickstart: https://github.com/ddev/coder-ddev/blob/main/docs/user/quickstart.md
580+
DDEV: https://docs.ddev.com/
581+
Drupal: https://www.drupal.org/docs
582+
Drupal API: https://api.drupal.org/
583+
Project Template: https://github.com/joachim-n/drupal-core-development-project
584+
585+
📋 SETUP STATUS
586+
~/SETUP_STATUS.txt # Setup completion status
587+
/tmp/drupal-setup.log # Detailed setup logs
588+
589+
💡 TROUBLESHOOTING
590+
If setup failed, check the status and log files above.
591+
You can manually run setup steps from the log.
592+
593+
Good luck with your Drupal core development!
594+
WELCOME_STATIC
595+
596+
if [ -n "$ISSUE_FORK" ]; then
597+
echo ""
598+
echo "🐛 WORKING ON ISSUE"
599+
echo " #$${ISSUE_FORK}: $${ISSUE_TITLE}"
600+
echo " https://www.drupal.org/project/drupal/issues/$${ISSUE_FORK}"
601+
fi
602+
} > ~/WELCOME.txt
603+
chown coder:coder ~/WELCOME.txt 2>/dev/null || true
604+
echo "✓ Created Drupal-specific welcome message"
605+
fi
606+
583607
# Step 4: Set up Drupal core project — use seed cache when available (fast path)
584608
# Issue forks skip the cache: the seed composer.json requires "drupal/core: dev-main" and
585609
# vendor is resolved for PHP 8.5/drupal12, both incompatible with non-main issue branches.
@@ -854,6 +878,16 @@ STATUS_HEADER
854878
# - No issue fork (issue code may differ from cached DB)
855879
# - Install profile is demo_umami (cache was built with that profile)
856880
# - Cache tarball exists
881+
882+
# Compute site name for drush si (used when running a full install)
883+
if [ -n "$ISSUE_FORK" ] && [ -n "$ISSUE_TITLE" ]; then
884+
SITE_NAME="#$${ISSUE_FORK}: $${ISSUE_TITLE}"
885+
elif [ -n "$ISSUE_FORK" ]; then
886+
SITE_NAME="Issue #$${ISSUE_FORK}"
887+
else
888+
SITE_NAME="Drupal Core Development"
889+
fi
890+
857891
if ddev drush status 2>/dev/null | grep -q "Drupal bootstrap.*Successful"; then
858892
log_setup "✓ Drupal already installed"
859893
update_status "✓ Drupal install: Already present"
@@ -874,7 +908,7 @@ STATUS_HEADER
874908
log_setup "⚠ DB import failed ($((SECONDS - _t))s), falling back to full site install..."
875909
update_status "⚠ DB import failed, running full install..."
876910
_t=$SECONDS
877-
if ddev drush si -y "$INSTALL_PROFILE" --account-pass=admin >> "$SETUP_LOG" 2>&1; then
911+
if ddev drush si -y "$INSTALL_PROFILE" --account-pass=admin --site-name="$SITE_NAME" >> "$SETUP_LOG" 2>&1; then
878912
log_setup "✓ Drupal installed successfully (fallback, $((SECONDS - _t))s)"
879913
update_status "✓ Drupal install: Success (fallback)"
880914
else
@@ -891,7 +925,7 @@ STATUS_HEADER
891925
fi
892926
update_status "⏳ Drupal install: In progress..."
893927
894-
if ddev drush si -y "$INSTALL_PROFILE" --account-pass=admin >> "$SETUP_LOG" 2>&1; then
928+
if ddev drush si -y "$INSTALL_PROFILE" --account-pass=admin --site-name="$SITE_NAME" >> "$SETUP_LOG" 2>&1; then
895929
log_setup "✓ Drupal installed ($((SECONDS - _t))s)"
896930
log_setup ""
897931
log_setup " Admin Credentials:"
@@ -1362,6 +1396,14 @@ resource "coder_metadata" "workspace_info" {
13621396
key = "image"
13631397
value = "${docker_image.workspace_image.name} (version: ${local.image_version})"
13641398
}
1399+
item {
1400+
key = "issue"
1401+
value = local.issue_fork_clean != "" ? "#${local.issue_fork_clean}" : "(standard workspace)"
1402+
}
1403+
item {
1404+
key = "issue_url"
1405+
value = local.issue_url
1406+
}
13651407
}
13661408

13671409
# Output for Vault integration status (visible in Terraform logs)

0 commit comments

Comments
 (0)