Compare commits

...
3 Commits
Author SHA1 Message Date
waozi a3743c9b37 improve profile screen 2026-06-29 03:16:43 -03:00
waozi fe96b6c61e bug fixes 2026-06-29 03:06:17 -03:00
waozi eabbff2972 fix critical inset issue 2026-06-29 00:15:28 -03:00
37 changed files with 526 additions and 78 deletions

No files matched your search

+3 -3
View File
@@ -571,7 +571,7 @@ jobs:
butler push "$linux_appimage" waozi/inbe:linux --userversion "$VERSION"
publish-google-play:
name: Publish Google Play Alpha
name: Publish Google Play Open Testing
runs-on: ubuntu-latest
needs:
- build-android
@@ -595,13 +595,13 @@ jobs:
name: release-android
path: build/release/android
- name: Publish AAB to Closed Testing Alpha
- name: Publish AAB to Play Games on PC Open Testing
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.PLAY_STORE_JSON_KEY }}
packageName: xyz.waozi.inbe
releaseFiles: build/release/android/*.aab
tracks: alpha
tracks: google_play_games_pc:beta
status: completed
publish-chrome-web-store:
+7
View File
@@ -1,5 +1,12 @@
# Changelog
## [1.7.4] - 2026-06-29
### Fixed
- Clean up practice stats, friend removal, sync review, and Android inset handling.
## [1.7.3] - 2026-06-29
### Fixed
- bottom inset in practice
### Changed
- Improve habit management
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 104 KiB

+2 -2
View File
@@ -35,8 +35,8 @@ android {
defaultConfig {
minSdk 21
targetSdk 35
versionCode 66
versionName "1.7.3"
versionCode 67
versionName "1.7.4"
}
+1
View File
@@ -207,6 +207,7 @@ target_link_options(main PRIVATE
-Wl,--gc-sections
-Wl,--strip-all
-Wl,-z,max-page-size=16384
-Wl,-z,common-page-size=16384
-Wl,--wrap=fopen
)
@@ -447,7 +447,6 @@ public class MainActivity extends NativeActivity {
// Notify native code that activity is ready for wake lock
nativeWakeLockReady();
requestNotificationPermissionIfNeeded();
}
@Override
+1 -1
View File
@@ -1,3 +1,3 @@
plugins {
id 'com.android.application' version '8.4.2' apply false
id 'com.android.application' version '8.5.1' apply false
}
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
@@ -0,0 +1,3 @@
Fixed
---
- bottom inset in practice
+6
View File
@@ -67,6 +67,12 @@ Prijmout
[profile_friend_decline_button]
Odmitnout
---
[profile_friend_remove_title]
Odebrat pritele?
---
[profile_friend_remove_message]
%s bude odebran. Pro obnoveni poslete novou zadost.
---
[profile_updating_status]
Aktualizace
---
+6
View File
@@ -67,6 +67,12 @@ Annehmen
[profile_friend_decline_button]
Ablehnen
---
[profile_friend_remove_title]
Freund entfernen?
---
[profile_friend_remove_message]
%s wird entfernt. Sende eine neue Anfrage zum Wiederverbinden.
---
[profile_updating_status]
Aktualisieren
---
+6
View File
@@ -67,6 +67,12 @@ Accept
[profile_friend_decline_button]
Decline
---
[profile_friend_remove_title]
Remove friend?
---
[profile_friend_remove_message]
%s will be removed. Send a new request to reconnect.
---
[profile_updating_status]
Updating
---
+6
View File
@@ -67,6 +67,12 @@ Aceptar
[profile_friend_decline_button]
Rechazar
---
[profile_friend_remove_title]
¿Eliminar amigo?
---
[profile_friend_remove_message]
Se eliminara a %s. Envia una nueva solicitud para reconectar.
---
[profile_updating_status]
Actualizando
---
+6
View File
@@ -67,6 +67,12 @@ Accepter
[profile_friend_decline_button]
Refuser
---
[profile_friend_remove_title]
Supprimer l'ami ?
---
[profile_friend_remove_message]
%s sera supprime. Envoyez une nouvelle demande pour vous reconnecter.
---
[profile_updating_status]
Mise a jour
---
+6
View File
@@ -67,6 +67,12 @@ Terima
[profile_friend_decline_button]
Tolak
---
[profile_friend_remove_title]
Hapus teman?
---
[profile_friend_remove_message]
%s akan dihapus. Kirim permintaan baru untuk terhubung lagi.
---
[profile_updating_status]
Memperbarui
---
+6
View File
@@ -67,6 +67,12 @@ Accetta
[profile_friend_decline_button]
Rifiuta
---
[profile_friend_remove_title]
Rimuovere amico?
---
[profile_friend_remove_message]
%s sara rimosso. Invia una nuova richiesta per riconnetterti.
---
[profile_updating_status]
Aggiornamento
---
+6
View File
@@ -67,6 +67,12 @@ Pet
[profile_friend_decline_button]
拒否
---
[profile_friend_remove_title]
フレンドを削除?
---
[profile_friend_remove_message]
%s を削除します。再接続には新しいリクエストが必要です。
---
[profile_updating_status]
更新中
---
+6
View File
@@ -67,6 +67,12 @@ Pet
[profile_friend_decline_button]
거절
---
[profile_friend_remove_title]
친구 삭제?
---
[profile_friend_remove_message]
%s 님이 삭제됩니다. 다시 연결하려면 새 요청을 보내세요.
---
[profile_updating_status]
업데이트 중
---
+6
View File
@@ -67,6 +67,12 @@ Aceitar
[profile_friend_decline_button]
Recusar
---
[profile_friend_remove_title]
Remover amigo?
---
[profile_friend_remove_message]
%s sera removido. Envie uma nova solicitacao para reconectar.
---
[profile_updating_status]
Atualizando
---
+6
View File
@@ -67,6 +67,12 @@ Pet
[profile_friend_decline_button]
Отклонить
---
[profile_friend_remove_title]
Удалить друга?
---
[profile_friend_remove_message]
%s будет удален. Для связи отправьте новый запрос.
---
[profile_updating_status]
Обновление
---
+6
View File
@@ -67,6 +67,12 @@ Pet
[profile_friend_decline_button]
拒绝
---
[profile_friend_remove_title]
删除好友?
---
[profile_friend_remove_message]
将删除 %s。重新连接需发送新请求。
---
[profile_updating_status]
正在更新
---
+31 -3
View File
@@ -206,6 +206,10 @@ app_social_worker(void *userdata)
result = sync_client_decline_friend_request(args->url, args->action_value);
if(result != FLINT_LYRA_SYNC_OK)
goto done;
} else if(strcmp(args->action, "remove") == 0) {
result = sync_client_remove_friend(args->url, args->action_value);
if(result != FLINT_LYRA_SYNC_OK)
goto done;
}
result = sync_client_get_friend_requests(args->url, requests_json,
sizeof(requests_json));
@@ -432,6 +436,7 @@ app_modal_type_name(UIModalType type)
case UIModalSyncReview: return "sync_review";
case UIModalSyncAlias: return "sync_alias";
case UIModalSyncPublicId: return "sync_public_id";
case UIModalConfirmRemoveFriend: return "confirm_remove_friend";
default: break;
}
return "unknown";
@@ -689,6 +694,13 @@ app_request_friend_decline(InbeApp *app, const char *request_id)
app_request_social_action("decline", request_id);
}
void
app_request_friend_remove(InbeApp *app, const char *friend_user_id)
{
(void)app;
app_request_social_action("remove", friend_user_id);
}
static int
app_sync_now(InbeApp *app)
{
@@ -1715,6 +1727,10 @@ draw_global_modal(InbeApp *app)
}
if(app->modal.type == UIModalThemePicker)
settings_screen_draw_theme_picker_modal(app);
if(app->modal.type == UIModalConfirmRemoveFriend) {
profile_screen_draw_remove_friend_modal(app);
return;
}
if(app->modal.type == UIModalPracticeManual ||
app->modal.type == UIModalPracticeConfig ||
app->modal.type == UIModalEditProgressiveStartSpeed) {
@@ -1751,7 +1767,8 @@ static void
updateapp(InbeApp *app)
{
int center_x = view_width / 2;
int center_y = view_height / 2;
int frame_view_height = view_height;
int center_y;
int play_center_y;
int hover = 0;
int frame_screen = app->inbe.screen;
@@ -1759,6 +1776,7 @@ updateapp(InbeApp *app)
int habits_guide_active = 0;
int profile_guide_active = 0;
int practice_fullscreen_modal = 0;
int global_modal_drawn = 0;
#if !ANDROID_BUILD && !defined(PLATFORM_WEB)
app->backgrounded = (!IsWindowFocused() || IsWindowMinimized()) ? 1 : 0;
@@ -1786,6 +1804,9 @@ updateapp(InbeApp *app)
ui_push_input_capture((Rectangle){0, 0, (float)view_width, (float)view_height}, 0);
}
view_height = app_page_height(app, view_height);
center_y = view_height / 2;
if(IsKeyPressed(KEY_BACK)) {
if(first_run_guide_active || habits_guide_active || profile_guide_active) {
app->tutorial_step = 0;
@@ -1907,15 +1928,22 @@ updateapp(InbeApp *app)
}
finish_frame:
if(practice_fullscreen_modal) {
draw_global_modal(app);
global_modal_drawn = 1;
}
view_height = frame_view_height;
app_draw_bottom_nav(app);
practice_screen_draw_first_run_guide(app);
habits_screen_draw_first_run_guide(app);
profile_screen_draw_first_run_guide(app);
draw_global_modal(app);
if(!global_modal_drawn)
draw_global_modal(app);
app_flush_deferred_settings(app);
app_observe_direct_screen_change(app, frame_screen);
if(app->transition_mode == APP_TRANSITION_FADE) {
flint_transition_draw_fade(&app->screen_transition, view_width, view_height,
flint_transition_draw_fade(&app->screen_transition, view_width,
app_page_height(app, view_height),
flint_theme_get_bg());
}
app_advance_screen_transition(app);
+4
View File
@@ -97,6 +97,7 @@ typedef enum {
UIModalSyncReview,
UIModalSyncAlias,
UIModalSyncPublicId,
UIModalConfirmRemoveFriend,
} UIModalType;
typedef struct {
@@ -284,6 +285,8 @@ struct InbeApp {
int profile_friend_input_focused;
int profile_friends_loaded;
char profile_friend_input[80];
char profile_pending_friend_remove_id[80];
char profile_pending_friend_remove_name[96];
char profile_friends_json[8192];
char profile_friend_requests_json[8192];
char profile_leaderboard_json[8192];
@@ -373,6 +376,7 @@ void app_request_social_refresh(InbeApp *app);
void app_request_friend_send(InbeApp *app, const char *target);
void app_request_friend_accept(InbeApp *app, const char *request_id);
void app_request_friend_decline(InbeApp *app, const char *request_id);
void app_request_friend_remove(InbeApp *app, const char *friend_user_id);
int app_should_use_tab_bar(const InbeApp *app);
void app_play_sound(InbeApp *app, Sound sound, float scale);
Texture2D app_load_asset_texture(const char *name);
+37 -4
View File
@@ -92,7 +92,30 @@ app_content_bottom_reserved(const InbeApp *app)
return 0;
if(app_current_nav_route(app) == APP_NAV_ROUTE_NONE)
return 0;
return ui_bottom_nav_height() + app_android_bottom_nav_height();
return ui_bottom_nav_height();
}
int
app_page_height(const InbeApp *app, int full_height)
{
int bottom_reserved;
if(full_height <= 0)
return 0;
bottom_reserved = app_fullscreen_bottom_reserved(app);
if(bottom_reserved > 0 && bottom_reserved < full_height)
return full_height - bottom_reserved;
return full_height;
}
static int
app_has_fullscreen_overlay(const InbeApp *app)
{
if(app == NULL || !app->modal.active)
return 0;
return app->modal.type == UIModalPracticeManual ||
app->modal.type == UIModalPracticeConfig ||
app->modal.type == UIModalEditProgressiveStartSpeed;
}
static const char *
@@ -172,9 +195,19 @@ app_should_draw_bottom_nav(const InbeApp *app)
{
if(app == NULL)
return 0;
if(app_has_fullscreen_overlay(app))
return 0;
return app_current_nav_route(app) != APP_NAV_ROUTE_NONE;
}
int
app_fullscreen_bottom_reserved(const InbeApp *app)
{
if(app == NULL)
return 0;
return app_android_bottom_nav_height();
}
void
app_draw_bottom_nav(InbeApp *app)
{
@@ -189,6 +222,9 @@ app_draw_bottom_nav(InbeApp *app)
FlintUIBottomNavItem items[BOTTOM_NAV_ROUTE_COUNT];
FlintUIBottomNavResult result;
if(app_android_bottom_nav_height() > 0)
DrawRectangle(0, view_height - app_android_bottom_nav_height(),
view_width, app_android_bottom_nav_height(), BLACK);
if(!app_should_draw_bottom_nav(app))
return;
for(int i = 0; i < BOTTOM_NAV_ROUTE_COUNT; i++) {
@@ -201,9 +237,6 @@ app_draw_bottom_nav(InbeApp *app)
app->modal.active
};
}
if(app_android_bottom_nav_height() > 0)
DrawRectangle(0, view_height - app_android_bottom_nav_height(),
view_width, app_android_bottom_nav_height(), BLACK);
result = ui_draw_bottom_nav((FlintUIBottomNav){
.view_width = view_width,
.view_height = view_height,
+2
View File
@@ -4,7 +4,9 @@
#include "app_fwd.h"
int app_current_nav_route(const InbeApp *app);
int app_page_height(const InbeApp *app, int full_height);
int app_content_bottom_reserved(const InbeApp *app);
int app_fullscreen_bottom_reserved(const InbeApp *app);
void app_set_android_bottom_nav_height(int height);
int app_android_bottom_nav_height(void);
void app_draw_bottom_nav(InbeApp *app);
+2 -2
View File
@@ -3,7 +3,7 @@
#define INBE_VERSION_MAJOR 1
#define INBE_VERSION_MINOR 7
#define INBE_VERSION_PATCH 3
#define INBE_VERSION_STRING "1.7.3"
#define INBE_VERSION_PATCH 4
#define INBE_VERSION_STRING "1.7.4"
#endif
+2 -1
View File
@@ -175,7 +175,8 @@ meditation_config_screen_draw(InbeApp *app)
}
scroll_y = title_h + flint_px(16);
scroll_h = view_height - scroll_y - bottom_reserved - flint_px(8);
scroll_h = view_height - scroll_y - bottom_reserved -
(integrated ? flint_px(8) : 0);
if(scroll_h < 0)
scroll_h = 0;
+2 -1
View File
@@ -383,7 +383,8 @@ whm_config_screen_draw(InbeApp *app)
app->settings_scroll = 0;
}
scroll_y = title_h + config_tab_h + config_tab_gap;
scroll_h = view_height - scroll_y - bottom_reserved - flint_px(8);
scroll_h = view_height - scroll_y - bottom_reserved -
(integrated ? flint_px(8) : 0);
if(scroll_h < 0)
scroll_h = 0;
+1 -1
View File
@@ -425,7 +425,7 @@ finish_round(InbeApp *app)
if(session_ensure_results_saved(app)) {
#if ANDROID_BUILD
android_allow_screen_off();
android_timer_stop();
stop_android_background_session(app);
#endif
app_switch_screen(app, InbeScreenResults);
#if ANDROID_BUILD
+129 -28
View File
@@ -294,6 +294,49 @@ profile_json_number_value(const char *object, const char *key)
static void profile_refresh_friends(InbeApp *app);
static void
profile_public_id_short(char *out, size_t out_size, const char *user_id)
{
if(out == NULL || out_size == 0)
return;
if(user_id == NULL || user_id[0] == '\0')
snprintf(out, out_size, "----");
else
snprintf(out, out_size, "%.*s", 4, user_id);
}
static void
profile_display_name(char *out, size_t out_size, const char *alias,
const char *user_id)
{
char short_id[8];
if(out == NULL || out_size == 0)
return;
if(alias != NULL && alias[0] != '\0') {
snprintf(out, out_size, "@%s", alias);
} else if(user_id != NULL && user_id[0] != '\0') {
profile_public_id_short(short_id, sizeof(short_id), user_id);
snprintf(out, out_size, "%s...", short_id);
} else {
snprintf(out, out_size, "----...");
}
}
static void
profile_prompt_remove_friend(InbeApp *app, const char *friend_user_id,
const char *friend_name)
{
if(app == NULL || friend_user_id == NULL || friend_user_id[0] == '\0')
return;
snprintf(app->profile_pending_friend_remove_id,
sizeof(app->profile_pending_friend_remove_id), "%s", friend_user_id);
snprintf(app->profile_pending_friend_remove_name,
sizeof(app->profile_pending_friend_remove_name), "%s",
friend_name != NULL && friend_name[0] != '\0' ? friend_name : friend_user_id);
app_open_modal(app, UIModalConfirmRemoveFriend);
}
static void
profile_draw_json_people(const char *json, const char *array_key,
int x, int w, int *y, int with_actions, InbeApp *app)
@@ -304,6 +347,8 @@ profile_draw_json_people(const char *json, const char *array_key,
int rows = 0;
int font = flint_ui_font();
int small = flint_ui_font_small();
int with_remove = !with_actions && strcmp(array_key, "friends") == 0;
int with_cancel = !with_actions && strcmp(array_key, "outgoing") == 0;
snprintf(key_pattern, sizeof(key_pattern), "\"%s\"", array_key);
p = strstr(json != NULL ? json : "", key_pattern);
@@ -329,6 +374,8 @@ profile_draw_json_people(const char *json, const char *array_key,
int row_h = with_actions ? flint_px(42) : flint_px(30);
int hover_accept = 0;
int hover_decline = 0;
int hover_remove = 0;
int hover_cancel = 0;
char url[256];
id[0] = '\0';
@@ -353,9 +400,32 @@ profile_draw_json_people(const char *json, const char *array_key,
profile_json_string_value(p, "alias", alias, sizeof(alias));
if(display_id[0] == '\0')
snprintf(display_id, sizeof(display_id), "%s", id);
snprintf(title, sizeof(title), "%s%s", alias[0] != '\0' ? "@" : "",
alias[0] != '\0' ? alias : display_id);
profile_display_name(title, sizeof(title), alias, display_id);
flint_text_draw(title, x, *y, font, flint_theme_get_text());
if(with_remove) {
int icon_size = flint_px(18);
int icon_padding = flint_px(6);
int button_w = icon_size + icon_padding * 2;
if(ui_draw_icon_btn_padded(x + w - button_w, *y - flint_px(6),
icon_size, icon_padding,
app->icons[UI_ICON_TYPE_TRASH],
&hover_remove)) {
profile_prompt_remove_friend(app, display_id, title);
}
} else if(with_cancel) {
int icon_size = flint_px(18);
int icon_padding = flint_px(6);
int button_w = icon_size + icon_padding * 2;
if(ui_draw_icon_btn_padded(x + w - button_w, *y - flint_px(6),
icon_size, icon_padding,
app->icons[UI_ICON_TYPE_TRASH],
&hover_cancel) &&
profile_sync_url(url, sizeof(url))) {
app_request_friend_decline(app, id);
settings_screen_set_status_success(locale_get("profile_updating_status"),
NULL);
}
}
if(with_actions) {
int btn_w = (w - flint_px(8)) / 2;
if(ui_draw_generic_button(x, *y + flint_px(22), btn_w, flint_px(30),
@@ -386,6 +456,44 @@ profile_draw_json_people(const char *json, const char *array_key,
}
}
void
profile_screen_draw_remove_friend_modal(InbeApp *app)
{
char message[384];
int modal_result;
if(app == NULL || !app->modal.active ||
app->modal.type != UIModalConfirmRemoveFriend)
return;
snprintf(message, sizeof(message),
locale_get("profile_friend_remove_message"),
app->profile_pending_friend_remove_name[0] != '\0'
? app->profile_pending_friend_remove_name
: "this friend");
modal_result = ui_draw_modal(locale_get("profile_friend_remove_title"), message,
locale_get("cancel_button"),
locale_get("delete_button"));
if(modal_result == 1) {
app->profile_pending_friend_remove_id[0] = '\0';
app->profile_pending_friend_remove_name[0] = '\0';
app_close_modal(app);
} else if(modal_result == 2) {
char url[256];
if(profile_sync_url(url, sizeof(url))) {
app_request_friend_remove(app, app->profile_pending_friend_remove_id);
settings_screen_set_status_success(locale_get("profile_updating_status"),
NULL);
} else {
settings_screen_set_status_error(locale_get("sync_server_url_invalid"));
}
app->profile_pending_friend_remove_id[0] = '\0';
app->profile_pending_friend_remove_name[0] = '\0';
app_close_modal(app);
}
}
static void
profile_draw_stat_row(int x, int w, int *y, const char *label, const char *value)
{
@@ -726,9 +834,13 @@ profile_draw_friends(InbeApp *app, int x, int w, int *y)
int hover_refresh = 0;
int commit = 0;
char url[256];
int incoming_count;
int outgoing_count;
if(!app->profile_friends_loaded)
profile_load_friends_cache(app);
incoming_count = profile_json_array_count(app->profile_friend_requests_json, "incoming");
outgoing_count = profile_json_array_count(app->profile_friend_requests_json, "outgoing");
*y += flint_px(16);
flint_text_draw(locale_get("profile_friends_title"), x, *y, font,
@@ -771,20 +883,24 @@ profile_draw_friends(InbeApp *app, int x, int w, int *y)
}
*y += btn_h + flint_px(22);
flint_text_draw(locale_get("profile_incoming_title"), x, *y, font,
flint_theme_get_text());
*y += flint_px(28);
profile_draw_json_people(app->profile_friend_requests_json, "incoming", x, w, y, 1, app);
*y += flint_px(16);
if(incoming_count > 0) {
flint_text_draw(locale_get("profile_incoming_title"), x, *y, font,
flint_theme_get_text());
*y += flint_px(28);
profile_draw_json_people(app->profile_friend_requests_json, "incoming", x, w, y, 1, app);
*y += flint_px(16);
}
flint_text_draw(locale_get("profile_friends_title"), x, *y, font,
flint_theme_get_text());
*y += flint_px(28);
profile_draw_json_people(app->profile_friends_json, "friends", x, w, y, 0, app);
*y += flint_px(16);
flint_text_draw(locale_get("profile_outgoing_title"), x, *y, font,
flint_theme_get_text());
*y += flint_px(28);
profile_draw_json_people(app->profile_friend_requests_json, "outgoing", x, w, y, 0, app);
if(outgoing_count > 0) {
*y += flint_px(16);
flint_text_draw(locale_get("profile_outgoing_title"), x, *y, font,
flint_theme_get_text());
*y += flint_px(28);
profile_draw_json_people(app->profile_friend_requests_json, "outgoing", x, w, y, 0, app);
}
}
static void
@@ -798,24 +914,9 @@ static void
profile_leaderboard_display_name(char *out, size_t out_size,
const char *alias, const char *user_id)
{
int written;
if(out == NULL || out_size == 0)
return;
if(alias != NULL && alias[0] != '\0') {
if(out_size <= 2) {
snprintf(out, out_size, "@");
return;
}
written = snprintf(out, out_size, "@%.*s", (int)out_size - 2, alias);
if(written < 0)
out[0] = '\0';
} else if(user_id != NULL && strlen(user_id) > 12) {
snprintf(out, out_size, "%.12s...", user_id);
} else {
snprintf(out, out_size, "%.*s", (int)out_size - 1,
user_id != NULL ? user_id : "");
}
profile_display_name(out, out_size, alias, user_id);
}
static int
+1
View File
@@ -4,6 +4,7 @@
#include "app_fwd.h"
int profile_screen_draw(InbeApp *app);
void profile_screen_draw_remove_friend_modal(InbeApp *app);
void profile_screen_refresh_social_cache(InbeApp *app);
int profile_screen_first_run_guide_active(const InbeApp *app);
void profile_screen_prepare_first_run_guide(InbeApp *app);
+27 -24
View File
@@ -29,6 +29,8 @@ storage_has_orphan_habit_days(void);
static int
storage_json_array_count(const char *json, const char *path);
static int
storage_apply_remote_full_snapshot(const char *response_json);
static int
storage_clear_local_sync_data(void);
static int
storage_json_valid(const char *json);
@@ -2112,20 +2114,9 @@ storage_apply_sync_response_json(const char *response_json)
storage_set_setting_text(STORAGE_SYNC_ACCOUNT_ALIAS_KEY, account_alias);
if(storage_json_extract_int64(response_json, "$.full_snapshot_required", 0) != 0 &&
get_meta_int64(STORAGE_SYNC_APPLY_REVIEW_KEY, 0) == 0) {
if(!storage_sync_review_json_has_visible_diff(response_json)) {
char *copy = strdup(response_json);
int ok;
if(copy == NULL)
return 0;
if(!storage_clear_local_sync_data()) {
free(copy);
return 0;
}
set_meta_int64(STORAGE_SYNC_APPLY_REVIEW_KEY, 1);
ok = storage_apply_sync_response_json(copy);
free(copy);
return ok;
}
if(!storage_has_any() ||
storage_sync_review_json_should_auto_apply_remote(response_json))
return storage_apply_remote_full_snapshot(response_json);
if(!storage_sync_review_write_json(response_json))
return 0;
set_meta(STORAGE_SYNC_PENDING_REVIEW_KEY, "1");
@@ -2185,6 +2176,27 @@ storage_apply_sync_response_json(const char *response_json)
return 1;
}
static int
storage_apply_remote_full_snapshot(const char *response_json)
{
char *copy;
int ok;
if(response_json == NULL)
return 0;
copy = strdup(response_json);
if(copy == NULL)
return 0;
if(!storage_clear_local_sync_data()) {
free(copy);
return 0;
}
set_meta_int64(STORAGE_SYNC_APPLY_REVIEW_KEY, 1);
ok = storage_apply_sync_response_json(copy);
free(copy);
return ok;
}
static int
storage_clear_local_sync_data(void)
{
@@ -2389,7 +2401,6 @@ storage_profile_activity_stats(int activity, int today_date,
int seen[371] = {0};
int streak = 0;
long avg_value = 0;
int mask = 1 << activity;
if(streak_out != NULL)
*streak_out = 0;
@@ -2401,19 +2412,11 @@ storage_profile_activity_stats(int activity, int today_date,
if(sqlite3_prepare_v2(g_storage.db,
"SELECT local_date FROM sessions "
"WHERE user_id=?1 AND deleted_at=0 AND activity=?2 "
" AND local_date>0 "
"UNION "
"SELECT hd.local_date "
"FROM habit_days hd JOIN habits h ON h.id=hd.habit_id "
"WHERE h.user_id=?1 AND h.deleted_at=0 "
" AND h.sync_mode=?3 AND (h.sync_activity & ?4)<>0 "
" AND (hd.completed!=0 OR hd.count>0)",
" AND local_date>0",
-1, &stmt, NULL) != SQLITE_OK)
return 0;
bind_text(stmt, 1, g_storage.user_id);
sqlite3_bind_int(stmt, 2, activity);
sqlite3_bind_int(stmt, 3, INBE_HABIT_SYNC_ACTIVITIES);
sqlite3_bind_int(stmt, 4, mask);
while(sqlite3_step(stmt) == SQLITE_ROW) {
int offset = storage_profile_day_offset(sqlite3_column_int(stmt, 0), today_date);
if(offset >= 0 && offset <= 370)
+1
View File
@@ -89,6 +89,7 @@ int storage_sync_review_details(char **local_out, char **remote_out);
int storage_sync_review_diff(char **diff_out);
int storage_sync_review_has_visible_diff(void);
int storage_sync_review_json_has_visible_diff(const char *json);
int storage_sync_review_json_should_auto_apply_remote(const char *json);
int storage_sync_review_clear_if_no_visible_diff(void);
int storage_sync_review_apply_remote_if_local_empty(void);
int storage_apply_pending_sync_review(int use_remote);
+118
View File
@@ -11,6 +11,7 @@
#define STORAGE_SYNC_APPLY_REVIEW_KEY "sync_apply_pending_review"
#define STORAGE_SYNC_FULL_REPLACE_KEY "sync_full_replace_requested"
#define STORAGE_SYNC_LAST_SERVER_HASH_KEY "sync_last_server_state_hash"
#define STORAGE_SYNC_AUTO_APPLY_VISIBLE_CHANGE_LIMIT 2
typedef struct ReviewText {
char *data;
@@ -24,7 +25,10 @@ static void review_append_remote(ReviewText *out, const char *json);
static void review_append_unique_lines(ReviewText *out, const char *prefix,
const char *lines, const char *other);
static int review_has_pending_outbox(void);
static int review_pending_outbox_sessions_only(void);
static int review_has_unknown_activity(const char *json);
static int review_small_session_only_change(const char *diff);
static int review_visible_change_count(const char *diff);
static int
review_reserve(ReviewText *text, size_t extra)
@@ -617,6 +621,31 @@ storage_sync_review_json_has_visible_diff(const char *json)
return has_diff;
}
int
storage_sync_review_json_should_auto_apply_remote(const char *json)
{
char *diff = NULL;
int result;
if(review_has_unknown_activity(json))
return 0;
if(!storage_sync_review_diff_for_json(json, 0, &diff)) {
free(diff);
return 0;
}
if(diff == NULL || diff[0] == '\0') {
free(diff);
return 1;
}
if(!review_has_pending_outbox()) {
free(diff);
return 1;
}
result = review_small_session_only_change(diff);
free(diff);
return result;
}
static int
review_has_pending_outbox(void)
{
@@ -635,6 +664,25 @@ review_has_pending_outbox(void)
return result;
}
static int
review_pending_outbox_sessions_only(void)
{
sqlite3_stmt *stmt = NULL;
int result = 0;
if(g_storage.db == NULL)
return 0;
if(sqlite3_prepare_v2(g_storage.db,
"SELECT EXISTS(SELECT 1 FROM sync_outbox LIMIT 1) "
"AND NOT EXISTS(SELECT 1 FROM sync_outbox WHERE entity_type<>'session')",
-1, &stmt, NULL) != SQLITE_OK)
return 0;
if(sqlite3_step(stmt) == SQLITE_ROW)
result = sqlite3_column_int(stmt, 0) != 0;
sqlite3_finalize(stmt);
return result;
}
static int
review_has_unknown_activity(const char *json)
{
@@ -673,6 +721,76 @@ review_has_unknown_activity(const char *json)
return 0;
}
static int
review_small_session_only_change(const char *diff)
{
int count;
if(!review_pending_outbox_sessions_only())
return 0;
count = review_visible_change_count(diff);
return count > 0 && count <= STORAGE_SYNC_AUTO_APPLY_VISIBLE_CHANGE_LIMIT;
}
static int
review_line_starts_with_date(const char *line, size_t len)
{
if(line == NULL || len < 10)
return 0;
return line[0] >= '0' && line[0] <= '9' &&
line[1] >= '0' && line[1] <= '9' &&
line[2] >= '0' && line[2] <= '9' &&
line[3] >= '0' && line[3] <= '9' &&
line[4] == '-' &&
line[5] >= '0' && line[5] <= '9' &&
line[6] >= '0' && line[6] <= '9' &&
line[7] == '-' &&
line[8] >= '0' && line[8] <= '9' &&
line[9] >= '0' && line[9] <= '9';
}
static int
review_line_equals_literal(const char *line, size_t len, const char *literal)
{
size_t literal_len;
if(line == NULL || literal == NULL)
return 0;
literal_len = strlen(literal);
return len == literal_len && strncmp(line, literal, len) == 0;
}
static int
review_visible_change_count(const char *diff)
{
const char *p = diff;
const char *line;
const char *end;
size_t len;
int date_lines = 0;
int changed_lines = 0;
if(diff == NULL)
return 0;
while(*p != '\0') {
end = strchr(p, '\n');
len = end != NULL ? (size_t)(end - p) : strlen(p);
if(len > 2 && (p[0] == '-' || p[0] == '+') && p[1] == ' ') {
line = p + 2;
len -= 2;
if(review_line_starts_with_date(line, len))
date_lines++;
else if(!review_line_equals_literal(line, len, "Sessions") &&
!review_line_equals_literal(line, len, "Habit days"))
changed_lines++;
}
if(end == NULL)
break;
p = end + 1;
}
return date_lines > 0 ? date_lines : changed_lines;
}
int
storage_apply_pending_sync_review(int use_remote)
{
+75 -2
View File
@@ -261,6 +261,28 @@ mark_empty_local_pending(const char *root)
"VALUES('account','alias',0,1782300000);"));
}
static void
seed_local_session_only(const char *root)
{
check_true("seed local session only",
exec_db_sql(root, "INSERT INTO "
"sessions(id,user_id,started_at,local_date,topic,activity,source,"
"imported_at,rounds_hash,deleted_at,updated_at)"
"VALUES('tiny-local-session',(SELECT id FROM users LIMIT "
"1),1782300000,20260624,1,1,'test',1782300000,101,0,1782300000);"
"INSERT INTO session_rounds(session_id,round_index,seconds)"
"VALUES('tiny-local-session',0,40);"));
}
static void
mark_local_session_only_pending(const char *root)
{
check_true("mark local session only pending",
exec_db_sql(root, "INSERT OR REPLACE INTO "
"sync_outbox(entity_type,entity_id,local_date,queued_at)"
"VALUES('session','tiny-local-session',0,1782300000);"));
}
static void
seed_local_yoga_data(const char *root)
{
@@ -356,6 +378,29 @@ remote_additive_yoga_response(void)
"}";
}
static const char *
remote_tiny_session_snapshot_response(void)
{
return "{"
"\"server_version\":15,"
"\"server_state_hash\":\"remote-hash-tiny-session\","
"\"full_snapshot_required\":true,"
"\"changes_complete\":false,"
"\"changes\":{"
"\"habits\":[],"
"\"habit_days\":[],"
"\"sessions\":[{\"id\":\"tiny-remote-session\",\"started_at\":\"2026-06-24T10:"
"05:00Z\","
"\"local_date\":20260624,\"topic\":1,\"activity\":1,\"source\":\"lyra-"
"test\","
"\"rounds_hash\":404,\"deleted_at\":0,\"updated_at\":\"2026-06-24T10:"
"05:00Z\","
"\"rounds\":[{\"round_index\":0,\"hold_seconds\":55}]}],"
"\"meditation_logs\":[]"
"}"
"}";
}
static void
test_full_snapshot_waits_for_review(void)
{
@@ -406,6 +451,34 @@ test_full_snapshot_waits_for_review(void)
remove_tree(root);
}
static void
test_tiny_pending_snapshot_applies_remote_without_review(void)
{
char root[1024];
make_clean_root(root, sizeof(root), "tiny-pending");
check_true("init tiny pending db", storage_init(root));
seed_local_session_only(root);
mark_local_session_only_pending(root);
check_true("apply tiny review response",
storage_apply_sync_response_json(remote_tiny_session_snapshot_response()));
check_false("tiny review not pending", storage_sync_review_pending());
check_int("tiny local session replaced",
read_db_count(root,
"SELECT COUNT(*) FROM sessions WHERE id='tiny-local-session'"),
0);
check_int("tiny remote session applied",
read_db_count(root,
"SELECT COUNT(*) FROM sessions WHERE id='tiny-remote-session'"),
1);
check_int("tiny outbox cleared",
read_db_count(root, "SELECT COUNT(*) FROM sync_outbox"), 0);
storage_close();
remove_tree(root);
}
static void
test_empty_local_pending_snapshot_applies_remote(void)
{
@@ -417,8 +490,7 @@ test_empty_local_pending_snapshot_applies_remote(void)
check_true("apply empty local review response",
storage_apply_sync_response_json(remote_snapshot_response()));
check_true("empty local review pending before policy", storage_sync_review_pending());
check_true("empty local applies remote", storage_sync_review_apply_remote_if_local_empty());
check_false("empty local review not pending", storage_sync_review_pending());
check_false("empty local review cleared", storage_sync_review_pending());
check_int("empty local remote session applied",
read_db_count(root, "SELECT COUNT(*) FROM sessions WHERE id='remote-session'"), 1);
@@ -696,6 +768,7 @@ main(void)
tzset();
test_full_snapshot_waits_for_review();
test_tiny_pending_snapshot_applies_remote_without_review();
test_empty_local_pending_snapshot_applies_remote();
test_review_ignores_deleted_remote_rows();
test_remote_additions_apply_without_review();
+4 -4
View File
@@ -3,8 +3,8 @@
IDI_APP_ICON ICON "inbe.ico"
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,7,3,0
PRODUCTVERSION 1,7,3,0
FILEVERSION 1,7,4,0
PRODUCTVERSION 1,7,4,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -21,11 +21,11 @@ BEGIN
BEGIN
VALUE "CompanyName", "waozi"
VALUE "FileDescription", "Inner Breeze"
VALUE "FileVersion", "1.7.3"
VALUE "FileVersion", "1.7.4"
VALUE "InternalName", "inbe"
VALUE "OriginalFilename", "inbe-windows-x86_64.exe"
VALUE "ProductName", "Inner Breeze"
VALUE "ProductVersion", "1.7.3"
VALUE "ProductVersion", "1.7.4"
END
END
BLOCK "VarFileInfo"