Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/desktop/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@t3tools/desktop",
"version": "0.0.49",
"version": "0.0.50",
"private": true,
"type": "module",
"main": "dist-electron/main.cjs",
Expand Down
4 changes: 4 additions & 0 deletions apps/desktop/src/ipc/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const GET_ADVERTISED_ENDPOINTS_CHANNEL = "desktop:get-advertised-endpoint
export const GET_WSL_STATE_CHANNEL = "desktop:get-wsl-state";
export const SET_WSL_BACKEND_ENABLED_CHANNEL = "desktop:set-wsl-backend-enabled";
export const SET_WSL_DISTRO_CHANNEL = "desktop:set-wsl-distro";
export const SET_SSH_RUNNER_CHANNEL = "desktop:set-ssh-runner";
export const SET_WSL_ONLY_CHANNEL = "desktop:set-wsl-only";
export const SSH_PASSWORD_PROMPT_CANCELLED_RESULT = "ssh-password-prompt-cancelled";
export const PREVIEW_CREATE_TAB_CHANNEL = "desktop:preview-create-tab";
Expand Down Expand Up @@ -106,6 +107,9 @@ export const PREVIEW_RECORDING_FRAME_CHANNEL = "desktop:preview-recording-frame"
export const PREVIEW_STATE_CHANGE_CHANNEL = "desktop:preview-state-change";
export const PREVIEW_POINTER_EVENT_CHANNEL = "desktop:preview-pointer-event";

export const PROBE_TERMINAL_EDITOR_CHANNEL = "desktop:probe-terminal-editor";
export const OPEN_TERMINAL_EDITOR_CHANNEL = "desktop:open-terminal-editor";
export const SET_TERMINAL_EDITOR_SETTINGS_CHANNEL = "desktop:set-terminal-editor-settings";
export const MAC_PERMISSION_HELPER_CHANNEL = "desktop:mac-permission-helper";

export const CHECK_SYSTEM_PERMISSION_CHANNEL = "desktop:check-system-permission";
13 changes: 13 additions & 0 deletions apps/desktop/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner";
import { resolveDesktopSshRunner } from "./ssh/DesktopSshRunner.ts";
import * as MacPermissions from "./permissions/MacPermissions.ts";
for (const stream of [process.stdout, process.stderr]) {
stream.on("error", (err: NodeJS.ErrnoException) => {
Expand Down Expand Up @@ -111,7 +113,18 @@ const desktopSshEnvironmentLayer = Layer.unwrap(
Effect.gen(function* () {
const environment = yield* DesktopEnvironment.DesktopEnvironment;
const settings = yield* DesktopAppSettings.DesktopAppSettings;
const wslEnvironment = yield* DesktopWslEnvironment.DesktopWslEnvironment;
const sshSpawner = yield* ChildProcessSpawner.ChildProcessSpawner;
const resolveSshRunner = yield* Effect.cachedWithTTL(
settings.get.pipe(
Effect.flatMap(resolveDesktopSshRunner),
Effect.provideService(DesktopWslEnvironment.DesktopWslEnvironment, wslEnvironment),
Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, sshSpawner),
),
"5 seconds",
);
return DesktopSshEnvironment.layer({
resolveSshRunner,
resolveCliRunner: settings.get.pipe(
Effect.map((currentSettings) => resolveDesktopSshCliRunner(environment, currentSettings)),
),
Expand Down
2 changes: 1 addition & 1 deletion apps/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "t3",
"version": "0.0.49",
"version": "0.0.50",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/pullRequest/PullRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2701,11 +2701,11 @@ export const make = Effect.gen(function* () {
) {
const route = yield* requireProject(reference).pipe(Effect.orElseSucceed(() => undefined));
const host = route?.host ?? reference.host?.trim().toLowerCase();
const snapshot = yield* projections.getShellSnapshot().pipe(Effect.orElseSucceed(() => null));
const projects = yield* projections.getProjectShells().pipe(Effect.orElseSucceed(() => []));
const projectIds = new Set(reference.host === undefined ? [reference.projectId] : []);
// Hosted references can borrow any checkout. Their epoch belongs to the host and
// repository; legacy references still need the epoch of each owning checkout.
for (const project of snapshot?.projects ?? []) {
for (const project of projects) {
const identity = project.repositoryIdentity;
const repository = sourceControlRepositorySelector(identity);
if (
Expand Down
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@t3tools/web",
"version": "0.0.49",
"version": "0.0.50",
"private": true,
"type": "module",
"scripts": {
Expand Down
60 changes: 43 additions & 17 deletions apps/web/src/components/ChatMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,7 @@ import { ScrollArea } from "./ui/scroll-area";
import { Menu, MenuItem, MenuPopup, MenuTrigger } from "./ui/menu";
import { stackedThreadToast, toastManager } from "./ui/toast";
import { recordVisitForThread } from "../browserHistoryStore";
import {
PreferredEditorEnvironmentRequiredError,
useOpenInPreferredEditor,
usePreferredEditor,
} from "../editorPreferences";
import { PreferredEditorEnvironmentRequiredError, useEditorDispatch } from "../editorPreferences";
import { openInEditorMenuLabel } from "../editorLabels";
import { resolveDiffThemeName, type DiffThemeName } from "../lib/diffRendering";
import { fnv1a32 } from "../lib/diffRendering";
Expand Down Expand Up @@ -191,6 +187,11 @@ import {
import { resolveLinkTarget } from "../browser/browserLinkTarget";
import { PullRequestLinkPreview } from "./pullRequest/PullRequestLinkPreview";

type MarkdownImageAssetResource = Extract<
AssetResource,
{ readonly _tag: "attachment" | "workspace-file" | "media-file" | "source-control-image" }
>;

interface ChatMarkdownProps {
text: string;
cwd: string | undefined;
Expand All @@ -212,6 +213,8 @@ interface ChatMarkdownProps {
/** Directory that anchors relative links and images; defaults to `cwd`. Set
to the file's own directory when rendering a markdown file. */
imageBaseDir?: string | undefined;
/** Host-backed images, such as private uploads in a pull request description. */
resolveImageAsset?: ((source: string) => MarkdownImageAssetResource | null) | undefined;
onImageExpand?: ((preview: ExpandedImagePreview) => void) | undefined;
extraRemarkPlugins?: NonNullable<ReactMarkdownOptions["remarkPlugins"]>;
/** Renders a `t3-context://` link as a chip; without it the link shows its label as text. */
Expand Down Expand Up @@ -1563,10 +1566,7 @@ function ChatMarkdownVideo(props: {
/** Environment-hosted media loads through an exact-file signed asset URL. */
export const ChatMarkdownAssetImage = memo(function ChatMarkdownAssetImage(props: {
readonly environmentId: EnvironmentId;
readonly resource: Extract<
AssetResource,
{ readonly _tag: "attachment" | "workspace-file" | "media-file" }
>;
readonly resource: MarkdownImageAssetResource;
readonly kind?: "image" | "video";
readonly alt: string;
readonly copyMarkdown?: string;
Expand Down Expand Up @@ -1609,7 +1609,7 @@ export const ChatMarkdownAssetImage = memo(function ChatMarkdownAssetImage(props
src,
asset: { environmentId: props.environmentId, resource },
...(reference ? { reference } : {}),
...(relativePath && resource._tag !== "attachment"
...(relativePath && (resource._tag === "workspace-file" || resource._tag === "media-file")
? {
onOpenFile: () =>
useRightPanelStore
Expand Down Expand Up @@ -2215,6 +2215,7 @@ function useChatMarkdownState({
skills = EMPTY_MARKDOWN_SKILLS,
onUseArtifactTemplate,
imageBaseDir,
resolveImageAsset,
onImageExpand,
renderContextReference,
}: ChatMarkdownProps) {
Expand Down Expand Up @@ -2293,9 +2294,11 @@ function useChatMarkdownState({
const serverConfig = useAtomValue(serverEnvironment.configValueAtom(environmentId));
const projects = useProjects();
const availableEditors = serverConfig?.availableEditors ?? [];
const [preferredEditor] = usePreferredEditor(availableEditors);
const preferredEditorMenuLabel = openInEditorMenuLabel(preferredEditor);
const openInPreferredEditor = useOpenInPreferredEditor(environmentId, availableEditors);
const editorDispatch = useEditorDispatch(environmentId, availableEditors, cwd);
const preferredEditorMenuLabel = openInEditorMenuLabel(editorDispatch.choice?.editor ?? null);
const openInPreferredEditor = editorDispatch.open;
const canOpenPreferredEditor =
canUseShellActions || (environmentId !== null && editorDispatch.choice !== null);
const openInEditor = useAtomCommand(shellEnvironment.openInEditor, {
reportFailure: false,
});
Expand Down Expand Up @@ -2567,7 +2570,7 @@ function useChatMarkdownState({
copyMarkdown={copyMarkdown}
theme={resolvedTheme}
threadRef={threadRef}
{...(canUseShellActions ? { onOpen: openInPreferredEditor } : {})}
{...(canOpenPreferredEditor ? { onOpen: openInPreferredEditor } : {})}
onOpenInPanel={openFileInPanel}
onOpenMedia={
threadRef && canPreviewMedia
Expand All @@ -2594,6 +2597,7 @@ function useChatMarkdownState({
},
[
canUseShellActions,
canOpenPreferredEditor,
fileLinkParentSuffixByPath,
openFileInPanel,
openInPreferredEditor,
Expand All @@ -2616,6 +2620,7 @@ function useChatMarkdownState({
fileLinkChip,
renderContextReference,
imageBaseDir,
resolveImageAsset,
inlineCodeFileLinkMetaByText,
isStreaming,
linkTargetPreference,
Expand Down Expand Up @@ -2644,6 +2649,7 @@ function useChatMarkdownState({
fileLinkChip,
renderContextReference,
imageBaseDir,
resolveImageAsset,
inlineCodeFileLinkMetaByText,
isStreaming,
linkTargetPreference,
Expand Down Expand Up @@ -3045,9 +3051,15 @@ const CHAT_MARKDOWN_COMPONENTS = {
);
},
img: function MarkdownImage({ node, title, src, alt, ...props }) {
const { expandMedia, cwd, imageBaseDir, threadRef, renderContextReference } = use(
ChatMarkdownRendererContext,
);
const {
expandMedia,
cwd,
imageBaseDir,
threadRef,
environmentId,
resolveImageAsset,
renderContextReference,
} = use(ChatMarkdownRendererContext);
const imageExpand = use(MarkdownLinkContext) ? undefined : expandMedia;
const contextReference = typeof src === "string" ? parseComposerContextHref(src) : null;
if (contextReference) {
Expand All @@ -3071,6 +3083,20 @@ const CHAT_MARKDOWN_COMPONENTS = {
const copyMarkdown = markdownImageCopy(altText, srcString, authoredTitle);
const { className, style: _style, width, height, ...imageProps } = props;
const authoredSizeStyle = authoredImageSizeStyle(width, height);
const imageAsset = resolveImageAsset?.(classifiedSrc);
if (imageAsset && environmentId) {
return (
<ChatMarkdownAssetImage
environmentId={environmentId}
resource={imageAsset}
alt={altText}
copyMarkdown={copyMarkdown}
standalone={standalone}
style={authoredSizeStyle}
onImageExpand={imageExpand}
/>
);
}
const imageSource = classifyMarkdownImageSource(classifiedSrc, imageBaseDir ?? cwd);
const kind = mediaKindFromPath(classifiedSrc) ?? "image";
if (imageSource._tag === "Direct") {
Expand Down
Loading
Loading