Skip to content

UI: UI refactor - #362

Merged
zhouwg merged 7 commits into
masterfrom
ui-refactor
Jul 28, 2026
Merged

UI: UI refactor#362
zhouwg merged 7 commits into
masterfrom
ui-refactor

Conversation

@zhouwg

@zhouwg zhouwg commented Jul 28, 2026

Copy link
Copy Markdown
Member

Overview

UI refactor:#360

AI assistance disclosure

AI assistance was utilized during development. However, this is not an unreviewed dump of AI-generated code or documentation. All testing was performed manually by JZ.

Assisted-by: Trae + MiniMax-M3

zhouwg added 7 commits July 27, 2026 18:07
Assisted-by: Trae + MiniMax-M3
Address three follow-up items from code review of the LLM Setting
refactor (93a913d):

1. .gitignore: clarify the blanket *.png rule with a comment explaining
   the convention (screenshots / one-off artifacts go in out/, which
   is already gitignored at the top of the file). The rule itself is
   unchanged so this is documentation-only.

2. LLMSettingFragment: document the "heal on access" side effect of
   preference.setValue() inside onCreatePreferences(). The previous
   "6" default caused first-launch users to NPE in
   KANTVAIModelMgr.getModelName(); the silent overwrite is intentional
   but should be loud in the code so the next maintainer doesn't strip
   it as dead code.

3. KANTVAIModel: rewrite getModalityTag() using List + String.join.
   The previous StringBuilder+boolean-first dance was hard to extend
   to a fourth modality (e.g. video) without subtle ordering bugs.
   The new version scales by adding one line per modality.

Assisted-by: Trae + MiniMax-M3
…rkdown

The old AI page was a single big TextView under a long row of spinners.
It was hard to follow long inference outputs (no clear turn boundaries)
and the settings surface was overwhelming on first launch.

Layout:
  - RecyclerView of user / assistant bubbles (ChatAdapter, ChatMessage,
    bubble drawables, item_chat_user.xml, item_chat_assistant.xml)
  - Sticky input row (IMG / AUD / prompt / Send / CLR) at the bottom
  - Bench button on the top bar opens a single settings dialog,
    replacing the old 4-spinner row + 3-dot overflow

UX fixes bundled with the refactor:
  - Default bench type is LLM on first launch (was ASR, which made
    the app send the user to a broken state when no ASR model was
    present)
  - ASR mode auto-fills the prompt with "help to transcribe the audio
    file"; switching back to LLM clears it back to "Ask AI..."
  - Pre-flight check for ASR subsystem init: toast a clear error
    instead of the cryptic "asr instance not initialized" string
  - Backend status (NPU vs CPU) is colour-coded in the top info bar
    and refreshed from Settings on onResume, not from a stale field

Streaming improvements:
  - 80ms throttle on the event handler so we re-bind at most ~12.5 fps
  - UI thread hop for native events (the EventListener callback was
    firing on the workThread, racing the UI thread's onBindViewHolder
    and causing visible flicker)
  - Markwon rendering applies to STREAMING rows too, not just
    COMPLETE, so **bold** / lists / headings appear as tokens arrive
    instead of the whole row suddenly reformatting at the end

Docs:
  - Move known issues out of the model table into a new "Known
    issues" section in the top-level README, so GitHub users see
    them at a glance

Cleanup:
  - Remove llInfoLayout (the unused intermediate view) and the
    associated displayImage() / ivInfo plumbing
  - Drop the 3-dot overflow + PopupMenu that was over-engineered for
    a single "Bench" item

Assisted-by: Trae + MiniMax-M3
- vendored markwon due to network access issue
- pre-strip `^#{1,6}\s+` in ChatAdapter before passing text to Markwon,
  since Markwon renders `##` as 2x-sized bold which breaks chat layout;
  the stripping is gated by a `debug` field (0=off, 1=on) for release
- when debug=1, ChatAdapter also writes streaming snapshots to
  /sdcard/Android/data/.../chat_dumps/ (text+spans state.txt +
  per-chunk PNG) for offline debugging of future regressions

Assisted-by: Trae + MiniMax-M3
Previously, AIResearchFragment.onSend() fell back to strDefaultPrompt
("introduce the movie Once Upon a Time in America") whenever the user
hit Send with an empty input box. That prompt is meaningful for LLM
inference but is nonsense for ASR (whisper can't act on a movie plot
request), so an empty ASR input silently used the wrong default and
then surfaced a transcription failure.

Match the ASR default to the string the Bench dialog already auto-fills
("help to transcribe the audio file") so empty ASR inputs are
self-consistent: bench dialog auto-fill = empty-input fallback.

Assisted-by: Trae + MiniMax-M3
During LLM streaming, the chat adapter's 5Hz markwon re-render was
the only path updating the assistant TextView. Between re-renders
(up to 200ms) the TextView did not refresh, so the user saw no
growth on chunks that arrived after the row was bound. The next
re-render then jumped to a freshly-formatted Spannable, which
looked like "no markdown until inference ends".

Split the per-chunk update into two stages:
  1. appendRawChunk() runs on every chunk arrival and writes the
     raw text straight into the TextView's underlying buffer
     (SpannableStringBuilder / Spannable / plain CharSequence)
     so new characters appear instantly.
  2. maybePeriodicFullRender() is the existing 5Hz markwon
     full re-render, which catches cross-chunk markdown
     (e.g. `**` / `bold` / `**` split across three chunks).

Heuristic for the LLM's unclosed-bold output ("**总结:" with no
matching close): preprocessUnclosedBold() runs on the text that
goes to markwon (NOT the data model), splits on \n\n, and only
repairs paragraphs with an ODD `**` count. This preserves valid
commonmark cross-line bold like `**xxx\nyyy**` which a naive
line-level pass would break.

Applied at both bind(COMPLETE) and maybePeriodicFullRender().

Assisted-by: Trae + MiniMax-M3
@zhouwg
zhouwg merged commit 5eb4778 into master Jul 28, 2026
2 checks passed
@zhouwg
zhouwg deleted the ui-refactor branch July 28, 2026 04:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant