Skip to content

Commit f3d48dc

Browse files
wip v28
1 parent af10167 commit f3d48dc

19 files changed

Lines changed: 446 additions & 149 deletions

uapi/app/api/external-realization/route.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,56 @@ import { getBitcodeAppContext, toBitcodeErrorResponse } from '@/lib/bitcode-app-
44

55
export const runtime = 'nodejs';
66

7+
type ExternalRealizationEnvironmentMode = 'production' | 'staging' | 'development' | 'mock';
8+
9+
const EXTERNAL_REALIZATION_ENVIRONMENT_MODES = new Set<ExternalRealizationEnvironmentMode>([
10+
'production',
11+
'staging',
12+
'development',
13+
'mock',
14+
]);
15+
16+
function normalizeExternalEnvironmentMode(value: string | null | undefined): ExternalRealizationEnvironmentMode | null {
17+
const normalized = value?.trim().toLowerCase();
18+
if (!normalized) return null;
19+
return EXTERNAL_REALIZATION_ENVIRONMENT_MODES.has(normalized as ExternalRealizationEnvironmentMode)
20+
? (normalized as ExternalRealizationEnvironmentMode)
21+
: null;
22+
}
23+
24+
function normalizeBitcodeEnvironment(value: string | null | undefined): ExternalRealizationEnvironmentMode | null {
25+
const normalized = value?.trim().toLowerCase();
26+
if (!normalized) return null;
27+
if (normalized === 'testnet' || normalized === 'staging-testnet') return 'staging';
28+
if (normalized === 'mainnet') return 'production';
29+
return normalizeExternalEnvironmentMode(normalized);
30+
}
31+
32+
function resolveExternalRealizationEnvironmentMode(
33+
requestUrl: URL,
34+
env: NodeJS.ProcessEnv = process.env,
35+
): ExternalRealizationEnvironmentMode | null {
36+
const explicitMode = normalizeExternalEnvironmentMode(requestUrl.searchParams.get('environmentMode'));
37+
if (explicitMode) return explicitMode;
38+
39+
const protocolMode = normalizeExternalEnvironmentMode(env.BITCODE_V24_ENVIRONMENT_MODE);
40+
if (protocolMode) return protocolMode;
41+
42+
const bitcodeMode = normalizeBitcodeEnvironment(env.NEXT_PUBLIC_BITCODE_ENV || env.BITCODE_ENV);
43+
if (bitcodeMode) return bitcodeMode;
44+
45+
if (env.VERCEL_ENV === 'preview') return 'staging';
46+
if (env.VERCEL_ENV === 'production') return 'production';
47+
48+
return null;
49+
}
50+
751
export async function GET(request: Request) {
852
try {
953
const url = new URL(request.url);
1054
return NextResponse.json(
1155
getBitcodeAppContext().getExternalRealization({
12-
environmentMode: url.searchParams.get('environmentMode'),
56+
environmentMode: resolveExternalRealizationEnvironmentMode(url),
1357
}),
1458
);
1559
} catch (error) {

uapi/app/terminal/TerminalCoreNativeSections.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export default function TerminalCoreNativeSections({
122122
</div>
123123
) : (
124124
<div className="mt-4 rounded-[1.2rem] border border-white/8 bg-white/5 px-4 py-4 text-sm leading-6 text-neutral-300">
125-
Connect and select a repository above to make Bitcode give-side supply explicit before the deposit chain.
125+
Connect and select a repository above to make Bitcode give-side supply explicit before the Giving chain.
126126
</div>
127127
)
128128
) : null}
@@ -189,7 +189,7 @@ export default function TerminalCoreNativeSections({
189189
eyebrow: 'Selected repository supply',
190190
subtitle:
191191
selectedRepository.description ||
192-
'Selected repository supply is the current give-side source before deposit and fit.',
192+
'Selected repository supply is the current give-side source before Giving and fit.',
193193
help:
194194
connectionStatus?.connected && connectionStatus.valid
195195
? `Connected as ${connectionStatus.username || connectionStatus.metadata?.account || 'bitcode'}.`

uapi/app/terminal/TerminalDepositComposer.tsx

Lines changed: 141 additions & 55 deletions
Large diffs are not rendered by default.

uapi/app/terminal/TerminalExternalInterfacingPanel.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ export default function TerminalExternalInterfacingPanel({
130130
};
131131

132132
const counts = snapshot?.counts;
133+
const hasMockRuntime =
134+
snapshot?.configuredEnvironmentMode === 'mock' ||
135+
Boolean(snapshot?.interfaces.some((entry) => entry.runtimeState === 'mock'));
133136

134137
return (
135138
<TerminalWorkspaceCard
@@ -147,7 +150,7 @@ export default function TerminalExternalInterfacingPanel({
147150
<div className="grid gap-3 text-xs uppercase tracking-[0.2em] text-neutral-400 tablet:grid-cols-2">
148151
<div className="rounded-2xl border border-white/8 bg-black/20 px-4 py-4">
149152
<p className="text-emerald-300/85">Runtime scope</p>
150-
<p className="mt-2 text-neutral-200">connected interfaces</p>
153+
<p className="mt-2 text-neutral-200">{snapshot?.configuredEnvironmentMode || 'connected interfaces'}</p>
151154
</div>
152155
<div className="rounded-2xl border border-white/8 bg-black/20 px-4 py-4">
153156
<p className="text-emerald-300/85">Read posture</p>
@@ -317,8 +320,9 @@ export default function TerminalExternalInterfacingPanel({
317320
)}
318321
</div>
319322
<div className="mt-4 rounded-[1.3rem] border border-white/8 bg-white/5 px-4 py-4 text-sm leading-6 text-neutral-300">
320-
Boundary truth remains explicit here: what is mocked, what is boundary-only, what is live-configured, and what
321-
is misconfigured all stay visible from the Terminal surface.
323+
{hasMockRuntime
324+
? 'Boundary truth remains explicit here: what is mocked, what is boundary-only, what is live-configured, and what is misconfigured all stay visible from the Terminal surface.'
325+
: 'Boundary truth remains explicit here: what is boundary-only, what is live-configured, what is execution-disabled, and what is misconfigured all stay visible from the Terminal surface.'}
322326
</div>
323327
</div>
324328
</div>

uapi/app/terminal/TerminalMvpMap.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const TERMINAL_MVP_STATIONS = [
1212
{
1313
id: 'giving',
1414
label: 'Giving',
15-
value: 'repository + deposit',
15+
value: 'repository + Giving',
1616
targetId: 'terminalSupplySelection',
1717
},
1818
{

uapi/app/terminal/TerminalPageClient.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,13 @@ const ConversationsOverlay = dynamic(() => import('@/app/conversations/component
7171
export default function TerminalPageClient() {
7272
const { user } = useAuth();
7373
const {
74+
data: userData,
7475
hasGitHubConnection,
7576
hasValidGitHubConnection = hasGitHubConnection,
7677
hasWalletConnection,
7778
hasStoredVerifiedWalletConnection = false,
7879
hasVerifiedWalletConnection,
80+
walletConnectionStatus,
7981
repositoryConnectionStatus,
8082
} = useUserData();
8183
const router = useRouter();
@@ -154,6 +156,17 @@ export default function TerminalPageClient() {
154156
user,
155157
],
156158
);
159+
const preferredSignerAddress = useMemo(() => {
160+
const profile = userData?.profile as Record<string, unknown> | null | undefined;
161+
const profileAuthAddress = typeof profile?.auth_address === 'string' ? profile.auth_address.trim() : '';
162+
const profileWalletAddress = typeof profile?.wallet_address === 'string' ? profile.wallet_address.trim() : '';
163+
const walletAuthAddress = walletConnectionStatus?.metadata?.authAddress?.trim() || '';
164+
const walletAddress = walletConnectionStatus?.address?.trim() || '';
165+
return walletAuthAddress || walletAddress || profileAuthAddress || profileWalletAddress || null;
166+
}, [userData?.profile, walletConnectionStatus]);
167+
const preferredSignerLabel = walletConnectionStatus?.provider
168+
? `${walletConnectionStatus.provider} wallet`
169+
: 'connected wallet';
157170
const replaceTerminalSearchParams = useCallback(
158171
(nextParams: URLSearchParams) => {
159172
if (typeof window !== 'undefined' && window.location.pathname !== TERMINAL_ROUTE) return;
@@ -527,6 +540,8 @@ export default function TerminalPageClient() {
527540
onRepositorySourceCommitChange={handleRepositorySourceCommitChange}
528541
transactionReadiness={transactionReadiness}
529542
showDemonstrationDraft={showDemonstrationSurfaces}
543+
preferredSignerAddress={preferredSignerAddress}
544+
preferredSignerLabel={preferredSignerLabel}
530545
/>
531546
</div>
532547
</div>

uapi/app/terminal/TerminalRepositoryContextPanel.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ export default function TerminalRepositoryContextPanel({
445445
id="terminalRepositorySupply"
446446
kicker="Repository supply"
447447
title="Connect and select searchable supply"
448-
summary="Choose the provider and repository that will anchor give-side supply before you move deeper into deposit, need, and closure."
448+
summary="Choose the GitHub repository that will anchor give-side supply before you move deeper into Giving, Need, and closure."
449449
explainer={TERMINAL_WORKSPACE_EXPLAINERS.repositorySupply}
450450
tone="emerald"
451451
>
@@ -697,7 +697,7 @@ export default function TerminalRepositoryContextPanel({
697697
</div>
698698
<div>
699699
<dt className="text-amber-100/70">Write admission</dt>
700-
<dd className="mt-1 text-neutral-100">Reconnect required before deposit, branch, or closure writes.</dd>
700+
<dd className="mt-1 text-neutral-100">Reconnect required before Giving, branch, or closure writes.</dd>
701701
</div>
702702
<div>
703703
<dt className="text-amber-100/70">Inventory source</dt>
@@ -742,7 +742,7 @@ export default function TerminalRepositoryContextPanel({
742742
{selectedRepository ? (
743743
<div className="mt-4 space-y-4">
744744
<p className="text-sm leading-6 text-neutral-300">
745-
The selected repository now anchors the give-side Terminal frame before the live Bitcode deposit
745+
The selected repository now anchors the give-side Terminal frame before live Bitcode Giving
746746
surfaces below.
747747
</p>
748748
{connectionStatus?.connected && !connectionStatus.valid ? (
@@ -795,7 +795,7 @@ export default function TerminalRepositoryContextPanel({
795795
onClick={() => jumpToShellSection('terminalDepositComposer')}
796796
className="rounded-[1.2rem] border border-emerald-400/30 bg-emerald-400/10 px-4 py-3 text-sm font-medium text-emerald-100 transition hover:border-emerald-300/45 hover:bg-emerald-400/15"
797797
>
798-
Open deposit draft
798+
Open Giving draft
799799
</button>
800800
<button
801801
type="button"
@@ -831,7 +831,7 @@ export default function TerminalRepositoryContextPanel({
831831
<article className="rounded-[1.5rem] border border-white/8 bg-black/20 px-5 py-5">
832832
<p className="text-[0.68rem] uppercase tracking-[0.24em] text-neutral-400">Give-side guidance</p>
833833
<p className="mt-3 text-sm leading-6 text-neutral-300">
834-
Keep repository connection, repository selection, and deposit focus visible before you move deeper into
834+
Keep repository connection, repository selection, and Giving focus visible before you move deeper into
835835
supply, need, and closure.
836836
</p>
837837
<div className="mt-4 grid gap-3">

uapi/app/terminal/terminal-core-surface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ type ShellSnapshot = {
3737

3838
const CORE_PANEL_CONFIG = [
3939
{ id: 'panelOperatingPicture', key: 'operatingPicture', fallbackLabel: 'Operating picture' },
40-
{ id: 'panelDepositing', key: 'depositing', fallbackLabel: 'Depositing' },
40+
{ id: 'panelDepositing', key: 'depositing', fallbackLabel: 'Giving' },
4141
{ id: 'panelNeeding', key: 'needing', fallbackLabel: 'Needing + measured demand' },
42-
{ id: 'panelFit', key: 'fit', fallbackLabel: 'Depositing-to-needing fit' },
42+
{ id: 'panelFit', key: 'fit', fallbackLabel: 'Giving-to-Needing fit' },
4343
] as const;
4444

4545
function stringValue(value: string | number | null | undefined, fallback = '') {

uapi/app/terminal/terminal-flow-guide.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ export function deriveTerminalFlowGuide(
107107
? transactionReadiness?.summary || 'The Bitcode Terminal is in review-only mode until transactional readiness is complete.'
108108
: draftOnly
109109
? guideStep
110-
? `The flow guide is ${commandState.flowGuideOpen ? 'open' : 'saved'} at ${guideStep}. ${transactionReadiness?.summary || 'Bitcode can keep drafting, but branch, deposit, and closure remain fail-closed until signed settlement readiness is complete.'}`
110+
? `The flow guide is ${commandState.flowGuideOpen ? 'open' : 'saved'} at ${guideStep}. ${transactionReadiness?.summary || 'Bitcode can keep drafting, but branch, Giving, and closure remain fail-closed until signed settlement readiness is complete.'}`
111111
: transactionReadiness?.summary ||
112-
'Bitcode can keep drafting, but branch, deposit, and closure remain fail-closed until signed settlement readiness is complete.'
112+
'Bitcode can keep drafting, but branch, Giving, and closure remain fail-closed until signed settlement readiness is complete.'
113113
: guideStep
114114
? `The flow guide is ${commandState.flowGuideOpen ? 'open' : 'saved'} at ${guideStep}.`
115115
: 'The Bitcode Terminal is ready for a fresh give-to-closure flow.';

uapi/app/terminal/terminal-give-need-workbench.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export function normalizeTerminalGiveNeedWorkbench(
315315
fit: {
316316
summary:
317317
String(snapshot.fitSurface?.fitSummary || '').trim() ||
318-
'Depositing-to-needing fit stays the decisive Bitcode relation before branch, proof, and settlement are justified.',
318+
'Giving-to-Needing fit stays the decisive Bitcode relation before branch, proof, and settlement are justified.',
319319
metrics: [
320320
{
321321
label: 'Pressure',

0 commit comments

Comments
 (0)