Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
refactor(view): isolate sharing presentation [N26,H5]
Corey Olson70df172da1b1
diff --git a/src/cockpit.js b/src/cockpit.jsindex da16b1b0..633da712 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -1,3 +1,4 @@+import { sharingPresentation } from './view/sharing-invitation.js';import {hostedReleaseDistance,hostedReleaseInfo,@@ -1109,42 +1110,7 @@ let sharingReady = null;let sharingTask = Promise.resolve();let sharing = { state: 'idle', intentId: null, popup: null, timer: null, closing: false, boards: [] };-/** Show the opt-in once after a real local read; quiet boards do not acquire another polling loop. */-async function sharingInvitation() {- if (!$('share-note') || snapshot || (hosted.local ? !localSession : pageReadOnly || configuredTransportModule)) return;- let available = false;- try { available = Boolean((await sharingApi()).available); } catch { available = false; }- const hiddenByPerson = keep('pb.share') === 'hidden';- $('share-note').hidden = !available || hiddenByPerson;- if ($('share-again')) $('share-again').hidden = !available || !hiddenByPerson;-}-$('share-hide')?.addEventListener('click', () => { keep('pb.share', 'hidden'); $('share-note').hidden = true; if ($('share-again')) $('share-again').hidden = false; });-$('share-again')?.addEventListener('click', () => { keep('pb.share', 'shown'); $('share-again').hidden = true; $('share-note').hidden = false; });--/** Render names and reasons as text, without exposing machine paths or private sign-in material. */-function sharingProgress(status) {- sharing.state = status.state;- sharing.boards = status.boards || [];- const linked = sharing.boards.filter(board => board.outcome === 'linked');- if (linked.length) {- $('share-note').hidden = true;- if ($('share-again')) $('share-again').hidden = true;- }- const lines = sharing.boards.map(board => board.outcome === 'linked' ? 'Linked ' + board.name + '.'- : 'Did not link ' + board.name + ': ' + board.reason);- if (status.error) lines.push(status.error.message);- else if (['cancelled', 'declined', 'expired'].includes(status.state)) lines.push('No boards were linked. You can sign in again whenever you want.');- else if (status.state === 'pairing') lines.push('Your boards are linked. Pair a device to open them there, or close this step; the links stay in place.');- else if (status.state === 'pairing-stopped') lines.push('Phone pairing stopped. Your boards remain linked.');- else if (status.state === 'linking') lines.push('Linking every registered board…');- else if (status.state === 'done' && !linked.length && !lines.length) lines.push('No boards were linked.');- if (lines.length) $('share-status').textContent = lines.join('\\n');- $('share-pair').hidden = status.state !== 'pairing';- $('share-close').textContent = linked.length ? 'Close' : 'Cancel sign-in';- if (status.state !== 'waiting') { sharing.popup?.close(); sharing.popup = null; }-}--/** Stop the one operation and await core cleanup; a linking batch is never described as rolled back. */+${sharingPresentation()}/** Stop the one operation and await core cleanup; a linking batch is never described as rolled back. */async function closeSharing() {clearTimeout(sharing.timer);sharing.closing = true;diff --git a/src/view/sharing-invitation.js b/src/view/sharing-invitation.jsnew file mode 100644index 00000000..31085b6b--- /dev/null+++ b/src/view/sharing-invitation.js@@ -0,0 +1,43 @@+/** Browser presentation for the shared-board invitation and sign-in progress [N26,H5]. */++/** Return source embedded in the cockpit's existing browser scope, keeping its state and authority unchanged.+ * @returns {string}+ */+export function sharingPresentation() {+ return `/** Show the opt-in once after a real local read; quiet boards do not acquire another polling loop. */+async function sharingInvitation() {+ if (!$('share-note') || snapshot || (hosted.local ? !localSession : pageReadOnly || configuredTransportModule)) return;+ let available = false;+ try { available = Boolean((await sharingApi()).available); } catch { available = false; }+ const hiddenByPerson = keep('pb.share') === 'hidden';+ $('share-note').hidden = !available || hiddenByPerson;+ if ($('share-again')) $('share-again').hidden = !available || !hiddenByPerson;+}+$('share-hide')?.addEventListener('click', () => { keep('pb.share', 'hidden'); $('share-note').hidden = true; if ($('share-again')) $('share-again').hidden = false; });+$('share-again')?.addEventListener('click', () => { keep('pb.share', 'shown'); $('share-again').hidden = true; $('share-note').hidden = false; });++/** Render names and reasons as text, without exposing machine paths or private sign-in material. */+function sharingProgress(status) {+ sharing.state = status.state;+ sharing.boards = status.boards || [];+ const linked = sharing.boards.filter(board => board.outcome === 'linked');+ if (linked.length) {+ $('share-note').hidden = true;+ if ($('share-again')) $('share-again').hidden = true;+ }+ const lines = sharing.boards.map(board => board.outcome === 'linked' ? 'Linked ' + board.name + '.'+ : 'Did not link ' + board.name + ': ' + board.reason);+ if (status.error) lines.push(status.error.message);+ else if (['cancelled', 'declined', 'expired'].includes(status.state)) lines.push('No boards were linked. You can sign in again whenever you want.');+ else if (status.state === 'pairing') lines.push('Your boards are linked. Pair a device to open them there, or close this step; the links stay in place.');+ else if (status.state === 'pairing-stopped') lines.push('Phone pairing stopped. Your boards remain linked.');+ else if (status.state === 'linking') lines.push('Linking every registered board…');+ else if (status.state === 'done' && !linked.length && !lines.length) lines.push('No boards were linked.');+ if (lines.length) $('share-status').textContent = lines.join('\\n');+ $('share-pair').hidden = status.state !== 'pairing';+ $('share-close').textContent = linked.length ? 'Close' : 'Cancel sign-in';+ if (status.state !== 'waiting') { sharing.popup?.close(); sharing.popup = null; }+}++`;+}