Files
archived-orca/src/renderer/src/lib/connection-context.ts
T
Jinjing ac8879c789 feat(markdown): support HTML superscript links (#8307)
* feat(markdown): support HTML superscript links

* Add HTML superscript citation links to the rich markdown editor

- Introduce marked-based tokenizer support for `<sup><a>` citation
  links, with a shared editor context so key/link handlers can resolve
  selection status and open an action bubble for citation atoms
  (which markdown setLink/unsetLink can't edit).
- Extract clipboard-write logic shared by cut and cut-visual-line into
  rich-markdown-clipboard-write.ts, and surface a cut-limit error when
  clipboard readback fails.
- Fix MarkdownPreview same-file anchor scrolling to run before the
  unknown-ownership guard so ambiguous folder-workspace ownership
  still scrolls within the open document.
- Keep search's replace-disabled state derived from live matches
  instead of a stale snapshot.

* Update lockfile to dedupe stale package versions after dependency resolu

- Removes duplicate/superseded resolutions (older @babel/* versions, fs-extra 11.3.4/11.3.5, plist 3.1.0, semver 7.7.4) left over from a prior install
- Aligns transitive deps to the single resolved versions already in use elsewhere in the tree
2026-07-11 14:51:52 -07:00

47 lines
1.9 KiB
TypeScript

import { useAppStore } from '@/store'
import { parseWorkspaceKey } from '../../../shared/workspace-scope'
import {
getConnectionIdForFileFromState,
getConnectionIdFromState
} from './connection-owner-resolution'
export { getConnectionIdFromState } from './connection-owner-resolution'
/**
* Resolve the SSH connectionId for a worktree. Returns null for local repos,
* the target ID string for remote repos, or undefined if the worktree/repo
* cannot be found (e.g., store not yet hydrated).
*/
export function getConnectionId(worktreeId: string | null): string | null | undefined {
return getConnectionIdFromState(useAppStore.getState(), worktreeId)
}
/**
* True when we can determine the owning host (local vs. a specific SSH target)
* for a worktree. False means the backing repo has not landed in the store yet
* — e.g. right after a session restore while the SSH connection is still
* establishing. Callers must not fall back to a LOCAL read of a remote path in
* that window; doing so denies the path with a terminal "access denied" (#6648).
*/
export function isWorktreeConnectionResolved(worktreeId: string | null): boolean {
if (!worktreeId) {
return true
}
const parsedWorkspaceKey = parseWorkspaceKey(worktreeId)
if (parsedWorkspaceKey?.type === 'folder') {
// Folder workspaces resolve per-file; treat them as resolved here and let
// getConnectionIdForFile decide ownership for the concrete path.
return true
}
// Why: getConnectionId returns undefined only when the backing repo is absent;
// any found repo yields a string or null, so this mirrors "repo has hydrated".
return getConnectionId(worktreeId) !== undefined
}
export function getConnectionIdForFile(
worktreeId: string | null,
filePath: string
): string | null | undefined {
return getConnectionIdForFileFromState(useAppStore.getState(), worktreeId, filePath)
}