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
109 changes: 109 additions & 0 deletions .github/workflows/custom-cli-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Custom CLI release

on:
push:
branches: [custom]
pull_request:
branches: [custom]
paths:
- .github/workflows/custom-cli-release.yml
workflow_dispatch:

permissions:
contents: read

concurrency:
group: custom-cli-${{ github.ref }}
cancel-in-progress: false

jobs:
build:
if: github.repository == 'mdatsev/t3code'
runs-on: ubuntu-24.04
timeout-minutes: 45
steps:
- uses: actions/checkout@v4
- uses: voidzero-dev/setup-vp@250f29ce396baf5e8f24498e17c0dfdebabc26eb
with:
node-version-file: package.json
run-install: false
- uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87
with:
toolchain: stable
- name: Install locked dependencies with the repository build policy
run: vp install --frozen-lockfile --filter=t3... --filter=@t3tools/scripts...
- name: Set release identity
run: |
revision=$(git rev-parse HEAD)
version=$(node -p "require('./apps/server/package.json').version.split('-')[0]")-custom.${revision}
echo "APP_VERSION=$version" >> "$GITHUB_ENV"
echo "CUSTOM_REVISION=$revision" >> "$GITHUB_ENV"
node scripts/update-release-package-versions.ts "$version"
- name: Build web client and server
env:
NODE_OPTIONS: --max-old-space-size=6144
T3CODE_WEB_SOURCEMAP: "0"
run: |
(cd apps/web && vp build)
node apps/server/scripts/cli.ts build --verbose
node -e 'require("node:fs").writeFileSync("apps/server/dist/client/remote-agent-box-release.json", JSON.stringify({commit: process.env.CUSTOM_REVISION}) + "\n")'
- name: Build resource monitor
run: |
cargo build --locked --release --manifest-path native/resource-monitor/Cargo.toml
install -D native/resource-monitor/target/release/t3-resource-monitor apps/server/dist/resource-monitor/linux-x64/t3-resource-monitor
- name: Build single executable
env:
VP_NODE_VERSION: "26.8.2"
run: node apps/server/scripts/cli.ts build-exe --verbose
- name: Package and verify CLI archive
run: |
node scripts/build-cli-archive.ts --platform linux --arch x64 --version "$APP_VERSION" --output-dir release-cli
node scripts/smoke-cli-archive.ts --archive release-cli/*.tar.gz --expect-version "$APP_VERSION"
python3 - <<'PY'
import hashlib
import json
import os
from pathlib import Path
archive, = Path('release-cli').glob('*.tar.gz')
manifest = {
'commit': os.environ['CUSTOM_REVISION'],
'tag': 'custom-' + os.environ['CUSTOM_REVISION'],
'version': os.environ['APP_VERSION'],
'asset': archive.name,
'sha256': hashlib.sha256(archive.read_bytes()).hexdigest(),
}
Path('release-cli/custom-release.json').write_text(json.dumps(manifest, indent=2) + '\n')
PY
- uses: actions/upload-artifact@v4
with:
name: custom-cli-linux-x64
path: release-cli/
if-no-files-found: error

publish:
needs: build
if: github.ref == 'refs/heads/custom' && github.event_name != 'pull_request'
runs-on: ubuntu-24.04
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
name: custom-cli-linux-x64
path: release-cli
- name: Publish verified fork release
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
tag="custom-${GITHUB_SHA}"
if draft=$(gh release view "$tag" --json isDraft --jq .isDraft 2>/dev/null); then
if [[ "$draft" == false ]]; then
echo "Release $tag is already published."
exit 0
fi
gh release upload "$tag" release-cli/* --clobber
else
gh release create "$tag" release-cli/* --target "$GITHUB_SHA" --title "Custom CLI ${GITHUB_SHA:0:12}" --notes "Linux x64 CLI built from custom commit ${GITHUB_SHA}." --prerelease --latest=false --draft
fi
gh release edit "$tag" --draft=false
86 changes: 86 additions & 0 deletions apps/mobile/src/features/threads/CommandOutput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { useAtomRefresh, useAtomValue } from "@effect/atom-react";
import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
import { useState } from "react";
import { Pressable, View } from "react-native";
import { AppText as Text } from "../../components/AppText";
import { orchestrationEnvironment } from "../../state/orchestration";
import { serverEnvironment } from "../../state/server";

type CommandOutputProps = { environmentId: EnvironmentId; threadId: ThreadId; activityId: string };

export function CommandOutput(
props: CommandOutputProps & {
fallback: string;
command: string;
preview: string;
fileChange?: boolean;
},
) {
const supported = useAtomValue(
serverEnvironment.configValueAtom(props.environmentId),
(config) =>
config?.environment.capabilities[props.fileChange ? "fileChangeOutput" : "commandOutput"] ===
true,
);
if (!supported)
return (
<Text selectable className="font-mono text-2xs text-foreground-muted">
{props.fileChange
? `${props.fallback}\nEdit contents aren't available from this server.`
: props.fallback}
</Text>
);
return (
<View>
{props.command && (
<Text selectable className="font-mono text-2xs leading-normal text-foreground-muted">
{props.command}
{"\n"}
</Text>
)}
<CommandOutputPage key={props.activityId} {...props} offset={0} />
</View>
);
}

function CommandOutputPage(
props: CommandOutputProps & { offset: number; preview: string; fileChange?: boolean },
) {
const query = orchestrationEnvironment.commandOutput({
environmentId: props.environmentId,
input: { threadId: props.threadId, activityId: props.activityId, offset: props.offset },
});
const result = useAtomValue(query);
const retry = useAtomRefresh(query);
const [showMore, setShowMore] = useState(false);
if (result._tag === "Failure")
return (
<View>
<Text>Could not load output.</Text>
<Pressable accessibilityRole="button" onPress={retry}>
<Text>Retry</Text>
</Pressable>
</View>
);
if (result._tag !== "Success") return <Text>Loading output…</Text>;
return (
<View>
<Text selectable className="font-mono text-2xs leading-normal text-foreground-muted">
{result.value.text ||
(props.offset === 0
? props.fileChange
? "No edit contents were recorded."
: props.preview || "No output recorded."
: "")}
</Text>
{result.value.nextOffset !== null &&
(showMore ? (
<CommandOutputPage {...props} offset={result.value.nextOffset} />
) : (
<Pressable accessibilityRole="button" onPress={() => setShowMore(true)}>
<Text className="py-2 underline">Load more output</Text>
</Pressable>
))}
</View>
);
}
4 changes: 4 additions & 0 deletions apps/mobile/src/features/threads/ThreadFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1355,6 +1355,7 @@ function renderFeedEntry(
props: Pick<
ThreadFeedProps,
| "environmentId"
| "threadId"
| "onUseArtifactTemplate"
| "skills"
| "dispatchingMessageId"
Expand Down Expand Up @@ -1754,6 +1755,7 @@ function renderFeedEntry(
// Anchors/details live in ThreadFeed and survive this group-only remount.
key={`${entry.id}:${props.workRowSizing.textSizeKey}`}
activities={entry.activities}
threadId={props.threadId}
environmentId={props.environmentId}
anchorKey={entry.id}
copiedRowId={props.copiedRowId}
Expand Down Expand Up @@ -2754,6 +2756,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
>
<ThreadMediaVisibility>
{renderFeedEntry(info, {
threadId: props.threadId,
environmentId: props.environmentId,
dispatchingMessageId: props.dispatchingMessageId,
onEditPendingMessage: props.onEditPendingMessage,
Expand Down Expand Up @@ -2829,6 +2832,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
onToggleWorkGroup,
onToggleWorkRow,
props.environmentId,
props.threadId,
props.onUseArtifactTemplate,
props.skills,
renderMarkdownImage,
Expand Down
31 changes: 26 additions & 5 deletions apps/mobile/src/features/threads/thread-work-log.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CommandOutput } from "./CommandOutput";
import { QuestionAnswerHistory } from "./QuestionAnswerHistory";
import {
getQuestionAnswerPreview,
Expand Down Expand Up @@ -32,7 +33,7 @@ import {
View,
} from "react-native";
import Svg, { Defs, LinearGradient, Rect, Stop } from "react-native-svg";
import type { EnvironmentId, ToolActivityIcon } from "@t3tools/contracts";
import type { EnvironmentId, ThreadId, ToolActivityIcon } from "@t3tools/contracts";
import { toolActivityFaviconUrl } from "@t3tools/shared/favicon";

import { AppText as Text } from "../../components/AppText";
Expand Down Expand Up @@ -413,6 +414,7 @@ export function collapsedWorkLogHeight(activities: ReadonlyArray<ThreadFeedActiv
}

interface ThreadWorkLogProps {
readonly threadId: ThreadId;
readonly activities: ReadonlyArray<ThreadFeedActivity>;
readonly anchorKey: string;
readonly environmentId: EnvironmentId;
Expand All @@ -439,6 +441,7 @@ export function ThreadWorkLog(props: ThreadWorkLogProps) {
copied={props.copiedRowId === row.id}
expanded={props.expandedRows[row.id] ?? false}
environmentId={props.environmentId}
threadId={props.threadId}
iconSubtleColor={props.iconSubtleColor}
onCopyRow={props.onCopyRow}
onToggleRow={props.onToggleRow}
Expand All @@ -450,6 +453,7 @@ export function ThreadWorkLog(props: ThreadWorkLogProps) {
props.anchorKey,
props.copiedRowId,
props.expandedRows,
props.threadId,
props.environmentId,
props.iconSubtleColor,
props.onCopyRow,
Expand Down Expand Up @@ -879,7 +883,12 @@ const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
</View>
</Pressable>

{expanded && (fullDetail || viewedImagePath || row.workEntry.questionAnswer) ? (
{expanded &&
(fullDetail ||
row.workEntry.command ||
row.workEntry.itemType === "file_change" ||
viewedImagePath ||
row.workEntry.questionAnswer) ? (
<Animated.View
entering={WORK_LOG_DETAIL_ENTER_TRANSITION}
exiting={WORK_LOG_DETAIL_EXIT_TRANSITION}
Expand All @@ -904,9 +913,21 @@ const ThreadWorkLogRow = memo(function ThreadWorkLogRow(
className="max-h-60"
contentContainerStyle={{ paddingRight: 8 }}
>
<Text selectable className="font-mono text-2xs leading-normal text-foreground-muted">
{fullDetail}
</Text>
{row.workEntry.command || row.workEntry.itemType === "file_change" ? (
<CommandOutput
environmentId={props.environmentId}
threadId={props.threadId}
activityId={row.workEntry.sourceActivityId ?? row.workEntry.id}
fallback={fullDetail ?? ""}
command={row.workEntry.rawCommand ?? row.workEntry.command ?? ""}
preview={row.workEntry.detail ?? ""}
fileChange={row.workEntry.itemType === "file_change"}
/>
) : (
<Text selectable className="font-mono text-2xs leading-normal text-foreground-muted">
{fullDetail}
</Text>
)}
</ScrollView>
</Animated.View>
) : null}
Expand Down
1 change: 1 addition & 0 deletions apps/mobile/src/lib/threadActivity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1129,6 +1129,7 @@ describe("buildThreadFeed", () => {
expect(group.activities).toHaveLength(1);
expect(group.activities[0]).toMatchObject({
id: "tool-updated",
workEntry: { sourceActivityId: "tool-completed" },
createdAt: "2026-04-01T00:00:01.000Z",
turnId: "turn-1",
summary: "Run tests",
Expand Down
3 changes: 3 additions & 0 deletions apps/mobile/src/lib/threadActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export interface ThreadFeedActivity {
}

export interface WorkLogEntry {
sourceActivityId?: string;
readonly questionAnswer?: UserInputAttachmentAnswerPayload;
id: string;
createdAt: string;
Expand Down Expand Up @@ -509,6 +510,7 @@ function toDerivedWorkLogEntry(activity: OrchestrationThreadActivity): DerivedWo
: undefined;
const entry: DerivedWorkLogEntry = {
id: activity.id,
sourceActivityId: activity.id,
createdAt: activity.createdAt,
turnId: activity.turnId,
...(taskId ? { taskId } : {}),
Expand Down Expand Up @@ -1016,6 +1018,7 @@ function buildWorkEntryExpandedBody(entry: WorkLogEntry): string | null {
* for every row (see the deferred-expansion test).
*/
function workEntryCanExpand(entry: WorkLogEntry): boolean {
if (entry.itemType === "file_change") return true;
if (entry.questionAnswer) return true;
if (entry.agentSpawn) return agentSpawnMembers(entry.agentSpawn).length > 0;
if (entry.itemType === "mcp_tool_call" && entry.toolData !== undefined) return true;
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/auth/RpcAuthorization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type WsRpcMethod = RpcGroup.Rpcs<typeof WsRpcGroup>["_tag"];
*/
export const RPC_REQUIRED_SCOPES = {
[ORCHESTRATION_WS_METHODS.dispatchCommand]: AuthOrchestrationOperateScope,
[ORCHESTRATION_WS_METHODS.getCommandOutput]: AuthOrchestrationReadScope,
[ORCHESTRATION_WS_METHODS.getWorkflowScript]: AuthOrchestrationReadScope,
[ORCHESTRATION_WS_METHODS.getTurnDiff]: AuthOrchestrationReadScope,
[ORCHESTRATION_WS_METHODS.getFullThreadDiff]: AuthOrchestrationReadScope,
Expand Down
5 changes: 5 additions & 0 deletions apps/server/src/checkpointing/CheckpointDiffQuery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ describe("CheckpointDiffQuery.layer", () => {
Layer.provideMerge(Layer.succeed(CheckpointStore.CheckpointStore, checkpointStore)),
Layer.provideMerge(
Layer.succeed(ProjectionSnapshotQuery.ProjectionSnapshotQuery, {
getCommandOutput: () => Effect.die("unused"),
getUserInputActivity: () => Effect.die("unused"),
listActivitiesByKind: () => Effect.die("unused"),
getCommandReadModel: () =>
Expand Down Expand Up @@ -193,6 +194,7 @@ describe("CheckpointDiffQuery.layer", () => {
Layer.provideMerge(Layer.succeed(CheckpointStore.CheckpointStore, checkpointStore)),
Layer.provideMerge(
Layer.succeed(ProjectionSnapshotQuery.ProjectionSnapshotQuery, {
getCommandOutput: () => Effect.die("unused"),
getUserInputActivity: () => Effect.die("unused"),
listActivitiesByKind: () => Effect.die("unused"),
getCommandReadModel: () =>
Expand Down Expand Up @@ -286,6 +288,7 @@ describe("CheckpointDiffQuery.layer", () => {
Layer.provideMerge(Layer.succeed(CheckpointStore.CheckpointStore, checkpointStore)),
Layer.provideMerge(
Layer.succeed(ProjectionSnapshotQuery.ProjectionSnapshotQuery, {
getCommandOutput: () => Effect.die("unused"),
getUserInputActivity: () => Effect.die("unused"),
listActivitiesByKind: () => Effect.die("unused"),
getCommandReadModel: () =>
Expand Down Expand Up @@ -364,6 +367,7 @@ describe("CheckpointDiffQuery.layer", () => {
Layer.provideMerge(Layer.succeed(CheckpointStore.CheckpointStore, checkpointStore)),
Layer.provideMerge(
Layer.succeed(ProjectionSnapshotQuery.ProjectionSnapshotQuery, {
getCommandOutput: () => Effect.die("unused"),
getUserInputActivity: () => Effect.die("unused"),
listActivitiesByKind: () => Effect.die("unused"),
getCommandReadModel: () =>
Expand Down Expand Up @@ -427,6 +431,7 @@ describe("CheckpointDiffQuery.layer", () => {
Layer.provideMerge(Layer.succeed(CheckpointStore.CheckpointStore, checkpointStore)),
Layer.provideMerge(
Layer.succeed(ProjectionSnapshotQuery.ProjectionSnapshotQuery, {
getCommandOutput: () => Effect.die("unused"),
getUserInputActivity: () => Effect.die("unused"),
listActivitiesByKind: () => Effect.die("unused"),
getCommandReadModel: () =>
Expand Down
2 changes: 2 additions & 0 deletions apps/server/src/environment/ServerEnvironment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ export const make = Effect.gen(function* () {
threadActiveReorder: true,
threadAutoSettleOptOut: true,
threadTitleRegeneration: true,
commandOutput: true,
fileChangeOutput: true,
threadPullRequests: true,
pullRequestStackActions: true,
threadPullRequestLinking: true,
Expand Down
Loading
Loading