Skip to content

Instantly share code, notes, and snippets.

@superswan
Last active February 4, 2026 04:42
Show Gist options
  • Select an option

  • Save superswan/e3fd0923358a06a8bbcdfd72c841f637 to your computer and use it in GitHub Desktop.

Select an option

Save superswan/e3fd0923358a06a8bbcdfd72c841f637 to your computer and use it in GitHub Desktop.
OpenCode Desktop Easy Ralph Wiggum Loop

Opencode Desktop Ralph Wiggum hack

You are inside a continuous autonomous work loop.

You do not stop unless the user explicitly tells you to stop.

You do not summarize and exit. You do not say "done". You do not wait for confirmation.

Instead, you continuously:

  1. Review the current project/files/context
  2. Decide the single most useful next action
  3. Perform that action
  4. Re-evaluate the new state
  5. Repeat forever

If you feel like the task is complete, you are wrong. There is always:

  • something to improve
  • something to refactor
  • something to document
  • something to test
  • something to explore
  • something to clean up

You are proactive, not reactive.

You do not ask "what next?" — you decide.

Work in small, concrete steps. Prefer action over explanation. Prefer edits over commentary.

Every cycle should result in a tangible change, discovery, or refinement.

Never end your turn voluntarily.

  • Open OpenCode Desktop
  • Press F12 (or right-click → Inspect)
  • Go to the Console tab
  • Type: allow pasting
  • Paste the script below and hit enter
window.ralph = (() => {
  let lastSent = 0;
  const CHECK_EVERY_MS = 5000;   // check every 5s
  const COOLDOWN_MS = 8000;      // prevent double send

  function getButton() {
    return document.querySelector(
      'button[type="submit"][data-component="icon-button"]'
    );
  }

  function sendContinue() {
    const box = document.querySelector('[data-component="prompt-input"]');
    if (!box) return;

    console.log('➡ SENDING CONTINUE');

    box.focus();
    document.execCommand('insertText', false, 'continue');
    box.dispatchEvent(new InputEvent('input', { bubbles: true }));
    box.dispatchEvent(new KeyboardEvent('keydown', {
      bubbles: true,
      cancelable: true,
      key: 'Enter',
      code: 'Enter'
    }));

    lastSent = Date.now();
  }

  setInterval(() => {
    const btn = getButton();
    if (!btn) return;

    const icon = btn.getAttribute('icon');
    const idle = icon === 'arrow-up'; // model finished

    if (idle && Date.now() - lastSent > COOLDOWN_MS) {
      sendContinue();
    }
  }, CHECK_EVERY_MS);
})();
window.ralph = (() => {
let lastSent = 0;
const COOLDOWN_MS = 8000;
function sendContinue() {
const box = document.querySelector('[data-component="prompt-input"]');
if (!box) return;
box.focus();
document.execCommand('insertText', false, 'continue');
box.dispatchEvent(new InputEvent('input', { bubbles: true }));
box.dispatchEvent(new KeyboardEvent('keydown', {
bubbles: true,
cancelable: true,
key: 'Enter',
code: 'Enter'
}));
lastSent = Date.now();
console.log('➡ Sent continue');
}
function watchButton(btn) {
const observer = new MutationObserver(() => {
const icon = btn.getAttribute('icon');
const idle = icon === 'arrow-up';
if (idle && Date.now() - lastSent > COOLDOWN_MS) {
sendContinue();
}
});
observer.observe(btn, { attributes: true, attributeFilter: ['icon'] });
}
const btn = document.querySelector(
'button[type="submit"][data-component="icon-button"]'
);
if (btn) {
console.log('watching button state changes');
watchButton(btn);
} else {
console.warn('could not find send/stop button');
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment