diff --git a/changelog.d/fixed-16550-reader-context-lines.md b/changelog.d/fixed-16550-reader-context-lines.md
new file mode 100644
index 0000000000..09744f34cf
--- /dev/null
+++ b/changelog.d/fixed-16550-reader-context-lines.md
@@ -0,0 +1 @@
+- The code activity reader now accepts unchanged diff context lines (`op: ' '`) from a regions source and renders them in a neutral color with their space prefix, instead of dropping the whole region; the current published-checkpoint source still emits only `+`/`-` lines ([#16550](https://github.com/hivecommons/hive/issues/16550)).
diff --git a/src/pkg/dashboard/reader_ui_test.go b/src/pkg/dashboard/reader_ui_test.go
index 2a7d8a3acb..a40db176e2 100644
--- a/src/pkg/dashboard/reader_ui_test.go
+++ b/src/pkg/dashboard/reader_ui_test.go
@@ -45,7 +45,7 @@ func TestReaderUIWiring(t *testing.T) {
}
css := read("css/reader.css")
// Long text wraps at a fixed size and the feed scrolls natively.
- for _, want := range []string{"white-space: pre-wrap; overflow-wrap: anywhere;", "body.reader-mode .reader-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto;", "font: 20px/1.5 monospace;"} {
+ for _, want := range []string{"white-space: pre-wrap; overflow-wrap: anywhere;", "body.reader-mode .reader-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto;", "font: 20px/1.5 monospace;", "body.reader-mode .reader-context { color: var(--reader-text); }"} {
if !strings.Contains(css, want) {
t.Errorf("reader.css missing %q", want)
}
@@ -98,16 +98,18 @@ const reader = fs.readFileSync('static-src/js/reader.js', 'utf8');
const boot = fs.readFileSync('static-src/js/boot.js', 'utf8').split('})();')[0] + '})();';
const at = '2026-11-03T12:00:00Z';
const first = [
- {seq: 1, repo: 'org/repo', pr: 2, head: 'abc', path: 'main.go', line: '', at},
+ {seq: 1, repo: 'org/repo', pr: 2, head: 'abc', path: 'main.go', line: '', op: '+', at},
{seq: 2, repo: 'org/repo', pr: 2, head: 'abc', path: 'main.go', line: '', at},
{seq: 3, repo: 'org/repo', pr: 2, head: 'abc', path: 'main.go', line: '\tx := 1', at},
{seq: 4, repo: 'org/repo', pr: 2, head: 'abc', path: 'main.go', line: '\tx := 1', at},
{seq: 5, repo: 'org/repo', pr: 2, head: 'abc', path: 'main.go', line: ' old()', op: '-', at},
- {seq: 6, repo: 'org/other', pr: 7, head: 'def', path: 'README.md', line: 'a very long line '.repeat(40), pr_url: 'https://github.com/org/other/pull/7', at},
+ {seq: 6, repo: 'org/repo', pr: 2, head: 'abc', path: 'main.go', line: '\tunchanged()', op: ' ', at},
+ {seq: 7, repo: 'org/repo', pr: 2, head: 'abc', path: 'main.go', line: '', op: ' ', at},
+ {seq: 8, repo: 'org/other', pr: 7, head: 'def', path: 'README.md', line: 'a very long line '.repeat(40), pr_url: 'https://github.com/org/other/pull/7', at},
];
async function scenario(query, opts = {}) {
const docEvents = {}, timers = new Map(), requests = [], scrolls = [], sse = {};
- let id = 0, status = opts.status || 200, seq = 6, lines = first;
+ let id = 0, status = opts.status || 200, seq = 8, lines = first;
const elements = [];
function el(tag) { const e = {tagName: tag.toUpperCase(), children: [], listeners: {}, attrs: {}, className: '',
textContent: '', hidden: false, scrollTop: 0, offsetHeight: 10, classList: {add(){}},
@@ -186,9 +188,10 @@ async function scenario(query, opts = {}) {
const checkFirst = card => {
// One contiguous region: blank, indented and repeated lines kept as text.
- assert.deepEqual(rows(card), ['+ \n', '+ \n', '+ \tx := 1\n', '+ \tx := 1\n', '\u2212 old()\n']);
+ // Context retains its space prefix and stays neutral, including blank lines.
+ assert.deepEqual(rows(card), ['+ \n', '+ \n', '+ \tx := 1\n', '+ \tx := 1\n', '\u2212 old()\n', ' \tunchanged()\n', ' \n']);
assert.equal(card.children[1].tagName, 'PRE');
- assert.deepEqual(card.children[1].children.map(r => r.className), ['reader-line reader-add', 'reader-line reader-add', 'reader-line reader-add', 'reader-line reader-add', 'reader-line reader-del']);
+ assert.deepEqual(card.children[1].children.map(r => r.className), ['reader-line reader-add', 'reader-line reader-add', 'reader-line reader-add', 'reader-line reader-add', 'reader-line reader-del', 'reader-line reader-context', 'reader-line reader-context']);
const [repo, file, stage, delivery, time] = meta(card);
assert.equal(repo.tagName, 'A'); assert.equal(repo.textContent, 'org/repo #2');
assert.equal(repo.href, 'https://github.com/org/repo/pull/2'); assert.equal(repo.attrs.rel, 'noopener noreferrer');
@@ -206,7 +209,7 @@ async function scenario(query, opts = {}) {
// Static and scrollable: everything shown at once, nothing scheduled or scrolled.
assert.equal(feed.children.length, 2); assert.equal(timers.size, 0); assert.equal(scrolls.length, 0);
checkFirst(feed.children[0]); checkSecond(feed.children[1]);
- lines = [{seq: 7, repo: 'org/repo', pr: 2, head: 'abc', path: 'b.go', line: 'next', at}]; seq = 7;
+ lines = [{seq: 9, repo: 'org/repo', pr: 2, head: 'abc', path: 'b.go', line: 'next', at}]; seq = 9;
sse['code-lines'](); await flush();
assert.equal(feed.children.length, 3); assert.equal(timers.size, 0); assert.equal(scrolls.length, 0);
return;
@@ -216,9 +219,9 @@ async function scenario(query, opts = {}) {
assert.equal(timers.size, 1); assert.equal(scrolls.at(-1).behavior, 'smooth');
assert(statusEl.textContent.includes('1 change waiting'));
// Incoming work queues behind the paragraph being read.
- lines = [{seq: 7, repo: 'org/repo', pr: 2, head: 'abc', path: 'b.go', line: 'next', at}]; seq = 7;
+ lines = [{seq: 9, repo: 'org/repo', pr: 2, head: 'abc', path: 'b.go', line: 'next', at}]; seq = 9;
sse['code-lines'](); await flush();
- assert.equal(requests.at(-1), '/api/matrix/lines?since=6&format=regions');
+ assert.equal(requests.at(-1), '/api/matrix/lines?since=8&format=regions');
assert.equal(feed.children.length, 1); assert.equal(timers.size, 1);
// P pauses and resumes; the button mirrors it.
key('p'); assert.equal(timers.size, 0); assert.equal(button.textContent, 'Resume');
diff --git a/src/pkg/dashboard/static-src/css/reader.css b/src/pkg/dashboard/static-src/css/reader.css
index 9f3a4398ca..c12e6dc01c 100644
--- a/src/pkg/dashboard/static-src/css/reader.css
+++ b/src/pkg/dashboard/static-src/css/reader.css
@@ -21,5 +21,6 @@ body.reader-mode a.reader-repo { text-decoration: underline; }
body.reader-mode .reader-diff { margin: .5rem 0 0; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
body.reader-mode .reader-add { color: var(--reader-add); }
body.reader-mode .reader-del { color: var(--reader-del); }
+body.reader-mode .reader-context { color: var(--reader-text); }
body.reader-mode #hive-reader [hidden] { display: none !important; }
body.reader-mode #kiosk-cta { position: fixed; right: var(--sp-6); bottom: var(--sp-6); z-index: 100001; opacity: .85; }
diff --git a/src/pkg/dashboard/static-src/js/reader.js b/src/pkg/dashboard/static-src/js/reader.js
index 58a1d473fb..fc03ec7729 100644
--- a/src/pkg/dashboard/static-src/js/reader.js
+++ b/src/pkg/dashboard/static-src/js/reader.js
@@ -51,7 +51,7 @@
function group(regions){
regions.forEach(function(region){
if (!region || !Array.isArray(region.lines) || !region.lines.length) return;
- if (!region.lines.every(function(line){ return line && typeof line.line === 'string' && (line.op === '+' || line.op === '-'); })) return;
+ if (!region.lines.every(function(line){ return line && typeof line.line === 'string' && (line.op === '+' || line.op === '-' || line.op === ' '); })) return;
var size = region.lines.reduce(function(n, line){ return n + line.line.length * 2; }, 0);
if (region.lines.length > MAX_LINES || size > MAX_BYTES) return;
var item = {repo: region.repo, pr: region.pr, path: region.path, prURL: region.pr_url,
@@ -104,9 +104,9 @@
if (when.iso) time.setAttribute('datetime', when.iso);
var diff = element('pre', 'reader-diff', '', article);
region.lines.forEach(function(line){
- var removed = line.op === '-';
- var row = element('span', 'reader-line ' + (removed ? 'reader-del' : 'reader-add'), '', diff);
- row.textContent = (removed ? '\u2212 ' : '+ ') + line.line + '\n';
+ var removed = line.op === '-', context = line.op === ' ';
+ var row = element('span', 'reader-line ' + (removed ? 'reader-del' : context ? 'reader-context' : 'reader-add'), '', diff);
+ row.textContent = (removed ? '\u2212 ' : context ? ' ' : '+ ') + line.line + '\n';
});
return article;
}
diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html
index d32c59f71a..7f49c07acc 100644
--- a/src/pkg/dashboard/static/index.html
+++ b/src/pkg/dashboard/static/index.html
@@ -7122,6 +7122,7 @@
body.reader-mode .reader-diff { margin: .5rem 0 0; font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
body.reader-mode .reader-add { color: var(--reader-add); }
body.reader-mode .reader-del { color: var(--reader-del); }
+body.reader-mode .reader-context { color: var(--reader-text); }
body.reader-mode #hive-reader [hidden] { display: none !important; }
body.reader-mode #kiosk-cta { position: fixed; right: var(--sp-6); bottom: var(--sp-6); z-index: 100001; opacity: .85; }
.var-empty{color:var(--muted);font-size:var(--fs-sm);padding:var(--sp-2) var(--sp-0)}
@@ -7541,7 +7542,7 @@
function group(regions){
regions.forEach(function(region){
if (!region || !Array.isArray(region.lines) || !region.lines.length) return;
- if (!region.lines.every(function(line){ return line && typeof line.line === 'string' && (line.op === '+' || line.op === '-'); })) return;
+ if (!region.lines.every(function(line){ return line && typeof line.line === 'string' && (line.op === '+' || line.op === '-' || line.op === ' '); })) return;
var size = region.lines.reduce(function(n, line){ return n + line.line.length * 2; }, 0);
if (region.lines.length > MAX_LINES || size > MAX_BYTES) return;
var item = {repo: region.repo, pr: region.pr, path: region.path, prURL: region.pr_url,
@@ -7594,9 +7595,9 @@
if (when.iso) time.setAttribute('datetime', when.iso);
var diff = element('pre', 'reader-diff', '', article);
region.lines.forEach(function(line){
- var removed = line.op === '-';
- var row = element('span', 'reader-line ' + (removed ? 'reader-del' : 'reader-add'), '', diff);
- row.textContent = (removed ? '\u2212 ' : '+ ') + line.line + '\n';
+ var removed = line.op === '-', context = line.op === ' ';
+ var row = element('span', 'reader-line ' + (removed ? 'reader-del' : context ? 'reader-context' : 'reader-add'), '', diff);
+ row.textContent = (removed ? '\u2212 ' : context ? ' ' : '+ ') + line.line + '\n';
});
return article;
}