From 94c19bea6b11dadef886e070e4490cb3886d544b Mon Sep 17 00:00:00 2001 From: Sebastian Hanss Date: Wed, 11 Jun 2025 00:23:18 +0200 Subject: [PATCH 1/6] feat(Root): show spinner while initializing and refactor auth redirect --- .../src/components/navigation/Root.tsx | 82 ++++++++++++------- 1 file changed, 53 insertions(+), 29 deletions(-) diff --git a/packages/frontend/src/components/navigation/Root.tsx b/packages/frontend/src/components/navigation/Root.tsx index 9bca1ce..234ac56 100644 --- a/packages/frontend/src/components/navigation/Root.tsx +++ b/packages/frontend/src/components/navigation/Root.tsx @@ -2,17 +2,18 @@ import React, { useEffect, useState } from "react"; import { Outlet, useNavigate } from "react-router-dom"; -import { i18n } from "@lingui/core"; // keep if you use programmatic i18n APIs -import { Trans } from "@lingui/react"; // keep if you’re using anywhere +import { i18n } from "@lingui/core"; +import { Trans } from "@lingui/react"; import { Layout } from "../../layout/Layout"; import { SystemContext } from "ts-actors-react"; -import { Button, Modal } from "react-bootstrap"; +import { Button, Modal, Spinner } from "react-bootstrap"; import { cookie } from "../../utils"; import { system } from "../../system"; import { ActorSystem } from "ts-actors"; import { Try, fromError, fromValue } from "tsmonads"; export const Root: React.FC = () => { + // 1) Keep the monadic Try so it matches your context type const [init, setInit] = useState>(fromError(new Error())); const [rpcError, setRpcError] = useState(""); const navigate = useNavigate(); @@ -22,57 +23,80 @@ export const Root: React.FC = () => { document.location.href = `${import.meta.env.VITE_BACKEND_URI}/auth/logout`; }; - // 1) Initialize the actor system once on mount + // 2) Bootstrap the actor system just once useEffect(() => { - const run = async () => { - try { - const s: ActorSystem = await system; - setInit(fromValue(s)); - } catch (e) { - setInit(fromError(e as Error)); - } - }; - run(); + system + .then(s => setInit(fromValue(s))) + .catch(err => setInit(fromError(err))); }, []); - // 2) After initialization, check the bearer cookie and redirect if missing + // 3) After a successful init, check for the bearer cookie and redirect if missing useEffect(() => { - if (init.isValue) { - if (!cookie("bearer")) { - navigate("/", { replace: true }); + init.match( + // onSuccess + () => { + if (!cookie("bearer")) { + navigate("/", { replace: true }); + } + }, + // onFailure + () => { + /* do nothing on failure; modal handle below */ } - } + ); }, [init, navigate]); - // 3) Handle any RPC‐level errors in a modal - if (rpcError !== "") { + // 4) If we hit an RPC error, show the modal + if (rpcError) { return ( setRpcError("")}> - Communication Error + + + - There was a problem communicating with the backend. +
- Please try again or contact support. +
); } - // 4) While the actor system is initializing, render nothing (or a spinner) - if (!init.isValue) { - return null; + // 5) While initializing, show a centered spinner + const ready = init.match(() => true, () => false); + if (!ready) { + return ( +
+ + + + + +
+ ); } - // 5) Once ready and authenticated, render the layout and child routes + // 6) Everything’s good: render your app return ( - + From 258d2a0e07dbad12290d06c01b19e945c9037e43 Mon Sep 17 00:00:00 2001 From: Sebastian Hanss Date: Wed, 11 Jun 2025 08:39:45 +0200 Subject: [PATCH 2/6] :chore: issues with auto-deploy on the test server --- .github/workflows/deploy-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-test.yml b/.github/workflows/deploy-test.yml index 270c150..6d73e33 100644 --- a/.github/workflows/deploy-test.yml +++ b/.github/workflows/deploy-test.yml @@ -29,5 +29,5 @@ jobs: echo "➡️ Starting remote deployment of branch '${BRANCH_NAME}'" ssh -o StrictHostKeyChecking=no \ ${{ secrets.TEST_SERVER_USER }}@${{ secrets.TEST_SERVER_HOST }} \ - "bash ~/deploy_recapp_to_test.sh \"${BRANCH_NAME}\"" + "bash ~/deploy_recapp_to_test.sh '${BRANCH_NAME}'" echo "✅ Remote deployment of branch '${BRANCH_NAME}' succeeded" From 94dc6019c0656e39bf87f90a3e79f18268763a22 Mon Sep 17 00:00:00 2001 From: Sebastian Hanss Date: Wed, 11 Jun 2025 08:52:24 +0200 Subject: [PATCH 3/6] =?UTF-8?q?=E2=9C=A8=20chore:=20issues=20with=20auto-d?= =?UTF-8?q?eploy=20to=20testserver?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-test.yml b/.github/workflows/deploy-test.yml index 6d73e33..4f3f1d0 100644 --- a/.github/workflows/deploy-test.yml +++ b/.github/workflows/deploy-test.yml @@ -29,5 +29,5 @@ jobs: echo "➡️ Starting remote deployment of branch '${BRANCH_NAME}'" ssh -o StrictHostKeyChecking=no \ ${{ secrets.TEST_SERVER_USER }}@${{ secrets.TEST_SERVER_HOST }} \ - "bash ~/deploy_recapp_to_test.sh '${BRANCH_NAME}'" - echo "✅ Remote deployment of branch '${BRANCH_NAME}' succeeded" + "bash ~/deploy_recapp_to_test.sh ${{ env.BRANCH_NAME }}" + echo "✅ Remote deployment of branch ${{ env.BRANCH_NAME }} succeeded" From 49977c69bc16b8ecb6baaeb7fbae7139f6262317 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Han=C3=9F?= Date: Wed, 11 Jun 2025 08:55:37 +0200 Subject: [PATCH 4/6] Update deploy-test.yml --- .github/workflows/deploy-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-test.yml b/.github/workflows/deploy-test.yml index 4f3f1d0..8ff351c 100644 --- a/.github/workflows/deploy-test.yml +++ b/.github/workflows/deploy-test.yml @@ -26,7 +26,7 @@ jobs: - name: Deploy ${{ env.BRANCH_NAME }} to test server run: | - echo "➡️ Starting remote deployment of branch '${BRANCH_NAME}'" + echo "➡️ Starting remote deployment of branch ${{ env.BRANCH_NAME }}" ssh -o StrictHostKeyChecking=no \ ${{ secrets.TEST_SERVER_USER }}@${{ secrets.TEST_SERVER_HOST }} \ "bash ~/deploy_recapp_to_test.sh ${{ env.BRANCH_NAME }}" From 64b6f3d5bdc74329a8526d3ce0a6cf84160d9888 Mon Sep 17 00:00:00 2001 From: Sebastian Hanss Date: Wed, 11 Jun 2025 09:30:48 +0200 Subject: [PATCH 5/6] =?UTF-8?q?=E2=9C=A8=20chore:=20issues=20with=20auto-d?= =?UTF-8?q?eploy=20to=20testserver?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-test.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-test.yml b/.github/workflows/deploy-test.yml index 8ff351c..a1ec405 100644 --- a/.github/workflows/deploy-test.yml +++ b/.github/workflows/deploy-test.yml @@ -6,12 +6,17 @@ on: - main - 'feature/**' workflow_dispatch: + inputs: + branch: + description: "Branch to deploy" + required: true + default: main jobs: deploy: runs-on: ubuntu-latest env: - BRANCH_NAME: ${{ github.ref_name }} + BRANCH_NAME: ${{ github.event.inputs.branch || github.head_ref || github.ref_name }} steps: - name: Set up SSH agent @@ -26,8 +31,8 @@ jobs: - name: Deploy ${{ env.BRANCH_NAME }} to test server run: | - echo "➡️ Starting remote deployment of branch ${{ env.BRANCH_NAME }}" + echo "➡️ Starting remote deployment of branch $BRANCH_NAME" ssh -o StrictHostKeyChecking=no \ ${{ secrets.TEST_SERVER_USER }}@${{ secrets.TEST_SERVER_HOST }} \ - "bash ~/deploy_recapp_to_test.sh ${{ env.BRANCH_NAME }}" - echo "✅ Remote deployment of branch ${{ env.BRANCH_NAME }} succeeded" + "export BRANCH_NAME='${BRANCH_NAME}'; bash ~/deploy_recapp_to_test.sh '${BRANCH_NAME}'" + echo "✅ Remote deployment of branch $BRANCH_NAME succeeded" From 07af78279fa9a55cdb52a3e09655d2be38f83d02 Mon Sep 17 00:00:00 2001 From: Sebastian Hanss Date: Wed, 11 Jun 2025 09:49:00 +0200 Subject: [PATCH 6/6] version bump --- NEWS.md | 2 +- packages/backend/package.json | 2 +- packages/frontend/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 4fe1125..1a86eb2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,2 +1,2 @@ -# recapp 1.6.2 +# recapp 1.6.3 diff --git a/packages/backend/package.json b/packages/backend/package.json index 71182c2..b1c3403 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -48,5 +48,5 @@ "start": "ts-node ./src/index.ts", "test": "npm test" }, - "version": "1.0.0" + "version": "1.0.1" } diff --git a/packages/frontend/package.json b/packages/frontend/package.json index 844d8fb..ee10955 100644 --- a/packages/frontend/package.json +++ b/packages/frontend/package.json @@ -1,7 +1,7 @@ { "name": "@recapp/frontend", "private": true, - "version": "1.6.2", + "version": "1.6.3", "type": "module", "scripts": { "dev": "vite",