Commit Graph
8 Commits
Author SHA1 Message Date
konghaojie-k2andClaude 932eccb1c7 fix(slides): strip stale embedded-font subsets after text edits (#283)
Decks saved by WPS/PowerPoint with font embedding carry subsetted,
MicroType-Express-compressed EOT fonts we cannot re-generate (licensed
compressor). After any text edit the subsets no longer cover the new
glyphs; WPS honors the stale subset strictly and renders the missing
glyphs as invisible ("white") text, while the in-app system-font
fallback shows everything fine.

On save, once any slide has content edits (structureDirty or a dirty
element — including new slides from insert/duplicate), strip the
embedding: drop p:embeddedFontLst + embedTrueTypeFonts/saveSubsetFonts
from presentation.xml, the font rels, the ppt/fonts/*.fntdata parts and
the fntdata content-type. Viewers then fall back to system fonts.
No-edit saves stay byte-identical and keep the embedding.

Known limit: master/layout text edits write archive parts directly and
don't trigger the strip.

Co-authored-by: Claude <noreply@anthropic.com>
2026-09-10 17:23:42 +08:00
konghaojie-k2 f105f366e2 feat ai settings for the per-turn output token cap (#185)
Every app's AI IPC handler computed `request.maxTokens ?? 8192`, and no
renderer ever sends maxTokens — so the per-turn output budget was a
hardcoded 8192 that BYOK users could not change. For a reasoning model
that cap is shared with thinking: probed against api.deepseek.com/v1 with
max_tokens=3000, usage came back completion_tokens=3000 /
reasoning_tokens=3000 with zero content deltas and finish_reason=length,
i.e. the model never started answering. At the observed ~129 tok/s the
8192 default is exactly the ~60s "empty reply" users reported.

Thinking cannot simply be switched off for these models: registry.ts pins
the *direct* deepseek endpoint to non-thinking because its transcript
could not round-trip reasoning, while modelEchoesReasoning() documents
that DeepSeek V4 rejects tool turns unless the reasoning is echoed back.
So the honest lever is the budget, not the switch.

- AiSettings.maxOutputTokens (absent = default, so existing settings
  files keep behaving identically), clamped to [1024, 131072] when read
  and when typed: a hand-edited or mistyped value can never be forwarded
  to an endpoint verbatim.
- docs/sheets/slides main handlers resolve the cap through
  maxOutputTokensOf(settings); markdown and pdf share docs' ai:stream
  channel, so all six apps follow the setting from one place.
- Settings ▸ AI model: a numeric field (clamped on blur) labelled in all
  19 languages.
- sheets' aiSettingsInputSchema is .strict(), so it had to learn the key
  or saving settings would have started failing.
2026-09-03 14:58:48 +08:00
konghaojie-k2 99d376b3c3 fix markdown/pdf ai panels surfacing a truncated reply as "no reply" (#184)
A BYOK reasoning model can spend the whole output budget on thinking and
close the turn with finish_reason=length and no prose at all. The loop
already reports that as `truncated`, and docs appends aiTruncatedNote to
the bubble, but markdown and pdf destructure only
{text, cancelled, turnLimit} — so the run rendered the bare "(no reply)"
(while an empty "(no reply)" turn also made the following turns look like
the assistant had stopped listening).

Probe against api.deepseek.com/v1 (max_tokens=50/3000, thinking on by
default): completion_tokens == reasoning_tokens, content deltas never
start, finish_reason=length — reasoning tokens are billed against
max_tokens, at ~129 tok/s (≈ the agent default cap of 8192 in 60s).

Both panels now take `truncated` and append the note exactly like docs;
aiTruncatedNote is added to all 19 locales of both apps, copied from
apps/docs/src/renderer/i18n/ai/*.ts so the wording stays uniform.
2026-09-03 14:51:12 +08:00
konghaojie-k2 93b8938c45 fix docs per-section page margins and pct table widths (#177)
* fix docs canvas losing per-section left page margins

The editor pads .doc-page by the FIRST section's margins (--page-pad) and
only ever gave later sections their own wrap width, never their own x
offset. A document whose opening section is full-bleed (w:pgMar
w:left="0", typical for a cover page) therefore lost the 30mm left margin
on every following page: body blocks kept the correct width but were
glued to the paper edge, leaving a dead band on the right.

sectionWidthSpecs now emits a real dx (the block's section marginLeft
minus the canvas inset). It rides the existing visual-translate channel,
composes with column/vAlign offsets, and is neutralized while measuring,
so page slicing is untouched. Gap header/footer strips follow their own
section inset (--gap-ml on the gap box) instead of being pinned to the
first section's column; table gaps keep the canvas target.

Vertical margins were already per-page (the gap bands carry each
section's top/bottom), which is why only the horizontal offset leaked.

* fix docs pct-width tables spanning the whole paper

w:tblW type="pct" (and AutoFit to Window, which parses as 100%) is a share
of the section's TEXT COLUMN. Both rendered a bare width:100%, which
resolves against the canvas' padding box — and that box is padded by the
FIRST section's margins. A document opening with a full-bleed cover
section (w:pgMar w:left="0") therefore laid every later table across the
whole paper, hanging past the right edge as soon as the body sections'
own left inset was applied.

Both paths now resolve through the per-block --doc-content-w that
sectionWidthSpecs already delivers (unset → the old percentage, so
single-section documents are byte-identical). Protected tables get the
same treatment; nested tables keep their cell-relative % since they
inherit the outer table's --doc-content-w.
2026-09-02 20:06:25 +08:00
konghaojie-k2andClaude 583a045212 feat(markdown): prompt to save before pasting images into untitled docs (#162)
Co-authored-by: Claude <noreply@anthropic.com>
2026-08-27 18:14:38 +08:00
konghaojie-k2andClaude 607c77086f feat(shell): open documents dropped onto the window (#161)
Dropping a local file from Explorer/Finder anywhere over the app previously
did nothing visible: the navigation guard blocks Chromium's default
navigate-to-file, so drops were silently swallowed.

Add a preload-side bridge (@genoffice/electron-utils/drop-open, installed by
every surface's preload) that resolves dropped files via webUtils and forwards
recognized documents to the shell over one IPC channel. The shell routes each
path through the normal File > Open pipeline, reveals its window when the drop
landed in a detached editor, and shows the existing "not supported" dialog for
known legacy formats. Page-level drop zones that cancel their events (AI
attachment panels, slides image insert) keep priority.

While files hover, Home shows a pointer-events-none drop overlay (tokens only,
i18n key in all 19 locales).

The bridge module gets its own package subpath export so sandboxed preloads
bundle only it — importing the barrel would pull node builtins into sandboxed
preloads (bundled) or leave a bare require (externalized), both fatal there.

Co-authored-by: Claude <noreply@anthropic.com>
2026-08-27 18:14:28 +08:00
konghaojie-k2andClaude 2e3e97f53a feat(slides): add a set_speaker_notes agent tool (#153)
The slides AI skill gains a set_speaker_notes tool that writes or clears a
page's speaker notes through the existing slides:set-notes IPC (persisted
into the .pptx notesSlide part, marks the deck dirty, refreshable via the
annotations nonce). DeckAccess grows an optional setSpeakerNotes hook; the
AiPanel wires it from a new onSetSpeakerNotes prop supplied by App, which
flushes any pending notes edit before invoking the IPC.

Split out from #129 per maintainer feedback — single-purpose, without the
local-environment bits.

Co-authored-by: Claude <noreply@anthropic.com>
2026-08-26 11:38:39 +08:00
konghaojie-k2andClaude 9792915878 feat(slides): flag horizontal text overflow in the layout audit (#154)
The audit only compared laid-out content height against the box, so a line
wider than the box (wrap=false, or a single unbreakable token wider than
the available width) passed silently and then overlapped whatever sits
next to it. collectEntries now also records each text node's widest
laid-out line (run.x already includes marL/indent/alignment, so the
content-area comparison is exact), and auditSlideLayout reports a
'Text overflow (width)' issue past the same tolerance, prompting the AI
to widen the box, shrink the font, or enable wrapping.

Split out from #129 per maintainer feedback.

Co-authored-by: Claude <noreply@anthropic.com>
2026-08-26 11:34:09 +08:00