feat(ocm-cli): label the attached manager with an optional login name

This commit is contained in:
Chris Scott committed 2026-10-17 20:09:00 -04:00
1 parent 612b0e6621
commit 8b428837c3
6 files changed
+66 -8

No files matched your search

+9
View File
@@ -1,3 +1,6 @@
import type { OcmState } from './state.js'
import { normalizeManagerUrl } from './manager-auth.js'
export const REMOTE_MANAGER_URL_ENV = 'OCM_REMOTE_MANAGER_URL'
export const REMOTE_REPO_NAME_ENV = 'OCM_REMOTE_REPO_NAME'
export const REMOTE_REPO_ID_ENV = 'OCM_REMOTE_REPO_ID'
@@ -37,3 +40,9 @@ export function readRemoteContext(env: NodeJS.ProcessEnv): RemoteContext | undef
return { managerUrl, managerHost, repoName, repoId }
}
/** Returns the saved manager name when it belongs to the attached manager, else the manager host. */
export function remoteDisplayName(remote: RemoteContext, state: OcmState | null): string {
if (state?.managerName && normalizeManagerUrl(state.managerUrl) === normalizeManagerUrl(remote.managerUrl)) return state.managerName
return remote.managerHost
}
+1
View File
@@ -5,6 +5,7 @@ import { readJsonFile, writeJsonFileAtomic } from './json-store.js'
export interface OcmState {
managerUrl: string
managerName?: string
lastRepoId?: number
lastRepoName?: string
lastRepoDir?: string
+4 -2
View File
@@ -6,7 +6,8 @@ import { showGoalDialog } from './tui-goal-dialog.js'
import { showMultiRunLaunchDialog, showMultiRunsDialog } from './tui-multi-run-dialogs.js'
import { formatMoveProgress } from './move-progress.js'
import type { MoveProgress } from './move-progress.js'
import { readRemoteContext } from './remote-context.js'
import { readRemoteContext, remoteDisplayName } from './remote-context.js'
import { readState } from './state.js'
import { createGoalStore } from './goal-store.js'
import type { GoalStore } from './goal-store.js'
import { formatGoalStatus, goalOutcomeToast } from './tui-goal.js'
@@ -40,9 +41,10 @@ export default Plugin.define({
const remote = readRemoteContext(process.env)
if (remote) {
const managerLabel = remoteDisplayName(remote, readState())
const indicator = () => (
<box flexDirection="row" flexShrink={0} gap={1}>
<text fg={context.theme.hue.accent[200]}>{remote.managerHost}</text>
<text fg={context.theme.hue.orange?.[400] ?? context.theme.text.feedback.warning.base}>{managerLabel}</text>
{remote.repoName && <text fg={context.theme.text.muted}> · {remote.repoName}</text>}
</box>
)