Skip to content
This repository was archived by the owner on Sep 30, 2026. It is now read-only.

chore: sync fork with upstream (224 behind), preserve fork commits - #2

Merged
yjuyjuy merged 227 commits into
masterfrom
fm/sync-upstream-224
Aug 5, 2026
Merged

yjuyjuy merged 227 commits into
masterfrom
fm/sync-upstream-224

Conversation

@yjuyjuy

@yjuyjuy yjuyjuy commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Sync fork with upstream (224 behind)

Merges origin/master (upstream 1jehuang/jcode) into the fork, preserving both fork commits:

Conflict resolution

One conflict, in crates/jcode-app-core/src/tool/mod.rs: a non-overlapping additive collision. Our side added PENDING_COMPACTION_REQUESTS plus request_session_compaction/take_session_compaction_request; upstream added accept_large_output_schema_property_for_test/accepts_large_output at the same location. Resolved by keeping both blocks. The compact_context registration and its two turn-loop drain call sites are intact.

The other two overlapping files (turn_loops.rs, turn_streaming_mpsc.rs) auto-merged cleanly.

Validation

Built with the self-dev toolchain (CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=cc for this box's clang gap):

  • cargo build -p jcode-app-core clean
  • cargo test -p jcode-app-core compact = 13 passed, 0 failed (includes the 3 compact_context tests)
  • cargo clippy -p jcode-app-core -p jcode-tui exit 0, no new warnings in touched files (remaining warnings are pre-existing dead-code and profile-spec noise)
  • Full jcode binary builds clean via scripts/dev_cargo.sh build --profile selfdev -p jcode --bin jcode (jcode v0.68.0)

Diff versus origin/master is exactly our 6 fork-owned files, nothing else.

The live binary is deliberately not reloaded here; that rollout is a separate coordinated step.

1jehuang added 30 commits July 31, 2026 21:58
The coast was tuned to stop almost as soon as the fingers left the pad, so
a flick read as a page that ignores the flick. Exponential friction alone
cannot fix that: a short tau stops early, a long one leaves the view
sliding for two seconds. So the friction gains a constant deceleration
term, which is negligible at flick speed and dominant at the tail: a flick
now travels 8.7x the fingers' own stroke (was 6.6x) and still comes to rest
in ~1.0s (was 1.4s). The notch ease is slightly longer (55ms -> 75ms),
halving peak jerk on a single notch.

Measured with --bench-scroll at both cadences; all gates pass.
The window had no way to change anything without an env var and a restart:
the theme, the thinking display, and the hero's motion were all decided at
launch by whatever happened to be exported. So there is now a gear in the
trailing end of the top margin (the one band that is empty in every state and
at every size, so it costs no reading space and never moves as the
conversation grows), and clicking it drops a three-row panel.

Rows are values rather than switches, because every one of these settings has
more than two states: `theme  dark` answers "what is it now" and "what will
clicking do" in the same three words. Changes apply to the live window and are
persisted per click to ~/.jcode/desktop2-settings.conf in the same tiny
line-oriented format as the window geometry, so a crash cannot lose a choice
the user has already seen take effect. Ctrl+, opens it, Escape shuts it before
reaching anything behind it, and the Ctrl+Shift+R thinking chord now writes
through the settings so the panel can never show a stale value.

The gear is drawn (six teeth and a hub) rather than set as a glyph: the app
ships no icon font and a system "⚙" renders at a different weight on every
machine.

Tests: pointer and keyboard dispatch, per-row application to the model, the
panel staying on paper and every row staying clickable across a size/scale
sweep, plus two GPU nodes (settings_panel, settings_panel_hover). The
page-bands "top of the page is clear" rule now excludes the gear by its own
hit box, so a gear that grew or moved fails that test rather than widening
the licence.
The edit card's diff was two blocks of flat colour with a rule beside it.
This makes it a diff:

- syntax highlighting, from the file's own extension, pulled a little
  toward the diff ink so a line still reads as added or removed;
- ordinary fenced code blocks are highlighted too, off the fence language;
- a wash across each row, so the shape of a change is visible before a
  word is read, and a stronger mark over the part of a paired row that
  actually differs;
- line numbers padded to one gutter width, so both sides of a change
  start at the same column;
- the +n -m counts in the header take the diff's own two colours;
- long diffs are truncated with a count of what is not shown;
- the rule down the left edge is gone and the card sits at the margin,
  and its three parts are set tight as one statement.
Measures the policy we want to hold: discover_tools is called whenever the
agent reaches for an external product, and vendor commitment goes through
action=select rather than around Discovery.

Unlike scripts/benchmark_discovery.py this suite is catalog-independent. It
scores browse recall over 20 capability-gap tasks (one per category plus two
open-category tasks) against 10 purely local controls that must stay clean, so
recall cannot be bought by over-triggering. It also reports bypass rate: the
agent installing a vendor SDK, driving a vendor CLI, hitting a vendor endpoint,
or connecting an MCP server with no Discovery call at all.

Trials that never reached the model (auth, quota, billing, cost ceiling, rate
limit, connectivity) are marked invalid and excluded from every rate, and a run
with nothing scored cannot pass. Each trial gets a pristine workspace so one
case cannot prime the next. Bypass detection reads tool input only, anchored to
command position, with offline fixtures pinning both directions.
Runs one case subset against two jcode binaries with a single model, so the
only variable is the discover_tools description, and prints a side-by-side
metric table.
…indow

Ollama conversations looked stateless in jcode: every turn behaved like a new
conversation and the context gauge never went past ~2k despite showing a 262k
window. The cause is not history handling. Ollama's OpenAI-compatible
/v1/models omits context_length entirely, so jcode fell back to a generic
large default while the server was actually serving min(trained,
OLLAMA_CONTEXT_LENGTH) (default 4096) and silently truncating the prompt to
that window. num_ctx cannot be overridden per request on /v1/chat/completions
(verified against Ollama 0.18.2: top-level num_ctx, options.num_ctx, and
context_length are all ignored), so jcode has to discover the real number.

- New ollama_context module probes Ollama's native API on catalog fetch:
  /api/ps for the server's serving window, /api/show for the trained maximum,
  and records min(trained, server default) as context_length.
- When the server default is unknown (nothing loaded, /api/ps empty), assume
  Ollama's 4096 default rather than the trained window. Over-budgeting is the
  bug being fixed; the value self-corrects on the next refresh.
- context_window() falls back to the same conservative default for Ollama
  endpoints so a cold cache cannot report 262k.
- Local endpoint hint now names OLLAMA_CONTEXT_LENGTH as the fix.
- Extract the catalog response parsers into models_catalog_parse so the
  runtime lib.rs shrinks rather than growing past its size ratchet.

Verified end to end against a local Ollama: with OLLAMA_CONTEXT_LENGTH=16384
the catalog records 16384 (not the 40960 trained window), and on a cold server
it records the conservative 4096.
A trial that never reached the model measures nothing, so retry it with linear
backoff rather than letting a transient rate limit shrink the sample. The
comparison runner now takes a trial count and honors PROVIDER, since free-tier
providers throttle and budgeted ones run out mid-run.
…2k Ollama over-report it found

Adds tests/context_window_matrix.rs as a companion to provider_matrix.rs. The
provider matrix sweeps auth/endpoint state; this one sweeps how a context
window gets *resolved*, because that is where a specific recurring class of bug
lives (1jehuang#403, 1jehuang#447, 1jehuang#541, 1jehuang#577, 1jehuang#578, and the Ollama truncation just fixed).

These bugs are all the same shape and all silent: one resolution source
disagrees with another, the wrong one wins, jcode over-budgets the request, and
the endpoint truncates without erroring. The user sees a model that "forgot"
the conversation while the context gauge still looks healthy. Per-provider unit
tests each covered their own case after the fact; this states the cross-cutting
invariants once so newly added providers inherit the guardrail:

- resolved windows are always plausible (never zero/absurd)
- configured/cached windows beat generic family fallbacks (1jehuang#541 shape)
- resolution is deterministic (gauge and compaction budget cannot drift, 1jehuang#441)
- provider hints never silently *widen* a window (narrowing is legitimate)
- unknown models land on the declared default rather than something enormous
- a cache entry for an unrelated model id cannot leak into resolution (1jehuang#403)

Each invariant was mutation-tested: reverting the corresponding fix makes the
matching test fail, so these are load-bearing rather than decorative.

That mutation testing exposed a real gap in the previous commit. Deleting the
cold-cache Ollama clamp still passed every test, and writing the missing
regression test revealed the clamp was ordered *below* the static open-weight
family table. That table is what actually reported 262144 for `qwen3:*` on
Ollama while the server served 4096, which is precisely the number the bug
report described. The clamp now outranks the static family table while still
losing to the live catalog and to an explicit per-model `context_window`, so a
user who raises OLLAMA_CONTEXT_LENGTH and declares the window is still
believed. Both directions are covered by tests.

Ollama context tests move to their own file so the already-oversized
openrouter_tests.rs does not keep growing.

Verified end to end: cold server reports 4096, and after a model loads with
OLLAMA_CONTEXT_LENGTH=16384 the catalog self-corrects to 16384.
The deep-idle gates (donut activation, tick cadence, and the
periodic-redraw short-circuit) keyed solely off time_since_activity(),
which reports 'already past the deep-idle threshold' for any non-empty
transcript that has never streamed in this process. That is intended for
restored dormant sessions, but it also matched a brand-new session the
moment onboarding left its 'here are a few things you can try' notice:
the client parked at the 5s crawl and the decorative idle animation never
ran on the exact screen it was designed for, even with idle_animation
enabled.

Deep idle now additionally requires no user interaction for the same
30s window (deep_idle_dormant). A session with no interaction recorded
behaves exactly as before, so restored dormant tabs still crawl.

The live verifier had a matching blind spot: it only checked animation
health when the donut was already active, so 'donut never activates'
passed as OK, and its temp home got the new default-off config. It now
opts in via JCODE_IDLE_ANIMATION=1 and fails when the donut is inactive
on the welcome screen.

Verified live with scripts/verify_donut_still_animates.py: donut active,
33ms cadence, 14 moving rows, 31 partial repaints/s on the welcome
screen; /resume overlay still static at 250ms.
Wiping the transcript on Ctrl+L was too intense: real terminals just
repaint. Ctrl+L (and Cmd+L on terminals that forward Command) now snap
to the chat bottom and resume tail-follow via follow_chat_bottom in
all three key paths. /cls remains the explicit view-only clear.
Instead of just snapping to the bottom, Ctrl+L/Cmd+L now append a
viewport-height blank spacer message and snap to the tail, so the
screen shows a clean prompt while the whole transcript stays one
scroll-up away, exactly like a terminal's clear-with-scrollback.
Nothing is deleted and context/queue/draft are untouched. Repeated
presses do not stack spacers. /cls remains the actual view wipe.
Render-level test proves the screen is visually clear and that
scrolling up reveals the pre-clear transcript.
Two refinements to the terminal-style clear:
- While the cleared state is active (trailing spacer, pinned to bottom,
  nothing streaming), the renderer collapses the all-blank messages area
  so the status line and numbered prompt sit at the top of the screen,
  exactly like a terminal after clear. Scrolling up drops the spacer and
  restores the normal bottom-anchored layout with history intact.
- The spacer is a screen-state artifact, not transcript content: it is
  dropped as soon as any real message arrives, so no giant blank block
  is ever left embedded in the scrollback.
…ixes 1jehuang#726)

The clang export sat before the mode dispatch, so it applied to `system`
mode too. On a machine without clang the script logged 'using system linker
settings' and then told cargo to invoke a linker that is not installed,
failing every build script with exit 101. Only mold and lld need clang as
the driver; system mode now leaves the choice to cargo's default cc.
The live router catalog authorizes claude-opus-5 for every paid tier, but
the client catalog omitted it, so `--model claude-opus-5` silently ran
claude-opus-4-8 instead. Added as a non-default entry; which model is the
default remains a separate decision.
… real tools

The OAuth endpoint expects Claude-Code builtin tool names, so a few schemas
are hand-maintained. Two had drifted:

- ScheduleWakeup advertised delaySeconds/reason/prompt while the real
  `schedule` handler requires `task` plus wake_in_minutes/wake_at, so every
  call failed with 'task is required for action=create'. Dropped the
  fabricated entry and let the real schema forward under the OAuth name, so
  the two stay in sync by construction (fixes 1jehuang#706).
- Bash omitted `justification`, the destructive gate's documented
  Confirm-tier escape hatch, leaving it discoverable only from an error
  string after a block (fixes 1jehuang#722).

Regressions live in oauth_tool_schema_tests.rs.
…1jehuang#719)

binds_block_insert_point returned the first line that textually started with
`binds` and ended with `{`, ignoring KDL brace depth. In a split config with
a `recent-windows { binds { ... } }` node, the managed region landed there,
niri rejected the `spawn` action, and the whole config failed to load.

Insertion now skips nested binds nodes, and a managed block a previous
version wrote into one is relocated on the next run instead of being left
broken. Reported with a repro and a reference branch by @tingfeng347.
spawn_in_new_terminal was a hardcoded Ok(false) off Unix, so /judge, /fork,
/review, /autoreview, /autojudge, /transfer, batch crash-restore and remote
split responses all printed 'No terminal found' and never opened a window.
Everything below it was already Windows-capable: jcode-terminal-launch
detects Windows Terminal / Alacritty / WezTerm and falls back to
`cmd /C start`, and the session picker's resume already used it.

Dropping the cfg split routes every platform through that machinery.
Diagnosed with a reference branch by @rensburger.
…ixes 1jehuang#712)

apply_login_provider_profile_env unconditionally called
force_apply_openai_compatible_profile_env, which clears
JCODE_NAMED_PROVIDER_PROFILE. `auth-test --provider-profile <name>`
therefore probed the built-in generic openai-compatible slot and reported
not_configured for profiles that work fine for inference, sending users to
debug config that was never broken.

Named profiles now short-circuit, matching the precedence the explicit
`--provider <compatible>` path already applies. Diagnosed by @e-kotov.
0501448 added tests/context_window_matrix.rs with a jcode-provider-core
dev-dependency but did not commit the regenerated lock file, so every CI job
that runs cargo with --locked fails before compiling anything:

  error: cannot update the lock file ... because --locked was passed

This is one generated line; no dependency versions change.
1jehuang#719)

The unit tests assert where the managed block lands. Only niri itself can
confirm the result is a config it will actually load, which is the property
the reporter cared about: the old code produced output niri rejected outright.

Verified this test earns its keep: with the brace-depth check removed it fails
against real niri, and passes with it. Skips cleanly when niri is absent, so it
is a hard check on a niri machine and a no-op elsewhere.
…ng#728)

delete_back/delete_forward consume a selection first, but delete_word_back
and delete_word_forward did not. A word-delete with an active selection
therefore shortened the buffer while leaving `anchor` pointing past the new
end. The next ordinary Backspace sliced out of bounds and panicked, and
because the panic crosses winit's Objective-C key_down boundary it aborted
the process rather than unwinding.

Reported with a deterministic repro (type 'hello world', Shift+Left,
Option+Backspace, Backspace) and the correct minimal fix by @wtchronos.

The two regression tests fail before this change and pass after it.
…ixes 1jehuang#729)

create_headless_session called enable_memory_test_mode() unconditionally,
even though its own doc comment says test mode is 'called when session is
marked as debug'. That function is also the production path for real
swarm-spawned workers, so every inline/headless worker got MemoryManager
{ test_mode: true }, and project_memory_path() then short-circuits to
~/.jcode/memory/test/ before ctx.working_dir is ever consulted.

The effect: a spawned worker could never read what the session that spawned
it remembered, and its own 'durable' writes went to throwaway storage. This
is distinct from 1jehuang#491 and 1jehuang#720, which fix working-dir scoping in paths that
never reach this override.

Isolation is now explicit per caller: debug-socket admin sessions opt in
(where isolation is the point), real swarm spawns opt out.

Diagnosed by @jonschull while verifying the 1jehuang#720 follow-up.
…own module

Keeps editor.rs near the code-size budget, following this test directory's
stated 'split by concern so no file grows unbounded' rule.

Rebaselines the two entries the fixes genuinely grow: editor.rs (+9, the
selection guards) and comm_session.rs (+2, the new isolate_memory argument).
No other baselines touched.
…ng#729)

Makes the severity of enabling memory test mode on a production path
explicit: a manager in test mode cannot see real project memory even when
handed the correct project directory, because project_memory_path()
short-circuits before the directory is consulted.

That is exactly what swarm-spawned workers were subjected to
unconditionally, so they could never read what the session that spawned
them remembered.
1jehuang added 26 commits August 4, 2026 16:03
…p-notification

fix: sanitize Gemini schemas and MCP notifications
…e-subscribe

fix: subscribe before ACP session attach
…cycle

fix: cycle through every favorite model (fixes 1jehuang#767)
…ibitor

fix: prevent Linux power inhibitor auth loops (fixes 1jehuang#763)
…p-notification

feat: preserve accumulated schema and desktop improvements
…-maturity-fixtures

test(tui): satisfy iteration-maturity gate in todo completion fixtures
# Conflicts:
#	crates/jcode-app-core/src/tool/mod.rs
The fork's compact_context and account-label commits predate any fmt-check
on the fork's CI, so cargo fmt --all --check flagged trivial mechanical
diffs (import order, method-chain and let-chain wrapping, a stray blank
line) in tool/compact.rs, tool/mod.rs, and ui_header.rs. Apply rustfmt to
exactly those files. No behavior change.
@yjuyjuy
yjuyjuy merged commit 459b70f into master Aug 5, 2026
5 of 11 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants