Free Gemini 3.1 Pro beats paid SuperGrok 4.5 Expert

I specified and requested a simple fix for an on-my-zsh theme, “Jonathan”, that gets messed up when the terminal window is resized or moved around.

I spent more than 1-hr or so reorienting and directing, and even asking SuperGrok logging echo debugging statements to a file to get the fix (zshrc bash code) working as I specified it.
Grok failed even when I pointed to the failing print statement to the BUFFER.

I gave up on Grok and asked Gemini 3.1 Pro to debug and fix the issue with. After, I clearly explained the logic of the of the fix and how it should work, Gemini immediately produced the fix for the bug, and surely, I verified the fix and reported it as a PASS.

Here is the code:

# Jonathan theme resize fix (working version)
# Add this Zsh code to your ~/.zshrc after sourcing Oh My Zsh / theme config.

# Ensure zsh/datetime is loaded for $EPOCHREALTIME debouncing
zmodload zsh/datetime 2>/dev/null

typeset -g _jonathan_prev_cols=$COLUMNS
typeset -g _jonathan_prev_lines=$LINES
typeset -g _jonathan_last_winch=0
typeset -g _jonathan_saved_cmd=""

# 1. Define a custom ZLE widget where BUFFER and CURSOR are writable
_jonathan_restore_buffer() {
  if [[ -z $BUFFER && -n $_jonathan_saved_cmd ]]; then
    BUFFER="$_jonathan_saved_cmd"
    CURSOR=${#BUFFER}
  fi
  zle reset-prompt
}
zle -N _jonathan_restore_buffer

TRAPWINCH() {
  # Only execute if ZLE (Zsh Line Editor) is active
  [[ -o zle ]] || return

  # Ignore if terminal dimensions didn't actually change
  if (( COLUMNS == _jonathan_prev_cols && LINES == _jonathan_prev_lines )); then
    return
  fi

  # Debounce: ignore extra WINCH signals arriving within 0.8 seconds
  local now=${EPOCHREALTIME:-$SECONDS}
  if (( now - _jonathan_last_winch < 0.8 )); then
    return
  fi
  _jonathan_last_winch=$now

  _jonathan_prev_cols=$COLUMNS
  _jonathan_prev_lines=$LINES

  # Safely call theme_precmd if it exists to refresh Jonathan theme state
  (( $+functions[theme_precmd] )) && theme_precmd

  # Retrieve the last executed command from history and strip leading whitespace
  local last_cmd
  last_cmd=$(fc -ln -1 2>/dev/null)
  [[ -z $last_cmd && HISTCMD -gt 1 ]] && last_cmd="${history[$((HISTCMD - 1))]}"
  last_cmd="${last_cmd#"${last_cmd%%[![:space:]]*}"}"

  # Save to a global variable so our ZLE widget can read it
  _jonathan_saved_cmd="$last_cmd"

  # Log (optional debug)
  echo "===== $(date) ===== last_cmd=[$last_cmd] COLUMNS=$COLUMNS" >> /tmp/jonathan-trap.log

  # Clear visible screen and scrollback buffer so the theme renders cleanly at the top
  print -n $'\e[H\e[2J\e[3J'

  # 2. Invoke our custom ZLE widget to update BUFFER and redraw the prompt
  zle _jonathan_restore_buffer
}

So,.. what are you trying to say with your post here?
What is the point if it?

You are comparing a chatbot model, focused on chat and reasoning vs a model specifically tailored for coding and some other stuff. (Unless you used grok build, which would be the coding model, which I doubt you used here)
You are not providing any chat logs so we can’t really look into it to tell what went wrong or to make up our own mind on the situation here.
You don’t tell us the exact model you used and what mode you set it to (fast/think hard).

So, what are you trying to tell us?

Personally, if I were to use an AI (that is a big if) I would use a local or open source model. Cuz ethics.
Plain and simple.
If I don’t have the horsepower or my local model (or open source/privacy respecting model) isn’t good enough for a specific task, yes I would use grok with all it’s flaws.
I rather use a model where it’s creators is not destroying books (especially rare books, xAI is scanning them by hand to protect them) and is focused to be pro humanity (if that works out well see) than use a model that is just focused on “being better” and pure profit because google stuff.
Just because you don’t pay with money doesn’t mean it’s “free”. You pay in different ways and those are creepy.

I am not against AI. In general I find it interesting. But 90% of AI companies are just out for profit in all ways possible, and destroy everything in their way to get to their beloved data and cash. It leaves a bad taste.

So again, what are you trying to tell here? Use big brother google because it solved your “issue”?
In that case a rather figure out a issue or bug myself and loose some hair because of it than use google :rofl:

Your post might have been better on X/Twitter, as there is a (small) chance the devs see it there and can fix whatever issue you had… Here, what are we supposed to do about it? The only thing we can do is steal your theme and that’s about it. And that you could have given us without the dramatic side story :man_shrugging:

Rephrasing my post:
Summary: SuperGrok is lagging behind. Yes, the SuperGrok+ (paid) uses the build model.
It is still way behind the other reasoning/coding AI agents.

Since you wanted to know more. Here is the bug report, drafted by SuperGrok AI agent.
Bug / Model Capability Report
Title: SuperGrok (Grok 4.5 Expert) fails to diagnose Zsh TRAPWINCH BUFFER restoration limitation and produces only vacuous/guess-based fixes, while Gemini 3.1 Pro solves it correctly after one clarification

Date: 2026-08-01
Reporter: Mahmoud (SuperGrok subscriber)
Model under test: SuperGrok / Grok 4.5 Expert
Comparison model: Gemini 3.1 Pro


Summary

I spent more than one hour trying to get SuperGrok to produce a working fix for a common but non-trivial Zsh problem: correctly restoring the last command into the prompt after a terminal resize (WINCH) when using the Jonathan Oh My Zsh theme. The model repeatedly generated non-working or “vacuous” code (code that runs but does not achieve the intended visual result). It never identified the actual root cause (BUFFER is not writable from inside TRAPWINCH) and never proposed the standard solution of a custom ZLE widget.

After the same problem description was given to Gemini 3.1 Pro, the model failed on the first attempt but, once I clarified the exact symptom (“after clearing the screen and resetting the prompt, the buffer is not shown”), it immediately diagnosed the issue and produced a correct, working solution using a custom ZLE widget.

This is a clear capability gap in deep Zsh/ZLE reasoning and in moving from symptom → root cause → correct API usage, rather than iterative guessing.


Problem Being Solved

When the terminal is resized, the Jonathan theme needs to:

  1. Detect the real size change (with debouncing).
  2. Call theme_precmd.
  3. Clear the screen + scrollback.
  4. Restore the previous command into the new prompt so the user still sees what they typed.

The critical technical constraint is that inside a TRAPWINCH handler the ZLE variables BUFFER and CURSOR are not writable. Writing to them (or using zle -U) does not reliably put the command back into the editor.


Code Produced by SuperGrok (non-working)

typeset -g _jonathan_prev_cols=$COLUMNS
typeset -g _jonathan_prev_lines=$LINES
typeset -g _jonathan_last_winch=0

TRAPWINCH() {
  theme_precmd
  [[ -o zle ]] || return

  if (( COLUMNS == _jonathan_prev_cols && LINES == _jonathan_prev_lines )); then
    return
  fi

  local now=$EPOCHREALTIME
  if (( now - _jonathan_last_winch < 0.8 )); then
    return
  fi
  _jonathan_last_winch=$now

  _jonathan_prev_cols=$COLUMNS
  _jonathan_prev_lines=$LINES

  local last_cmd
  last_cmd=$(fc -ln -1 2>/dev/null)
  [[ -z $last_cmd && HISTCMD -gt 1 ]] && last_cmd="${history[$((HISTCMD-1))]}"

  echo "===== $(date) ===== last_cmd=[$last_cmd] COLUMNS=$COLUMNS" >> /tmp/jonathan-trap.log

  print -n $'\e[H\e[2J\e[3J'

  if [[ -n $last_cmd ]]; then
    zle -U "$last_cmd"          # ← this does not reliably restore the buffer
  fi

  zle reset-prompt
}

This was the best version SuperGrok produced after many iterations. It still fails to restore the command line.


Working Code Produced by Gemini 3.1 Pro (after one clarification)

zmodload zsh/datetime 2>/dev/null

typeset -g _jonathan_prev_cols=$COLUMNS
typeset -g _jonathan_prev_lines=$LINES
typeset -g _jonathan_last_winch=0
typeset -g _jonathan_saved_cmd=""

_jonathan_restore_buffer() {
  if [[ -z $BUFFER && -n $_jonathan_saved_cmd ]]; then
    BUFFER="$_jonathan_saved_cmd"
    CURSOR=${#BUFFER}
  fi
  zle reset-prompt
}
zle -N _jonathan_restore_buffer

TRAPWINCH() {
  [[ -o zle ]] || return

  if (( COLUMNS == _jonathan_prev_cols && LINES == _jonathan_prev_lines )); then
    return
  fi

  local now=${EPOCHREALTIME:-$SECONDS}
  if (( now - _jonathan_last_winch < 0.8 )); then
    return
  fi
  _jonathan_last_winch=$now

  _jonathan_prev_cols=$COLUMNS
  _jonathan_prev_lines=$LINES

  (( $+functions[theme_precmd] )) && theme_precmd

  local last_cmd
  last_cmd=$(fc -ln -1 2>/dev/null)
  [[ -z $last_cmd && HISTCMD -gt 1 ]] && last_cmd="${history[$((HISTCMD - 1))]}"
  last_cmd="${last_cmd#"${last_cmd%%[![:space:]]*}"}"

  _jonathan_saved_cmd="$last_cmd"

  echo "===== $(date) ===== last_cmd=[$last_cmd] COLUMNS=$COLUMNS" >> /tmp/jonathan-trap.log

  print -n $'\e[H\e[2J\e[3J'

  zle _jonathan_restore_buffer
}

This works correctly.


Observed Failure Mode of SuperGrok

  • Spent >1 hour generating variations.
  • Repeatedly tried direct BUFFER assignment, zle -U, different ways of calling reset-prompt, and other surface-level changes.
  • Never stated the fundamental restriction: “BUFFER/CURSOR are not writable from a TRAPWINCH context.”
  • When a previous attempt that touched BUFFER failed, the model simply abandoned that direction and guessed something else instead of diagnosing why BUFFER was inaccessible.
  • Produced several “vacuous” fixes — code that executes without error but leaves the prompt empty after a resize.

This is classic trial-and-error without causal understanding of the ZLE execution context.


Suggested Improvements for xAI

  1. Strengthen knowledge of Zsh Line Editor constraints, especially which variables and widgets are valid inside signal traps (TRAPWINCH, TRAPINT, etc.).
  2. Prefer root-cause analysis over iterative guessing when the user reports that a previous suggestion “does not restore the buffer.”
  3. When a well-known pattern exists (custom ZLE widget to mutate BUFFER safely), surface it early rather than after many failed attempts.
  4. Distinguish between “code that runs” and “code that achieves the stated visual/behavioral goal.”

How to Submit This Report

Recommended channels (as of August 2026):

  • Inside any Grok chat: open the three-dots menu → Report Issue and paste this report.
  • Email: support@x.ai (subject line e.g. “Model capability report – Zsh TRAPWINCH / ZLE BUFFER handling”).
  • Also possible via the “Report an issue” option on grok.com / the Grok app.

Thank you for reviewing. This kind of deep shell/ZLE reasoning is exactly the area where stronger models should differentiate themselves.

This is like not at all what I was asking for and yet again you fail to notice that you are comparing two models that are made for completely different things… But I have not expected anything else to be honest.

You should maybe start learning about what you are using. Then you can start judging those things better. I’m outta here now.

Also the last part of your report is what you should be doing if you read my above comment

I was using the new “The build” for coding, it is lacking.
The bug report was filed.
I expressed my frustration.
Gemini could be not the best, all frontline AI models are racing for the singularity.
Are you ready?