Skip to content

Commit 13ae6ca

Browse files
authored
Fix status bar resets and restrict action to ChatGPT (#11)
* Improve action gating and empty chat status * Fix lint in background action listener * Harden empty chat detection and action sync * Broaden empty chat detection selectors * Bump version to 1.6.3
1 parent f14d880 commit 13ae6ca

20 files changed

+460
-239
lines changed

.beads/.gitignore

Lines changed: 0 additions & 32 deletions
This file was deleted.

.beads/README.md

Lines changed: 0 additions & 81 deletions
This file was deleted.

.beads/config.yaml

Lines changed: 0 additions & 62 deletions
This file was deleted.

.beads/issues.jsonl

Lines changed: 0 additions & 15 deletions
This file was deleted.

.beads/metadata.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

AGENTS.md

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,3 @@
11
# Agent Instructions
22

3-
This project uses **bd** (beads) for issue tracking. Run `bd onboard` to get started.
4-
5-
## Quick Reference
6-
7-
```bash
8-
bd ready # Find available work
9-
bd show <id> # View issue details
10-
bd update <id> --status in_progress # Claim work
11-
bd close <id> # Complete work
12-
bd sync # Sync with git
13-
```
14-
15-
## Landing the Plane (Session Completion)
16-
17-
**When ending a work session**, you MUST complete ALL steps below. Work is NOT complete until `git push` succeeds.
18-
19-
**MANDATORY WORKFLOW:**
20-
21-
1. **File issues for remaining work** - Create issues for anything that needs follow-up
22-
2. **Run quality gates** (if code changed) - Tests, linters, builds
23-
3. **Update issue status** - Close finished work, update in-progress items
24-
4. **PUSH TO REMOTE** - This is MANDATORY:
25-
```bash
26-
git pull --rebase
27-
bd sync
28-
git push
29-
git status # MUST show "up to date with origin"
30-
```
31-
5. **Clean up** - Clear stashes, prune remote branches
32-
6. **Verify** - All changes committed AND pushed
33-
7. **Hand off** - Provide context for next session
34-
35-
**CRITICAL RULES:**
36-
- Work is NOT complete until `git push` succeeds
37-
- NEVER stop before pushing - that leaves work stranded locally
38-
- NEVER say "ready to push when you are" - YOU must push
39-
- If push fails, resolve and retry until it succeeds
40-
3+
No issue tracker configured.

extension/manifest.chrome.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "LightSession Pro for ChatGPT",
4-
"version": "1.6.2",
4+
"version": "1.6.3",
55
"description": "Keep ChatGPT fast by keeping only the last N messages in the DOM. Local-only.",
66
"icons": {
77
"16": "icons/icon-16.png",
@@ -13,7 +13,7 @@
1313
"default_title": "LightSession Pro",
1414
"default_popup": "popup/popup.html"
1515
},
16-
"permissions": ["storage", "tabs"],
16+
"permissions": ["storage", "tabs", "declarativeContent"],
1717
"host_permissions": [
1818
"*://chat.openai.com/*",
1919
"*://chatgpt.com/*"

extension/manifest.firefox.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "LightSession Pro for ChatGPT",
4-
"version": "1.6.2",
4+
"version": "1.6.3",
55
"description": "Keep ChatGPT fast by keeping only the last N messages in the DOM. Local-only.",
66
"icons": {
77
"16": "icons/icon-16.png",
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/**
2+
* LightSession Pro - Action icon state
3+
* Enable the action only on ChatGPT sites.
4+
*/
5+
6+
import browser from '../shared/browser-polyfill';
7+
import { isChatGptUrl } from '../shared/url';
8+
9+
const DEFAULT_POPUP = browser.runtime.getManifest().action?.default_popup ?? 'popup/popup.html';
10+
const CHATGPT_RULES = [
11+
{ hostEquals: 'chatgpt.com' },
12+
{ hostEquals: 'chat.openai.com' },
13+
];
14+
15+
function setPopupForTab(tabId: number, popup: string): void {
16+
if (!browser.action) {
17+
return;
18+
}
19+
20+
try {
21+
void browser.action.setPopup({ tabId, popup });
22+
} catch {
23+
// Ignore action update failures (e.g., restricted tabs)
24+
}
25+
}
26+
27+
export function updateActionForTab(tabId: number, url?: string | null): void {
28+
if (!browser.action || !tabId) {
29+
return;
30+
}
31+
32+
try {
33+
if (isChatGptUrl(url)) {
34+
void browser.action.enable(tabId);
35+
setPopupForTab(tabId, DEFAULT_POPUP);
36+
} else {
37+
void browser.action.disable(tabId);
38+
setPopupForTab(tabId, '');
39+
}
40+
} catch {
41+
// Ignore action update failures (e.g., restricted tabs)
42+
}
43+
}
44+
45+
export function disableActionByDefault(): void {
46+
if (!browser.action) {
47+
return;
48+
}
49+
50+
try {
51+
void browser.action.disable();
52+
void browser.action.setPopup({ popup: '' });
53+
} catch {
54+
// Ignore failures for restricted contexts
55+
}
56+
}
57+
58+
export async function ensureDeclarativeActionRules(): Promise<void> {
59+
const declarative = (
60+
browser as unknown as { declarativeContent?: typeof chrome.declarativeContent }
61+
).declarativeContent;
62+
63+
if (!declarative?.onPageChanged || !declarative.PageStateMatcher || !declarative.ShowAction) {
64+
return;
65+
}
66+
67+
const rules = [
68+
{
69+
conditions: CHATGPT_RULES.map(
70+
(rule) => new declarative.PageStateMatcher({ pageUrl: rule })
71+
),
72+
actions: [new declarative.ShowAction()],
73+
},
74+
];
75+
76+
await new Promise<void>((resolve) => {
77+
declarative.onPageChanged.removeRules(undefined, () => resolve());
78+
});
79+
80+
declarative.onPageChanged.addRules(rules);
81+
}
82+
83+
export async function syncActionStateForAllTabs(): Promise<void> {
84+
if (!browser.action) {
85+
return;
86+
}
87+
88+
try {
89+
const tabs = await browser.tabs.query({});
90+
for (const tab of tabs) {
91+
if (!tab?.id) continue;
92+
updateActionForTab(tab.id, tab.url);
93+
}
94+
} catch {
95+
try {
96+
const tabs = await browser.tabs.query({ active: true, currentWindow: true });
97+
for (const tab of tabs) {
98+
if (!tab?.id) continue;
99+
updateActionForTab(tab.id, tab.url);
100+
}
101+
} catch {
102+
// Ignore tab query failures
103+
}
104+
}
105+
}

0 commit comments

Comments
 (0)