AndroidAPS icon indicating copy to clipboard operation
AndroidAPS copied to clipboard

WIP: State DB

Open MilosKozak opened this issue 9 months ago • 3 comments

MilosKozak avatar May 05 '25 14:05 MilosKozak

Initial thoughts after testing with AAPS and AAPSClient app on phone only.

I like the idea to display loop states / pump disconnects with the bar at top of graph. This also seem to sync well to AAPSClient. Could the icon for loop state (top right corner) also be synced to AAPSClient? And if you tap it in AAPSClient, you get info about the current state (name, duration).

I would prefer, if the most common used state, "closed loop", won't generate a green bar at the top. The normal state should not disturb the graph. It will look more clean this way, and also make user more aware if some other state is activated.

Edit: After running this build and AAPS and AAPSClient being running idle with closed loop for a few hours the green bar at the top disappear, not sure if it is intended? I will test now setting open loop and leaving it on that mode.

olorinmaia avatar May 05 '25 23:05 olorinmaia

Just installed. AAPS seems happy, no issues so far.

  • On update loop defaulted to "Disabled". Is that intented?
  • Like the status bar, but agree with @olorinmaia, better not show this unless getting user attention has value (will see if the green bar also disappears in time for)

vanelsberg avatar May 07 '25 19:05 vanelsberg

Problem: At 1.44 AM automation fired setting temp profile. Then Loop got suspended. No way to close loop again. Had te revert to current dev and database was reset and all well. Updating again to this PR: came up with same problem state: Loop suspended and unable to unsuspend.

@MilosKozak Do you want me to create an issue for this?

Screenshot_20250508_100556_Gallery

Problems at 1.44AM (see AndroidAPS.2025-05-08_02-17-24.4) AndroidAPS_LOG_1746664503738.log.zip

Still problems after reverting to current dev, manually resetting database and then updating to PR again at approx 10:15AM Update ended up with loop still suspended. No way to unsuspend. So database resets did not clear the problem:

AndroidAPS_LOG_1746692421329.log.zip

Screenshot_20250508_023925_AAPS 20250508_132036

(Edit: logfiles upload issue fixed) (Remark: .onOlderVersionDetected():103]: Version newer than master. Ignore: have been building with a 1-line patch for max_carbs_absorbsion maxlimit setting limit)

vanelsberg avatar May 08 '25 08:05 vanelsberg

When I select User Entry icon, I enter in a searching loop, but no entries are shown, even after a long while...

image

Philoul avatar May 08 '25 09:05 Philoul

UI consistency? If I select Suspend loop during one hour, loop icon is red but status line is yellow... image

And within treatment, status is "Unkown" image

Philoul avatar May 08 '25 09:05 Philoul

Just installed. AAPS seems happy, no issues so far.

  • On update loop defaulted to "Disabled". Is that intented?
  • Like the status bar, but agree with @olorinmaia, better not show this unless getting user attention has value (will see if the green bar also disappears in time for)

can you check Treatments - User actions? Migration should be mentioned there ....

MilosKozak avatar May 13 '25 16:05 MilosKozak

can you check Treatments - User actions? Migration should be mentioned there ....

Will do. Need to redo repro on my main AAPS phone. Will need a good time for that. Likely on in 2 days.

vanelsberg avatar May 14 '25 16:05 vanelsberg

can you check Treatments - User actions? Migration should be mentioned there ....

@MilosKozak Tried new build, merging PR with yesterdays commit (current has merge conflict?): Still same result as describe above: After updating loop has state suspended. And I can't find a way to unsuspend loop. Running mode in treatments says: "Pump suspended Until change"?

Can not find anything on Migration under treatments...

Strangely enough I was unable to repro this behavior on my other 2 test phones. Somehow this phone is locked into an unrecoverable state resulting in loop unsuspended that can not be changed through the UI?

User entry Screenshot_20250515_221946_AAPS

  • Running mode * Screenshot_20250515_222009_AAPS

  • Pressing "Loop suspended Icon" Screenshot_20250515_223638_AAPS

vanelsberg avatar May 15 '25 20:05 vanelsberg

@MilosKozak Could have a look with logcat and/or debugger.

As far as I can see?; the (my?) problem occurred when automation tried to set a temporary profile percentage. It suspended the loop but then somehow was unable to close the loop again. Leaving AAPS is a state when the mop-up menu does not show the usual UI buttons (see screenprint) to repair to the correct state.

Unfortunately, I was unable to reproduce the occurrence. So no other option then to read the code logic with some help from the debugger?

Any hints on where in the code to look for the problem?

vanelsberg avatar May 16 '25 20:05 vanelsberg

In latest commit I addressed reported issues and improved UI. Loop dialog not reports limitations forced by constraints plugins

MilosKozak avatar May 16 '25 20:05 MilosKozak

In latest commit I addressed reported issues edit: this was about other issues on main channel?

PR merges ok with current dev now (= no build errors). After updating, AAPS crashes on start: Tried stopping + delete cache, restart. Still crashing.

thumbnail_Screenshot_20250516_222825_Device care

(Reverted to current build (update install) successfully.)

Logs: AndroidAPS_LOG_1747427812473.log.zip

vanelsberg avatar May 16 '25 20:05 vanelsberg

Tried stopping + delete cache, restart. Still crashing. Logs: AndroidAPS_LOG_1747427812473.log.zip

Could you try switching to virtual pump before updating?

Gohtraw avatar May 16 '25 21:05 Gohtraw

@MilosKozak Tested abit more and I think the sync between AAPS and AAPSClient is working, but a bit unstable. Very good job on adding the possibility to view/change running mode in AAPSClient :) Some times it doesn't sync to AAPSClient or from. Seems like it stops and I need to toogle the new ACv3 setting for RunningMode.

I noticed an issue with virtual pump, not tested with Dash. On AAPSClient you are not able to disconnect pump. (Is that intentional? It would be nice to be able to do this from AAPSClient also, but perhaps reasons for this not being shown) If I disconnect pump on AAPS, the running mode icon in AAPSClient turns into "Disconnected pump", and I can click the icon and select "Reconnect pump". This does not sync to AAPS.

Issue two: If I go to Treatments > User entry > the page is only loading, no content shown. (Only AAPS; not happening on AAPSClient)

olorinmaia avatar May 17 '25 23:05 olorinmaia

@olorinmaia your second issue is the same than mine described here https://github.com/nightscout/AndroidAPS/pull/3968#issuecomment-2862429892 It seems to work for @vanelsberg 🤔

Philoul avatar May 18 '25 11:05 Philoul

@MilosKozak Fix 48ba781 fixed my problem 🥇

Successfully updated main phone with current AAPS dev + PR3980 + fix (10 mins ago) Loop active, all seems well. Will closely monitor/test behavior for the next 48 hours.

vanelsberg avatar May 19 '25 13:05 vanelsberg

anyone else is testing? ready to merge?

MilosKozak avatar May 22 '25 07:05 MilosKozak

anyone else is testing? ready to merge?

On AAPS its working fine on my testrig. The sync between AAPS and client stops working after a while but not sure how to reproduce it. If I toggle the new sync setting for running mode it starts working again. I can provide logs if it helps but this is something that can be improved later on.

What about disconnect pump? Should that be possible on client? If I disconnect pump on AAPS I can resume loop on client but it doesn't sync. Testing with virtual pump.

olorinmaia avatar May 22 '25 08:05 olorinmaia

Logs. AAPS: AndroidAPS_LOG_1747903073970.log.zip

AAPSClient: AndroidAPS_LOG_1747903058076.log.zip

Screenshot of Open Loop set on AAPSClient 10:14 and screenshot from AAPS around 10:36 missing sync

AAPS AAPSClient
image image

I now toggled the Running mode setting in AAPS AAPSClientV3 sync settings off and on again and next attempt from AAPSClient then synced to AAPS.

olorinmaia avatar May 22 '25 08:05 olorinmaia

This is screenshots and logs of the reconnect pump sync issue. Around 10:52 AAPSClient try to resume loop after AAPS has synced a disconnected pump.

AAPS: AndroidAPS_LOG_1747904586255.log.zip

AAPSClient: ![image](https://git AndroidAPS_LOG_1747904571729.log.zip

image

olorinmaia avatar May 22 '25 18:05 olorinmaia

anyone else is testing? ready to merge?

Since latest fix, have been running latest AAPS dev commits while merging PR3968. Using BYODA/G6 and both DASH and Metrum Nano. Did not encounter any problems. So for me: yes, ready to merge 👍

(not using AAPSClient)

vanelsberg avatar May 25 '25 21:05 vanelsberg

Codecov Report

Attention: Patch coverage is 27.57296% with 943 lines in your changes missing coverage. Please review.

Project coverage is 27.44%. Comparing base (1590206) to head (5f2e672). Report is 40 commits behind head on dev.

Files with missing lines Patch % Lines
...ivities/fragments/TreatmentsRunningModeFragment.kt 0.00% 132 Missing :warning:
...ain/kotlin/app/aaps/plugins/aps/loop/LoopPlugin.kt 30.86% 104 Missing and 8 partials :warning:
.../aaps/database/persistence/PersistenceLayerImpl.kt 21.64% 74 Missing and 2 partials :warning:
...ins/sync/wear/wearintegration/DataHandlerMobile.kt 1.44% 68 Missing :warning:
.../src/main/kotlin/app/aaps/ui/dialogs/LoopDialog.kt 0.00% 54 Missing :warning:
...ase/persistence/converters/RunningModeExtension.kt 0.00% 49 Missing :warning:
...aaps/core/graph/data/PointsWithLabelGraphSeries.kt 0.00% 28 Missing :warning:
...abase/transactions/SyncNsRunningModeTransaction.kt 0.00% 25 Missing :warning:
...n/app/aaps/core/graph/data/RunningModeDataPoint.kt 0.00% 24 Missing :warning:
...src/main/kotlin/app/aaps/database/AppRepository.kt 35.13% 23 Missing and 1 partial :warning:
... and 66 more
Additional details and impacted files
@@             Coverage Diff              @@
##                dev    #3968      +/-   ##
============================================
+ Coverage     27.40%   27.44%   +0.03%     
- Complexity     6436     6462      +26     
============================================
  Files          2360     2364       +4     
  Lines        121552   121742     +190     
  Branches      15600    15628      +28     
============================================
+ Hits          33316    33409      +93     
- Misses        85652    85737      +85     
- Partials       2584     2596      +12     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar May 30 '25 08:05 codecov[bot]

With latest updates, User Entry works now (but tested only on my emulator) Looks good now for merging on my side.

Philoul avatar Jun 01 '25 07:06 Philoul

Have been running latest dev version while merging this PR for the past 4 weeks. No issues encountered 👍

vanelsberg avatar Jun 05 '25 15:06 vanelsberg

👍 Build and install ok. Not seeing any issues.

vanelsberg avatar Jun 10 '25 11:06 vanelsberg