Skip to content

Commit ce27118

Browse files
Merge pull request #78 from ScriptedAlchemy/codex/sync-upstream-main-20261107
chore(sync): merge upstream main and preserve fork integrations
2 parents a186b5c + 80bb433 commit ce27118

112 files changed

Lines changed: 2201 additions & 1731 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/desktop/src/ipc/DesktopIpcHandlers.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { getClientSettings, setClientSettings } from "./methods/clientSettings.t
77
import { getConnectionCatalog, setConnectionCatalog } from "./methods/connectionCatalog.ts";
88
import { discoverLanServices } from "./methods/lanDiscovery.ts";
99
import {
10+
getHostEnvironmentId,
1011
getLocalEnvironmentEnabled,
1112
setLocalEnvironmentEnabled,
1213
} from "./methods/localEnvironment.ts";
@@ -101,6 +102,7 @@ export const installDesktopIpcHandlers = Effect.fn("desktop.ipc.installHandlers"
101102
yield* ipc.handleSync(getLocalEnvironmentBootstraps);
102103
yield* ipc.handleSync(getLocalEnvironmentEnabled);
103104
yield* ipc.handle(setLocalEnvironmentEnabled);
105+
yield* ipc.handle(getHostEnvironmentId);
104106
yield* ipc.handle(getLocalEnvironmentBearerToken);
105107

106108
yield* ipc.handle(getClientSettings);

‎apps/desktop/src/ipc/channels.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const GET_PREFERRED_SYSTEM_LANGUAGES_CHANNEL = "desktop:get-preferred-sys
3838
export const GET_LOCAL_ENVIRONMENT_BOOTSTRAPS_CHANNEL = "desktop:get-local-environment-bootstraps";
3939
export const GET_LOCAL_ENVIRONMENT_ENABLED_CHANNEL = "desktop:get-local-environment-enabled";
4040
export const SET_LOCAL_ENVIRONMENT_ENABLED_CHANNEL = "desktop:set-local-environment-enabled";
41+
export const GET_HOST_ENVIRONMENT_ID_CHANNEL = "desktop:get-host-environment-id";
4142
export const GET_LOCAL_ENVIRONMENT_BEARER_TOKEN_CHANNEL =
4243
"desktop:get-local-environment-bearer-token";
4344
export const GET_CLIENT_SETTINGS_CHANNEL = "desktop:get-client-settings";

‎apps/desktop/src/ipc/methods/localEnvironment.test.ts‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import { assert, describe, it } from "@effect/vitest";
2+
import * as NodeServices from "@effect/platform-node/NodeServices";
3+
import * as FileSystem from "effect/FileSystem";
4+
import * as Path from "effect/Path";
25
import * as Effect from "effect/Effect";
36
import * as Layer from "effect/Layer";
47

@@ -10,7 +13,11 @@ import * as ElectronApp from "../../electron/ElectronApp.ts";
1013
import * as ElectronTheme from "../../electron/ElectronTheme.ts";
1114
import * as DesktopAppSettings from "../../settings/DesktopAppSettings.ts";
1215
import * as DesktopWindow from "../../window/DesktopWindow.ts";
13-
import { getLocalEnvironmentEnabled, setLocalEnvironmentEnabled } from "./localEnvironment.ts";
16+
import {
17+
getHostEnvironmentId,
18+
getLocalEnvironmentEnabled,
19+
setLocalEnvironmentEnabled,
20+
} from "./localEnvironment.ts";
1421

1522
const layerUnusedLifecycleRuntime = Layer.mergeAll(
1623
DesktopShutdown.layer,
@@ -27,6 +34,26 @@ const layerUnusedLifecycleRuntime = Layer.mergeAll(
2734
);
2835

2936
describe("local environment IPC", () => {
37+
it.effect("reads the shared home identity without creating one", () =>
38+
Effect.gen(function* () {
39+
const fs = yield* FileSystem.FileSystem;
40+
const path = yield* Path.Path;
41+
const stateDir = yield* fs.makeTempDirectoryScoped();
42+
const environment = DesktopEnvironment.DesktopEnvironment.of({
43+
path,
44+
stateDir,
45+
} as DesktopEnvironment.DesktopEnvironment["Service"]);
46+
const read = getHostEnvironmentId
47+
.handler(undefined)
48+
.pipe(Effect.provideService(DesktopEnvironment.DesktopEnvironment, environment));
49+
assert.strictEqual(yield* read, null);
50+
assert.isFalse(yield* fs.exists(path.join(stateDir, "environment-id")));
51+
yield* fs.writeFileString(path.join(stateDir, "environment-id"), " service-id\n");
52+
assert.strictEqual(yield* read, "service-id");
53+
yield* fs.writeFileString(path.join(stateDir, "environment-id"), "\n");
54+
assert.strictEqual(yield* read, null);
55+
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
56+
);
3057
it.effect("relaunches only when the setting changes and keeps other settings", () => {
3158
const relaunchReasons: Array<string> = [];
3259
const layer = Layer.mergeAll(

‎apps/desktop/src/ipc/methods/localEnvironment.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as Effect from "effect/Effect";
2+
import * as FileSystem from "effect/FileSystem";
23
import * as Schema from "effect/Schema";
34

5+
import * as DesktopEnvironment from "../../app/DesktopEnvironment.ts";
46
import * as DesktopLifecycle from "../../app/DesktopLifecycle.ts";
57
import * as DesktopAppSettings from "../../settings/DesktopAppSettings.ts";
68
import * as IpcChannels from "../channels.ts";
@@ -28,3 +30,18 @@ export const setLocalEnvironmentEnabled = makeIpcMethod({
2830
}
2931
}),
3032
});
33+
34+
// A background service sharing this app's T3 home records its environment ID in the same state dir.
35+
export const getHostEnvironmentId = makeIpcMethod({
36+
channel: IpcChannels.GET_HOST_ENVIRONMENT_ID_CHANNEL,
37+
payload: Schema.Void,
38+
result: Schema.NullOr(Schema.String),
39+
handler: Effect.fn("desktop.ipc.localEnvironment.getHostEnvironmentId")(function* () {
40+
const environment = yield* DesktopEnvironment.DesktopEnvironment;
41+
const fileSystem = yield* FileSystem.FileSystem;
42+
const contents = yield* fileSystem
43+
.readFileString(environment.path.join(environment.stateDir, "environment-id"))
44+
.pipe(Effect.orElseSucceed(() => ""));
45+
return contents.trim() || null;
46+
}),
47+
});

‎apps/desktop/src/preload.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ contextBridge.exposeInMainWorld("desktopBridge", {
126126
ipcRenderer.sendSync(IpcChannels.GET_LOCAL_ENVIRONMENT_ENABLED_CHANNEL) !== false,
127127
setLocalEnvironmentEnabled: (enabled) =>
128128
ipcRenderer.invoke(IpcChannels.SET_LOCAL_ENVIRONMENT_ENABLED_CHANNEL, enabled),
129+
getHostEnvironmentId: () => ipcRenderer.invoke(IpcChannels.GET_HOST_ENVIRONMENT_ID_CHANNEL),
129130
getClientSettings: () => ipcRenderer.invoke(IpcChannels.GET_CLIENT_SETTINGS_CHANNEL),
130131
setClientSettings: (settings) =>
131132
ipcRenderer.invoke(IpcChannels.SET_CLIENT_SETTINGS_CHANNEL, settings),

‎apps/mobile/modules/t3-terminal/android/src/main/java/expo/modules/t3terminal/T3TerminalView.kt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,10 @@ class T3TerminalView(context: Context, appContext: AppContext) : ExpoView(contex
286286
onInput(mapOf("data" to "\r"))
287287
},
288288
)
289+
val navigationKeys = TerminalNavigationKeyListener { onInput(mapOf("data" to it)) }
289290
inputView.setOnKeyListener { _, keyCode, event ->
290291
if (readOnly) return@setOnKeyListener true
292+
if (navigationKeys.onKey(inputView, keyCode, event)) return@setOnKeyListener true
291293
if (event.action != KeyEvent.ACTION_DOWN) return@setOnKeyListener false
292294
when {
293295
keyCode == KeyEvent.KEYCODE_DEL -> {
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package expo.modules.t3terminal
2+
3+
import android.view.KeyEvent
4+
import android.view.View
5+
6+
internal class TerminalNavigationKeyListener(
7+
private val send: (String) -> Unit
8+
) : View.OnKeyListener {
9+
override fun onKey(view: View?, keyCode: Int, event: KeyEvent): Boolean {
10+
val sequence = sequenceFor(keyCode, event) ?: return false
11+
if (event.action == KeyEvent.ACTION_DOWN) send(sequence)
12+
// Unconsumed arrow and Tab key events move focus off the terminal input.
13+
return true
14+
}
15+
16+
// Matches iOS: these keys only without modifiers, plus Shift+Tab.
17+
private fun sequenceFor(keyCode: Int, event: KeyEvent): String? = when {
18+
keyCode == KeyEvent.KEYCODE_TAB && event.hasModifiers(KeyEvent.META_SHIFT_ON) -> "\u001b[Z"
19+
!event.hasNoModifiers() -> null
20+
keyCode == KeyEvent.KEYCODE_DPAD_UP -> "\u001b[A"
21+
keyCode == KeyEvent.KEYCODE_DPAD_DOWN -> "\u001b[B"
22+
keyCode == KeyEvent.KEYCODE_DPAD_RIGHT -> "\u001b[C"
23+
keyCode == KeyEvent.KEYCODE_DPAD_LEFT -> "\u001b[D"
24+
keyCode == KeyEvent.KEYCODE_TAB -> "\t"
25+
keyCode == KeyEvent.KEYCODE_ESCAPE -> "\u001b"
26+
else -> null
27+
}
28+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package expo.modules.t3terminal
2+
3+
import android.app.Activity
4+
import android.view.KeyEvent
5+
import android.view.View
6+
import android.widget.Button
7+
import android.widget.EditText
8+
import android.widget.LinearLayout
9+
import org.junit.Assert.assertEquals
10+
import org.junit.Assert.assertTrue
11+
import org.junit.Test
12+
import org.junit.runner.RunWith
13+
import org.robolectric.Robolectric
14+
import org.robolectric.RobolectricTestRunner
15+
import org.robolectric.annotation.Config
16+
17+
@RunWith(RobolectricTestRunner::class)
18+
@Config(sdk = [36], manifest = Config.NONE)
19+
class TerminalNavigationKeyListenerTest {
20+
@Test
21+
fun hardwareNavigationKeysReachThePtyAndKeepFocus() {
22+
val activity = Robolectric.buildActivity(Activity::class.java).setup().get()
23+
val sent = StringBuilder()
24+
val input = EditText(activity).apply {
25+
setSingleLine(true)
26+
isFocusableInTouchMode = true
27+
setOnKeyListener(TerminalNavigationKeyListener { sent.append(it) })
28+
}
29+
val nextControl = Button(activity).apply { isFocusableInTouchMode = true }
30+
val root = LinearLayout(activity).apply {
31+
orientation = LinearLayout.VERTICAL
32+
addView(input)
33+
addView(nextControl)
34+
}
35+
activity.setContentView(root)
36+
// Focus search below the input only finds controls that have bounds.
37+
root.measure(
38+
View.MeasureSpec.makeMeasureSpec(1080, View.MeasureSpec.EXACTLY),
39+
View.MeasureSpec.makeMeasureSpec(1920, View.MeasureSpec.EXACTLY),
40+
)
41+
root.layout(0, 0, 1080, 1920)
42+
assertTrue(input.requestFocus())
43+
44+
val shift = KeyEvent.META_SHIFT_ON or KeyEvent.META_SHIFT_LEFT_ON
45+
val keys = listOf(
46+
Triple(KeyEvent.KEYCODE_DPAD_UP, 0, "\u001b[A"),
47+
Triple(KeyEvent.KEYCODE_DPAD_DOWN, 0, "\u001b[B"),
48+
Triple(KeyEvent.KEYCODE_DPAD_RIGHT, 0, "\u001b[C"),
49+
Triple(KeyEvent.KEYCODE_DPAD_LEFT, 0, "\u001b[D"),
50+
Triple(KeyEvent.KEYCODE_TAB, 0, "\t"),
51+
Triple(KeyEvent.KEYCODE_TAB, shift, "\u001b[Z"),
52+
Triple(KeyEvent.KEYCODE_ESCAPE, 0, "\u001b"),
53+
)
54+
for ((keyCode, meta, expected) in keys) {
55+
sent.clear()
56+
input.dispatchKeyEvent(KeyEvent(0, 0, KeyEvent.ACTION_DOWN, keyCode, 0, meta))
57+
input.dispatchKeyEvent(KeyEvent(0, 0, KeyEvent.ACTION_UP, keyCode, 0, meta))
58+
assertEquals("bytes for key $keyCode meta $meta", expected, sent.toString())
59+
assertTrue("focus left the input after key $keyCode meta $meta", input.isFocused)
60+
}
61+
62+
sent.clear()
63+
val ctrl = KeyEvent.META_CTRL_ON or KeyEvent.META_CTRL_LEFT_ON
64+
input.dispatchKeyEvent(KeyEvent(0, 0, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DPAD_UP, 0, ctrl))
65+
assertEquals("modified arrows are left to the app, as on iOS", "", sent.toString())
66+
}
67+
}

‎apps/mobile/src/components/ui/AppBar.android.tsx‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,15 @@ function AppBarView(props: AppBarProps & { readonly searchState?: SearchState })
155155
</Menu>
156156
));
157157
const confirmButton = props.confirm ? (
158-
<Button
159-
label={props.confirm.label}
160-
tone="text"
161-
loading={props.confirm.loading}
162-
disabled={props.confirm.disabled}
163-
onPress={props.confirm.onPress}
164-
/>
158+
<View className="self-center">
159+
<Button
160+
label={props.confirm.label}
161+
tone="text"
162+
loading={props.confirm.loading}
163+
disabled={props.confirm.disabled}
164+
onPress={props.confirm.onPress}
165+
/>
166+
</View>
165167
) : null;
166168
const options =
167169
props.embedded || props.sheet ? null : (

‎apps/mobile/src/features/pull-requests/PullRequestAgentRow.tsx‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ export function PullRequestAgentRow(props: {
1919
title={props.title ?? action.title}
2020
icon="sparkles"
2121
accessibilityLabel={props.title ?? action.title}
22-
menu={agent.threads.length > 1}
22+
menu={agent.chooseThread && !action.attributes.disabled}
2323
onPress={
24-
action.attributes.disabled || agent.threads.length > 1
25-
? undefined
26-
: () => agent.start(props.task)
24+
action.attributes.disabled || agent.chooseThread ? undefined : () => agent.start(props.task)
2725
}
2826
/>
2927
);
30-
if (agent.threads.length <= 1 || action.attributes.disabled) return row;
28+
if (!agent.chooseThread || action.attributes.disabled) return row;
3129
return (
3230
<Menu
3331
title={props.title ?? action.title}

0 commit comments

Comments
 (0)