Skip to content
Merged
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
6 changes: 1 addition & 5 deletions .github/actions/db-sync-server/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ name: Start db-sync server
description: >-
Check out logseq@feature/native-mobile-app, build the db-sync node adapter,
and start it on the given port (default 8787). The app e2e flows create sync
graphs against it.
graphs against it. logseq/logseq is public, so no credential is needed.
inputs:
token:
description: GitHub token with access to the private logseq/logseq repo.
required: true
ref:
description: logseq/logseq ref to check out.
required: false
Expand Down Expand Up @@ -35,7 +32,6 @@ runs:
repository: logseq/logseq
ref: ${{ inputs.ref }}
path: logseq-server
token: ${{ inputs.token }}
fetch-depth: 1

- uses: actions/setup-java@v4
Expand Down
19 changes: 8 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
ocaml-core:
runs-on: ubuntu-latest
env:
LOGSEQ_GITHUB_PAT: ${{ secrets.LOGSEQ_GITHUB_PAT }}
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -63,14 +62,13 @@ jobs:
run: |
eval $(opam env)
# opam clears file-based git config for its fetch subprocesses, but
# GIT_CONFIG_* env pairs pass through; use them to authenticate the
# private pin-depends (git+ssh://github.com/logseq/...) via PAT.
# GIT_CONFIG_* env pairs pass through; rewrite the ssh pin-depends
# URLs to https (the pinned repos are public, no credential needed).
export GIT_TERMINAL_PROMPT=0
export GIT_CONFIG_COUNT=3
export GIT_CONFIG_KEY_0="url.https://github.com/.insteadOf" GIT_CONFIG_VALUE_0="git@github.com:"
export GIT_CONFIG_KEY_1="url.https://github.com/.insteadOf" GIT_CONFIG_VALUE_1="ssh://git@github.com/"
export GIT_CONFIG_KEY_2="credential.helper"
export GIT_CONFIG_VALUE_2='!f() { [ -n "$LOGSEQ_GITHUB_PAT" ] || exit 0; echo username=x-access-token; echo "password=$LOGSEQ_GITHUB_PAT"; }; f'
export GIT_CONFIG_KEY_2="url.https://github.com/.insteadOf" GIT_CONFIG_VALUE_2="git+ssh://git@github.com/"
opam pin add -n -y melange-edn-core git+https://github.com/logseq/melange-edn.git#main
opam pin add -n -y melange-edn-native git+https://github.com/logseq/melange-edn.git#main
opam pin add -n -y melange-transit-core git+https://github.com/logseq/melange-transit.git#main
Expand Down Expand Up @@ -113,12 +111,11 @@ jobs:
run: |
set -e
eval $(opam env)
# The lockfile only lists public deps; private pin-depends are cloned
# at their pinned commits below. Authenticate clones with the PAT.
git config --global url."https://x-access-token:${LOGSEQ_GITHUB_PAT}@github.com/".insteadOf "git@github.com:"
git config --global url."https://x-access-token:${LOGSEQ_GITHUB_PAT}@github.com/".insteadOf "ssh://git@github.com/"
git config --global url."https://x-access-token:${LOGSEQ_GITHUB_PAT}@github.com/".insteadOf "git+ssh://git@github.com/"
git config --global url."https://x-access-token:${LOGSEQ_GITHUB_PAT}@github.com/".insteadOf "https://github.com/"
# The lockfile only lists public deps; pin-depends are cloned at
# their pinned commits below over public https.
git config --global url."https://github.com/".insteadOf "git@github.com:"
git config --global url."https://github.com/".insteadOf "ssh://git@github.com/"
git config --global url."https://github.com/".insteadOf "git+ssh://git@github.com/"
# Call the binary directly: the `opam monorepo` plugin shim rejects
# plugins built under a different opam version (restored caches).
# Retry: release-tarball downloads occasionally fail with HTTP 5xx.
Expand Down
38 changes: 14 additions & 24 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
LOGSEQ_GITHUB_PAT: ${{ secrets.LOGSEQ_GITHUB_PAT }}
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -84,8 +83,7 @@ jobs:
export GIT_CONFIG_COUNT=3
export GIT_CONFIG_KEY_0="url.https://github.com/.insteadOf" GIT_CONFIG_VALUE_0="git@github.com:"
export GIT_CONFIG_KEY_1="url.https://github.com/.insteadOf" GIT_CONFIG_VALUE_1="ssh://git@github.com/"
export GIT_CONFIG_KEY_2="credential.helper"
export GIT_CONFIG_VALUE_2='!f() { [ -n "$LOGSEQ_GITHUB_PAT" ] || exit 0; echo username=x-access-token; echo "password=$LOGSEQ_GITHUB_PAT"; }; f'
export GIT_CONFIG_KEY_2="url.https://github.com/.insteadOf" GIT_CONFIG_VALUE_2="git+ssh://git@github.com/"
opam pin add -n -y melange-edn-core git+https://github.com/logseq/melange-edn.git#main
opam pin add -n -y melange-edn-native git+https://github.com/logseq/melange-edn.git#main
opam pin add -n -y melange-transit-core git+https://github.com/logseq/melange-transit.git#main
Expand Down Expand Up @@ -115,10 +113,10 @@ jobs:
run: |
set -e
eval $(opam env)
git config --global url."https://x-access-token:${LOGSEQ_GITHUB_PAT}@github.com/".insteadOf "git@github.com:"
git config --global url."https://x-access-token:${LOGSEQ_GITHUB_PAT}@github.com/".insteadOf "ssh://git@github.com/"
git config --global url."https://x-access-token:${LOGSEQ_GITHUB_PAT}@github.com/".insteadOf "git+ssh://git@github.com/"
git config --global url."https://x-access-token:${LOGSEQ_GITHUB_PAT}@github.com/".insteadOf "https://github.com/"
# All pins are public; ssh URLs just need rewriting to https.
git config --global url."https://github.com/".insteadOf "git@github.com:"
git config --global url."https://github.com/".insteadOf "ssh://git@github.com/"
git config --global url."https://github.com/".insteadOf "git+ssh://git@github.com/"
# Call the binary directly: the `opam monorepo` plugin shim rejects
# plugins built under a different opam version (restored caches).
# Retry: release-tarball downloads occasionally fail with HTTP 5xx.
Expand Down Expand Up @@ -154,16 +152,15 @@ jobs:
runs-on: macos-15
timeout-minutes: 90
env:
LOGSEQ_GITHUB_PAT: ${{ secrets.LOGSEQ_GITHUB_PAT }}
LOGSEQ_CHAT_OPAM_SWITCH: ${{ github.workspace }}
# SwiftPM clones lui over ssh://; rewrite to authenticated https.
# SwiftPM clones lui over ssh://; rewrite to https (repos are public).
GIT_CONFIG_COUNT: 3
GIT_CONFIG_KEY_0: url.https://github.com/.insteadOf
GIT_CONFIG_VALUE_0: "git@github.com:"
GIT_CONFIG_KEY_1: url.https://github.com/.insteadOf
GIT_CONFIG_VALUE_1: "ssh://git@github.com/"
GIT_CONFIG_KEY_2: credential.helper
GIT_CONFIG_VALUE_2: '!f() { [ -n "$LOGSEQ_GITHUB_PAT" ] || exit 0; echo username=x-access-token; echo "password=$LOGSEQ_GITHUB_PAT"; }; f'
GIT_CONFIG_KEY_2: url.https://github.com/.insteadOf
GIT_CONFIG_VALUE_2: "git+ssh://git@github.com/"
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -215,8 +212,7 @@ jobs:
export GIT_CONFIG_COUNT=3
export GIT_CONFIG_KEY_0="url.https://github.com/.insteadOf" GIT_CONFIG_VALUE_0="git@github.com:"
export GIT_CONFIG_KEY_1="url.https://github.com/.insteadOf" GIT_CONFIG_VALUE_1="ssh://git@github.com/"
export GIT_CONFIG_KEY_2="credential.helper"
export GIT_CONFIG_VALUE_2='!f() { [ -n "$LOGSEQ_GITHUB_PAT" ] || exit 0; echo username=x-access-token; echo "password=$LOGSEQ_GITHUB_PAT"; }; f'
export GIT_CONFIG_KEY_2="url.https://github.com/.insteadOf" GIT_CONFIG_VALUE_2="git+ssh://git@github.com/"
opam pin add -n -y melange-edn-core git+https://github.com/logseq/melange-edn.git#main
opam pin add -n -y melange-edn-native git+https://github.com/logseq/melange-edn.git#main
opam pin add -n -y melange-transit-core git+https://github.com/logseq/melange-transit.git#main
Expand Down Expand Up @@ -271,7 +267,6 @@ jobs:
# Builds while the iOS app build runs; "Wait for db-sync" polls it.
uses: ./.github/actions/db-sync-server
with:
token: ${{ secrets.LOGSEQ_GITHUB_PAT }}
background: "true"

