dev: version a dev run by its jj change
rake dev sets VERSION to the change id of the working copy it runs from,
so the footer names a real build instead of a label that says "dev server";
a run with no VERSION at all leaves that part of the footer blank,
because the layout does not guess what kind of run it is anymore.
Assisted-by: Claude Opus 5 via Claude Code
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
diff --git a/Rakefile b/Rakefile
index 46effa7..7ed2d41 100644
--- a/Rakefile
+++ b/Rakefile
@@ -31,6 +31,11 @@ task :dev do
ENV["PRO_TACTS_INSTANCE_NAME"] ||= "pro-tacts (dev)"
ENV["PRO_TACTS_FAVICON"] ||= "/favicon-dev.svg"
ENV["PRO_TACTS_ACCENT"] ||= "ink-blue"
+ # The change being worked on names a dev build, the way a release's tag
+ # names an image; a change id holds still while its content is edited.
+ change = `jj log --no-graph -r @ -T 'change_id.short()'`
+ fail "jj could not name the working-copy change" unless $?.success?
+ ENV["VERSION"] ||= change
File.truncate("log/dev.log", 0) if File.exist?("log/dev.log")
Dir.mktmpdir("pro-tacts-dev") do |dir|
diff --git a/docs/DESIGN.md b/docs/DESIGN.md
index 7321167..748a375 100644
--- a/docs/DESIGN.md
+++ b/docs/DESIGN.md
@@ -103,9 +103,9 @@ single reading column.
Under every screen sits the footer, the header's counterpart, holding what no
search can turn up because none of it is a record: the version answering,
-whether debug logging is recording, and a link to device setup. A run with no
-release behind it says "dev server" in the version's place, since a working
-copy dressed as the deployment is the confusion the line exists to end. A run
+whether debug logging is recording, and a link to device setup. `rake dev`
+names its version after the jj change it runs from, since a working copy
+dressed as the deployment is the confusion the line exists to end. A run
with its own accent fills the header and footer with it, so the difference
shows before a word of either is read. Debug
logging appears only while it is on, written `+debug` — a flag on the build,
diff --git a/lib/pro_tacts/admin/layout.rb b/lib/pro_tacts/admin/layout.rb
index ee1f009..997ace9 100644
--- a/lib/pro_tacts/admin/layout.rb
+++ b/lib/pro_tacts/admin/layout.rb
@@ -101,11 +101,9 @@ module ProTacts
# The version is the image's tag and the release's name at
# once, so it stands alone: the commit and the build time
# are spelled inside it, and a second label repeating either
- # would be the same fact twice. Nothing built by the release
- # job carries one, and that absence is its own fact worth
- # stating — a screen that looks like the deployment but
- # answers out of a working copy is exactly the confusion the
- # footer exists to end.
+ # would be the same fact twice. `rake dev` stamps the jj
+ # change it runs from instead; a run with neither says
+ # nothing rather than guessing what it is.
#
# Debug logging says so while it is on because it dumps
# every sync whole, contact data included (see ExchangeLog),
@@ -121,7 +119,8 @@ module ProTacts
# header link would put it beside the search on every
# screen, at the weight the app's own name has.
footer(class: "admin-footer") do
- span(class: "type-label") { ProTacts.config.version || "dev server" }
+ version = ProTacts.config.version
+ span(class: "type-label") { version } if version
span(class: "type-label") { "+debug" } if ProTacts.config.debug?
a(href: "/setup", class: "type-label") { "device setup" }
end
diff --git a/test/pro_tacts/admin/test_footer.rb b/test/pro_tacts/admin/test_footer.rb
index 5440458..a9c9caa 100644
--- a/test/pro_tacts/admin/test_footer.rb
+++ b/test/pro_tacts/admin/test_footer.rb
@@ -45,15 +45,15 @@ class AdminFooterTest < Minitest::Test
# Blank is what an image built by hand says (see Config#version): the
# Dockerfile sets the variable from a build arg that was never passed,
# so it arrives empty rather than absent. Either way there is no
- # release behind the screen, which is the thing to say.
- def test_an_unversioned_run_says_it_is_the_dev_server
+ # version to name, and the footer does not invent one.
+ def test_an_unversioned_run_names_no_version
with_env("VERSION" => "")
- assert_includes last_response.body, "dev server"
+ assert_includes last_response.body, %(<footer class="admin-footer"><a href="/setup")
with_env({})
- assert_includes last_response.body, "dev server"
+ assert_includes last_response.body, %(<footer class="admin-footer"><a href="/setup")
end
# The label is a standing notice, not a status: the log is recording