core, store: merge master into names (#8298)
* core, ui: validate short link type, show contact info for long addresses and rejected contacts (#8184) * tests: short link type, QR code capacity and contact statuses * core: validate the type of short links * android, desktop: show contact info for addresses above QR code capacity * ui: show chats with rejected contact requests * tests: short link types with group, channel and contact data * core: validate short link type against link data * tests: fix short link data test * tests: group data in invitation link before its first use * tests: connect via address in contact profile with group link * core: connect via contact address only with address links * core: parse short link data once, by link type * core: types of short link data parser * core: test short link types and contact rejection, record app fixtures * android, desktop: test contact info, link alerts and rejected contacts * ios: test invalid link alerts and rejected contacts in the chat list * desktop: contact info tests find texts without app resources * ui: core responses of invalid link plans and a rejected contact request * desktop: contact info tests provide the app bar handler * core: normalise file and message keys in app test fixtures * core: normalise deletion times in app test fixtures * desktop: test that a QR code above capacity is not shared on tap * core: test relay link checks and known channel refresh from link data * libs: nodejs 7.1.4 (#8263) * nodejs: live test reads the updated item under the key of 7.1 and 7.2 cores * libs: nodejs 7.1.4 * mcp: session states coloured by what they need, green for working (#8265) * mcp: session states in the colours of what they need: green working, orange waiting in the chat, red idle * mcp: the space after waiting for you in the tests * mcp: a session with a background command shows working in the background * mcp: a readable README, and the roadmap lines of 0.3.0 (#8264) * mcp: readme by what the plugin does for its users, roadmap lines of 0.3.0 * mcp: almost every waiting state * mcp: reply, edit and react in one line * mcp: flat layout without the avatar note * mcp: sessions use flat layout * mcp: shorter lines on answers, the Main group and approvals * mcp: approvals line without the taps * mcp: live stream line * mcp: status line * mcp: shorter lines * mcp: 0.3.1 with simplex-chat 7.1.4 (#8266) * docs: testing approaches of the codebase (#8255) * docs: app changes come with app tests on the core's recorded responses (#8252) * ci: decide the library claim from the written releases (#8137) * ci: test the library claim when reads return the previous releases * ci: decide the library claim from the written releases * tests: record name fixtures after the channel join settles (#8250) * core, ci: update sqlcipher-simple to 0.4.19.0 and simplexmq (#8270) * update sqlcipher-simple to 0.4.19.0 * sqlcipher-simple from simplex-chat/sqlcipher-simple * update simplexmq * ci: restore source repositories only for the same cabal.project * ci: keep restored source checkouts only at their pinned commits * android, desktop, ios: copy markdown files with line breaks, and the whole file with one button (#8269) * android, desktop: test copying lines from the markdown text view * android, desktop: keep line breaks in text copied from markdown files * android, desktop: check the last copied text in the markdown view test * android, desktop, ios: button to copy the whole markdown file * android, desktop: test the markdown file copy button * android, desktop, ios: ask before copying markdown files over 128 KB * android, desktop, ios: title the markdown copy alerts File too large * ios: test the markdown file copy button * android, desktop, ios: preview the markdown file view and test the copy limit * android, desktop, ios: snapshot references of the markdown file view * docs: names conditions describe upgradeable registry contracts (#8277) * docs: names conditions describe upgradeable registry contracts * docs: names conditions without the immutability after stabilization --------- Co-authored-by: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> * ci: reproducible Linux builds of 7.1 releases (#8276) * ci: plan reproducible Linux builds of 7.1 releases * ci: reproduce Linux builds with the cabal store path of releases * ci: reproduce releases with the current reproduce script * ci: build in the image with the cabal directory of releases * ci: reproduce releases on the Ubuntu 24.04 runner * ci: correct the failure history and rollout in the plan --------- Co-authored-by: sh-agents <350651734+sh-agents@users.noreply.github.com> * website: remove the webinar promotion (#8281) * website: remove the webinar invitation from the home page * website: redirect the livestream page to Wefunder * mcp server: recall the chat history in a new agent session (#8141) * mcp server: recall the chat history in a new agent session * docs: chat history in receive for a new agent session * mcp server: type the history page for the compiler * mcp server: recall the chat history after a compaction too * docs: history plan changes with the message helpers of master Claude-Session: https://claude.ai/code/session_01AV2VpomCCQNciqggT9gr75 * docs: drop anchor remapping from the docs table of the history plan Claude-Session: https://claude.ai/code/session_01AV2VpomCCQNciqggT9gr75 --------- Co-authored-by: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> * core: prevent stalled join of channel subscribers to a new relay (#8239) * core: save relay connection before requesting relay link data * core: share relay connection creation between join and retry * tests: connect to a re-added relay when its connection is saved late * tests: delay only the relay connection record, not the command * ci, tests: run all tests in CI (#8238) * bots, tests: run broadcast bot test in CI * tests: test moderation that arrives before the message * ci, tests: run all tests in CI * tests: update re-enabled tests, restore query plans, PostgreSQL schema from CI * tests: remove CI skip helpers no longer used * tests: expect XFTP AUTH error of cancelled standalone file * tests: update query plans from CI * tests: update query plans from CI * tests: expect group history and member contacts in async group test * tests: accept subscription summary after first events on restart * tests: make AUTH and client timeout direct tests deterministic * tests: keep bob's badge clock before renewal until the move back * tests: keep the quota of 2 messages only on the member's receive queue * tests: keep query plans files with repeated entries of one query * tests: update query plans from CI * tests: stop the host before a member requests to join with a badge * tests: remove repeated entries of one query from query plans files * tests: accept the refusal of an unknown remote host after its session code * ci: state when the query plans test fails * tests: skip multicast discovery on macOS CI runners * tests: accept a remote host started with one local address * tests: restore the client timeout test except its zero timeout * tests: fail when a remote host prints another line than its other addresses * ci: name the tests that overwrite generated files * tests: move the badge clock after the restoring device arms its wake * tests: keep both members on the quota server in the member inactivity test * tests: accept subscription summaries in any order in the async group test * tests: update query plans from CI * tests: quota of 2 only on bob's queues in member inactivity test * tests: connect to a deleted link after its queue is deleted * core: save relay connection before requesting relay link data * core: share relay connection creation between join and retry * tests: connect to a re-added relay when its connection is saved late * tests: delay only the relay connection record, not the command * tests: record API fixtures on SQLite only * core: update query plans * ci: run PostgreSQL tests with the steps of build-linux * desktop: prevent crash on Linux with bitmap and WOFF2 fallback fonts (#8288) * desktop: prevent crash on Linux with bitmap and WOFF2 fallback fonts * desktop: record time offsets and snapshots rendered with Skia m138 * desktop: name the time offset test, skip only a missing fc-cache, update plan --------- Co-authored-by: sh-agents <350651734+sh-agents@users.noreply.github.com> * core, directory: stop cancelled actions instead of continuing them (#8279) * ci: retry npm install once after a failure (#8280) * core: query plans of the store group tests that master now verifies --------- Co-authored-by: brenzi-agent <346870783+brenzi-agent@users.noreply.github.com> Co-authored-by: sh-agents <justcheckingifitwillwork@gmail.com> Co-authored-by: sh-agents <350651734+sh-agents@users.noreply.github.com> Co-authored-by: brenzi-agent <brenzi-agent@brenzi.ch> Co-authored-by: Evgeny Poberezkin <evgeny@poberezkin.com>
No files matched your search
@@ -276,7 +276,7 @@ jobs:
|
||||
image_cache: ghcr.io/${{ github.repository_owner }}/simplex-chat-build-cache:${{ matrix.os }}-${{ matrix.arch }}-ghc${{ matrix.ghc }}
|
||||
source_hashes: dist-newstyle/sources.sha256
|
||||
concurrency: &linux-concurrency
|
||||
group: ${{ github.workflow }}-${{ github.ref }}-linux-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.ghc }}-${{ needs.maybe-release.outputs.libs_tag }}
|
||||
group: ${{ github.workflow }}-${{ github.ref }}-linux-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.ghc }}${{ matrix.postgres && '-postgres' || '' }}-${{ needs.maybe-release.outputs.libs_tag }}
|
||||
cancel-in-progress: ${{ github.event_name != 'push' }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
@@ -378,7 +378,7 @@ jobs:
|
||||
toolchain=$(docker exec builder dpkg-query -W -f '${db:Status-Status} ${binary:Package} ${Version}\n' 'binutils*' 'cpp*' 'gcc*' '*-dev' | grep '^installed ' | sha256sum | cut -c1-16)
|
||||
target=ubuntu-${{ matrix.os }}-${{ matrix.arch }}-ghc${{ matrix.ghc }}-$toolchain
|
||||
echo "deps=deps-$target" >> "$GITHUB_OUTPUT"
|
||||
echo "dist=dist-$target" >> "$GITHUB_OUTPUT"
|
||||
echo "dist=${{ env.dist_name || 'dist' }}-$target" >> "$GITHUB_OUTPUT"
|
||||
echo "dist_lib=dist-lib-$target" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Restore dependencies from cache
|
||||
@@ -474,14 +474,14 @@ jobs:
|
||||
run: |
|
||||
scripts/ci/prune-old-builds.sh dist-newstyle
|
||||
cabal update
|
||||
cabal build -j --enable-tests ${{ env.ghc_options }}
|
||||
cabal build -j --enable-tests ${{ env.ghc_options }} ${{ env.cabal_targets }}
|
||||
mkdir -p /out
|
||||
for i in simplex-chat simplex-chat-test; do
|
||||
for i in ${{ env.bins || 'simplex-chat simplex-chat-test' }}; do
|
||||
bin=$(find /project/dist-newstyle -name "$i" -type f -executable)
|
||||
chmod +x "$bin"
|
||||
cp "$bin" /out/
|
||||
done
|
||||
strip /out/simplex-chat
|
||||
[ ! -f /out/simplex-chat ] || strip /out/simplex-chat
|
||||
|
||||
# Also for pull requests that change the chat core, for the package tests.
|
||||
- name: Build library
|
||||
@@ -658,6 +658,36 @@ jobs:
|
||||
github_ref: ${{ github.ref }}
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Setup Node.js for tests
|
||||
if: matrix.should_run == true && matrix.arch == 'x86_64'
|
||||
uses: actions/setup-node@v7
|
||||
with:
|
||||
node-version: 22
|
||||
|
||||
- name: Build badge web app for tests
|
||||
if: matrix.should_run == true && matrix.arch == 'x86_64'
|
||||
working-directory: apps/simplex-store-service/web
|
||||
run: |
|
||||
npm ci
|
||||
npm run build
|
||||
|
||||
- name: Install PostgreSQL 15 client tools
|
||||
if: matrix.postgres == true
|
||||
shell: bash
|
||||
run: |
|
||||
sudo install -d /usr/share/postgresql-common/pgdg
|
||||
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
|
||||
sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||
sudo apt update
|
||||
sudo apt -y install postgresql-client-15
|
||||
|
||||
- name: Start PostgreSQL
|
||||
if: matrix.postgres == true
|
||||
shell: bash
|
||||
run: |
|
||||
docker run -d --name postgres -p 5432:5432 -e POSTGRES_HOST_AUTH_METHOD=trust postgres:15 -c max_connections=3000 -c fsync=off
|
||||
timeout 60 sh -c 'until pg_isready -h localhost; do sleep 1; done'
|
||||
|
||||
- name: Mount RAM disk for tests
|
||||
if: matrix.should_run == true && matrix.arch == 'x86_64'
|
||||
shell: bash
|
||||
@@ -667,6 +697,7 @@ jobs:
|
||||
sudo chown $(id -u):$(id -g) tests/tmp
|
||||
|
||||
- name: Run tests
|
||||
id: tests
|
||||
if: matrix.should_run == true && matrix.arch == 'x86_64'
|
||||
timeout-minutes: 120
|
||||
shell: bash
|
||||
@@ -675,7 +706,22 @@ jobs:
|
||||
TESTS: ${{ github.event_name == 'workflow_dispatch' && inputs.tests || '' }}
|
||||
PR_BODY: ${{ github.event.pull_request.draft == true && github.event.pull_request.body || '' }}
|
||||
ATTEMPTS: ${{ (github.ref == 'refs/heads/stable' || startsWith(github.ref, 'refs/tags/v')) && 3 || 1 }}
|
||||
run: scripts/ci/run-tests.sh timeout 35m ./simplex-chat-test
|
||||
run: scripts/ci/run-tests.sh timeout ${{ env.test_timeout || '35m' }} ./simplex-chat-test
|
||||
|
||||
- name: Check generated files
|
||||
id: generated
|
||||
if: ${{ !cancelled() && steps.tests.outcome != 'skipped' }}
|
||||
shell: bash
|
||||
run: |
|
||||
git diff > "$RUNNER_TEMP/generated-files.patch"
|
||||
git diff --stat --exit-code
|
||||
|
||||
- name: Upload generated files
|
||||
if: ${{ !cancelled() && steps.generated.outcome == 'failure' }}
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: generated-files-ubuntu-${{ matrix.os }}-ghc${{ matrix.ghc }}${{ matrix.postgres && '-postgres' || '' }}
|
||||
path: ${{ runner.temp }}/generated-files.patch
|
||||
|
||||
# Compiling the desktop and Android targets of :common in parallel exceeds the 2 GB Kotlin daemon heap.
|
||||
# cmakeBuildAndCopy links the JNI library against libsimplex, which this job does not build.
|
||||
@@ -1169,6 +1215,46 @@ jobs:
|
||||
test=$(cabal list-bin --constraint 'simplexmq +client_postgres' --constraint 'simplex-chat +client_postgres' simplex-chat-test | tail -n 1)
|
||||
"$test" --fail-on=empty -m "Supporter badges" -m "SimpleX store service" -m "StoreService names"
|
||||
|
||||
# =================================
|
||||
# Linux PostgreSQL Tests
|
||||
# =================================
|
||||
|
||||
test-postgres:
|
||||
name: "ubuntu-${{ matrix.os }}-${{ matrix.arch }} (PostgreSQL tests), GHC: ${{ matrix.ghc }}"
|
||||
needs: [maybe-release, variables]
|
||||
if: needs.maybe-release.outputs.haskell == 'true' && !(github.ref == 'refs/heads/stable' || startsWith(github.ref, 'refs/tags/v'))
|
||||
runs-on: ${{ matrix.runner }}
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
env:
|
||||
image_cache: ghcr.io/${{ github.repository_owner }}/simplex-chat-build-cache:${{ matrix.os }}-${{ matrix.arch }}-ghc${{ matrix.ghc }}
|
||||
source_hashes: dist-newstyle/sources.sha256
|
||||
opt: O0
|
||||
ghc_options: --ghc-options=-O0
|
||||
cache_o0: false
|
||||
cabal_targets: --constraint 'simplexmq +client_postgres' --constraint 'simplex-chat +client_postgres' test:simplex-chat-test
|
||||
bins: simplex-chat-test
|
||||
dist_name: dist-postgres
|
||||
test_timeout: 60m
|
||||
PGHOST: localhost
|
||||
ALLOW_EMPTY: true
|
||||
concurrency: *linux-concurrency
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: 22.04
|
||||
os_underscore: 22_04
|
||||
arch: x86_64
|
||||
runner: "ubuntu-22.04"
|
||||
should_run: true
|
||||
ghc: ${{ needs.variables.outputs.GHC_VER }}
|
||||
hash: 'sha256:5c8b2c0a6c745bc177669abfaa716b4bc57d58e2ea3882fb5da67f4d59e3dda5'
|
||||
kotlin: false
|
||||
postgres: true
|
||||
steps: *linux-steps
|
||||
|
||||
# =========================
|
||||
# MacOS Build
|
||||
# =========================
|
||||
@@ -1420,6 +1506,7 @@ jobs:
|
||||
ln -s /Volumes/tests tests/tmp
|
||||
|
||||
- name: Run tests
|
||||
id: tests
|
||||
if: matrix.should_run == true && matrix.arch == 'aarch64'
|
||||
timeout-minutes: 120
|
||||
shell: bash
|
||||
@@ -1441,6 +1528,21 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Check generated files
|
||||
id: generated
|
||||
if: ${{ !cancelled() && steps.tests.outcome != 'skipped' }}
|
||||
shell: bash
|
||||
run: |
|
||||
git diff > "$RUNNER_TEMP/generated-files.patch"
|
||||
git diff --stat --exit-code
|
||||
|
||||
- name: Upload generated files
|
||||
if: ${{ !cancelled() && steps.generated.outcome == 'failure' }}
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: generated-files-${{ matrix.os }}
|
||||
path: ${{ runner.temp }}/generated-files.patch
|
||||
|
||||
- name: Build library
|
||||
id: mac_lib_build
|
||||
if: ${{ !cancelled() && matrix.should_run == true && needs.maybe-release.outputs.libs_tag && steps.mac_cli_build.outcome == 'success' }}
|
||||
@@ -2024,8 +2126,8 @@ jobs:
|
||||
if: steps.plan.outputs.nodejs_version
|
||||
working-directory: packages/simplex-chat-nodejs
|
||||
run: |
|
||||
(cd ../simplex-chat-client/types/typescript && npm install --no-audit --no-fund && npx tsc)
|
||||
npm install --ignore-scripts --no-save --no-audit --no-fund ../simplex-chat-client/types/typescript
|
||||
(cd ../simplex-chat-client/types/typescript && "$GITHUB_WORKSPACE/scripts/ci/npm-install.sh" && npx tsc)
|
||||
"$GITHUB_WORKSPACE/scripts/ci/npm-install.sh" --ignore-scripts --no-save ../simplex-chat-client/types/typescript
|
||||
npx tsc && cp src/simplex.* dist
|
||||
npx jest tests/libs.test.ts tests/api.unit.test.ts
|
||||
|
||||
@@ -2041,7 +2143,7 @@ jobs:
|
||||
VERSION: ${{ steps.plan.outputs.types_version }}
|
||||
DIST_TAG: ${{ steps.plan.outputs.types_dist_tag }}
|
||||
run: |
|
||||
npm install --no-audit --no-fund
|
||||
"$GITHUB_WORKSPACE/scripts/ci/npm-install.sh"
|
||||
npm publish --provenance --access public --tag "$DIST_TAG"
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ on:
|
||||
|
||||
jobs:
|
||||
reproduce:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Get latest release
|
||||
shell: bash
|
||||
@@ -22,9 +22,6 @@ jobs:
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ env.TAG }}
|
||||
repository: simplex-chat/simplex-chat
|
||||
|
||||
# Otherwise we run out of disk space with Docker build
|
||||
- name: Free disk space
|
||||
|
||||
@@ -28,6 +28,10 @@ jobs:
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: website
|
||||
run: ../scripts/ci/npm-install.sh
|
||||
|
||||
- name: Install dependencies & build
|
||||
run: |
|
||||
./website/web.sh
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@docs/CONTRIBUTING.md
|
||||
@docs/contributing/PROJECT.md
|
||||
@docs/contributing/CODE.md
|
||||
@docs/contributing/TESTS.md
|
||||
@scripts/ci/README.md
|
||||
@@ -54,6 +54,7 @@ RUN apt-get update --error-on=any && \
|
||||
wget \
|
||||
fuse3 \
|
||||
file \
|
||||
fontconfig \
|
||||
appstream \
|
||||
gpg \
|
||||
zipalign \
|
||||
@@ -98,6 +99,7 @@ WORKDIR /home/${USER_NAME}
|
||||
|
||||
# Setup basic env variables (required)
|
||||
ENV HOME="/home/${USER_NAME}" USER="${USER_NAME}"
|
||||
ENV CABAL_DIR="$HOME/.cabal"
|
||||
# Adjust PATH
|
||||
ENV PATH="$HOME/.cabal/bin:$HOME/.ghcup/bin:$PATH"
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import SimpleXChat
|
||||
import Ink
|
||||
|
||||
private let MAX_MARKDOWN_VIEW_SIZE: Int64 = 1_048_576
|
||||
private let MAX_MARKDOWN_COPY_SIZE: Int64 = 131_072
|
||||
private let MAX_MARKDOWN_LINE_LENGTH = 15_000
|
||||
private let MAX_MARKDOWN_NESTING = 16
|
||||
private let MAX_MARKDOWN_LINK_NESTING = 4
|
||||
@@ -27,7 +28,7 @@ func showMarkdownFile(_ file: CIFile) {
|
||||
let hasBidiControls = text.unicodeScalars.contains(where: isBidiControl)
|
||||
await MainActor.run {
|
||||
showAppSheet {
|
||||
MarkdownFileView(file: file, fileSource: fileSource, lines: shownLines, html: html, hasBidiControls: hasBidiControls)
|
||||
MarkdownFileView(file: file, fileSource: fileSource, text: text, lines: shownLines, html: html, hasBidiControls: hasBidiControls)
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
@@ -166,10 +167,31 @@ private func openMarkdownFileLink(_ url: URL) {
|
||||
}
|
||||
}
|
||||
|
||||
func copyMarkdownFile(_ file: CIFile, _ text: String) {
|
||||
if file.fileSize > MAX_MARKDOWN_COPY_SIZE {
|
||||
showAlert(
|
||||
NSLocalizedString("File too large", comment: "alert title"),
|
||||
message: String.localizedStringWithFormat(
|
||||
NSLocalizedString("Your file is %@. Do you want to copy it?", comment: "alert message"),
|
||||
ByteCountFormatter.string(fromByteCount: file.fileSize, countStyle: .binary)
|
||||
),
|
||||
actions: {[
|
||||
cancelAlertAction,
|
||||
UIAlertAction(title: NSLocalizedString("Copy", comment: "alert button"), style: .default) { _ in
|
||||
UIPasteboard.general.string = text
|
||||
}
|
||||
]}
|
||||
)
|
||||
} else {
|
||||
UIPasteboard.general.string = text
|
||||
}
|
||||
}
|
||||
|
||||
struct MarkdownFileView: View {
|
||||
@AppStorage(DEFAULT_MARKDOWN_FILE_TEXT_VIEW) private var textView = false
|
||||
let file: CIFile
|
||||
let fileSource: CryptoFile
|
||||
let text: String
|
||||
let lines: [String]
|
||||
let html: String?
|
||||
let hasBidiControls: Bool
|
||||
@@ -203,6 +225,11 @@ struct MarkdownFileView: View {
|
||||
.navigationBarTitleDisplayMode(.inline)
|
||||
.toolbar {
|
||||
ToolbarItemGroup(placement: .navigationBarTrailing) {
|
||||
Button {
|
||||
copyMarkdownFile(file, text)
|
||||
} label: {
|
||||
Image(systemName: "doc.on.doc")
|
||||
}
|
||||
if html != nil {
|
||||
Button {
|
||||
textView.toggle()
|
||||
@@ -221,3 +248,17 @@ struct MarkdownFileView: View {
|
||||
.navigationViewStyle(.stack)
|
||||
}
|
||||
}
|
||||
|
||||
struct MarkdownFileView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
let text = "# Release notes\n\n- markdown files in chats\n- a button to copy the file\n"
|
||||
MarkdownFileView(
|
||||
file: CIFile.getSample(fileName: "notes.md", fileSize: Int64(text.utf8.count), filePath: "notes.md"),
|
||||
fileSource: CryptoFile.plain("notes.md"),
|
||||
text: text,
|
||||
lines: text.components(separatedBy: "\n"),
|
||||
html: nil,
|
||||
hasBidiControls: false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 20 KiB |
@@ -728,6 +728,7 @@ private func previewScenes() -> [SnapshotScene] {
|
||||
SnapshotScene(IntegrityErrorItemView_Previews.self, allSizes: true),
|
||||
SnapshotScene(LargeLinkPreview_Previews.self, allSizes: true),
|
||||
SnapshotScene(LocalAuthView_Previews.self),
|
||||
SnapshotScene(MarkdownFileView_Previews.self, device: true),
|
||||
SnapshotScene(MarkdownHelp_Previews.self),
|
||||
SnapshotScene(MarkedDeletedItemView_Previews.self, allSizes: true),
|
||||
SnapshotScene(MemberAdmissionView_Previews.self),
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import XCTest
|
||||
import UIKit
|
||||
@testable import SimpleX
|
||||
@testable import SimpleXChat
|
||||
|
||||
final class MarkdownFileTests: XCTestCase {
|
||||
@MainActor
|
||||
func testCopyAsksAbove128KB() async throws {
|
||||
let text = "alpha\n\ngamma"
|
||||
UIPasteboard.general.string = "unchanged"
|
||||
copyMarkdownFile(CIFile.getSample(fileSize: 131_072), text)
|
||||
XCTAssertEqual(UIPasteboard.general.string, text)
|
||||
UIPasteboard.general.string = "unchanged"
|
||||
copyMarkdownFile(CIFile.getSample(fileSize: 131_073), text)
|
||||
try await waitFor { (getTopViewController() as? UIAlertController)?.isBeingPresented == false }
|
||||
let alert = try XCTUnwrap(getTopViewController() as? UIAlertController)
|
||||
XCTAssertEqual(alert.title, "File too large")
|
||||
XCTAssertEqual(alert.message, "Your file is 128 KB. Do you want to copy it?")
|
||||
XCTAssertEqual(UIPasteboard.general.string, "unchanged")
|
||||
let copy = try XCTUnwrap(alert.actions.first { $0.title == "Copy" })
|
||||
let handler = unsafeBitCast(copy.value(forKey: "handler") as AnyObject, to: (@convention(block) (UIAlertAction) -> Void).self)
|
||||
await withCheckedContinuation { done in alert.dismiss(animated: false) { done.resume() } }
|
||||
handler(copy)
|
||||
XCTAssertEqual(UIPasteboard.general.string, text)
|
||||
}
|
||||
}
|
||||
@@ -221,6 +221,29 @@ final class NameAlertsTests: XCTestCase {
|
||||
XCTAssertEqual(shownLocalChats, ["@3"])
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testGroupLinkAsAddress() async throws {
|
||||
try recorded("connect/group-link-as-address")
|
||||
connect("GROUP_LINK")
|
||||
try await assertTexts(["Invalid connection link", "Please check that you used the correct link or ask your contact to send you another one.", "Ok"])
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testGroupLinkAsChannel() async throws {
|
||||
try recorded("connect/group-link-as-channel")
|
||||
connect("GROUP_LINK")
|
||||
try await assertTexts(["Invalid connection link", "Please check that you used the correct link or ask your contact to send you another one.", "Ok"])
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testRejectedContactInChatList() async throws {
|
||||
try recorded("connect/request-rejected")
|
||||
ChatModel.shared.updateChats(try apiGetChats())
|
||||
guard case let .direct(contact)? = ChatModel.shared.getContactChat(2)?.chatInfo else { return XCTFail("contact not decoded: \(ChatModel.shared.chats.map(\.id))") }
|
||||
XCTAssertEqual(contact.contactStatus.rawValue, "rejected")
|
||||
XCTAssertFalse(contact.active)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func testNameMovedEvent() async throws {
|
||||
var contact = Contact.sampleData
|
||||
|
||||
@@ -272,6 +272,7 @@
|
||||
E5AEC0C22F9C000100270665 /* SnapshotTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5AEC0C12F9C000100270665 /* SnapshotTests.swift */; };
|
||||
4E57A1E70000000000000006 /* NameAlertsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E57A1E70000000000000005 /* NameAlertsTests.swift */; };
|
||||
4E57A1E70000000000000014 /* ChatItemUpdateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4E57A1E70000000000000013 /* ChatItemUpdateTests.swift */; };
|
||||
6D4F1C2A9B3E000000000002 /* MarkdownFileTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D4F1C2A9B3E000000000001 /* MarkdownFileTests.swift */; };
|
||||
E5AEC0AF2F91A73500270665 /* ComposeChatLinkView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5AEC0AE2F91A73500270665 /* ComposeChatLinkView.swift */; };
|
||||
E5C0BBE82F82B45500EA7527 /* SimpleXAssets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E5C0BBE72F82B45500EA7527 /* SimpleXAssets.xcassets */; };
|
||||
E5C0BBEB2F82B45500EA7527 /* SharedAssets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E5C0BBEA2F82B45500EA7527 /* SharedAssets.xcassets */; };
|
||||
@@ -684,6 +685,7 @@
|
||||
E5AEC0C32F9C000100270665 /* SimpleX Snapshots.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SimpleX Snapshots.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
4E57A1E70000000000000005 /* NameAlertsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NameAlertsTests.swift; sourceTree = "<group>"; };
|
||||
4E57A1E70000000000000013 /* ChatItemUpdateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatItemUpdateTests.swift; sourceTree = "<group>"; };
|
||||
6D4F1C2A9B3E000000000001 /* MarkdownFileTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MarkdownFileTests.swift; sourceTree = "<group>"; };
|
||||
4E57A1E70000000000000007 /* SimpleX Unit Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SimpleX Unit Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
E5AEC0AE2F91A73500270665 /* ComposeChatLinkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposeChatLinkView.swift; sourceTree = "<group>"; };
|
||||
E5C0BBE72F82B45500EA7527 /* SimpleXAssets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = SimpleXAssets.xcassets; sourceTree = "<group>"; };
|
||||
@@ -1038,6 +1040,7 @@
|
||||
children = (
|
||||
4E57A1E70000000000000005 /* NameAlertsTests.swift */,
|
||||
4E57A1E70000000000000013 /* ChatItemUpdateTests.swift */,
|
||||
6D4F1C2A9B3E000000000001 /* MarkdownFileTests.swift */,
|
||||
);
|
||||
path = "SimpleX Unit Tests";
|
||||
sourceTree = "<group>";
|
||||
@@ -1926,6 +1929,7 @@
|
||||
files = (
|
||||
4E57A1E70000000000000006 /* NameAlertsTests.swift in Sources */,
|
||||
4E57A1E70000000000000014 /* ChatItemUpdateTests.swift in Sources */,
|
||||
6D4F1C2A9B3E000000000002 /* MarkdownFileTests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -2760,6 +2760,7 @@ public enum ContactStatus: String, Decodable, Hashable {
|
||||
case active = "active"
|
||||
case deleted = "deleted"
|
||||
case deletedByUser = "deletedByUser"
|
||||
case rejected = "rejected"
|
||||
}
|
||||
|
||||
public struct ContactRef: Decodable, Equatable, Hashable {
|
||||
|
||||
@@ -107,6 +107,14 @@ configure(subprojects) {
|
||||
if (jvmVersion.isPresent) jvmTarget = jvmVersion.get()
|
||||
}
|
||||
}
|
||||
|
||||
configurations.configureEach {
|
||||
resolutionStrategy.eachDependency {
|
||||
if (requested.group == "org.jetbrains.skiko" && requested.version == "0.9.4.2") {
|
||||
useVersion("0.9.24")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("clean", Delete::class) {
|
||||
|
||||
@@ -2105,7 +2105,8 @@ enum class ConnectionMode {
|
||||
enum class ContactStatus {
|
||||
@SerialName("active") Active,
|
||||
@SerialName("deleted") Deleted,
|
||||
@SerialName("deletedByUser") DeletedByUser;
|
||||
@SerialName("deletedByUser") DeletedByUser,
|
||||
@SerialName("rejected") Rejected;
|
||||
}
|
||||
|
||||
@Serializable
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
package chat.simplex.common.views.chat.item
|
||||
|
||||
import SectionBottomSpacer
|
||||
import androidx.compose.desktop.ui.tooling.preview.Preview
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.text.selection.SelectionContainer
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.ImageBitmap
|
||||
import androidx.compose.ui.graphics.painter.BitmapPainter
|
||||
import androidx.compose.ui.platform.LocalClipboardManager
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.platform.UriHandler
|
||||
import androidx.compose.ui.semantics.clearAndSetSemantics
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
@@ -25,6 +29,7 @@ import chat.simplex.common.model.*
|
||||
import chat.simplex.common.model.ChatController.appPrefs
|
||||
import chat.simplex.common.platform.*
|
||||
import chat.simplex.common.ui.theme.DEFAULT_PADDING
|
||||
import chat.simplex.common.ui.theme.SimpleXTheme
|
||||
import chat.simplex.common.ui.theme.WarningOrange
|
||||
import chat.simplex.common.views.chat.topPaddingToContent
|
||||
import chat.simplex.common.views.helpers.*
|
||||
@@ -41,6 +46,7 @@ import dev.icerock.moko.resources.compose.painterResource
|
||||
import dev.icerock.moko.resources.compose.stringResource
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.intellij.markdown.MarkdownElementTypes
|
||||
import org.intellij.markdown.ast.ASTNode
|
||||
@@ -56,6 +62,8 @@ import java.util.Base64
|
||||
private const val DATA_IMAGE = "data:image/"
|
||||
private val IMAGE_TYPES = listOf(ImageFileType.JPEG, ImageFileType.PNG)
|
||||
private const val MAX_MARKDOWN_VIEW_SIZE: Long = 1_048_576
|
||||
private const val MAX_MARKDOWN_COPY_SIZE = 131_072
|
||||
private const val MAX_ANDROID_COPY_SIZE = 524_288
|
||||
private const val MAX_MARKDOWN_LINE_LENGTH = 15_000
|
||||
private const val MAX_MARKDOWN_DEPTH = 32
|
||||
private const val MAX_MARKDOWN_TABLE_ROWS = 200
|
||||
@@ -67,7 +75,9 @@ private val bidiControlChar = Regex("[\\u061C\\u200E\\u200F\\u202A-\\u202E\\u206
|
||||
|
||||
private val invisibleCharMarkerStyle = SpanStyle(color = WarningOrange)
|
||||
|
||||
private class MarkdownDocument(val lines: List<String>, val formatted: State.Success?, val hasBidiControls: Boolean)
|
||||
internal class MarkdownLine(val text: String, val lineBreak: Boolean)
|
||||
|
||||
internal class MarkdownDocument(val text: String, val lines: List<MarkdownLine>, val formatted: State.Success?, val hasBidiControls: Boolean)
|
||||
|
||||
fun isMarkdownFile(file: CIFile): Boolean =
|
||||
file.fileSize <= MAX_MARKDOWN_VIEW_SIZE && file.fileName.substringAfterLast('.', "").lowercase() in listOf("md", "markdown")
|
||||
@@ -90,26 +100,31 @@ fun showMarkdownFile(file: CIFile) {
|
||||
AlertManager.shared.showAlertMsg(generalGetString(MR.strings.error), e.message)
|
||||
return@withLongRunningApi
|
||||
}
|
||||
val text = decodedText(bytes)
|
||||
val lines = text.lines()
|
||||
val formatted = if (lines.all { it.length <= MAX_MARKDOWN_LINE_LENGTH }) formattedWithinLimits(text) else null
|
||||
val document = MarkdownDocument(
|
||||
lines.flatMap { line -> line.chunked(MAX_MARKDOWN_LINE_LENGTH).ifEmpty { listOf("") } },
|
||||
formatted,
|
||||
bidiControlChar.containsMatchIn(text)
|
||||
)
|
||||
val document = markdownDocument(bytes)
|
||||
withContext(Dispatchers.Main) {
|
||||
if (appPlatform.isDesktop && ModalManager.center.isTopModalOpen(ModalViewId.MARKDOWN_FILE)) ModalManager.center.closeModal()
|
||||
ModalManager.center.showModal(id = ModalViewId.MARKDOWN_FILE, endButtons = {
|
||||
if (formatted != null) MarkdownViewSwitch()
|
||||
MarkdownFileSaveButton(file, bytes)
|
||||
}) {
|
||||
ModalManager.center.showModal(id = ModalViewId.MARKDOWN_FILE, endButtons = { MarkdownFileButtons(file, bytes, document) }) {
|
||||
key(this) { MarkdownFileView(file.fileName, document) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal suspend fun markdownDocument(bytes: ByteArray): MarkdownDocument {
|
||||
val text = decodedText(bytes)
|
||||
val lines = text.lines()
|
||||
val formatted = if (lines.all { it.length <= MAX_MARKDOWN_LINE_LENGTH }) formattedWithinLimits(text) else null
|
||||
return MarkdownDocument(
|
||||
text,
|
||||
lines.flatMapIndexed { i, line ->
|
||||
val chunks = line.chunked(MAX_MARKDOWN_LINE_LENGTH).ifEmpty { listOf("") }
|
||||
chunks.mapIndexed { j, chunk -> MarkdownLine(chunk, lineBreak = i < lines.lastIndex && j == chunks.lastIndex) }
|
||||
},
|
||||
formatted,
|
||||
bidiControlChar.containsMatchIn(text)
|
||||
)
|
||||
}
|
||||
|
||||
private fun decodedText(bytes: ByteArray): String =
|
||||
Charsets.UTF_8.newDecoder()
|
||||
.onMalformedInput(CodingErrorAction.REPLACE)
|
||||
@@ -145,6 +160,39 @@ private fun MarkdownViewSwitch() {
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun MarkdownFileButtons(file: CIFile, bytes: ByteArray, document: MarkdownDocument) {
|
||||
MarkdownFileCopyButton(document.text, bytes.size, if (appPlatform.isAndroid) MAX_ANDROID_COPY_SIZE else null)
|
||||
if (document.formatted != null) MarkdownViewSwitch()
|
||||
MarkdownFileSaveButton(file, bytes)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun MarkdownFileCopyButton(text: String, fileSize: Int, maxSize: Int?) {
|
||||
val clipboard = LocalClipboardManager.current
|
||||
IconButton({
|
||||
val copy = {
|
||||
clipboard.setText(AnnotatedString(text))
|
||||
showToast(generalGetString(MR.strings.copied))
|
||||
}
|
||||
when {
|
||||
maxSize != null && fileSize > maxSize -> AlertManager.shared.showAlertMsg(
|
||||
generalGetString(MR.strings.markdown_file_too_large),
|
||||
String.format(generalGetString(MR.strings.markdown_file_copy_limit), formatBytes(maxSize.toLong()))
|
||||
)
|
||||
fileSize > MAX_MARKDOWN_COPY_SIZE -> AlertManager.shared.showAlertDialog(
|
||||
title = generalGetString(MR.strings.markdown_file_too_large),
|
||||
text = String.format(generalGetString(MR.strings.markdown_file_copy_large), formatBytes(fileSize.toLong())),
|
||||
confirmText = generalGetString(MR.strings.copy_verb),
|
||||
onConfirm = copy
|
||||
)
|
||||
else -> copy()
|
||||
}
|
||||
}) {
|
||||
Icon(painterResource(MR.images.ic_content_copy), stringResource(MR.strings.copy_verb), tint = MaterialTheme.colors.primary)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun MarkdownFileSaveButton(file: CIFile, bytes: ByteArray) {
|
||||
val saveFileLauncher = rememberFileChooserLauncher(false, bytes) { to: URI? ->
|
||||
@@ -156,14 +204,17 @@ private fun MarkdownFileSaveButton(file: CIFile, bytes: ByteArray) {
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun MarkdownFileView(fileName: String, document: MarkdownDocument) {
|
||||
internal fun MarkdownFileView(fileName: String, document: MarkdownDocument) {
|
||||
val textView = remember { appPrefs.markdownFileTextView.state }
|
||||
val formatted = document.formatted
|
||||
if (textView.value || formatted == null) {
|
||||
SelectionContainer {
|
||||
MarkdownFileColumn(fileName, document.hasBidiControls) {
|
||||
items(document.lines) { line ->
|
||||
Text(remember(line) { withInvisibleCharMarkers(line) }, Modifier.padding(horizontal = DEFAULT_PADDING), fontFamily = FontFamily.Monospace)
|
||||
Box(Modifier.padding(horizontal = DEFAULT_PADDING)) {
|
||||
Text(remember(line) { withInvisibleCharMarkers(line.text) }, fontFamily = FontFamily.Monospace)
|
||||
if (line.lineBreak) SelectableLineBreak()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,6 +223,11 @@ private fun MarkdownFileView(fileName: String, document: MarkdownDocument) {
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun BoxScope.SelectableLineBreak() {
|
||||
Text("\n", Modifier.align(Alignment.BottomEnd).height(1.dp).clearAndSetSemantics {})
|
||||
}
|
||||
|
||||
private fun withInvisibleCharMarkers(line: String): AnnotatedString = buildAnnotatedString {
|
||||
var start = 0
|
||||
invisibleChar.findAll(line).forEach {
|
||||
@@ -294,3 +350,15 @@ private fun hasImageSignature(base64: String): Boolean {
|
||||
val header = runCatching { Base64.getDecoder().decode(base64.take(12)) }.getOrNull() ?: return false
|
||||
return IMAGE_TYPES.any { it.matches(header) }
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewMarkdownFileView() {
|
||||
val bytes = remember { "# Release notes\n\n- markdown files in chats\n- a button to copy the file\n".encodeToByteArray() }
|
||||
val document = remember { runBlocking { markdownDocument(bytes) } }
|
||||
SimpleXTheme {
|
||||
ModalView(close = {}, endButtons = { MarkdownFileButtons(CIFile.getSample(fileName = "notes.md"), bytes, document) }) {
|
||||
MarkdownFileView("notes.md", document)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,9 +77,9 @@ fun QRCode(
|
||||
val errorLevel = if (small) QrCode.ErrorLevel.M else QrCode.ErrorLevel.L
|
||||
val fixedQRCode = LocalFixedQRCode.current
|
||||
val qr = remember(connReq, tintColor, withLogo) {
|
||||
(fixedQRCode ?: qrCodeBitmap(connReq, 1024, errorLevel)).replaceColor(Color.Black.toArgb(), tintColor.toArgb())
|
||||
.let { if (withLogo) it.addLogo(logoSize) else it }
|
||||
}
|
||||
(fixedQRCode ?: qrCodeBitmap(connReq, 1024, errorLevel))?.replaceColor(Color.Black.toArgb(), tintColor.toArgb())
|
||||
?.let { if (withLogo) it.addLogo(logoSize) else it }
|
||||
} ?: return
|
||||
Box(Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
|
||||
Image(
|
||||
bitmap = qr,
|
||||
@@ -92,8 +92,8 @@ fun QRCode(
|
||||
.then(modifier)
|
||||
.clickable {
|
||||
scope.launch {
|
||||
val image = qrCodeBitmap(connReq, 1024, errorLevel).replaceColor(Color.Black.toArgb(), tintColor.toArgb())
|
||||
.let { if (withLogo) it.addLogo(logoSize) else it }
|
||||
val image = qrCodeBitmap(connReq, 1024, errorLevel)?.replaceColor(Color.Black.toArgb(), tintColor.toArgb())
|
||||
?.let { if (withLogo) it.addLogo(logoSize) else it } ?: return@launch
|
||||
val file = saveTempImageUncompressed(image, true)
|
||||
if (file != null) {
|
||||
shareFile("", CryptoFile.plain(file.absolutePath))
|
||||
@@ -105,8 +105,13 @@ fun QRCode(
|
||||
}
|
||||
}
|
||||
|
||||
fun qrCodeBitmap(content: String, size: Int = 1024, errorLevel: QrCode.ErrorLevel): ImageBitmap {
|
||||
val qrCode = QrCodeEncoder().addAutomatic(content).setError(errorLevel).fixate()
|
||||
fun qrCodeBitmap(content: String, size: Int = 1024, errorLevel: QrCode.ErrorLevel): ImageBitmap? {
|
||||
val qrCode = try {
|
||||
QrCodeEncoder().addAutomatic(content).setError(errorLevel).fixate()
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "qrCodeBitmap error: ${e.message}")
|
||||
return null
|
||||
}
|
||||
/** See [QrCodeGeneratorImage.initialize] and [FiducialImageEngine.configure] for size calculation */
|
||||
val numModules = QrCode.totalModules(qrCode.version)
|
||||
// Hide border on light themes to make it fit to the same place as camera in QRCodeScanner.
|
||||
|
||||
@@ -721,6 +721,9 @@
|
||||
<string name="markdown_formatted_view">Formatted view</string>
|
||||
<string name="markdown_text_view">Text view</string>
|
||||
<string name="markdown_file_bidi_warning">This file has text direction characters. The text can be shown in a different order than it is written.</string>
|
||||
<string name="markdown_file_too_large">File too large</string>
|
||||
<string name="markdown_file_copy_limit">Only files up to %s can be copied. Save the file to open it in another app.</string>
|
||||
<string name="markdown_file_copy_large">Your file is %s. Do you want to copy it?</string>
|
||||
<string name="loading_remote_file_title">Loading the file </string>
|
||||
<string name="loading_remote_file_desc">Please, wait while the file is being loaded from the linked mobile</string>
|
||||
<string name="file_error">File error</string>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package chat.simplex.app
|
||||
|
||||
import chat.simplex.common.model.ContactStatus
|
||||
import chat.simplex.common.model.json
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class ContactStatusTest {
|
||||
@Test
|
||||
fun testContactStatusesOfCore() {
|
||||
listOf("active", "deleted", "deletedByUser", "rejected").forEach { status ->
|
||||
val decoded = json.decodeFromString(ContactStatus.serializer(), "\"$status\"")
|
||||
assertEquals("\"$status\"", json.encodeToString(ContactStatus.serializer(), decoded))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,18 @@ import kotlin.math.roundToInt
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
private val TIME_BELOW_TEXT_PX = mapOf(
|
||||
0.7f to listOf(0, 0, 0),
|
||||
0.8f to listOf(1, 0, 0),
|
||||
0.9f to listOf(-1, 0, 0),
|
||||
1f to listOf(0, 0, -1),
|
||||
1.1f to listOf(0, 0, 0),
|
||||
1.2f to listOf(1, 1, 0),
|
||||
1.3f to listOf(0, 0, 0),
|
||||
1.4f to listOf(-1, 0, 0),
|
||||
1.5f to listOf(0, 0, 0),
|
||||
)
|
||||
|
||||
class BubbleLayoutTest {
|
||||
private val density = Density(1f)
|
||||
private val inset = with(density) { BUBBLE_TEXT_INSET.roundToPx() }
|
||||
@@ -138,14 +150,14 @@ class BubbleLayoutTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun timeDrawnOnTextBaseline() {
|
||||
fun timeOffsetFromTextBaseline() {
|
||||
val texts = listOf<@Composable () -> TextStyle>(
|
||||
{ TextStyle(fontFamily = Inter, fontSize = 16.sp).merge(bubbleTextStyle(16.sp, HighOrLowlight)) },
|
||||
{ TextStyle(fontFamily = Inter, fontSize = 13.sp, lineHeight = 18.sp, lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)).merge(bubbleLineHeight(18.sp)) },
|
||||
{ TextStyle(fontFamily = Inter, fontSize = 16.sp).merge(bubbleLineHeight(16.sp * INTER_LINE_HEIGHT)) },
|
||||
)
|
||||
for (fontScale in listOf(0.7f, 0.8f, 0.9f, 1f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f)) {
|
||||
texts.forEachIndexed { i, textStyle ->
|
||||
val timeBelowText = TIME_BELOW_TEXT_PX.keys.associateWith { fontScale ->
|
||||
texts.map { textStyle ->
|
||||
val image = renderScene {
|
||||
CompositionLocalProvider(LocalBubbleLayout provides true, LocalDensity provides Density(1f, fontScale)) {
|
||||
Row(Modifier.background(Color.White)) {
|
||||
@@ -159,9 +171,10 @@ class BubbleLayoutTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
assertEquals(lastInkRow(image, placed.getValue("text")), lastInkRow(image, placed.getValue("time")), "text $i at font scale $fontScale")
|
||||
lastInkRow(image, placed.getValue("time")) - lastInkRow(image, placed.getValue("text"))
|
||||
}
|
||||
}
|
||||
assertEquals(TIME_BELOW_TEXT_PX, timeBelowText)
|
||||
}
|
||||
|
||||
private fun lastInkRow(image: Image, area: Placed): Int {
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package chat.simplex.app
|
||||
|
||||
import org.jetbrains.skia.FontMgr
|
||||
import org.jetbrains.skia.paragraph.FontCollection
|
||||
import org.jetbrains.skia.paragraph.ParagraphBuilder
|
||||
import org.jetbrains.skia.paragraph.ParagraphStyle
|
||||
import org.jetbrains.skia.paragraph.TextStyle
|
||||
import org.junit.Assume.assumeNoException
|
||||
import org.junit.Assume.assumeTrue
|
||||
import java.io.IOException
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.util.concurrent.TimeUnit
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
private const val LAYOUT_WAIT_SECONDS = 60L
|
||||
|
||||
private const val SNOWMAN_BDF = """STARTFONT 2.1
|
||||
FONT -misc-snowman-medium-r-normal--8-80-75-75-c-80-iso10646-1
|
||||
SIZE 8 75 75
|
||||
FONTBOUNDINGBOX 8 8 0 0
|
||||
STARTPROPERTIES 5
|
||||
FAMILY_NAME "Snowman"
|
||||
FONT_ASCENT 8
|
||||
FONT_DESCENT 0
|
||||
CHARSET_REGISTRY "ISO10646"
|
||||
CHARSET_ENCODING "1"
|
||||
ENDPROPERTIES
|
||||
CHARS 1
|
||||
STARTCHAR snowman
|
||||
ENCODING 9731
|
||||
SWIDTH 1000 0
|
||||
DWIDTH 8 0
|
||||
BBX 8 8 0 0
|
||||
BITMAP
|
||||
3C
|
||||
42
|
||||
3C
|
||||
42
|
||||
81
|
||||
81
|
||||
42
|
||||
3C
|
||||
ENDCHAR
|
||||
ENDFONT
|
||||
"""
|
||||
|
||||
class FallbackFontTest {
|
||||
@Test
|
||||
fun textIsLaidOutWhenTheOnlyFallbackFontIsBitmap() = withTempDir { dir ->
|
||||
assumeTrue("fontconfig selects fallback fonts only on Linux", System.getProperty("os.name") == "Linux")
|
||||
Files.createDirectory(dir.resolve("fonts"))
|
||||
Files.writeString(dir.resolve("fonts/snowman.bdf"), SNOWMAN_BDF)
|
||||
Files.writeString(dir.resolve("fonts.conf"), "<fontconfig><dir>$dir/fonts</dir><cachedir>$dir/cache</cachedir></fontconfig>")
|
||||
val fcCache = try {
|
||||
startWithFonts(dir, "fc-cache").waitFor()
|
||||
} catch (e: IOException) {
|
||||
assumeNoException("fc-cache is not installed", e)
|
||||
return@withTempDir
|
||||
}
|
||||
assumeTrue("fc-cache indexes the font, as it does for installed fonts", fcCache == 0)
|
||||
val java = Path.of(System.getProperty("java.home"), "bin", "java").toString()
|
||||
val layout = startWithFonts(dir, java, "-cp", System.getProperty("java.class.path"), LayOutSnowman::class.java.name)
|
||||
val finished = layout.waitFor(LAYOUT_WAIT_SECONDS, TimeUnit.SECONDS)
|
||||
if (!finished) layout.destroyForcibly()
|
||||
assertTrue(finished, "layout must end within $LAYOUT_WAIT_SECONDS s")
|
||||
assertEquals(0, layout.exitValue(), Files.readString(dir.resolve("output.log")))
|
||||
}
|
||||
|
||||
private fun startWithFonts(dir: Path, vararg command: String): Process =
|
||||
ProcessBuilder(*command)
|
||||
.directory(dir.toFile())
|
||||
.redirectErrorStream(true)
|
||||
.redirectOutput(dir.resolve("output.log").toFile())
|
||||
.apply { environment()["FONTCONFIG_FILE"] = dir.resolve("fonts.conf").toString() }
|
||||
.start()
|
||||
}
|
||||
|
||||
object LayOutSnowman {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
val fonts = FontCollection().setDefaultFontManager(FontMgr.default)
|
||||
ParagraphBuilder(ParagraphStyle(), fonts).pushStyle(TextStyle()).addText("☃").build().layout(100f)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package chat.simplex.app
|
||||
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.input.key.Key
|
||||
import androidx.compose.ui.platform.ClipEntry
|
||||
import androidx.compose.ui.platform.Clipboard
|
||||
import androidx.compose.ui.platform.ClipboardManager
|
||||
import androidx.compose.ui.platform.LocalClipboard
|
||||
import androidx.compose.ui.platform.LocalClipboardManager
|
||||
import androidx.compose.ui.platform.NativeClipboard
|
||||
import androidx.compose.ui.test.ExperimentalTestApi
|
||||
import androidx.compose.ui.test.onNodeWithContentDescription
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.onRoot
|
||||
import androidx.compose.ui.test.performClick
|
||||
import androidx.compose.ui.test.performKeyInput
|
||||
import androidx.compose.ui.test.performMouseInput
|
||||
import androidx.compose.ui.test.pressKey
|
||||
import androidx.compose.ui.test.runComposeUiTest
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import chat.simplex.common.model.ChatController.appPrefs
|
||||
import chat.simplex.common.simplexWindowState
|
||||
import chat.simplex.common.views.chat.item.MarkdownFileCopyButton
|
||||
import chat.simplex.common.views.chat.item.MarkdownFileView
|
||||
import chat.simplex.common.views.chat.item.markdownDocument
|
||||
import chat.simplex.common.views.helpers.AlertManager
|
||||
import chat.simplex.common.views.helpers.LocalAppBarHandler
|
||||
import chat.simplex.common.views.helpers.rememberAppBarHandler
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.awt.datatransfer.DataFlavor
|
||||
import java.awt.datatransfer.Transferable
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
|
||||
@OptIn(ExperimentalTestApi::class)
|
||||
class MarkdownFileViewTest {
|
||||
@Test
|
||||
fun copiedSelectionKeepsLineBreaks() = runComposeUiTest {
|
||||
val textView = appPrefs.markdownFileTextView.get()
|
||||
appPrefs.markdownFileTextView.set(true)
|
||||
try {
|
||||
val clipboard = RecordingClipboard()
|
||||
val document = runBlocking { markdownDocument("alpha\n\ngamma".toByteArray()) }
|
||||
setContent {
|
||||
CompositionLocalProvider(LocalClipboard provides clipboard, LocalAppBarHandler provides rememberAppBarHandler()) {
|
||||
MarkdownFileView("test.md", document)
|
||||
}
|
||||
}
|
||||
val first = onNodeWithText("alpha").fetchSemanticsNode().boundsInRoot
|
||||
val last = onNodeWithText("gamma").fetchSemanticsNode().boundsInRoot
|
||||
onRoot().performMouseInput {
|
||||
moveTo(Offset(first.left + 1f, first.center.y))
|
||||
press()
|
||||
moveTo(Offset(last.right + 10f, last.center.y))
|
||||
release()
|
||||
}
|
||||
onRoot().performKeyInput { pressKey(Key.Copy) }
|
||||
waitForIdle()
|
||||
assertEquals("alpha\n\ngamma", clipboard.text)
|
||||
} finally {
|
||||
appPrefs.markdownFileTextView.set(textView)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun copyButtonWarnsAbove128KB() = runComposeUiTest {
|
||||
var copied: String? = null
|
||||
val clipboard = object : ClipboardManager {
|
||||
override fun setText(annotatedString: AnnotatedString) { copied = annotatedString.text }
|
||||
override fun getText(): AnnotatedString? = null
|
||||
}
|
||||
val document = runBlocking { markdownDocument("alpha\n\ngamma".toByteArray()) }
|
||||
var fileSize by mutableStateOf(131_072)
|
||||
try {
|
||||
setContent {
|
||||
CompositionLocalProvider(LocalClipboardManager provides clipboard) {
|
||||
MarkdownFileCopyButton(document.text, fileSize, null)
|
||||
}
|
||||
AlertManager.shared.showInView()
|
||||
}
|
||||
onNodeWithContentDescription("Copy").performClick()
|
||||
assertEquals("alpha\n\ngamma", copied)
|
||||
copied = null
|
||||
fileSize = 131_073
|
||||
onNodeWithContentDescription("Copy").performClick()
|
||||
onNodeWithText("Your file is 128 KB. Do you want to copy it?").assertExists()
|
||||
assertNull(copied)
|
||||
onNodeWithText("Copy").performClick()
|
||||
assertEquals("alpha\n\ngamma", copied)
|
||||
} finally {
|
||||
AlertManager.shared.hideAllAlerts()
|
||||
simplexWindowState.toasts.clear()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun copyButtonRefusesAboveHardLimit() = runComposeUiTest {
|
||||
var copied: String? = null
|
||||
val clipboard = object : ClipboardManager {
|
||||
override fun setText(annotatedString: AnnotatedString) { copied = annotatedString.text }
|
||||
override fun getText(): AnnotatedString? = null
|
||||
}
|
||||
try {
|
||||
setContent {
|
||||
CompositionLocalProvider(LocalClipboardManager provides clipboard) {
|
||||
MarkdownFileCopyButton("alpha", 524_289, 524_288)
|
||||
}
|
||||
AlertManager.shared.showInView()
|
||||
}
|
||||
onNodeWithContentDescription("Copy").performClick()
|
||||
onNodeWithText("Only files up to 512 KB can be copied. Save the file to open it in another app.").assertExists()
|
||||
assertNull(copied)
|
||||
} finally {
|
||||
AlertManager.shared.hideAllAlerts()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class RecordingClipboard : Clipboard {
|
||||
var text: String? = null
|
||||
|
||||
override suspend fun getClipEntry(): ClipEntry? = null
|
||||
|
||||
override suspend fun setClipEntry(clipEntry: ClipEntry?) {
|
||||
text = (clipEntry?.nativeClipEntry as Transferable).getTransferData(DataFlavor.stringFlavor) as String
|
||||
}
|
||||
|
||||
override val nativeClipboard: NativeClipboard get() = this
|
||||
}
|
||||
@@ -246,6 +246,18 @@ class NameAlertsTest {
|
||||
assertLocalChats("@3")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun groupLinkAsAddress() = recordedAlerts("connect/group-link-as-address") {
|
||||
connect("GROUP_LINK")
|
||||
assertTexts("Invalid connection link", "Please check that you used the correct link or ask your contact to send you another one.", "OK")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun groupLinkAsChannel() = recordedAlerts("connect/group-link-as-channel") {
|
||||
connect("GROUP_LINK")
|
||||
assertTexts("Invalid connection link", "Please check that you used the correct link or ask your contact to send you another one.", "OK")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun connectByNameRowShowsLocalChats() = recorded("names/plan-known") {
|
||||
val searchText = mutableStateOf(TextFieldValue("alice"))
|
||||
@@ -298,6 +310,23 @@ class NameAlertsTest {
|
||||
onNodeWithText("Connect to team.simplex").assertExists()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun rejectedContactInChatList() = recorded("connect/request-rejected") {
|
||||
ChatModel.chatRunning.value = true
|
||||
runBlocking {
|
||||
val chats = ChatController.apiGetChats(null)
|
||||
withContext(Dispatchers.Main) { ChatModel.chatsContext.updateChats(chats) }
|
||||
}
|
||||
setContent {
|
||||
CompositionLocalProvider(LocalAppBarHandler provides rememberAppBarHandler()) {
|
||||
ChatListView(ChatModel, MutableStateFlow(AnimatedViewState.GONE), {}, false)
|
||||
}
|
||||
}
|
||||
assertEquals(listOf("@2"), chatIds())
|
||||
assertFalse((chatInfo("@2") as ChatInfo.Direct).contact.active)
|
||||
waitUntil(timeoutMillis = 5_000) { onAllNodesWithText("alice").fetchSemanticsNodes().isNotEmpty() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun verifiedNameIsCopied() = simplexName(DomainVerification.Verified) { verifications, copied ->
|
||||
onNodeWithText(SIMPLEX_NAME).performClick()
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package chat.simplex.app
|
||||
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.test.ComposeUiTest
|
||||
import androidx.compose.ui.test.ExperimentalTestApi
|
||||
import androidx.compose.ui.test.assertCountEquals
|
||||
import androidx.compose.ui.test.onAllNodesWithContentDescription
|
||||
import androidx.compose.ui.test.onNodeWithContentDescription
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.performClick
|
||||
import androidx.compose.ui.test.runComposeUiTest
|
||||
import boofcv.alg.fiducial.qrcode.QrCode
|
||||
import chat.simplex.common.model.*
|
||||
import chat.simplex.common.views.chat.ChatInfoView
|
||||
import chat.simplex.common.views.helpers.LocalAppBarHandler
|
||||
import chat.simplex.common.views.helpers.rememberAppBarHandler
|
||||
import chat.simplex.common.views.newchat.LocalFixedQRCode
|
||||
import chat.simplex.common.views.newchat.SimpleXLinkQRCode
|
||||
import chat.simplex.common.views.newchat.qrCodeBitmap
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlin.test.AfterTest
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertFalse
|
||||
import kotlin.test.assertNotNull
|
||||
import kotlin.test.assertNull
|
||||
|
||||
@OptIn(ExperimentalTestApi::class)
|
||||
class QRCodeTest {
|
||||
private val link = "https://simplex.chat/contact#/?v=2-7&smp=smp%3A%2F%2Fu2dS9sG8nMNURyZwqASV4yROM28Er0luVTx5X1CsMrU%3D%40smp4.simplex.im%2FWHV0YU1sYlU7NqiEHkHDB6gxO1ofTync%23%2F%3Fv%3D1-2%26dh%3DMCowBQYDK2VuAyEAWbebOqVYuBXaiqHcXYjEHCpYi6VzDlu6CVaijDTmsQU%253D"
|
||||
|
||||
@AfterTest
|
||||
fun tearDown() {
|
||||
ChatModel.chatsContext.chats.value.clear()
|
||||
ChatModel.currentUser.value = null
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testQRCodeBitmapOfLinkWithinCapacity() {
|
||||
assertNotNull(qrCodeBitmap(link, errorLevel = QrCode.ErrorLevel.L))
|
||||
assertNotNull(qrCodeBitmap(link, errorLevel = QrCode.ErrorLevel.M))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNoQRCodeBitmapOfLinkAboveCapacity() {
|
||||
assertNull(qrCodeBitmap("$link&data=${"a".repeat(3000)}", errorLevel = QrCode.ErrorLevel.L))
|
||||
assertNull(qrCodeBitmap("$link&data=${"a".repeat(2400)}", errorLevel = QrCode.ErrorLevel.M))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testContactInfoShowsQRCodeOfAddress() = contactInfo(link) {
|
||||
onNodeWithText(ADDRESS_FOOTER).assertExists()
|
||||
onAllNodesWithContentDescription("QR Code").assertCountEquals(1)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testContactInfoWithoutQRCodeOfAddressAboveCapacity() = contactInfo("$link&data=${"a".repeat(3000)}") {
|
||||
onNodeWithText(ADDRESS_FOOTER).assertExists()
|
||||
onAllNodesWithContentDescription("QR Code").assertCountEquals(0)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNoShareOfQRCodeAboveCapacity() = runComposeUiTest {
|
||||
var shared = false
|
||||
setContent {
|
||||
CompositionLocalProvider(LocalFixedQRCode provides qrCodeBitmap(link, errorLevel = QrCode.ErrorLevel.L)) {
|
||||
SimpleXLinkQRCode("$link&data=${"a".repeat(3000)}", onShare = { shared = true })
|
||||
}
|
||||
}
|
||||
onNodeWithContentDescription("QR Code").performClick()
|
||||
waitForIdle()
|
||||
assertFalse(shared)
|
||||
}
|
||||
|
||||
private fun contactInfo(address: String, test: ComposeUiTest.() -> Unit) = runComposeUiTest {
|
||||
val contact = Contact.sampleData.copy(profile = LocalProfile.sampleData.copy(contactLink = address))
|
||||
ChatModel.currentUser.value = User.sampleData
|
||||
runBlocking { withContext(Dispatchers.Main) { ChatModel.chatsContext.updateChat(null, ChatInfo.Direct(contact)) } }
|
||||
setContent {
|
||||
CompositionLocalProvider(LocalAppBarHandler provides rememberAppBarHandler()) {
|
||||
ChatInfoView(ChatModel.chatsContext, ChatModel, contact, connectionStats = null, customUserProfile = null, localAlias = "", connectionCode = null, close = {}, onSearchClicked = {})
|
||||
}
|
||||
}
|
||||
test()
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val ADDRESS_FOOTER = "You can share this address with your contacts to let them connect with alice."
|
||||
}
|
||||
}
|
||||
@@ -99,6 +99,7 @@ private val previewScenes = listOf(
|
||||
SnapshotScene("DeletedItemView.PreviewDeletedItemView", chatItemFontScales) { PreviewDeletedItemView() },
|
||||
SnapshotScene("IntegrityErrorItemView.IntegrityErrorItemViewPreview", chatItemFontScales) { IntegrityErrorItemViewPreview() },
|
||||
SnapshotScene("MarkedDeletedItemView.PreviewMarkedDeletedItemView", chatItemFontScales) { PreviewMarkedDeletedItemView() },
|
||||
SnapshotScene("MarkdownFileView.PreviewMarkdownFileView") { PreviewMarkdownFileView() },
|
||||
SnapshotScene("ChatHelpView.PreviewChatHelpLayout") { PreviewChatHelpLayout() },
|
||||
SnapshotScene("ChatListNavLinkView.PreviewChatListNavLinkDirect") { PreviewChatListNavLinkDirect() },
|
||||
SnapshotScene("ChatListNavLinkView.PreviewChatListNavLinkGroup") { PreviewChatListNavLinkGroup() },
|
||||
|
||||
|
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 7.7 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 84 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
|
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 17 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 110 KiB |
|
Before Width: | Height: | Size: 109 KiB After Width: | Height: | Size: 109 KiB |
|
Before Width: | Height: | Size: 49 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
@@ -215,7 +215,7 @@ In chats with avatars the item is in the message column, after the avatar column
|
||||
When `LocalBubbleLayout.current` is true (classic chats, provided by `ChatView` with `LocalTerminalLayout`, the classic theme preview, and the chat item and chat view previews through [`BubblePreview`](../../common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/ChatItemView.kt#L1506-L1509)), bubbles follow one inset (plans/2026-10-25-classic-bubbles.md). The previews of deleted and error items clip them as `ChatItemView` does (`clipChatItem`).
|
||||
|
||||
- Texts use `chatTextStyle`, as terminal rows: message text, captions, Markdown blocks, quote text and sender (`body1`, Inter), headers, the time, event texts; the texts of `DeletedItemView` and error items through [`bubbleTextStyle(fontSize, color)`](../../common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/TerminalItemView.kt#L91-L93), `chatTextStyle` in bubbles only, so the cards of terminal rows keep their style (the one-line text of `MarkedDeletedItemView` keeps its style, its line height rounded by `bubbleLineHeight`). Call items are drawn as in master: `ChatItemView` provides `LocalBubbleLayout` false for them. Markdown blocks in bubbles have the heading gaps, heading sizes and `headingBox` of terminal rows; cards and rules have `TERMINAL_BLOCK_TOP_GAP` (5.75sp) above and `TERMINAL_BLOCK_BOTTOM_GAP` (5sp) below, and each empty line typed is one line of the text style.
|
||||
- On desktop, [`bubbleLineHeight(lineHeight)`](../../common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/TerminalItemView.kt#L95-L101) rounds a line height in bubbles to whole pixels, with the proportional alignment of `chatTextStyle`: `chatTextStyle` applies it in bubbles, and so do the last text of a group invitation (18sp, or "Tap to join" at the line height of Inter, `INTER_LINE_HEIGHT`), "Fix connection" of decryption errors and the size line of files (the line height of Inter) and the text of `MarkedDeletedItemView` (22sp); on Android the line heights are unchanged. Skia draws the baseline of a line at its top plus the rounded ascent and reports the rounded line height less the descent, which Compose rounds into `FirstBaseline` and `LastBaseline`; both are one pixel row only when ascent and descent add up to whole pixels, so the time, placed by reported baselines, is drawn on the baseline of the text (owner report).
|
||||
- On desktop, [`bubbleLineHeight(lineHeight)`](../../common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/TerminalItemView.kt#L95-L101) rounds a line height in bubbles to whole pixels, with the proportional alignment of `chatTextStyle`: `chatTextStyle` applies it in bubbles, and so do the last text of a group invitation (18sp, or "Tap to join" at the line height of Inter, `INTER_LINE_HEIGHT`), "Fix connection" of decryption errors and the size line of files (the line height of Inter) and the text of `MarkedDeletedItemView` (22sp); on Android the line heights are unchanged. Skia draws the baseline of a line at its top plus the rounded ascent and reports the rounded line height less the descent, which Compose rounds into `FirstBaseline` and `LastBaseline`; both are one pixel row only when ascent and descent add up to whole pixels, so the time, placed by reported baselines, is drawn on the baseline of the text (owner report); with Skia m138 it is drawn 1 px from it at some font scales (`BubbleLayoutTest.timeOffsetFromTextBaseline`).
|
||||
- `BUBBLE_TEXT_INSET` (11dp, user) is the distance from a bubble or band edge to the capitals of the text under it, and from the last baseline to the edge under it; in dp, so it keeps its size at larger fonts (user). Message text, captions and an emoji under a quote or header have [`bubbleTextBoxPadding()`](../../common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/FramedItemView.kt#L575-L582): that inset less the space of 16sp text with the full line height above its capitals (`BUBBLE_LINE_ABOVE_CAPS`, 6sp) and under its last baseline (`BUBBLE_LINE_BELOW_BASELINE`, 4.375sp), at least 0; 5dp and 6.625dp at font scale 1. `BUBBLE_SIDE_INSET` (14dp, user) is the distance from the bubble sides to message text, captions, an emoji under a quote or header and the end of the time. Header bands, the quote band and deleted and error items use [`Modifier.bubbleTextPadding(firstLineFontSize, bottom)`](../../common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/FramedItemView.kt#L571-L573): `BUBBLE_SIDE_INSET` at the sides and the inset by the first and last baselines; a header followed by a quote or a forwarded header has no inset below. The header starts at `BUBBLE_SIDE_INSET` and its icon takes no height. Deleted and error items are drawn by [`ItemTextCard`](../../common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/DeletedItemView.kt#L33-L52) (`DeletedItemView`, `MarkedDeletedItemView`, `CIMsgError`) and the private `DecryptionErrorCard` (the decryption error items), each with one switch between the bubble and the rounded card of terminal rows: in bubbles they fill the shape of `clipChatItem` (`Surface` with its default `RectangleShape`, user). That shape has no tail for items without message content ([`shapeStyleWithTail`](../../common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/ChatItemView.kt#L1334-L1386): `msgContent` null; user): deleted, moderated, blocked, error, decryption error and invalid JSON items. [`chatItemTailRendered(chatItem, tailVisible, revealed)`](../../common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/ChatItemView.kt#L1222-L1224) tells whether the tail is drawn, from the shape style of the item as `clipChatItem` computes it; `FramedItemView`, `chatItemOffset` and the sender rows of `ChatItemsList` use it. The file row ends `BUBBLE_TEXT_INSET` under the baseline of its size line; the ink bottom of the file icon is aligned to that baseline ([`fileIconOnBaseline`](../../common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/CIFileView.kt#L258-L262): the icon size × `FILE_ICON_INK_INSET`, the space under the ink of `ic_draft_filled`, rounded down).
|
||||
- The time: [`Modifier.bubbleMeta()`](../../common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/FramedItemView.kt#L584-L588) places the baseline of the time `BUBBLE_TEXT_INSET` above the bubble bottom, on the last baseline of the text; ticks without a time where they stand next to a time (`metaBaseline`, shared with `TerminalMetaLayout`). In deleted and error items the time follows the text on its last baseline (`bubbleMetaOnBaseline`, the text aligned by `LastBaseline`), so a wrapped text keeps the time on its last line; in group invitations [`MetaOnLastBaseline(meta, content)`](../../common/src/commonMain/kotlin/chat/simplex/common/views/chat/item/FramedItemView.kt#L596-L608) places it at the end of the card on its last baseline (the card bottom without a baseline, in intrinsic measurement; user). Message text, an emoji under a quote or header, decryption errors and group invitations end with `metaReserveCopy`; after text it starts with a breaking space (`breakBefore`), so the time alone moves to the next line, except in group invitations, where the word joiner keeps the time with the last word (user); the size line of a file keeps the string of `reserveSpaceForMeta`.
|
||||
- Gaps between rows: `BUBBLE_CLOSE_GAP` (2sp) between close messages, `BUBBLE_FAR_GAP` (8sp) at a large gap, half above and half below each row. Event rows (`isEvent`: items without a sender, `hasTerminalSender` false, other than the chat banner: event, feature, preference and end-to-end encryption items, also collapsed) form runs (user): `eventRunLargeGap` makes the gap between two events close and the gap between an event and another row large; `ChatItemsList` applies it to the gap above a row (`eventGapAbove`) and to the separation below it (`eventGapBelow`, a large gap with the time), so a message above an event shows its tail and time. The avatar column of an event has no 8dp top padding.
|
||||
|
||||
@@ -2,10 +2,13 @@ module Main where
|
||||
|
||||
import Broadcast.Bot
|
||||
import Broadcast.Options
|
||||
import Control.Concurrent.Async
|
||||
import Control.Monad
|
||||
import Simplex.Chat.Core
|
||||
import Simplex.Chat.Terminal (terminalChatConfig)
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
opts <- welcomeGetOpts
|
||||
simplexChatCore terminalChatConfig (mkChatOpts opts) $ broadcastBot opts
|
||||
simplexChatCore terminalChatConfig (mkChatOpts opts) $ \user cc ->
|
||||
race_ (forever $ void getLine) $ broadcastBot opts user cc
|
||||
@@ -8,7 +8,6 @@
|
||||
module Broadcast.Bot where
|
||||
|
||||
import Control.Concurrent (forkIO)
|
||||
import Control.Concurrent.Async
|
||||
import Control.Concurrent.STM
|
||||
import Control.Monad
|
||||
import qualified Data.Text as T
|
||||
@@ -36,7 +35,7 @@ welcomeGetOpts = do
|
||||
broadcastBot :: BroadcastBotOpts -> User -> ChatController -> IO ()
|
||||
broadcastBot BroadcastBotOpts {publishers, welcomeMessage, prohibitedMessage} _user cc = do
|
||||
initializeBotAddress cc
|
||||
race_ (forever $ void getLine) . forever $ do
|
||||
forever $ do
|
||||
(_, evt) <- atomically . readTBQueue $ outputQ cc
|
||||
case evt of
|
||||
Right (CEvtContactConnected _ ct _) -> do
|
||||
|
||||
@@ -77,7 +77,7 @@ import Simplex.Messaging.Protocol (ErrorType (..))
|
||||
import Simplex.Messaging.SimplexName (SimplexNameInfo (..), SimplexNameType (..), shortNameInfoStr)
|
||||
import Simplex.Messaging.TMap (TMap)
|
||||
import qualified Simplex.Messaging.TMap as TM
|
||||
import Simplex.Messaging.Util (eitherToMaybe, raceAny_, safeDecodeUtf8, tshow, unlessM, (<$$>))
|
||||
import Simplex.Messaging.Util (catchOwn', eitherToMaybe, raceAny_, safeDecodeUtf8, tshow, unlessM, (<$$>))
|
||||
import System.Directory (getAppUserDataDirectory, removeFile)
|
||||
import System.Exit (exitFailure)
|
||||
import System.Process (readProcess)
|
||||
@@ -341,7 +341,7 @@ directoryServiceEvent opts@DirectoryOpts {adminUsers, superUsers, serviceName, o
|
||||
SDRUser -> deUserCommand ct ciId cmd
|
||||
SDRAdmin -> deAdminCommand ct ciId cmd
|
||||
SDRSuperUser -> deSuperUserCommand ct ciId cmd
|
||||
DEVoiceUploadEnded filePath -> void (try $ removeFile filePath :: IO (Either SomeException ()))
|
||||
DEVoiceUploadEnded filePath -> removeFile filePath `catchOwn'` \_ -> pure ()
|
||||
DELogChatResponse r -> logInfo r
|
||||
where
|
||||
groupLinkText (CCLink cReq sLnk_) = maybe (strEncodeTxt $ simplexChatContact cReq) strEncodeTxt sLnk_
|
||||
|
||||
@@ -63,8 +63,9 @@ import Network.HTTP.Types (hContentType, methodPost, statusCode, statusIsSuccess
|
||||
import Numeric (readHex, showHex)
|
||||
import Simplex.Messaging.Crypto (keccak256)
|
||||
import Simplex.Messaging.Crypto.Secp256k1 (RecoverableSignature (..))
|
||||
import Simplex.Messaging.Encoding (Encoding (..))
|
||||
import Simplex.Messaging.Eth.Address (Address, addressFromPrivateKey, recoverAddress)
|
||||
import Simplex.Messaging.Eth.RLP (RLPItem (..), rlpEncode)
|
||||
import Simplex.Messaging.Eth.RLP (RLPItem (..))
|
||||
import Simplex.Messaging.Eth.Transaction (Eip1559Tx (..), signEip1559Tx)
|
||||
import Simplex.Messaging.Util (tshow)
|
||||
import StoreService.Config (ChainConfig (..))
|
||||
@@ -255,7 +256,7 @@ transactionSigner raw = case signedTxItems raw of
|
||||
Right (fields@(chainIdItem : _), (RLPBytes yParity, RLPBytes r, RLPBytes s))
|
||||
| B.length yParity <= 1,
|
||||
Right chainId <- scalar chainIdItem ->
|
||||
fmap (chainId,) <$> recoverAddress RecoverableSignature {rsR = scalarBytes r, rsS = scalarBytes s, rsRecId = fromInteger $ os2ip yParity} (keccak256 $ B.cons eip1559TxType $ rlpEncode $ RLPList fields)
|
||||
fmap (chainId,) <$> recoverAddress RecoverableSignature {rsR = scalarBytes r, rsS = scalarBytes s, rsRecId = fromInteger $ os2ip yParity} (keccak256 $ B.cons eip1559TxType $ smpEncode $ RLPList fields)
|
||||
Right _ -> pure $ Left "transaction: not a chain id and signature"
|
||||
Left e -> pure $ Left e
|
||||
where
|
||||
|
||||
@@ -40,8 +40,9 @@ import Data.Word (Word64)
|
||||
import Simplex.Messaging.Agent.Store.Common (DBStore, withTransaction)
|
||||
import qualified Simplex.Messaging.Agent.Store.DB as DB
|
||||
import Simplex.Messaging.Crypto (sha256Hash)
|
||||
import Simplex.Messaging.Encoding (Encoding (..))
|
||||
import Simplex.Messaging.Eth.Address (Address, recoverAddress)
|
||||
import Simplex.Messaging.Eth.EIP712 (Eip712Domain, serializeSignature)
|
||||
import Simplex.Messaging.Eth.EIP712 (Eip712Domain)
|
||||
import Simplex.Messaging.SimplexName (LabelHash, SimplexTLD)
|
||||
import Simplex.Messaging.Util (tshow)
|
||||
import StoreService.Config (ChainConfig (..))
|
||||
@@ -168,7 +169,7 @@ relayEdit rs@Records {rsPendingAfter, rsEditsPerYear, rsNow} req@EditRequest {er
|
||||
where
|
||||
signed = L.map (\change -> (changeDigest rs erLabelHash change, change)) erChanges
|
||||
-- one change hashes as edits stored before requests took two, so their repeats still match
|
||||
bodyHash = sha256Hash $ B.concat [digest <> serializeSignature scSignature | (digest, SignedChange {scSignature}) <- L.toList signed]
|
||||
bodyHash = sha256Hash $ B.concat [digest <> smpEncode scSignature | (digest, SignedChange {scSignature}) <- L.toList signed]
|
||||
|
||||
newEdit :: Records -> TVar Bool -> EditRequest -> Address -> ByteString -> IO EditAnswer
|
||||
newEdit rs timer req signer bodyHash =
|
||||
|
||||
@@ -43,9 +43,10 @@ import Data.Text.Encoding (encodeUtf8)
|
||||
import Data.Word (Word64)
|
||||
import Simplex.Messaging.Crypto (keccak256)
|
||||
import Simplex.Messaging.Crypto.Secp256k1 (RecoverableSignature)
|
||||
import Simplex.Messaging.Encoding (Encoding (..))
|
||||
import Simplex.Messaging.Encoding.String (strEncode)
|
||||
import Simplex.Messaging.Eth.Address (Address, recoverAddress)
|
||||
import Simplex.Messaging.Eth.EIP712 (Eip712Domain (..), Eip712Value (..), hashTypedData, serializeSignature)
|
||||
import Simplex.Messaging.Eth.EIP712 (Eip712Domain (..), Eip712Value (..), hashTypedData)
|
||||
import Simplex.Messaging.SimplexName (LabelHash (..), SimplexTLD)
|
||||
import StoreService.Names.Abi (AbiValue (..), abiArray, abiBytes, abiTuple, addressWord, selector, uint256)
|
||||
|
||||
@@ -123,7 +124,7 @@ registerWithCreditCalldata RegisterIntent {riRegistration, riNonce, riDeadline,
|
||||
[ Dynamic $ registrationTuple riRegistration,
|
||||
Static $ uint256 riNonce,
|
||||
Static $ uint256 riDeadline,
|
||||
Dynamic $ abiBytes $ serializeSignature riSignature
|
||||
Dynamic $ abiBytes $ smpEncode riSignature
|
||||
]
|
||||
|
||||
registerIntentDigest :: Eip712Domain -> Registration -> Word64 -> Word64 -> ByteString
|
||||
@@ -168,7 +169,7 @@ acceptCalldata TermsKind {tkRelayFunction} commitment owner deadline TermsAccept
|
||||
Static $ addressWord owner,
|
||||
Static $ uint256 taNonce,
|
||||
Static $ uint256 deadline,
|
||||
Dynamic $ abiBytes $ serializeSignature taSignature
|
||||
Dynamic $ abiBytes $ smpEncode taSignature
|
||||
]
|
||||
|
||||
setTextDigest :: Eip712Domain -> Node -> Text -> Text -> Word64 -> Word64 -> ByteString
|
||||
@@ -194,13 +195,13 @@ setTextWithSigCalldata (Node node) key value nonce deadline sig =
|
||||
Dynamic $ abiBytes $ encodeUtf8 value,
|
||||
Static $ uint256 nonce,
|
||||
Static $ uint256 deadline,
|
||||
Dynamic $ abiBytes $ serializeSignature sig
|
||||
Dynamic $ abiBytes $ smpEncode sig
|
||||
]
|
||||
|
||||
clearRecordsWithSigCalldata :: Node -> Word64 -> Word64 -> RecoverableSignature -> ByteString
|
||||
clearRecordsWithSigCalldata (Node node) nonce deadline sig =
|
||||
selector "clearRecordsWithSig(bytes32,uint256,uint256,bytes)"
|
||||
<> abiTuple [Static node, Static $ uint256 nonce, Static $ uint256 deadline, Dynamic $ abiBytes $ serializeSignature sig]
|
||||
<> abiTuple [Static node, Static $ uint256 nonce, Static $ uint256 deadline, Dynamic $ abiBytes $ smpEncode sig]
|
||||
|
||||
-- | The resolver runs each call on itself in order, and reverts all of them when one fails.
|
||||
multicallCalldata :: [ByteString] -> ByteString
|
||||
|
||||
@@ -128,7 +128,6 @@ import Simplex.Messaging.Crypto (sha256Hash)
|
||||
import Simplex.Messaging.Crypto.Secp256k1 (RecoverableSignature)
|
||||
import Simplex.Messaging.Encoding.String (TextEncoding (..))
|
||||
import Simplex.Messaging.Eth.Address (Address, unAddress)
|
||||
import Simplex.Messaging.Eth.EIP712 (serializeSignature)
|
||||
import Simplex.Messaging.SimplexName (LabelHash (..))
|
||||
import Simplex.Messaging.Util (maybeFirstRow, tshow)
|
||||
import StoreService.Names.Abi (addressFromBytes, hex)
|
||||
@@ -791,8 +790,8 @@ updateRegistration db r now = do
|
||||
)))
|
||||
|]
|
||||
( (Binary lh, nrLength, int64 nrDuration, Binary nrCommitment, nrSealed, nrAgreedTerms, nrPhase, nrPrice)
|
||||
:. (rvLabel <$> nrReveal, Binary . rvSecret <$> nrReveal, rvContactLink =<< nrReveal, rvChannelLink =<< nrReveal, int64 . rvNonce <$> nrReveal, int64 . rvDeadline <$> nrReveal, Binary . serializeSignature . rvSignature <$> nrReveal)
|
||||
:. (Binary . taTermsHash <$> acceptance, int64 . taNonce <$> acceptance, Binary . serializeSignature . taSignature <$> acceptance)
|
||||
:. (rvLabel <$> nrReveal, Binary . rvSecret <$> nrReveal, rvContactLink =<< nrReveal, rvChannelLink =<< nrReveal, int64 . rvNonce <$> nrReveal, int64 . rvDeadline <$> nrReveal, rvSignature <$> nrReveal)
|
||||
:. (Binary . taTermsHash <$> acceptance, int64 . taNonce <$> acceptance, taSignature <$> acceptance)
|
||||
:. (txHashField <$> nrCommitTx, int64 <$> nrCommitBlock, txHashField <$> nrRegisterTx, int64 <$> nrRegisterBlock, int64 <$> nrRevealAfter, int64 <$> nrRevealBefore, int64 <$> nrExpiresAt)
|
||||
:. (truncateToSecond <$> nrRegisteredAt, truncateToSecond <$> nrFailedAt, nrError, BI live, nrMoves, truncateToSecond <$> nrLinksRefusedAt, truncateToSecond now)
|
||||
:. (rid, nrVersion, BI live, rid, Binary nrCommitment, Binary $ unAddress nrOwner, Binary lh)
|
||||
@@ -1479,7 +1478,7 @@ insertRecordEdit db NewRecordEdit {nreLabelHash = LabelHash lh, nreOwner, nreCha
|
||||
DB.execute
|
||||
db
|
||||
"INSERT INTO sx_badge_service_name_record_changes (name_record_edit_id, nonce, record_key, record_value, deadline, signature) VALUES (?,?,?,?,?,?)"
|
||||
(editId, int64 scNonce, key, value, int64 scDeadline, Binary $ serializeSignature scSignature)
|
||||
(editId, int64 scNonce, key, value, int64 scDeadline, scSignature)
|
||||
where
|
||||
(key, value) = case scChange of
|
||||
RCSetText k v -> (Just k, Just v)
|
||||
|
||||
@@ -21,7 +21,7 @@ constraints: zip +disable-bzip2 +disable-zstd
|
||||
source-repository-package
|
||||
type: git
|
||||
location: https://github.com/simplex-chat/simplexmq.git
|
||||
tag: dc118d3bcc7512398e55a1c7d7dbf87458ba0a61
|
||||
tag: d38bcf50131d59f027d170731e4ea22031650611
|
||||
|
||||
source-repository-package
|
||||
type: git
|
||||
@@ -36,7 +36,7 @@ source-repository-package
|
||||
source-repository-package
|
||||
type: git
|
||||
location: https://github.com/simplex-chat/sqlcipher-simple.git
|
||||
tag: a46bd361a19376c5211f1058908fc0ae6bf42446
|
||||
tag: 6bf2796de625dca678c70e98560010c6ec7ed635
|
||||
|
||||
source-repository-package
|
||||
type: git
|
||||
|
||||
@@ -21,6 +21,8 @@ Please discuss the problem you want to solve and your detailed implementation pl
|
||||
|
||||
./contributing/CODE.md has details about general requirements common for `simplexmq` and `simplex-chat` repositories.
|
||||
|
||||
./contributing/TESTS.md has the testing approaches of this repository: the tests required for a change, how they are written and run, and where CI runs them.
|
||||
|
||||
CLAUDE.md in the repository root imports these files, this guide and ../scripts/ci/README.md for Claude Code; apps/ios/CLAUDE.md and apps/multiplatform/CLAUDE.md import the README of each app.
|
||||
|
||||
## Compiling with SQLCipher encryption enabled
|
||||
@@ -87,12 +89,14 @@ For some complex features we create feature branches that will be merged once re
|
||||
|
||||
## Pull requests and CI
|
||||
|
||||
1. Open a pull request to `master` as a draft. On a draft, CI runs the reduced build: one Linux job that builds and tests the changed scopes, and one macOS job only when iOS code changed (CI guide: scripts/ci/README.md).
|
||||
1. Open a pull request to `master` as a draft. On a draft, CI runs the reduced build: one Linux job that builds and tests the changed scopes, one Linux job that runs the core tests on PostgreSQL when core code changed, and one macOS job only when iOS code changed (CI guide: scripts/ci/README.md).
|
||||
2. Select the core tests in a `ci-tests` block in the description, one hspec match pattern per line. `/` runs all tests; without a block, the reduced build runs no core tests.
|
||||
3. Push further changes to the same branch; on a draft, each push runs the reduced build.
|
||||
4. Mark the pull request ready for review once it is ready. CI then runs the full matrix on each push, and the code owners are requested for review.
|
||||
5. Mark it as a draft again when more work is needed. After the approval, the pull request is merged by squash once CI passes.
|
||||
6. A change to a scope without CI tests adds its build and tests to CI in the same pull request.
|
||||
7. A change of the apps' code adds, in the same pull request, app tests of all its changes on the core's real responses: core tests record the responses and events in tests/fixtures/api, and the Kotlin and iOS tests run the app code on them, with any platform service the code calls mocked (CI guide: "App test fixtures").
|
||||
8. Files that tests generate (schema dumps, query plans, API docs) are committed as CI generates them: when a test changes one, the step "Check generated files" fails, and the run's artifact `generated-files-<job>` holds the change as a patch.
|
||||
|
||||
## Differences between GHC 8.10.7 and GHC 9.6.3
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ You accept these Conditions of Use of SimpleX Names ("Names Conditions") by regi
|
||||
|
||||
**SimpleX names**. A name is a record controlled by your key. The record can contain links to addresses in the SimpleX Network. "Community names" are marked in the registry as referring to specific communities, usually cities or territories.
|
||||
|
||||
**Registry**. The .simplex names registry is a set of contracts on the Ethereum blockchain. Name registrations, records, subnames and controlling addresses are stored in immutable contracts. Other contracts may be updated during a stabilization period, expected to last 12 to 24 months from the first registration.
|
||||
**Registry**. The .simplex names registry is a set of contracts on the Ethereum blockchain. The contracts may be updated during a stabilization period, expected to last 12 to 24 months from the first registration.
|
||||
|
||||
**What the registry allows**.
|
||||
|
||||
|
||||
@@ -0,0 +1,301 @@
|
||||
# Testing
|
||||
|
||||
The testing approaches of this repository: what is checked, how a test is written and run, and where CI runs it. The CI scopes, the reduced build and the `ci-tests` block of a pull request: [CI on GitHub's runners](../../scripts/ci/README.md).
|
||||
|
||||
## Tests for a change
|
||||
|
||||
| Change | Tests |
|
||||
|---|---|
|
||||
| Behaviour of the chat core: messages, groups, files, profiles, connections | [chat scenario test](#chat-scenario-tests) |
|
||||
| Encoding of a protocol message or a JSON type, markdown, a pure function of the core | [unit test](#unit-tests) |
|
||||
| Command, response, event or type of the core API | [Bot API docs](#checks-against-committed-files), regenerated<br>[app fixture](#app-fixtures), when an app processes it |
|
||||
| Database migration | [schema dumps](#checks-against-committed-files) of SQLite and PostgreSQL<br>query plans |
|
||||
| Directory service, store service, remote sessions | the [suite](#suites) of the area |
|
||||
| App processing of a core response or event | [app fixture](#app-fixtures), replayed in Kotlin and iOS tests |
|
||||
| App screen | a preview, rendered by the [desktop](#desktop-snapshots) and [iOS](#simplex-snapshots) snapshot tests |
|
||||
| Flow across app screens | a case of an [app workflow](#app-workflows) |
|
||||
| Kotlin or Swift code without views | [desktopTest or commonTest](#kotlin-apps)<br>[SimpleX Unit Tests](#simplex-unit-tests) |
|
||||
| Package, bot, website or CI script | the tests of its [scope](#packages-and-other-scopes) |
|
||||
| Scope lacking CI tests | its CI coverage, in the same pull request ([Adding CI coverage](../../scripts/ci/README.md#adding-ci-coverage)) |
|
||||
|
||||
## Core
|
||||
|
||||
The hspec suite `simplex-chat-test` of simplex-chat.cabal, with the entry point [tests/Test.hs](../../tests/Test.hs). Building it, running it and selecting tests by hspec match patterns: [CI guide, core](../../scripts/ci/README.md#core). A pattern is a path of `describe` and `it` names, for example `/SimpleX chat client/direct tests/`.
|
||||
|
||||
- A new test module is added to `other-modules` of the test suite in simplex-chat.cabal, and its spec to `main` of Test.hs.
|
||||
- `tests/tmp` contains a directory per test (`tmpBracket` in Test.hs) and is emptied at the start and the end of a run (`withTmpFiles` in ChatClient.hs).
|
||||
- With `CI=true`, set on GitHub's runners, the tests marked `xdescribe''` and `xit''` are skipped, and on macOS those marked `xitMacCI` ([ChatTests/Utils.hs](../../tests/ChatTests/Utils.hs)); the tests marked `xit'` are skipped on Linux.
|
||||
- [tests/fixtures](../../tests/fixtures): images and files sent in the tests, TLS credentials of the test servers, and the [app fixtures](#app-fixtures) in `api`.
|
||||
- In the full matrix of build.yml, the whole suite runs on Linux x86_64, with GHC 9.6.3 and 8.10.7, and on macOS aarch64; on a draft pull request, the tests matched by its `ci-tests` block run.
|
||||
- Coverage: `-fhpc` added to `ghc-options` of the test suite in simplex-chat.cabal.
|
||||
|
||||
### Suites
|
||||
|
||||
| Pattern | Module | Checked |
|
||||
|---|---|---|
|
||||
| `/SimpleX chat client/` | [ChatTests.hs](../../tests/ChatTests.hs) | [chat scenarios](#chat-scenario-tests): direct, forward, group, chat relay, local, file, profile and chat list tests |
|
||||
| `/names tests/` | ChatTests/Names.hs | SimpleX names, resolved by a local resolver ([NameResolver.hs](../../tests/NameResolver.hs)); SQLite only |
|
||||
| `/SimpleX chat protocol/` | ProtocolTests.hs | chat protocol messages, short link data, batch limits, preferences JSON |
|
||||
| `/JSON Tests/` | JSONTests.hs, JSONFixtures.hs | conversion of the Swift JSON form to the tagged form, with QuickCheck; JSON of markdown |
|
||||
| `/SimpleX chat markdown/` | MarkdownTests.hs | the markdown parser |
|
||||
| `/SimpleX chat view/` | ViewTests.hs | functions of the CLI view |
|
||||
| `/Mobile API Tests/` | MobileTests.hs | the API of the core library (src/Simplex/Chat/Mobile.hs) and its C functions; SQLite only |
|
||||
| `/Message batching/` | MessageBatching.hs | batches of messages and of relay deliveries |
|
||||
| `/Valid names/` | ValidNames.hs | display names made valid |
|
||||
| `/Random servers/` | RandomServers.hs | the random choice of preset servers |
|
||||
| `/Operators/` | OperatorTests.hs | server operators, usage conditions, validation of user servers |
|
||||
| `/Member relations/` | MemberRelationsTests.hs | member relation vectors |
|
||||
| `/Image resize/` | ImageTests.hs | image resizing |
|
||||
| `/Supporter badges/` | BadgeTests.hs | badge credentials and proofs |
|
||||
| `/WebRTC encryption/` | WebRTCTests.hs | encryption of call media frames; SQLite only |
|
||||
| `/Remote session/` | RemoteTests.hs | a desktop controlling a mobile: handshake, messages, files |
|
||||
| `/SimpleX Directory service bot/`<br>`/SimpleX Directory names/` | Bots/DirectoryTests.hs | the directory service with chat clients (`withDirectoryService`); names: SQLite only |
|
||||
| `/SimpleX Broadcast bot/` | Bots/BroadcastTests.hs | the broadcast bot; skipped when `CI=true` |
|
||||
| `/SimpleX store service/` | Bots/StoreService/*Tests.hs | configuration, web server and schema, catalog, groups, invoice waiters, payment providers, store receipts; the providers are local fakes (`Fake*.hs`) |
|
||||
| `/SimpleX store service e2e/` | Bots/StoreService/BotTests.hs, GroupIntegrationTests.hs | the store service bot with chat clients |
|
||||
| `/Schema dump/`<br>`/Postgres schema dump/`<br>`/Bot API docs/`<br>`/Save query plans/` | SchemaDump.hs, PostgresSchemaDump.hs, APIDocs.hs | [committed files](#checks-against-committed-files) |
|
||||
|
||||
### Chat scenario tests
|
||||
|
||||
- Checked: chat cores of several clients connected through a test SMP server, by the terminal output of each client, and by queries of a client's database for a state absent from the output.
|
||||
- Pattern, registered with `it "<name>" testDirectMessage` in the spec of its module:
|
||||
|
||||
```haskell
|
||||
testDirectMessage :: HasCallStack => TestParams -> IO ()
|
||||
testDirectMessage =
|
||||
testChat2 aliceProfile bobProfile $ \alice bob -> do
|
||||
connectUsers alice bob
|
||||
alice #> "@bob hello"
|
||||
bob <# "alice> hello"
|
||||
```
|
||||
|
||||
- Helpers of [ChatClient.hs](../../tests/ChatClient.hs) and [ChatTests/Utils.hs](../../tests/ChatTests/Utils.hs):
|
||||
|
||||
| Helper | Use |
|
||||
|---|---|
|
||||
| `testChat2` … `testChat5`, `testChatCfgOpts2` | clients with new databases |
|
||||
| `withNewTestChat`, `withTestChat` | one client with a new database; a restart with its database |
|
||||
| `withNewTestChatCfgOpts` | a client with a `ChatConfig` and `ChatOpts`, such as `chatHooks` or `markRead = False` |
|
||||
| `connectUsers`, `createGroup2`, `createGroup3` | a contact; a group of 2 or 3 members |
|
||||
| `##>`, `#>`, `send` | a command and its echo; a message and its sent item, time removed; a command alone |
|
||||
| `<##`, `<#`, `<##.`, `.<##` | the next line; the next line, time removed; its prefix; its suffix |
|
||||
| `<###`, `concurrentlyN_` | lines in any order; lines of several clients at once |
|
||||
| `#$>` | a command and a function of its output line, as in `("/_get chat @2 count=100", chat, [...])` |
|
||||
| `withCCTransaction`, `shouldEventuallyReturn` | a query of the client's database; a value polled for 20 s |
|
||||
| `withXFTPServer`, `withSmpServer'`, `withSmpServerAndNames` | an XFTP server; another SMP server; an SMP server with a names resolver |
|
||||
| `versionTestMatrix2`, `testCfgVPrev`, `testCfgV1` | clients of the previous and of the first supported versions |
|
||||
| `withTestOutput` | the terminal output of the clients printed |
|
||||
|
||||
- Run: `/SimpleX chat client/<area> tests/`, for example `/SimpleX chat client/group tests/`.
|
||||
- CI: build-linux, step "Run tests".
|
||||
- Pitfalls:
|
||||
- The output of every client is read to its end: a test fails when a client prints a line within 0.1 s after the test (`<//` in `testChatN` and the `with…TestChat…` brackets).
|
||||
- The lines of one client are read in order; the lines of several clients are awaited with `concurrently_` or `concurrentlyN_`.
|
||||
- A test fails when a line is awaited for 20 s (`getTermLine'`) and when it runs longer than 180 s (`it` of ChatTests/Utils.hs, imported in place of hspec's).
|
||||
- Each test has its own ports (`withPortBase`): the ports 7001–7003 of server addresses in `ChatOpts` are mapped to them (`testPortsCfg`), and `smpServerStr`, `smpServer2Str` and `xftpServerStr` return the addresses for commands and expected lines.
|
||||
- One SMP server is started per test by `testBracket` of Test.hs; XFTP and other servers are started by the test.
|
||||
|
||||
### Unit tests
|
||||
|
||||
- Checked: functions and encodings of the core, in the [suites](#suites) without clients.
|
||||
- Pattern: a `Spec` of `describe` and `it` with hspec expectations, as in [ViewTests.hs](../../tests/ViewTests.hs) and [ProtocolTests.hs](../../tests/ProtocolTests.hs).
|
||||
- Pitfall: in MobileTests, the expected JSON is the Swift form on macOS with the `swift` flag and the tagged form otherwise; both forms are in JSONFixtures.hs.
|
||||
|
||||
### Checks against committed files
|
||||
|
||||
Each of these tests writes its file, then compares the new text with the previous one: the first run after a change of the text fails, and the next passes. The rewritten file is reviewed and committed with the change.
|
||||
|
||||
| Pattern | Written | Source |
|
||||
|---|---|---|
|
||||
| `/Bot API docs/` | bots/api/COMMANDS.md, EVENTS.md, TYPES.md<br>packages/simplex-chat-client/types/typescript/src/*.ts<br>packages/simplex-chat-python/src/simplex_chat/types/_*.py | the API docs in bots/src/API/Docs (`testGenerate` in [APIDocs.hs](../../tests/APIDocs.hs)) |
|
||||
| `/Schema dump/` | src/Simplex/Chat/Store/SQLite/Migrations/chat_schema.sql | SQLite migrations, dumped with `sqlite3` |
|
||||
| `/Postgres schema dump/` | src/Simplex/Chat/Store/Postgres/Migrations/chat_schema.sql | PostgreSQL migrations, dumped with `pg_dump` |
|
||||
| `/Save query plans/` | chat_query_plans.txt and agent_query_plans.txt in src/Simplex/Chat/Store/SQLite/Migrations | the queries recorded in the run (`chatQueryStats`, `agentQueryStats`) |
|
||||
| recording tests | tests/fixtures/api | [app fixtures](#app-fixtures) |
|
||||
|
||||
- Bot API docs also fail on a command, response or event of the API that is neither documented in bots/src/API/Docs nor listed in `cliCommands`, `undocumentedCommands`, `undocumentedResponses` or `undocumentedEvents`, on a type of a documented one missing from Docs/Types.hs, and on a documented command without responses. They run with GHC 9.6 and later (`MIN_VERSION_base(4,18,0)`), in SQLite builds.
|
||||
- Schema dump also checks down migrations (exceptions in `skipComparisonForDownMigrations`), STRICT tables, and the output of `.lint fkey-indexes` against chat_lint.sql, an empty file, so that the test fails for a foreign key without an index.
|
||||
- Save query plans is skipped when `CI=true`. The plans are of the queries of that run only, so the files are committed from a local run of the whole suite.
|
||||
|
||||
### PostgreSQL
|
||||
|
||||
- Run:
|
||||
|
||||
```sh
|
||||
cabal test simplex-chat-test --constraint 'simplexmq +client_postgres' --constraint 'simplex-chat +client_postgres' --ghc-options=-O0 --test-option=-m --test-option='/SimpleX chat client/'
|
||||
```
|
||||
|
||||
The flags `client_postgres` of simplexmq and simplex-chat, as in scripts/desktop/build-lib-linux.sh; `dbPostgres` is defined for the tests.
|
||||
- Needed: a PostgreSQL server that accepts the role `postgres` without a password, and `pg_dump`. The role `test_chat_user` and the database `test_chat_db` are created at the start of a run and dropped at its end (`withTestDB` in Test.hs); each client has its own schema, dropped after each test (`dropTestSchemas` in ChatClient.hs).
|
||||
- Left out of PostgreSQL builds: Schema dump, Bot API docs, WebRTC encryption, Mobile API Tests, both names suites, Save query plans.
|
||||
- CI: local runs only; build.yml builds the PostgreSQL library for releases (build-linux-postgres).
|
||||
- Pitfall: the Postgres schema dump calls `sed -i ''` (BSD sed) unless `CI=true`.
|
||||
|
||||
## App fixtures
|
||||
|
||||
The core's responses and events are recorded by core tests in [tests/fixtures/api](../../tests/fixtures/api) and replayed by Kotlin and iOS tests in place of the core library, so that app code is tested on the output of the current core.
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
CT["core test<br>tests/ChatTests"] -->|"apiFixture<br>eventsFixture"| F["tests/fixtures/api"]
|
||||
F --> T["Kotlin desktopTest<br>iOS SimpleX Unit Tests"]
|
||||
T -->|"recorded responses<br>in place of the core"| V["app functions and views"]
|
||||
T -->|"recorded events"| P["processReceivedMsg"]
|
||||
V --> M["ChatModel, alerts, notifications"]
|
||||
P --> M
|
||||
```
|
||||
|
||||
### Recording
|
||||
|
||||
Helpers of [ChatTests/Utils.hs](../../tests/ChatTests/Utils.hs), called in a chat scenario test:
|
||||
|
||||
| Helper | Written to `tests/fixtures/api/<fixture>.json` |
|
||||
|---|---|
|
||||
| `apiFixture fixture cc placeholders FixtureRequests {frCommands, frMarkdown, frUris}` | an object with `commands`, `markdown` and `uris`, keyed by the request: the response to each command, encoded by `chatSendCmd` of the core library's API; `chatParseMarkdown` of each text; `chatParseUri` of each link |
|
||||
| `nameFixture fixture cc name` | `apiFixture` of `/_connect plan 1 <name>` and of the markdown of the name, in `names/` |
|
||||
| `eventsFixture fixture events steps` | an array of the events appended by `recordItemEvent events`, in `eventHook` of `chatHooks`, during `steps`: `newChatItems` and `chatItemUpdated`, encoded as `chatRecvMsg` encodes them |
|
||||
| `nameMovedFixture` | a `nameMoved` event, built from the IDs of the named contacts and groups |
|
||||
|
||||
Examples: `testPlanKnownNameAvailable` in ChatTests/Names.hs, `testDirectMessageUpdatePrevItem` and `testMissedCall` in ChatTests/Direct.hs.
|
||||
|
||||
Stable recordings:
|
||||
|
||||
- Values of each run are replaced by `stableJSON`:
|
||||
|
||||
| Fields | Replaced by |
|
||||
|---|---|
|
||||
| `createdAt`<br>`updatedAt`<br>`chatTs`<br>`userMemberProfileSentAt`<br>`itemTs` | `1970-01-01T00:00:00Z` |
|
||||
| `agentConnId`<br>`xContactId`<br>`connFullLink`<br>`connShortLink`<br>`contactLink`<br>`groupLink`<br>`viaGroupLinkUri`<br>`simplexUri`<br>`memberId`<br>`memberPubKey`<br>`publicGroupId`<br>`businessId`<br>`customerId`<br>`itemSharedMsgId` | the field name |
|
||||
| `groupRelays` | `"groupRelay"` per element |
|
||||
|
||||
A field with a new value in each run is added to this list.
|
||||
- Strings of the test, such as links, are replaced by the `placeholders` of `apiFixture`, in keys and values: `[(cLink, "CONTACT_LINK")]` in `testPlanAddressContactViaAddress`, so that the app test connects to `CONTACT_LINK`.
|
||||
- The recorded state is awaited first: the response to an update is recorded after the item status in the database is `snd_rcvd ok complete` (`shouldEventuallyReturn` in `testDirectMessageUpdatePrevItem`), and the steps of `eventsFixture` end after the expected number of events (`testMissedCall`).
|
||||
- The client whose events are recorded has `markRead = False`: the CLI marks received items read when it prints them (`runTerminalOutput` in src/Simplex/Chat/Terminal/Output.hs), while the apps receive unread items.
|
||||
- Recordings are in the tagged JSON form of builds without the `swift` flag.
|
||||
|
||||
### Replay
|
||||
|
||||
| | Kotlin, common/src/commonMain | iOS |
|
||||
|---|---|---|
|
||||
| Commands | `chatSendCmdRetry`, platform/Core.kt | `sendSimpleXCmdStr`, SimpleXChat/API.swift |
|
||||
| Markdown | `chatParseMarkdown`, platform/Core.kt | `parseSimpleXMarkdownText`, SimpleXChat/API.swift |
|
||||
| Links | `chatParseUri`, platform/Core.kt | `parseSanitizeUri`, SimpleXChat/API.swift |
|
||||
| Events | `ChatController.processReceivedMsg`, model/SimpleXAPI.kt | `processReceivedMsg`, Shared/Model/SimpleXAPI.swift |
|
||||
| Notifications | `ntfManager`, platform/NtfManager.kt | `NtfManager.shared`, Shared/Model/NtfManager.swift |
|
||||
| Recording read by | `fixtureText` | `fixtureJSON`, then `singleFieldJSON` to the Swift JSON form |
|
||||
| Tests | [NameAlertsTest.kt](../../apps/multiplatform/common/src/desktopTest/kotlin/chat/simplex/app/NameAlertsTest.kt), [ChatItemUpdateTest.kt](../../apps/multiplatform/common/src/desktopTest/kotlin/chat/simplex/app/ChatItemUpdateTest.kt) | [NameAlertsTests.swift](../../apps/ios/SimpleX%20Unit%20Tests/NameAlertsTests.swift), [ChatItemUpdateTests.swift](../../apps/ios/SimpleX%20Unit%20Tests/ChatItemUpdateTests.swift) |
|
||||
|
||||
- Pattern: `recorded(fixture)` in the NameAlerts tests sets the first three seams to lookups in the recording; the test fails at tear-down on a request without a recorded response, unless the request is checked with `assertRequested`. The ChatItemUpdate tests decode the recorded events, pass each to `processReceivedMsg` and compare `ChatModel`. Tear-down restores the seams and clears the model.
|
||||
- Run and CI: [Kotlin apps](#kotlin-apps), [SimpleX Unit Tests](#simplex-unit-tests). CI runs the kotlin and ios scopes for a change in tests/fixtures/api (`BUILD_CHANGES` in scripts/ci/packages_release.py). The recording tests are core tests, selected in the `ci-tests` block by the patterns of the [CI guide, core](../../scripts/ci/README.md#core).
|
||||
- Pitfalls:
|
||||
- `singleFieldJSON` converts each object with a `type` field, except `MsgContent`, recognized by its tags. The core encodes other types with `type` in both JSON forms: the types of `taggedObjectJSON` in src, such as `MsgChatLink`, `LinkContent`, `MsgScope` and `ChatBotCommand`, and `MsgReaction`, by its own instance. A recording with them requires another conversion rule.
|
||||
- The tests use the app's singletons, such as `ChatModel` and `AlertManager`: each test restores what it changes.
|
||||
- The core is reached only through the replaced seams: the Kotlin test JVM does not load the core library, and the iOS app host in CI is linked with stub libraries.
|
||||
|
||||
## Kotlin apps
|
||||
|
||||
In apps/multiplatform:
|
||||
|
||||
| Source set | Gradle task | Contents |
|
||||
|---|---|---|
|
||||
| common/src/commonTest | `:common:desktopTest` | tests of common code (kotlin.test) |
|
||||
| common/src/desktopTest | `:common:desktopTest` | JVM tests: Compose views with `runComposeUiTest`, layout positions with `renderScene` and `Modifier.record` ([LayoutRecorder.kt](../../apps/multiplatform/common/src/desktopTest/kotlin/chat/simplex/app/LayoutRecorder.kt)), files with `withTempDir`, [app fixtures](#app-fixtures), [snapshots](#desktop-snapshots) |
|
||||
| android/src/test | `:android:testFossDebugUnitTest` | a template test, `ExampleUnitTest` |
|
||||
| android/src/androidTest | `connectedFossDebugAndroidTest`, with a device or an emulator | a template test, `ExampleInstrumentedTest` |
|
||||
|
||||
- Run: `./gradlew :common:desktopTest`; one class: `./gradlew :common:desktopTest --tests chat.simplex.app.ChatItemUpdateTest`. The CI command: [CI guide, kotlin](../../scripts/ci/README.md#kotlin).
|
||||
- CI: build.yml, step "Build and test Kotlin apps" (kotlin scope); desktop-linux, app job.
|
||||
- Pitfalls:
|
||||
- The working directory is apps/multiplatform/common: recordings are read from `../../../tests/fixtures/api`, sources from `src/`.
|
||||
- The tests use the app's singletons, such as `ChatModel`, `appPrefs` and `simplexWindowState`: they are restored in `@AfterTest`.
|
||||
- The test JVM does not load the core library: code that calls it is tested with the replaced seams of [app fixtures](#replay).
|
||||
|
||||
### Desktop snapshots
|
||||
|
||||
- Checked: each `@Preview` of commonMain and desktopMain, rendered in the light and dark themes by `SnapshotTest` ([SnapshotTest.kt](../../apps/multiplatform/common/src/desktopTest/kotlin/chat/simplex/app/SnapshotTest.kt)), equals its reference in [common/src/desktopTest/snapshots](../../apps/multiplatform/common/src/desktopTest/snapshots), within 8 of 255 per colour channel ([snapshots-compare.py](../../scripts/ci/snapshots-compare.py)).
|
||||
- Write: a new `@Preview` is added to `previewScenes`, with `chatItemFontScales` for a chat item, or to `previewsCallingCore` when its layout calls the core library; `everyPreviewIsRendered` fails otherwise. A preview uses `previewDate` in place of the current time.
|
||||
- Record and check: with `scripts/ci/snapshots-remote.py desktop record`, desktop-linux renders the previews of the pushed branch, and the renders replace the references, for review and commit; with `check`, the renders that differ are listed.
|
||||
- Run, from apps/multiplatform, then from the repository root:
|
||||
|
||||
```sh
|
||||
SNAPSHOT_DIR=<absolute dir> ./gradlew -Psimplex.assets.dir=../../assets :common:desktopTest --tests chat.simplex.app.SnapshotTest
|
||||
python3 scripts/ci/snapshots-compare.py apps/multiplatform/common/src/desktopTest/snapshots <absolute dir> <diff dir>
|
||||
```
|
||||
|
||||
- CI: desktop-linux, step "Compare snapshots"; in build.yml, the previews are rendered without a comparison.
|
||||
- Details: [desktop-linux README](../../scripts/ci/desktop-linux/README.md), "Snapshots".
|
||||
|
||||
## iOS app
|
||||
|
||||
In apps/ios, SimpleX.xcodeproj:
|
||||
|
||||
| Target | Kind | Scheme | CI |
|
||||
|---|---|---|---|
|
||||
| SimpleX Unit Tests | unit tests hosted by the app | SimpleX Unit Tests | build.yml, build-ios, step "Run iOS unit tests" (ios scope) |
|
||||
| SimpleX Snapshots | unit tests hosted by the app: preview renders and tests of a running chat | SimpleX (iOS) | ios-sim, after the smoke test |
|
||||
| Tests iOS | UI tests of Xcode's template | SimpleX (iOS) | local runs only |
|
||||
|
||||
A new test file is added to its target in project.pbxproj: a PBXBuildFile, a PBXFileReference, the target's group and its Sources phase.
|
||||
|
||||
### SimpleX Unit Tests
|
||||
|
||||
- Checked: app code on [app fixtures](#app-fixtures) and other logic of the app.
|
||||
- Write: an `XCTestCase` in [apps/ios/SimpleX Unit Tests](../../apps/ios/SimpleX%20Unit%20Tests); `fixtureJSON`, `singleFieldJSON` and `waitFor` are at file scope of NameAlertsTests.swift.
|
||||
- Run, on macOS: `scripts/ci/ios-stub-libs.sh`, then the `xcodebuild test` command of the step "Run iOS unit tests" of build-ios in build.yml; or Product > Test with the scheme SimpleX Unit Tests.
|
||||
- Pitfalls:
|
||||
- The stubs replace the libraries in apps/ios/Libraries/sim, where scripts/ios/prepare.sh puts the core built for the simulator.
|
||||
- With the stubs, the app opens its database error screen and calls the core no more.
|
||||
- The tests run with `-testLanguage en -testRegion US`; a test of dates sets `NSTimeZone.default` to UTC.
|
||||
|
||||
### SimpleX Snapshots
|
||||
|
||||
- Checked: each `PreviewProvider` of apps/ios, rendered in the light and dark themes, equals its reference in [References](../../apps/ios/SimpleX%20Snapshots/References), within 8 of 255 per colour channel; previews marked `allSizes` are rendered at three content sizes. [SnapshotTests.swift](../../apps/ios/SimpleX%20Snapshots/SnapshotTests.swift) also contains assertion tests of layout functions, calls and VoIP pushes; the VoIP push tests require a running chat (`waitUntilChatActive`).
|
||||
- Write: a new `PreviewProvider` is added to `previewScenes()`, or to `EXCLUDED` of [check-previews.py](../../apps/ios/SimpleX%20Snapshots/check-previews.py) when its renders differ between runs; check-previews.py fails on a `#Preview`. A preview uses `previewDate` in place of the current time.
|
||||
- Record and check: `scripts/ci/snapshots-remote.py ios record|check`, as for [desktop](#desktop-snapshots).
|
||||
- Run, from the repository root, with the core in apps/ios/Libraries/sim and a simulator where the app has a running chat: `SIM_UDID=<udid> scripts/ci/ios-sim/snapshots.sh <derived data> <out dir>` ([snapshots.sh](../../scripts/ci/ios-sim/snapshots.sh)).
|
||||
- CI: build-ios runs check-previews.py; ios-sim renders and compares at the end of the smoke test, whose step fails on a difference.
|
||||
- Details: [ios-sim README](../../scripts/ci/ios-sim/README.md), "Snapshots".
|
||||
|
||||
### Tests iOS
|
||||
|
||||
Xcode's UI test template: `testExample` launches the app, `testLaunchPerformance` measures its launch, `testLaunch` attaches a screenshot of the launch screen. It is in the test action of the scheme SimpleX (iOS), with SimpleX Snapshots: `xcodebuild test -scheme "SimpleX (iOS)"` of [apps/ios/README.md](../../apps/ios/README.md) runs both.
|
||||
|
||||
## App workflows
|
||||
|
||||
The app built from a branch, its core included, driven on a device by scripts and, on request, by Claude following a test plan, with an optional test backend (relay, directory, names server, peers).
|
||||
|
||||
| Workflow | App | Smoke test | Claude plan | README |
|
||||
|---|---|---|---|---|
|
||||
| `ios-sim` | iOS app in an iPhone simulator | onboarding<br>images sent in a group<br>snapshots | device-test-plan.md, cases per layout in claude-scope | [ios-sim](../../scripts/ci/ios-sim/README.md) |
|
||||
| `desktop-linux` | desktop app on a virtual display, Ubuntu | desktopTest with snapshots<br>onboarding<br>a local group<br>both layouts<br>images sent | claude-test.md, claude-scope | [desktop-linux](../../scripts/ci/desktop-linux/README.md) |
|
||||
| `android-emu` | debug APK in an Android emulator | onboarding<br>a local group<br>both layouts<br>images sent | claude-test.md, claude-scope | [android](../../scripts/ci/android/README.md) |
|
||||
|
||||
- Write: a scripted case in the workflow's `smoke-test.sh`, with its `ui` driver; a Claude plan in the files of the table, with `backend: yes` in claude-scope when the cases use the test backend.
|
||||
- Run: by hand only, on any branch: [CI guide, Starting a run](../../scripts/ci/README.md#starting-a-run). Each run uploads the app for manual tests.
|
||||
- Pitfalls:
|
||||
- A run with `claude` and `backend: yes` in claude-scope also requires the input `backend`, or its plan job fails.
|
||||
- A Claude run requires the branch rule of the GitHub environment `app-sim-claude` to include the branch.
|
||||
- The Android app runs under ARM translation: with the input `release`, the released app runs in the same emulator, to tell an app failure from the emulator's.
|
||||
|
||||
## Packages and other scopes
|
||||
|
||||
| Scope | Tests | Run |
|
||||
|---|---|---|
|
||||
| packages: Node.js library | [packages/simplex-chat-nodejs/tests](../../packages/simplex-chat-nodejs/tests), jest:<br>unit tests `*.unit.test.ts`, with `core` functions mocked<br>tests of the add-on and of library downloads<br>live tests with a local smp-server (`describeIfSmpServerAvailable`: `SMP_SERVER`, or a download on Linux) | `scripts/ci/package-tests.sh build linux-x86_64`<br>`scripts/ci/package-tests.sh test` |
|
||||
| packages: Python library | [packages/simplex-chat-python/tests](../../packages/simplex-chat-python/tests), pytest, with a fake libsimplex (`FakeLib`) | as above |
|
||||
| packages: TypeScript types | generated by [Bot API docs](#checks-against-committed-files), compiled by package-tests.sh | as above |
|
||||
| mcp | [packages/simplex-chat-mcp/test](../../packages/simplex-chat-mcp/test), jest:<br>`test/unit`<br>`test/e2e`, with a local smp-server and xftp-server<br>manual checks: [TESTING.md](../../packages/simplex-chat-mcp/TESTING.md) | `scripts/ci/scope-tests.sh mcp` |
|
||||
| support-bot | [apps/simplex-support-bot/bot.test.ts](../../apps/simplex-support-bot/bot.test.ts), vitest, with `simplex-chat` and `@simplex-chat/types` replaced by test/__mocks__ | `scripts/ci/scope-tests.sh support-bot` |
|
||||
| support-bot-light | [apps/simplex-support-bot-light/tests](../../apps/simplex-support-bot-light/tests), pytest, with `FakeChatApi` of conftest.py; ruff, pyright | `scripts/ci/scope-tests.sh support-bot-light` |
|
||||
| website | [website/test](../../website/test), `node --test` of src/js/simplex-lib.jsc | `npm test` in website |
|
||||
| badge-web | [apps/simplex-store-service/web/test](../../apps/simplex-store-service/web/test), `node --test` of the compiled tests, in UTC | `npm ci`, `npm test` in apps/simplex-store-service/web |
|
||||
| ci-scripts | [scripts/ci/test_packages_release.py](../../scripts/ci/test_packages_release.py), unittest of packages_release.py | `python3 scripts/ci/test_packages_release.py` |
|
||||
|
||||
CI of each scope: [CI guide, Scopes](../../scripts/ci/README.md#scopes). Scopes lacking CI tests, with tests run locally:
|
||||
|
||||
| Scope | Run | Notes |
|
||||
|---|---|---|
|
||||
| ts-client | `npm test` in packages/simplex-chat-client/typescript | prettier, eslint and jest; client.test.ts is skipped |
|
||||
| webrtc | `npm test` in packages/simplex-chat-webrtc | fullstack.test.js requires `SIMPLEX_CHAT` and `SMP_SERVER`, the paths of the chat CLI and of smp-server |
|
||||
| calculator-bot | `npm test` in apps/simplex-calculator-bot | calculatorBot.test.ts: smp-server from `SMP_SERVER` or a download on Linux, and tests/fixtures/tls |
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "simplex",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.1",
|
||||
"description": "Each Claude Code session gets its own SimpleX group. There you prompt the session, approve its actions and tool use, and read its answers.",
|
||||
"author": {"name": "SimpleX Chat", "url": "https://simplex.chat"},
|
||||
"homepage": "https://github.com/simplex-chat/simplex-chat/tree/stable/packages/simplex-chat-mcp#readme",
|
||||
|
||||
@@ -10,7 +10,32 @@ With this package, Claude Code can join channels and groups, talk to bots, and e
|
||||
<img src="https://raw.githubusercontent.com/simplex-chat/simplex-chat/master/packages/simplex-chat-mcp/images/session.png" alt="The group of a Claude Code session in the SimpleX app: a prompt, Claude's answer, and its requests to run commands, which one tap approves" width="320">
|
||||
</p>
|
||||
|
||||
## Run Claude Code from the app
|
||||
🏗️ marks what is on the [roadmap](https://github.com/simplex-chat/simplex-chat/blob/master/packages/simplex-chat-mcp/ROADMAP.md).
|
||||
|
||||
## Use your agents in private chats, with the full chat UX
|
||||
|
||||
- No phone number, email or account. Agents have their own profile, without access to your other chats.
|
||||
- Send prompts with images and files, and see answers live. Terminal prompts sent to the chat too.
|
||||
- Reply and edit messages, send reactions.
|
||||
- Sessions use flat layout.
|
||||
- 🏗️ Voice messages, code highlighting, widgets, etc.
|
||||
|
||||
## Work with others in the same session
|
||||
|
||||
- Invite people to the Main group, and they join any session's group.
|
||||
- Only owners and admins can approve tool calls.
|
||||
- The Main group shows every session's state.
|
||||
- 🏗️ Each session as a topic in one group.
|
||||
- 🏗️ Agent teams: mention an agent to message it.
|
||||
|
||||
## Control your agents' activity
|
||||
|
||||
- Agents ask before they act in other chats or use a tool such as Bash.
|
||||
- A live stream of agent's work: tasks, tool calls, etc.
|
||||
- Session and machine status.
|
||||
- 🏗️ Code diffs, almost every waiting state answered from the chat, etc.
|
||||
|
||||
## Start
|
||||
|
||||
You need Node.js 22 or later, Claude Code, and the [SimpleX Chat app](https://simplex.chat/downloads/) 7.1 or later.
|
||||
|
||||
@@ -27,41 +52,25 @@ You need Node.js 22 or later, Claude Code, and the [SimpleX Chat app](https://si
|
||||
claude --dangerously-load-development-channels plugin:simplex@simplex-chat
|
||||
```
|
||||
|
||||
If you don't want to run SimpleX MCP as a channel, start `claude` without the flag to use it as an MCP server. [Read more](https://github.com/simplex-chat/simplex-chat/blob/master/packages/simplex-chat-mcp/REFERENCE.md#install).
|
||||
Scan the QR code with the SimpleX app and tap Join: the Main group "Claude Control" appears. The first start downloads the SimpleX core library, so the QR code can take a minute.
|
||||
|
||||
Scan the QR code with the SimpleX app and tap Join. The group "Claude Control" appears. At the first start the plugin downloads the SimpleX core library, so the QR code can take a minute. If you close Claude Code before then, the next start shows it.
|
||||
3. Each Claude Code session gets its own group, such as "1 · my-project". Join it from the invitation in "Claude Control", and send prompts there.
|
||||
|
||||
On several machines or containers, set `SIMPLEX_MCP_MACHINE` on each, for example `SIMPLEX_MCP_MACHINE=laptop`, to name its group "Claude Control - laptop".
|
||||
|
||||
3. Each Claude Code session gets its own group, such as "1 · my-project". Join it from the invitation in "Claude Control". A list there shows every session and its state: working, waiting for you or idle.
|
||||
|
||||
4. Send prompts in the session's group, and Claude answers there, live as it writes. The answer's last message ends with a line in small print with the turn's time and tokens and the machine's free memory and disk, such as `Done in 2 min 51 s · 16K output tokens · 673K tokens in context · RAM 12 GB free · disk 3.4 GB free❗️`, with ❗️ when one runs low. A switch of the model or the effort level appears as one line. Reply to a message to show Claude which one you mean. Claude also gets your reactions, as emoji replies, and the new text of a prompt you edit. Prompts you type in the terminal appear there too, and Claude Code's own prompts, such as a finished background task, appear as one line each. Each step of Claude's work, such as running the tests, appears as one line, completed with its outcome when the step ends. A line also shows when Claude Code summarises the session's context. Before Claude acts in other chats or uses a tool such as Bash, it asks in the group, and one tap approves. Another tap approves the tool for the rest of the session.
|
||||
|
||||
5. Optionally, add your plan's 5-hour and weekly usage to the last line of each answer, and get a status line in the terminal, with this setting in `~/.claude/settings.json`. It replaces a status line of your own. [Read more](https://github.com/simplex-chat/simplex-chat/blob/master/packages/simplex-chat-mcp/REFERENCE.md#status-line).
|
||||
|
||||
```json
|
||||
"statusLine": {"type": "command", "command": "node \"${SIMPLEX_MCP_HOME:-$HOME/.simplex-mcp}/status-line.js\""}
|
||||
```
|
||||
[REFERENCE.md](https://github.com/simplex-chat/simplex-chat/blob/master/packages/simplex-chat-mcp/REFERENCE.md) covers the plugin without the channel, several machines or containers, the status line, options, recovery and security.
|
||||
|
||||
## Safety
|
||||
|
||||
- Anyone in "Claude Control" can join your sessions as an admin, so only invite people you trust.
|
||||
- In a session, admins and owners can prompt Claude and approve what it does. Other members can only prompt, and observers can only read.
|
||||
- In a session, admins and owners can prompt the agent and approve what it does. Other members can only prompt, and observers can only read.
|
||||
- A tool approved for the session runs without asking until the session ends or `/revoke`. Claude Code still asks where its own rules require it, such as before a change to `.git` or `.bashrc`.
|
||||
- Claude Code doesn't run `!` or `/` commands sent in the group.
|
||||
- Claude sends files to the group only if the group allows them.
|
||||
- Claude has no SimpleX address, so nobody can contact it first.
|
||||
- Agents send files to the group only if the group allows them.
|
||||
- Agents have no SimpleX address, so nobody can contact them first.
|
||||
|
||||
## Only Claude Code, for now
|
||||
|
||||
The agent is tested with Claude Code. Tell us which other apps and models you want to use in [an issue](https://github.com/simplex-chat/simplex-chat/issues), or contribute.
|
||||
|
||||
## Reference
|
||||
|
||||
[REFERENCE.md](https://github.com/simplex-chat/simplex-chat/blob/master/packages/simplex-chat-mcp/REFERENCE.md) covers the plugin's options, recovery and security. It also explains shared settings for several machines or containers, and running the agent as an MCP server without the channel.
|
||||
|
||||
What comes next: [Roadmap](https://github.com/simplex-chat/simplex-chat/blob/master/packages/simplex-chat-mcp/ROADMAP.md).
|
||||
|
||||
## Own a part of SimpleX
|
||||
|
||||
Business is moving into messages, and AI agents follow: an agent can ask a company's agent in a chat instead of opening the company's website, and buy there too. These chats hold plans, purchases and accounts, so with AI everyone feels the need for private and secure communication.
|
||||
|
||||
@@ -299,7 +299,7 @@ Six tools:
|
||||
|---|---|
|
||||
| `connect` | Joins a contact, bot, business, group or channel by a link or a SimpleX name, as the agent's profile or incognito. Returns the chat, its profile, welcome message, the commands a bot advertises, and the messages so far. |
|
||||
| `send` | Sends a message, with a file of this computer when asked, and returns every message received in that chat after it, until none arrives for `idle` seconds (30 by default). A directory bot's search results arrive this way. |
|
||||
| `receive` | Returns the chat's unread messages and those that arrive while it waits, waiting for one when asked. |
|
||||
| `receive` | Returns the chat's unread messages and those that arrive while it waits, waiting for one when asked. With `history`, it also returns up to 50 messages before the new ones, the agent's own included. |
|
||||
| `download` | Downloads the file of a received message to the data folder and returns its full path. |
|
||||
| `list` | Lists the agent's chats with unread counts and `approved: true` for chats approved for all messages, and its actions without a result. |
|
||||
| `leave` | Deletes a contact, or leaves a group, business chat or channel, and deletes the chat; the contact or the members are notified. |
|
||||
@@ -348,6 +348,8 @@ answer each one in that chat, and call receive again after every answer, until I
|
||||
|
||||
Approve the connection in "My Agent", and accept the request in the app if it asks. On the card of the agent's first answer, tap `all`: its later answers to you need no approval.
|
||||
|
||||
In a new Claude Code session, give the same prompt again. The agent can recall the conversation: `receive` with `history` returns up to 50 earlier messages of that chat, its own answers included.
|
||||
|
||||
## Several agents
|
||||
|
||||
Each agent is its own process, with its own data folder, port, agent control chat and Claude Code server:
|
||||
@@ -367,6 +369,7 @@ Add an entry with the URL `http://127.0.0.1:5226/mcp` and the header `Authorizat
|
||||
|---|---|
|
||||
| The server was not running when Claude Code started | Start the server, then run `/mcp reconnect all` in Claude Code (2.1.284 or later). |
|
||||
| The server restarted while Claude Code was running | Claude Code reconnects up to five times within about 30 seconds. After that, in an interactive session, run `/mcp reconnect all`; `claude -p` runs and Agent SDK sessions keep retrying for about half an hour. Open calls fail, and pending actions are cancelled; the agent's repeated call creates a new request. |
|
||||
| The Claude Code session ended or was compacted | Ask the agent to recall the chat: `receive` with `history` returns up to 50 messages before the new ones, the agent's own included. |
|
||||
| A second server was started on the same data folder | It exits with `Another server uses <folder> (PID N). If no server runs, remove <folder>/lock.` |
|
||||
| Every owner left the agent control chat or was removed | `connect`, `send`, `download` and `leave` fail. Without `--owners`, the server logs `No owners in the agent control chat.` and prints a new link; join with it. With an `--owners` list, the agent posts and the server logs `No owners remain: restart the server with --reset-owners --owners`. |
|
||||
| The agent was removed from the agent control chat, the chat was deleted, or the agent lost its owner role | `connect`, `send`, `download` and `leave` fail, and the server logs `The agent lost its control chat. Restart the server with --reset-owners.` |
|
||||
@@ -576,18 +579,20 @@ Only you see this link: it never enters Claude's context or tool results. Scan t
|
||||
After the first owner joins, Claude posts the list of sessions in the Main group, after its greeting:
|
||||
|
||||
```
|
||||
🟠 3 · simplex-chat: working
|
||||
🔵 6 · website: waiting for you, 2 approvals
|
||||
🔵 7 · docs: waiting for you in Claude Code
|
||||
🟢 8 · app: idle
|
||||
🟢 3 · simplex-chat: working
|
||||
🟠 6 · website: waiting for you, 2 approvals
|
||||
⛔️ 7 · docs: waiting for you in Claude Code
|
||||
🔴 8 · app: idle
|
||||
⚙️ 9 · api: working in the background
|
||||
⚪ Not running: 5 · bio, 4 · notes, 2 · openclaw, 1 · first
|
||||
```
|
||||
|
||||
- A session is running while its Claude Code runs, or while cards wait for a decision in its group. Each running session has a line, by number:
|
||||
- `🔵 N · NAME: waiting for you, K approvals`: K cards wait in the session's group. A tool-use card counts only while Claude Code shows its permission dialog, or while Claude Code's state can't be read.
|
||||
- `🔵 N · NAME: waiting for you in Claude Code`: Claude Code waits for an answer in its own window, such as a dialog.
|
||||
- `🟠 N · NAME: working`: Claude Code works on a turn, or a subagent works for it.
|
||||
- `🟢 N · NAME: idle`: Claude Code waits for the next prompt, also while a background command runs.
|
||||
- A session is running while its Claude Code runs, or while cards wait for a decision in its group. Each running session has a line, by number. Green is the state to keep:
|
||||
- `🟢 N · NAME: working`: Claude Code works on a turn, or a subagent works for it.
|
||||
- `🟠 N · NAME: waiting for you, K approvals`: K cards wait in the session's group, for a decision in the chat. A tool-use card counts only while Claude Code shows its permission dialog, or while Claude Code's state can't be read.
|
||||
- `⛔️ N · NAME: waiting for you in Claude Code`: Claude Code waits for an answer in its own window, such as a dialog, which the chat can't give.
|
||||
- `⚙️ N · NAME: working in the background`: Claude Code waits for the next prompt while a background command runs. The command's end starts a turn without a prompt.
|
||||
- `🔴 N · NAME: idle`: Claude Code waits for the next prompt, and nothing runs.
|
||||
- `▶️ N · NAME: running`: Claude Code's state can't be read.
|
||||
- The last line names every other session of the data folder, newest first. Without any session, the list is `No sessions.`
|
||||
- The states are Claude Code's own: the plugin reads them from Claude Code's record of its process, `sessions/PID.json` in `CLAUDE_CONFIG_DIR` or `~/.claude`.
|
||||
|
||||
@@ -15,17 +15,21 @@ What comes next for Claude Code in SimpleX Chat.
|
||||
|
||||
## In your sessions
|
||||
|
||||
- ✅ Reply to a message, and Claude knows which one you mean.
|
||||
- ✅ React to a message, and Claude sees your reaction.
|
||||
- ✅ Allow a tool for the rest of a session with one tap.
|
||||
- ✅ See when a session's context is summarised.
|
||||
- ✅ One list in the Main group shows every session and its state: working, waiting for you or idle.
|
||||
- See what Claude is doing while it works, with its code changes as diffs.
|
||||
- ✅ The model, effort and usage of each session show in its description, updated as they change.
|
||||
- ✅ React to a message, and Claude sees your reaction.
|
||||
- ✅ Reply to a message, and Claude knows which one you mean.
|
||||
- ✅ The model and effort of each session show in its description, updated as they change, and the usage of each turn in the last line of its answer.
|
||||
- ✅ See when a session's context is summarised.
|
||||
- ✅ Allow a tool for the rest of a session with one tap.
|
||||
- Each session is a topic inside one group, not a group of its own.
|
||||
- Claude can offer choices and other small interactive widgets in the chat.
|
||||
- Start a new session from the desktop app, in a folder you choose.
|
||||
- Send voice messages to Claude.
|
||||
- Delete your latest prompt, and Claude knows you withdrew it.
|
||||
- Answer from the chat almost every time Claude Code waits for you.
|
||||
|
||||
## More agents
|
||||
|
||||
- Codex and other agents, alongside Claude Code.
|
||||
- Claude's subagents and teammates join the session's group with their own profiles, and a mention of one by name sends it a message.
|
||||