- name: Restore iOS build artifacts
Expand Down Expand Up @@ -346,7 +341,6 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 90
env:
LOGSEQ_GITHUB_PAT: ${{ secrets.LOGSEQ_GITHUB_PAT }}
LOGSEQ_CHAT_OPAM_SWITCH: ${{ github.workspace }}
LOGSEQ_CHAT_ANDROID_ABI: x86_64
LOGSEQ_CHAT_E2E_BASE_URL: http://127.0.0.1:8787
Expand Down Expand Up @@ -401,8 +395,7 @@ jobs:
export GIT_CONFIG_COUNT=3
export GIT_CONFIG_KEY_0="url.https://github.com/.insteadOf" GIT_CONFIG_VALUE_0="git@github.com:"
export GIT_CONFIG_KEY_1="url.https://github.com/.insteadOf" GIT_CONFIG_VALUE_1="ssh://git@github.com/"
export GIT_CONFIG_KEY_2="credential.helper"
export GIT_CONFIG_VALUE_2='!f() { [ -n "$LOGSEQ_GITHUB_PAT" ] || exit 0; echo username=x-access-token; echo "password=$LOGSEQ_GITHUB_PAT"; }; f'
export GIT_CONFIG_KEY_2="url.https://github.com/.insteadOf" GIT_CONFIG_VALUE_2="git+ssh://git@github.com/"
opam pin add -n -y melange-edn-core git+https://github.com/logseq/melange-edn.git#main
opam pin add -n -y melange-edn-native git+https://github.com/logseq/melange-edn.git#main
opam pin add -n -y melange-transit-core git+https://github.com/logseq/melange-transit.git#main
Expand Down Expand Up @@ -468,24 +461,21 @@ jobs:
# step polls the port before the flows run.
uses: ./.github/actions/db-sync-server
with:
token: ${{ secrets.LOGSEQ_GITHUB_PAT }}
background: "true"

