Skip to content

Commit fd2e034

Browse files
wip v28
1 parent a8a6502 commit fd2e034

3 files changed

Lines changed: 78 additions & 23 deletions

File tree

uapi/app/terminal/TerminalDepositComposer.tsx

Lines changed: 62 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,35 @@ export default function TerminalDepositComposer({
6161
() => normalizeTerminalDepositComposer(snapshot),
6262
[snapshot],
6363
);
64+
const repositoryAnchorValue = String(repositoryAnchor || '').trim();
65+
const usesLiveRepositoryAnchor = Boolean(repositoryAnchorValue);
66+
const effectiveAuthSessionId = usesLiveRepositoryAnchor
67+
? `${repositoryProvider || 'github'}:${repositoryAnchorValue}`
68+
: composer?.authSessionId || '';
69+
const selectedSupplyCount = usesLiveRepositoryAnchor ? 1 : composer?.selectedCount || 0;
70+
const selectedInventoryEntryIds = usesLiveRepositoryAnchor ? [] : composer?.selectedInventoryEntryIds || [];
71+
const displayedSourceRepo = usesLiveRepositoryAnchor ? repositoryAnchorValue : sourceRepo;
6472

6573
useEffect(() => {
6674
setSignerAddress((current) => current || composer?.signerAddress || '');
75+
if (repositoryAnchorValue) {
76+
setSourceRepo(repositoryAnchorValue);
77+
return;
78+
}
6779
setSourceRepo((current) => current || composer?.sourceRepo || '');
68-
}, [composer?.signerAddress, composer?.sourceRepo]);
80+
}, [composer?.signerAddress, composer?.sourceRepo, repositoryAnchorValue]);
6981

7082
const selectedEntryLabels = useMemo(() => {
83+
if (repositoryAnchorValue) return [repositoryAnchorValue];
7184
return composer?.selectedEntries.slice(0, 5).map((entry) => entry.title) || [];
72-
}, [composer]);
85+
}, [composer, repositoryAnchorValue]);
7386
const settlementReady = transactionReadiness.canSettle;
7487

7588
const canSubmit = Boolean(
7689
composer &&
77-
(composer.selectedCount > 0 || content.trim()) &&
78-
(title.trim() || composer.selectedCount > 0) &&
79-
(author.trim() || composer.authSessionId) &&
90+
(selectedSupplyCount > 0 || content.trim()) &&
91+
(title.trim() || selectedSupplyCount > 0) &&
92+
(author.trim() || effectiveAuthSessionId) &&
8093
settlementReady,
8194
);
8295

