Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99fb86471e | ||
|
|
92724f1509 |
No files matched your search
@@ -272,18 +272,11 @@ export function HermesMobileWorkspace({ mode = "full" }: { mode?: "full" | "list
|
||||
</View>
|
||||
</ScrollView>
|
||||
)}
|
||||
<View className="flex-row gap-2">
|
||||
{mode === "full" && selection && (
|
||||
{mode === "full" && selection && (
|
||||
<View className="flex-row gap-2">
|
||||
<Action label="Sessions" onPress={() => setSelection(null)} />
|
||||
)}
|
||||
{(mode !== "full" || Platform.OS !== "android") && (
|
||||
<Action
|
||||
label={busy ? "Starting Hermes…" : "New task"}
|
||||
disabled={!connection || busy}
|
||||
onPress={() => void create()}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
)}
|
||||
{error && <ErrorDetail message={error} />}
|
||||
</View>
|
||||
)}
|
||||
@@ -438,10 +431,7 @@ function HermesSessionList({ connection }: { connection: HermesConnection }) {
|
||||
className={inputClass}
|
||||
/>
|
||||
{AsyncResult.isFailure(result) && (
|
||||
<>
|
||||
<ErrorDetail message={prettyHermesCause(result.cause)} />
|
||||
<HermesLogin connection={connection} onSuccess={() => registry.refresh(query)} />
|
||||
</>
|
||||
<ErrorDetail message={prettyHermesCause(result.cause)} />
|
||||
)}
|
||||
{error && <ErrorDetail message={error} />}
|
||||
</View>
|
||||
@@ -450,7 +440,7 @@ function HermesSessionList({ connection }: { connection: HermesConnection }) {
|
||||
<Text className="py-5 text-sm text-muted-foreground">
|
||||
{AsyncResult.isInitial(result)
|
||||
? "Loading sessions…"
|
||||
: "No Hermes sessions. Use New task to start chatting."}
|
||||
: "No Hermes sessions. Use New chat to start chatting."}
|
||||
</Text>
|
||||
}
|
||||
renderItem={({ item, index }) => (
|
||||
|
||||
@@ -571,7 +571,11 @@ function AdaptiveWorkspaceLayoutContent(
|
||||
<View className="flex-1" style={{ width: layout.listPaneWidth }}>
|
||||
<ConversationTabs topInset />
|
||||
{conversationSource === "hermes" ? (
|
||||
<HermesMobileWorkspace mode="list" />
|
||||
<AndroidHomeFabLayout
|
||||
onStartNewTask={() => requestHermesSession((value) => value + 1)}
|
||||
>
|
||||
<HermesMobileWorkspace mode="list" />
|
||||
</AndroidHomeFabLayout>
|
||||
) : (
|
||||
<AndroidHomeFabLayout onStartNewTask={handleStartNewTask}>
|
||||
<ThreadNavigationSidebar
|
||||
|
||||
@@ -159,9 +159,26 @@ describe("Android APK release selection", () => {
|
||||
).toBeNull();
|
||||
});
|
||||
|
||||
it("rejects same-origin assets outside the exact Gitea attachment path", () => {
|
||||
it("accepts the exact Gitea repository release download path", () => {
|
||||
const browser_download_url =
|
||||
"https://git.example.com/alex/t3code/releases/download/apk-5/t3code-apk-5.apk";
|
||||
expect(
|
||||
selectLatestAndroidApkRelease(
|
||||
[
|
||||
release(5, {
|
||||
assets: [{ id: 5, name: "t3code-apk-5.apk", size: 4, browser_download_url }],
|
||||
}),
|
||||
],
|
||||
API_URL,
|
||||
),
|
||||
).toEqual({ versionCode: 5, downloadUrl: browser_download_url, expectedSize: 4 });
|
||||
});
|
||||
|
||||
it("rejects same-origin assets outside trusted Gitea asset paths", () => {
|
||||
for (const browser_download_url of [
|
||||
`https://git.example.com/alex/t3code/releases/download/apk-5/t3code-apk-5.apk`,
|
||||
`https://git.example.com/other/t3code/releases/download/apk-5/t3code-apk-5.apk`,
|
||||
`https://git.example.com/alex/t3code/releases/download/apk-6/t3code-apk-5.apk`,
|
||||
`https://git.example.com/alex/t3code/releases/download/apk-5/other.apk`,
|
||||
`https://git.example.com/api/v1/repos/alex/t3code/releases/assets/5`,
|
||||
`https://git.example.com/other/attachments/${attachmentUuid(5)}`,
|
||||
`https://git.example.com/attachments/not-a-uuid`,
|
||||
@@ -201,6 +218,22 @@ describe("Android APK release selection", () => {
|
||||
expect(selectLatestAndroidApkRelease([valid], API_URL)).toBeNull();
|
||||
});
|
||||
|
||||
it("uses the exact configured Gitea subpath for release downloads", () => {
|
||||
const valid = release(5, {
|
||||
assets: [
|
||||
{
|
||||
id: 5,
|
||||
name: "t3code-apk-5.apk",
|
||||
size: 4,
|
||||
browser_download_url:
|
||||
"https://git.example.com/git/alex/t3code/releases/download/apk-5/t3code-apk-5.apk",
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(selectLatestAndroidApkRelease([valid], SUBPATH_API_URL)?.versionCode).toBe(5);
|
||||
expect(selectLatestAndroidApkRelease([valid], API_URL)).toBeNull();
|
||||
});
|
||||
|
||||
it("rejects assets with invalid or excessive declared sizes", () => {
|
||||
for (const size of [0, -1, 1.5, 500 * 1024 * 1024 + 1]) {
|
||||
expect(
|
||||
|
||||
@@ -136,23 +136,44 @@ function trustedHttpsUrl(rawUrl: string, kind: "API" | "asset"): URL {
|
||||
return url;
|
||||
}
|
||||
|
||||
function giteaServerBase(apiUrl: string): { readonly origin: string; readonly path: string } {
|
||||
function giteaServerBase(apiUrl: string): {
|
||||
readonly origin: string;
|
||||
readonly path: string;
|
||||
readonly owner: string;
|
||||
readonly repository: string;
|
||||
} {
|
||||
const url = trustedHttpsUrl(apiUrl, "API");
|
||||
const match = /^(.*)\/api\/v1\/repos\/[^/]+\/[^/]+\/releases\/?$/.exec(url.pathname);
|
||||
const match = /^(.*)\/api\/v1\/repos\/([^/]+)\/([^/]+)\/releases\/?$/.exec(url.pathname);
|
||||
if (!match) throw new Error("The update API URL is not a Gitea repository releases URL.");
|
||||
return { origin: url.origin, path: match[1] ?? "" };
|
||||
return {
|
||||
origin: url.origin,
|
||||
path: match[1] ?? "",
|
||||
owner: match[2] ?? "",
|
||||
repository: match[3] ?? "",
|
||||
};
|
||||
}
|
||||
|
||||
function trustedAttachmentUrl(rawUrl: unknown, apiUrl: string): string | null {
|
||||
function trustedAssetUrl(
|
||||
rawUrl: unknown,
|
||||
apiUrl: string,
|
||||
releaseTag: string,
|
||||
assetName: string,
|
||||
): string | null {
|
||||
if (typeof rawUrl !== "string") return null;
|
||||
try {
|
||||
const url = trustedHttpsUrl(rawUrl, "asset");
|
||||
const server = giteaServerBase(apiUrl);
|
||||
if (url.origin !== server.origin) return null;
|
||||
const prefix = `${server.path}/attachments/`;
|
||||
if (!url.pathname.startsWith(prefix)) return null;
|
||||
const uuid = url.pathname.slice(prefix.length);
|
||||
return GITEA_ATTACHMENT_UUID.test(uuid) ? url.href : null;
|
||||
const attachmentPrefix = `${server.path}/attachments/`;
|
||||
if (url.pathname.startsWith(attachmentPrefix)) {
|
||||
const uuid = url.pathname.slice(attachmentPrefix.length);
|
||||
return GITEA_ATTACHMENT_UUID.test(uuid) ? url.href : null;
|
||||
}
|
||||
const releaseUrl = new URL(
|
||||
`${server.path}/${server.owner}/${server.repository}/releases/download/${releaseTag}/${assetName}`,
|
||||
server.origin,
|
||||
);
|
||||
return url.href === releaseUrl.href ? url.href : null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
@@ -411,7 +432,12 @@ export function selectLatestAndroidApkRelease(
|
||||
asset.name !== expectedAssetName
|
||||
)
|
||||
continue;
|
||||
const downloadUrl = trustedAttachmentUrl(asset.browser_download_url, apiUrl);
|
||||
const downloadUrl = trustedAssetUrl(
|
||||
asset.browser_download_url,
|
||||
apiUrl,
|
||||
release.tag_name,
|
||||
expectedAssetName,
|
||||
);
|
||||
if (!downloadUrl) continue;
|
||||
candidate = { versionCode, downloadUrl, expectedSize: asset.size };
|
||||
break;
|
||||
|
||||
@@ -19,6 +19,9 @@ describe("native Hermes presentation", () => {
|
||||
expect(hermesErrorMessage("Error: Unknown request tag: hermes.write")).toContain(
|
||||
"Update and restart the T3 desktop app or server",
|
||||
);
|
||||
expect(hermesErrorMessage("Unknown request tag: hermes.read")).toContain(
|
||||
"Update and restart the T3 desktop app or server",
|
||||
);
|
||||
});
|
||||
it("merges overlapping transcript pages with stable message identities", () => {
|
||||
const older = hermesMessages({
|
||||
|
||||
@@ -46,7 +46,7 @@ export function hermesPretty(value: unknown): string {
|
||||
}
|
||||
|
||||
export function hermesErrorMessage(message: string): string {
|
||||
if (/Unknown request tag: hermes\.(?:read|write|events)/i.test(message)) {
|
||||
if (/unknown request tag:\s*hermes\.(?:read|write|events)/i.test(message)) {
|
||||
return "This T3 host is too old for native Hermes controls. Update and restart the T3 desktop app or server on the connected machine, then try again.";
|
||||
}
|
||||
return message;
|
||||
|
||||
Reference in new issue
Block a user