Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix: command output streams live while it runs #15094

Mergedscratchyone(GitHub profile, opens in a new tab)merged 30 commits intomain fromrefs/pull/15094/headmerged by maria-rcks View on GitHub

Showing 48 changed files with 145 additions and 20 deletions (loading 45).

x
0 of 48 viewed, 48 left
99 additions and 0 deletionsapps/mobile/src/features/threads/thread-command-output.tsxAdded
View file
@@ -0,0 +1,99 @@
+import type { EnvironmentId, ThreadId, TurnItemId } from "@t3tools/contracts";
+import { TERMINAL_PALETTES, terminalOutputSpans } from "@t3tools/shared/terminalOutput";
+import type React from "react";
+import { useMemo, useRef } from "react";
+import { ScrollView, View } from "react-native";
+​
+import { AppText as Text } from "../../components/AppText";
+import { useServerConfigs } from "../../state/entities";
+import { orchestrationEnvironment } from "../../state/orchestration";
+import { useEnvironmentQuery } from "../../state/query";
+​
+// Within this many points of the end still counts as following the output.
+const FOLLOW_SLACK = 8;
+​
+/** True when the environment streams command output; older servers only return final output. */
+export function useCommandOutputStreaming(environmentId: EnvironmentId): boolean {
+ return (
+ useServerConfigs().get(environmentId)?.environment.capabilities.commandOutputStreaming === true
+ );
+}
+​
+/**
+ * Output of one expanded command row: streams while the command runs, then
+ * shows its final output. Mount it only when `useCommandOutputStreaming` holds.
+ * It subscribes only while mounted, so collapsed rows and other threads receive nothing.
+ */
+export function ThreadCommandOutput(props: {
+ readonly environmentId: EnvironmentId;
+ readonly threadId: ThreadId;
+ readonly itemId: TurnItemId;