- name: Run Android e2e module
uses: reactivecircus/android-emulator-runner@v2
env:
# pub get clones the lui git dep over ssh; rewrite to https + PAT
# credential helper (file-based git config doesn't reliably reach
# the emulator-runner's script environment).
GIT_CONFIG_COUNT: 4
# pub get clones the lui git dep over ssh; rewrite to https
# (file-based git config doesn't reliably reach the
# emulator-runner's script environment).
GIT_CONFIG_COUNT: 3
GIT_CONFIG_KEY_0: url.https://github.com/.insteadOf
GIT_CONFIG_VALUE_0: "git@github.com:"
GIT_CONFIG_KEY_1: url.https://github.com/.insteadOf
GIT_CONFIG_VALUE_1: ssh://git@github.com/
GIT_CONFIG_KEY_2: url.https://github.com/.insteadOf
GIT_CONFIG_VALUE_2: git+ssh://git@github.com/
GIT_CONFIG_KEY_3: credential.helper
GIT_CONFIG_VALUE_3: '!f() { [ -n "$LOGSEQ_GITHUB_PAT" ] || exit 0; echo username=x-access-token; echo "password=$LOGSEQ_GITHUB_PAT"; }; f'
with:
api-level: 34
target: google_apis
Expand Down
6 changes: 3 additions & 3 deletions apple/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apple/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let package = Package(
.library(name: "LogseqChatModel", type: .dynamic, targets: ["LogseqChatModel"]),
],
dependencies: [
.package(url: "ssh://git@github.com/logseq/lui.git", revision: "55166025"),
.package(url: "ssh://git@github.com/logseq/lui.git", revision: "b7b7641"),
.package(url: "https://github.com/gonzalezreal/swiftui-math", from: "0.1.0"),
.package(url: "https://github.com/appstefan/highlightswift.git", from: "1.1.0")
],
Expand Down
68 changes: 0 additions & 68 deletions apple/Sources/LogseqChat/LGChatComposerAssetExtension.swift

This file was deleted.

27 changes: 20 additions & 7 deletions apple/Sources/LogseqChat/LGChatEffects.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public final class LGChatPlatformEffectHandler: LGChatEffectExecuting {
private let exportGraphDatabase: (@MainActor () async -> Bool)?
private let graphEffect: (@MainActor (LGChatEffect) async -> LGChatEffectResolution)?
private let presentAttachment: (@MainActor (String) async -> Bool)?
private let presentAsset: (@MainActor (LGChatAssetPresentationPayload) async -> Bool)?
private let presentAsset: (@MainActor (LGChatAssetPresentationPayload) async -> URL?)?
private let presentPageShare: (@MainActor (LGChatPageSharePayload) async -> Bool)?
private let syncNow: (@MainActor () -> Void)?

Expand All @@ -122,7 +122,7 @@ public final class LGChatPlatformEffectHandler: LGChatEffectExecuting {
exportGraphDatabase: (@MainActor () async -> Bool)? = nil,
graphEffect: (@MainActor (LGChatEffect) async -> LGChatEffectResolution)? = nil,
presentAttachment: (@MainActor (String) async -> Bool)? = nil,
presentAsset: (@MainActor (LGChatAssetPresentationPayload) async -> Bool)? = nil,
presentAsset: (@MainActor (LGChatAssetPresentationPayload) async -> URL?)? = nil,
presentPageShare: (@MainActor (LGChatPageSharePayload) async -> Bool)? = nil,
syncNow: (@MainActor () -> Void)? = nil
) {
Expand Down Expand Up @@ -301,11 +301,24 @@ public final class LGChatPlatformEffectHandler: LGChatEffectExecuting {
LGChatAssetPresentationPayload.self,
from: Data(metadata.utf8)
)
let succeeded = await presentAsset(asset)
guard let url = await presentAsset(asset) else {
return LGChatEffectResolution(
succeeded: false,
message: "The local asset is unavailable",
output: .discard
)
}
let payload = String(
data: try JSONEncoder().encode([
"title": asset.title,
"path": url.path,
]),
encoding: .utf8
) ?? "{}"
return LGChatEffectResolution(
succeeded: succeeded,
message: succeeded ? "" : "The local asset is unavailable",
output: .discard
succeeded: true,
message: payload,
output: .hostUpdate("asset-preview-resolved")
)
case "present-page-share":
guard let presentPageShare, let metadata = effect.metadata else {
Expand Down Expand Up @@ -687,7 +700,7 @@ public final class LGChatCoreEffectExecutor: LGChatEffectExecuting {
}
return Self.resolution(from: await deleteLocalGraph(effect.text))
case "persist-ui-session", "persist-composer-draft", "sign-in", "save-settings", "refresh-runtime-log",
"copy-runtime-log", "sign-out",
"copy-runtime-log", "sign-out", "export-graph-database", "open-external-url",
"present-attachment", "present-asset", "present-page-share", "sync-now":
guard let platformEffect else {
return LGChatEffectResolution(
Expand Down
2 changes: 1 addition & 1 deletion apple/Sources/LogseqChat/LGChatGraphLifecycle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ final class LGChatGraphLifecycle {
|| store.snapshot.selectedGraphId == graphID
if deletingSelected {
await syncCoordinator.stopForeground()
await store.resetToCatalog()
await store.resetToCatalog(applyResponse: false)
}
do {
try LogseqGraphLocalStorage.delete(databasePath: databasePath, graphID: graphID)
Expand Down
12 changes: 12 additions & 0 deletions apple/Sources/LogseqChat/LGChatNative.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public protocol LGChatNativeCalling {
text: String,
value: Int
) -> String
func picked(node: Int, payload: String) -> String
func visibleRange(node: Int, first: Int, last: Int) -> String
func scrollCompleted(node: Int, token: Int, outcome: String) -> String
func dispose() -> String
func takeEffect() -> String
func resolveEffect(id: Int, succeeded: Bool, message: String) -> String
Expand Down Expand Up @@ -79,6 +82,15 @@ public final class LGChatCoreNativeCaller: LGChatNativeCalling {
) -> String {
core.logseq_chat_lui_extension_event(node, identifier, name, text, value)
}
public func picked(node: Int, payload: String) -> String {
core.logseq_chat_lui_picked(node, payload)
}
public func visibleRange(node: Int, first: Int, last: Int) -> String {
core.logseq_chat_lui_visible_range(node, first, last)
}
public func scrollCompleted(node: Int, token: Int, outcome: String) -> String {
core.logseq_chat_lui_scroll_completed(node, token, outcome)
}
public func dispose() -> String { core.logseq_chat_lui_dispose() }
public func takeEffect() -> String { core.logseq_chat_lui_take_effect() }
public func resolveEffect(id: Int, succeeded: Bool, message: String) -> String {
Expand Down
Loading