@@ -100,11 +113,11 @@ export default function TerminalDepositComposer({
100113
author,
101114
artifactKind,
102115
artifactType,
103-
authSessionId: composer.authSessionId || undefined,
104-
inventoryEntryIds: composer.selectedInventoryEntryIds,
105-
repositoryAnchor: repositoryAnchor || composer.sourceRepo || undefined,
116+
authSessionId: effectiveAuthSessionId || undefined,
117+
inventoryEntryIds: selectedInventoryEntryIds,
118+
repositoryAnchor: repositoryAnchorValue || composer.sourceRepo || undefined,
106119
repositoryProvider: repositoryProvider || undefined,
107-
sourceRepo: sourceRepo || undefined,
120+
sourceRepo: displayedSourceRepo || undefined,
108121
sourceCommit,
109122
workflowRunId,
110123
signerAddress,
@@ -132,7 +145,7 @@ export default function TerminalDepositComposer({
132145
setAuthor('');
133146
setArtifactKind('');
134147
setArtifactType('');
135-
setSourceRepo(composer.sourceRepo || '');
148+
setSourceRepo(repositoryAnchorValue || composer.sourceRepo || '');
136149
setSourceCommit('');
137150
setWorkflowRunId('');
138151
setVisualPreview('');
@@ -146,12 +159,13 @@ export default function TerminalDepositComposer({
146159
summary:
147160
payload.asset?.title ||
148161
title.trim() ||
149-
`Deposited ${composer.selectedCount || 1} candidate Bitcode asset pack${composer.selectedCount === 1 ? '' : 's'}.`,
162+
`Deposited ${selectedSupplyCount || 1} candidate Bitcode asset pack${selectedSupplyCount === 1 ? '' : 's'}.`,
150163
context: {
151164
source: 'terminal-deposit-composer',
152-
authSessionId: composer.authSessionId || null,
153-
selectedInventoryEntryIds: composer.selectedInventoryEntryIds,
154-
selectedInventoryTitles: composer.selectedEntries.map((entry) => entry.title),
165+
authSessionId: effectiveAuthSessionId || null,
166+
selectedInventoryEntryIds,
167+
selectedInventoryTitles: selectedEntryLabels,
168+
repositoryAnchor: repositoryAnchorValue || null,
155169
candidateAssetId: payload.asset?.assetId || null,
156170
},
157171
output: {
@@ -201,8 +215,11 @@ export default function TerminalDepositComposer({
201215
headerAside={
202216
<BitcodeMetricGrid
203217
metrics={[
204-
{ label: 'Session', value: composer.authSessionId || 'none bound' },
205-
{ label: 'Selected supply', value: String(composer.selectedCount) },
218+
{
219+
label: usesLiveRepositoryAnchor ? 'Repository' : 'Session',
220+
value: usesLiveRepositoryAnchor ? repositoryAnchorValue : composer.authSessionId || 'none bound',
221+
},
222+
{ label: 'Selected supply', value: String(selectedSupplyCount) },
206223
]}
207224
columnsClassName="tablet:grid-cols-2"
208225
itemClassName="rounded-2xl border border-white/8 bg-black/20 px-4 py-4"
@@ -255,17 +272,37 @@ export default function TerminalDepositComposer({
255272
/>
256273
</label>
257274

258-
<div className="rounded-[1.5rem] border border-white/8 bg-black/20 px-4 py-4">
259-
<span className="flex items-center gap-2 text-[0.66rem] uppercase tracking-[0.24em] text-neutral-400">
260-
<span>Source repo</span>
275+
<div
276+
className={`rounded-[1.5rem] border px-4 py-4 ${
277+
usesLiveRepositoryAnchor
278+
? 'border-emerald-400/18 bg-emerald-400/10'
279+
: 'border-white/8 bg-black/20'
280+
}`}
281+
>
282+
<span
283+
className={`flex items-center gap-2 text-[0.66rem] uppercase tracking-[0.24em] ${
284+
usesLiveRepositoryAnchor ? 'text-emerald-200/85' : 'text-neutral-400'
285+
}`}
286+
>
287+
<span>{usesLiveRepositoryAnchor ? 'Selected source repo' : 'Source repo'}</span>
261288
<BitcodeInlineExplainer explainer={TERMINAL_INLINE_EXPLAINERS.sourceRepo} />
262289
</span>
263290
<input
264-
value={sourceRepo}
291+
value={displayedSourceRepo}
265292
onChange={(event) => setSourceRepo(event.target.value)}
293+
readOnly={usesLiveRepositoryAnchor}
266294
placeholder="repo boundary override"
267-
className="mt-3 w-full rounded-xl border border-white/10 bg-[rgba(10,15,30,0.88)] px-3 py-3 text-sm text-white outline-none transition placeholder:text-neutral-500 focus:border-emerald-400/40"
295+
className={`mt-3 w-full rounded-xl border px-3 py-3 text-sm text-white outline-none transition placeholder:text-neutral-500 ${
296+
usesLiveRepositoryAnchor
297+
? 'border-emerald-300/20 bg-[rgba(10,15,30,0.92)]'
298+
: 'border-white/10 bg-[rgba(10,15,30,0.88)] focus:border-emerald-400/40'
299+
}`}
268300
/>
301+
{usesLiveRepositoryAnchor ? (
302+
<p className="mt-2 text-[0.68rem] uppercase tracking-[0.18em] text-emerald-100/70">
303+
Selected from Give-side supply
304+
</p>
305+
) : null}
269306
</div>
270307

271308
<div className="rounded-[1.5rem] border border-white/8 bg-black/20 px-4 py-4">
@@ -414,8 +451,10 @@ export default function TerminalDepositComposer({
414451
<div className="rounded-[1.5rem] border border-white/8 bg-black/20 px-5 py-5">
415452
<p className="text-[0.68rem] uppercase tracking-[0.24em] text-neutral-400">Selected supply</p>
416453
<p className="mt-3 text-sm leading-6 text-neutral-300">
417-
{composer.selectedCount
418-
? `Bitcode will bind ${composer.selectedCount} selected repo artifact${composer.selectedCount === 1 ? '' : 's'} into this deposit.`
454+
{selectedSupplyCount
455+
? usesLiveRepositoryAnchor
456+
? `Bitcode will bind ${repositoryAnchorValue} as the selected repository source for this deposit.`
457+
: `Bitcode will bind ${selectedSupplyCount} selected repo artifact${selectedSupplyCount === 1 ? '' : 's'} into this deposit.`
419458
: 'No repo artifacts are currently selected. Use raw fallback content or select inventory above.'}
420459
</p>
421460
{selectedEntryLabels.length ? (

uapi/jest.config.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ module.exports = {
129129
'<rootDir>/tests/terminalShellBridge.test.tsx',
130130
'<rootDir>/tests/terminalSupplySelection.test.ts',
131131
'<rootDir>/tests/terminalGiveNeedWorkbench.test.ts',
132+
'<rootDir>/tests/terminalDepositComposer.test.ts',
133+
'<rootDir>/tests/terminalDepositComposerCard.test.tsx',
132134
'<rootDir>/tests/demonstrationWitnessMount.test.tsx',
133135
'<rootDir>/tests/protocolCommercialBoundary.test.ts',
134136
'<rootDir>/tests/demonstrationWitnessScopedStylesRoute.test.ts',

uapi/tests/terminalDepositComposerCard.test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ const baseTransactionReadiness = {
109109
};
110110

111111
describe('TerminalDepositComposer', () => {
112+
it('projects the live repository anchor into the visible give source', () => {
113+
render(
114+
<TerminalDepositComposer
115+
repositoryAnchor="engineeredsoftware/ENGI"
116+
repositoryProvider="github"
117+
transactionReadiness={baseTransactionReadiness}
118+
/>,
119+
);
120+
121+
expect(screen.getByDisplayValue('engineeredsoftware/ENGI')).toBeInTheDocument();
122+
expect(screen.getByText('Selected from Give-side supply')).toBeInTheDocument();
123+
expect(screen.getByText(/Bitcode will bind engineeredsoftware\/ENGI/i)).toBeInTheDocument();
124+
});
125+
112126
it('keeps deposit submission disabled until settlement readiness is complete', () => {
113127
const { rerender } = render(
114128
<TerminalDepositComposer

0 commit comments

Comments
 (0)